@@ -38,7 +38,9 @@ use bitcoin::psbt::Psbt;
38
38
use bitcoin:: secp256k1:: ecdh:: SharedSecret ;
39
39
use bitcoin:: secp256k1:: ecdsa:: { RecoverableSignature , Signature } ;
40
40
use bitcoin:: secp256k1:: { PublicKey , Scalar , Secp256k1 , SecretKey , Signing } ;
41
- use bitcoin:: { ScriptBuf , Transaction , TxOut , Txid , WPubkeyHash , WitnessProgram , WitnessVersion } ;
41
+ use bitcoin:: {
42
+ Amount , ScriptBuf , Transaction , TxOut , Txid , WPubkeyHash , WitnessProgram , WitnessVersion ,
43
+ } ;
42
44
43
45
use std:: ops:: { Deref , DerefMut } ;
44
46
use std:: sync:: { Arc , Mutex } ;
@@ -137,7 +139,7 @@ where
137
139
}
138
140
139
141
pub ( crate ) fn create_funding_transaction (
140
- & self , output_script : ScriptBuf , value_sats : u64 , confirmation_target : ConfirmationTarget ,
142
+ & self , output_script : ScriptBuf , amount : Amount , confirmation_target : ConfirmationTarget ,
141
143
locktime : LockTime ,
142
144
) -> Result < Transaction , Error > {
143
145
let fee_rate = self . fee_estimator . estimate_fee_rate ( confirmation_target) ;
@@ -146,7 +148,7 @@ where
146
148
let mut tx_builder = locked_wallet. build_tx ( ) ;
147
149
148
150
tx_builder
149
- . add_recipient ( output_script, value_sats )
151
+ . add_recipient ( output_script, amount )
150
152
. fee_rate ( fee_rate)
151
153
. nlocktime ( locktime)
152
154
. enable_rbf ( ) ;
@@ -217,7 +219,7 @@ where
217
219
/// If `amount_msat_or_drain` is `None` the wallet will be drained, i.e., all available funds will be
218
220
/// spent.
219
221
pub ( crate ) fn send_to_address (
220
- & self , address : & bitcoin:: Address , amount_msat_or_drain : Option < u64 > ,
222
+ & self , address : & bitcoin:: Address , amount_or_drain : Option < Amount > ,
221
223
) -> Result < Txid , Error > {
222
224
let confirmation_target = ConfirmationTarget :: OnchainPayment ;
223
225
let fee_rate = self . fee_estimator . estimate_fee_rate ( confirmation_target) ;
@@ -226,9 +228,9 @@ where
226
228
let mut locked_wallet = self . inner . lock ( ) . unwrap ( ) ;
227
229
let mut tx_builder = locked_wallet. build_tx ( ) ;
228
230
229
- if let Some ( amount_sats ) = amount_msat_or_drain {
231
+ if let Some ( amount ) = amount_or_drain {
230
232
tx_builder
231
- . add_recipient ( address. script_pubkey ( ) , amount_sats )
233
+ . add_recipient ( address. script_pubkey ( ) , amount )
232
234
. fee_rate ( fee_rate)
233
235
. enable_rbf ( ) ;
234
236
} else {
@@ -272,12 +274,12 @@ where
272
274
273
275
let txid = tx. compute_txid ( ) ;
274
276
275
- if let Some ( amount_sats ) = amount_msat_or_drain {
277
+ if let Some ( amount ) = amount_or_drain {
276
278
log_info ! (
277
279
self . logger,
278
280
"Created new transaction {} sending {}sats on-chain to address {}" ,
279
281
txid,
280
- amount_sats ,
282
+ amount . to_sat ( ) ,
281
283
address
282
284
) ;
283
285
} else {
0 commit comments