File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -579,8 +579,17 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
579579 let outpoint = vin. previous_output ;
580580 let vout = outpoint. vout ;
581581 let prev_tx = self . fetch_tx ( outpoint. txid ) ?;
582- let txout = prev_tx. output [ vout as usize ] . clone ( ) ;
583- let _ = tx_update. txouts . insert ( outpoint, txout) ;
582+ // Ensure server returns the expected txout.
583+ let txout = prev_tx
584+ . output
585+ . get ( vout as usize )
586+ . ok_or_else ( || {
587+ electrum_client:: Error :: Message ( format ! (
588+ "prevout {outpoint} does not exist"
589+ ) )
590+ } ) ?
591+ . clone ( ) ;
592+ tx_update. txouts . insert ( outpoint, txout) ;
584593 }
585594 }
586595 }
@@ -652,11 +661,11 @@ fn fetch_tip_and_latest_blocks(
652661 } )
653662 . fold ( agreement_cp, |prev_cp, block| {
654663 Some ( match prev_cp {
655- Some ( cp) => cp. push ( block) . expect ( "must extend checkpoint" ) ,
664+ Some ( cp) => cp. push ( block) . ok ( ) ? ,
656665 None => CheckPoint :: new ( block) ,
657666 } )
658667 } )
659- . expect ( "must have at least one checkpoint" ) ;
668+ . ok_or_else ( || Error :: Message ( "failed to construct new checkpoint tip" . to_string ( ) ) ) ? ;
660669
661670 Ok ( ( new_tip, new_blocks) )
662671}
You can’t perform that action at this time.
0 commit comments