@@ -61,10 +61,12 @@ where
61
61
pub ( crate ) fn add_outputs ( & self , output_descriptors : Vec < SpendableOutputDescriptor > ) {
62
62
let mut locked_outputs = self . outputs . lock ( ) . unwrap ( ) ;
63
63
64
- let ( spending_tx, broadcast_height) = match self . get_spending_tx ( & output_descriptors) {
64
+ let cur_height = self . best_block . lock ( ) . unwrap ( ) . height ( ) ;
65
+
66
+ let ( spending_tx, broadcast_height) = match self . get_spending_tx ( & output_descriptors, cur_height) {
65
67
Ok ( Some ( spending_tx) ) => {
66
68
self . wallet . broadcast_transactions ( & [ & spending_tx] ) ;
67
- ( Some ( spending_tx) , Some ( self . best_block . lock ( ) . unwrap ( ) . height ( ) ) )
69
+ ( Some ( spending_tx) , Some ( cur_height ) )
68
70
}
69
71
Ok ( None ) => {
70
72
log_debug ! (
@@ -101,15 +103,14 @@ where
101
103
}
102
104
103
105
fn get_spending_tx (
104
- & self , output_descriptors : & Vec < SpendableOutputDescriptor > ,
106
+ & self , output_descriptors : & Vec < SpendableOutputDescriptor > , cur_height : u32 ,
105
107
) -> Result < Option < Transaction > , ( ) > {
106
108
let tx_feerate = self . wallet . get_est_sat_per_1000_weight ( ConfirmationTarget :: Normal ) ;
107
109
108
110
let destination_address = self . wallet . get_new_address ( ) . map_err ( |e| {
109
111
log_error ! ( self . logger, "Failed to get destination address from wallet: {}" , e) ;
110
112
} ) ?;
111
113
112
- let cur_height = self . best_block . lock ( ) . unwrap ( ) . height ( ) ;
113
114
let locktime: PackedLockTime =
114
115
LockTime :: from_height ( cur_height) . map_or ( PackedLockTime :: ZERO , |l| l. into ( ) ) ;
115
116
0 commit comments