From 32cb0eb896febed4900ac94a732f9dfeb727fee1 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Fri, 26 Feb 2021 10:18:47 +1100 Subject: [PATCH] Rename `build_tx_lock_psbt` to `send_to_address` Being defined on the wallet itself, a more generic name fits better on what this function actually does. --- swap/src/bitcoin/lock.rs | 2 +- swap/src/bitcoin/wallet.rs | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/swap/src/bitcoin/lock.rs b/swap/src/bitcoin/lock.rs index c44143c2..46666fe3 100644 --- a/swap/src/bitcoin/lock.rs +++ b/swap/src/bitcoin/lock.rs @@ -19,7 +19,7 @@ impl TxLock { .address(wallet.get_network().await) .expect("can derive address from descriptor"); - let psbt = wallet.build_tx_lock_psbt(address, amount).await?; + let psbt = wallet.send_to_address(address, amount).await?; Ok(Self { inner: psbt, diff --git a/swap/src/bitcoin/wallet.rs b/swap/src/bitcoin/wallet.rs index 6a786dd1..212c1bd9 100644 --- a/swap/src/bitcoin/wallet.rs +++ b/swap/src/bitcoin/wallet.rs @@ -111,19 +111,18 @@ impl Wallet { Ok(()) } - pub async fn build_tx_lock_psbt( + pub async fn send_to_address( &self, - output_address: Address, - output_amount: Amount, + address: Address, + amount: Amount, ) -> Result { - tracing::debug!("building tx lock"); let wallet = self.inner.lock().await; let mut tx_builder = wallet.build_tx(); - tx_builder.add_recipient(output_address.script_pubkey(), output_amount.as_sat()); - tx_builder.fee_rate(FeeRate::from_sat_per_vb(5.0)); // todo: get actual fee + tx_builder.add_recipient(address.script_pubkey(), amount.as_sat()); + tx_builder.fee_rate(FeeRate::from_sat_per_vb(5.0)); // todo: make dynamic let (psbt, _details) = tx_builder.finish()?; - tracing::debug!("tx lock built"); + Ok(psbt) }