From 1e3c00c301052b12334a995956b2d459809b6549 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Thu, 21 Dec 2023 13:35:00 -0700 Subject: [PATCH] Add addl tx data to RBF. Fix test. --- src/bitcoin.rs | 25 +++++++++++++++++++++---- tests/web_wallet.rs | 4 ++-- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/bitcoin.rs b/src/bitcoin.rs index f4265bf8..5f1b1fbb 100644 --- a/src/bitcoin.rs +++ b/src/bitcoin.rs @@ -630,7 +630,7 @@ pub async fn bump_fee( descriptor: &SecretString, change_descriptor: &SecretString, broadcast: bool, -) -> Result { +) -> Result { let txid = Txid::from_str(&txid)?; let wallet = get_wallet(descriptor, Some(change_descriptor)).await?; @@ -643,6 +643,12 @@ pub async fn bump_fee( builder.finish()? }; + let vsize = details + .transaction + .as_ref() + .expect("transaction exists") + .vsize(); + if broadcast { let _finalized = wallet .lock() @@ -654,8 +660,11 @@ pub async fn bump_fee( let sent = tx.output.iter().fold(0, |sum, output| output.value + sum); + let txid = tx.txid(); + let vsize = tx.vsize(); + let details = TransactionDetails { - txid: tx.txid(), + txid, transaction: Some(tx), received: 0, sent, @@ -663,8 +672,16 @@ pub async fn bump_fee( confirmation_time: None, }; - Ok(details) + Ok(TransactionData { + details, + vsize, + fee_rate, + }) } else { - Ok(details) + Ok(TransactionData { + details, + vsize, + fee_rate, + }) } } diff --git a/tests/web_wallet.rs b/tests/web_wallet.rs index 48d4a02c..3beea03d 100644 --- a/tests/web_wallet.rs +++ b/tests/web_wallet.rs @@ -1,7 +1,7 @@ #![cfg(target_arch = "wasm32")] use bitmask_core::{ debug, info, - structs::{DecryptedWalletData, SecretString, TransactionDetails, WalletData}, + structs::{DecryptedWalletData, SecretString, TransactionData, WalletData}, web::{ bitcoin::{ decrypt_wallet, encrypt_wallet, get_wallet_data, hash_password, new_wallet, send_sats, @@ -186,7 +186,7 @@ async fn import_test_wallet() { .await; info!("Parse tx_details"); - let tx_data: TransactionDetails = json_parse(&tx_details); + let tx_data: TransactionData = json_parse(&tx_details); assert!( tx_data.confirmation_time.is_none(),