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> {
579
579
let outpoint = vin. previous_output ;
580
580
let vout = outpoint. vout ;
581
581
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) ;
584
593
}
585
594
}
586
595
}
@@ -652,11 +661,11 @@ fn fetch_tip_and_latest_blocks(
652
661
} )
653
662
. fold ( agreement_cp, |prev_cp, block| {
654
663
Some ( match prev_cp {
655
- Some ( cp) => cp. push ( block) . expect ( "must extend checkpoint" ) ,
664
+ Some ( cp) => cp. push ( block) . ok ( ) ? ,
656
665
None => CheckPoint :: new ( block) ,
657
666
} )
658
667
} )
659
- . expect ( "must have at least one checkpoint" ) ;
668
+ . ok_or_else ( || Error :: Message ( "failed to construct new checkpoint tip" . to_string ( ) ) ) ? ;
660
669
661
670
Ok ( ( new_tip, new_blocks) )
662
671
}
You can’t perform that action at this time.
0 commit comments