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.
This commit is contained in:
Thomas Eizinger 2021-02-26 10:18:47 +11:00
parent 67fe01a2ef
commit 32cb0eb896
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
2 changed files with 7 additions and 8 deletions

View File

@ -19,7 +19,7 @@ impl TxLock {
.address(wallet.get_network().await) .address(wallet.get_network().await)
.expect("can derive address from descriptor"); .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 { Ok(Self {
inner: psbt, inner: psbt,

View File

@ -111,19 +111,18 @@ impl Wallet {
Ok(()) Ok(())
} }
pub async fn build_tx_lock_psbt( pub async fn send_to_address(
&self, &self,
output_address: Address, address: Address,
output_amount: Amount, amount: Amount,
) -> Result<PartiallySignedTransaction> { ) -> Result<PartiallySignedTransaction> {
tracing::debug!("building tx lock");
let wallet = self.inner.lock().await; let wallet = self.inner.lock().await;
let mut tx_builder = wallet.build_tx(); let mut tx_builder = wallet.build_tx();
tx_builder.add_recipient(output_address.script_pubkey(), output_amount.as_sat()); tx_builder.add_recipient(address.script_pubkey(), amount.as_sat());
tx_builder.fee_rate(FeeRate::from_sat_per_vb(5.0)); // todo: get actual fee tx_builder.fee_rate(FeeRate::from_sat_per_vb(5.0)); // todo: make dynamic
let (psbt, _details) = tx_builder.finish()?; let (psbt, _details) = tx_builder.finish()?;
tracing::debug!("tx lock built");
Ok(psbt) Ok(psbt)
} }