@@ -152,7 +152,7 @@ private async Task<IActionResult> processSamRockProtocolRequest(SamRockProtocolR
152152 var descriptor = setupModel . BTC . Descriptor ;
153153
154154 // Extract script type, fingerprint, derivation path, xpub, and address derivation suffix
155- var match = Regex . Match ( descriptor , @"^(\w+)\(\[([a-fA-F0-9]{8})/([^\]]+)\](xpub[^/\)]+)(/[^\)]+)?\)(?:#[a-zA-Z0-9]+)?" ) ;
155+ var match = Regex . Match ( descriptor , @"^(\w+)\(\[([a-fA-F0-9]{8})/([^\]]+)\](xpub[^/\)]+)(/[^\)]+)?\)(?:#[a-zA-Z0-9]+)?$ " ) ;
156156 if ( ! match . Success )
157157 {
158158 result . Results [ key ] = new SamRockProtocolResponse ( false ,
@@ -252,7 +252,15 @@ private async Task<IActionResult> processSamRockProtocolRequest(SamRockProtocolR
252252 {
253253 if ( string . Equals ( setupModel . BTCLN . Type , "Boltz" , StringComparison . OrdinalIgnoreCase ) )
254254 {
255- await boltzWrapper . SetBoltz ( StoreId , setupModel . BTCLN . LBTC . Descriptor , result ) ;
255+ if ( string . IsNullOrWhiteSpace ( setupModel . BTCLN . LBTC ? . Descriptor ) )
256+ {
257+ result . Results [ SamRockProtocolKeys . BTC_LN ] = new SamRockProtocolResponse ( false ,
258+ "Boltz setup requires a Liquid descriptor." , null ) ;
259+ }
260+ else
261+ {
262+ await boltzWrapper . SetBoltz ( StoreId , setupModel . BTCLN . LBTC . Descriptor , result ) ;
263+ }
256264 }
257265 else
258266 {
@@ -264,12 +272,11 @@ private async Task<IActionResult> processSamRockProtocolRequest(SamRockProtocolR
264272 // TODO: If both LBTC is set and BtcLn is set, need to generate as many addresses for LiquidChain
265273 // as we have in setupModel.BtcLn.LiquidAddresses.Length to reserve them
266274
267- var allSuccess = result . Results . Values . All ( a => a . Success ) ;
275+ var allSuccess = result . Results . Count > 0 && result . Results . Values . All ( a => a . Success ) ;
268276 string errorMessage = null ;
269- if ( ! allSuccess && result . Results [ SamRockProtocolKeys . BTC_LN ] != null )
277+ if ( ! allSuccess && result . Results . TryGetValue ( SamRockProtocolKeys . BTC_LN , out var lnResult ) )
270278 {
271- var res = result . Results [ SamRockProtocolKeys . BTC_LN ] ;
272- errorMessage = res . Message ;
279+ errorMessage = lnResult . Message ;
273280 }
274281
275282 samrockProtocolService . OtpUsed ( otp , allSuccess , errorMessage ) ;
@@ -278,8 +285,8 @@ private async Task<IActionResult> processSamRockProtocolRequest(SamRockProtocolR
278285
279286 return Ok ( new
280287 {
281- Success = true ,
282- Message = "Wallet setup successfully." ,
288+ Success = allSuccess ,
289+ Message = allSuccess ? "Wallet setup successfully." : "Wallet setup failed .",
283290 Result = result
284291 } ) ;
285292 }
0 commit comments