From 1923fd4d6530f5becba74a0aac270d00a6143f7c Mon Sep 17 00:00:00 2001 From: rajarshimaitra Date: Tue, 5 Oct 2021 18:57:07 +0530 Subject: [PATCH] Fix broken bumpfee method --- src/lib.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e65a325..aaf6b25 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -639,6 +639,9 @@ pub enum OfflineWalletSubCommand { /// TXID of the transaction to update #[structopt(name = "TXID", short = "txid", long = "txid")] txid: String, + #[structopt(name = "CHANGE_VOUT", long = "vout")] + /// Change output index to reduce it's amount in order to bump fee + change_vout: u32, /// Allows the wallet to reduce the amount of the only output in order to increase fees. This is generally the expected behavior for transactions originally created with `send_all` #[structopt(short = "all", long = "send_all")] send_all: bool, @@ -847,6 +850,7 @@ where } BumpFee { txid, + change_vout, send_all, offline_signer, utxos, @@ -855,12 +859,17 @@ where } => { let txid = Txid::from_str(txid.as_str()).map_err(|s| Error::Generic(s.to_string()))?; + let outpoint = OutPoint::new(txid, change_vout); + let script_pubkey = match wallet.get_utxo(outpoint) { + Ok(Some(utxo)) => utxo.txout.script_pubkey, + _ => return Err(Error::UnknownUtxo), + }; + let mut tx_builder = wallet.build_fee_bump(txid)?; tx_builder.fee_rate(FeeRate::from_sat_per_vb(fee_rate)); if send_all { - // TODO: Find a way to get the recipient scriptpubkey to allow shrinking - //tx_builder.allow_shrinking() + tx_builder.allow_shrinking(script_pubkey)?; } if offline_signer {