Skip to content

Commit 1923fd4

Browse files
Fix broken bumpfee method
1 parent f9a9606 commit 1923fd4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ pub enum OfflineWalletSubCommand {
639639
/// TXID of the transaction to update
640640
#[structopt(name = "TXID", short = "txid", long = "txid")]
641641
txid: String,
642+
#[structopt(name = "CHANGE_VOUT", long = "vout")]
643+
/// Change output index to reduce it's amount in order to bump fee
644+
change_vout: u32,
642645
/// 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`
643646
#[structopt(short = "all", long = "send_all")]
644647
send_all: bool,
@@ -847,6 +850,7 @@ where
847850
}
848851
BumpFee {
849852
txid,
853+
change_vout,
850854
send_all,
851855
offline_signer,
852856
utxos,
@@ -855,12 +859,17 @@ where
855859
} => {
856860
let txid = Txid::from_str(txid.as_str()).map_err(|s| Error::Generic(s.to_string()))?;
857861

862+
let outpoint = OutPoint::new(txid, change_vout);
863+
let script_pubkey = match wallet.get_utxo(outpoint) {
864+
Ok(Some(utxo)) => utxo.txout.script_pubkey,
865+
_ => return Err(Error::UnknownUtxo),
866+
};
867+
858868
let mut tx_builder = wallet.build_fee_bump(txid)?;
859869
tx_builder.fee_rate(FeeRate::from_sat_per_vb(fee_rate));
860870

861871
if send_all {
862-
// TODO: Find a way to get the recipient scriptpubkey to allow shrinking
863-
//tx_builder.allow_shrinking()
872+
tx_builder.allow_shrinking(script_pubkey)?;
864873
}
865874

866875
if offline_signer {

0 commit comments

Comments
 (0)