Skip to content

Commit c63bd06

Browse files
Fix bump_fee method after BDK update
1 parent 50139de commit c63bd06

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,9 @@ pub enum OfflineWalletSubCommand {
712712
/// TXID of the transaction to update
713713
#[structopt(name = "TXID", short = "txid", long = "txid")]
714714
txid: String,
715+
#[structopt(name = "CHANGE_VOUT", long = "vout")]
716+
/// Change output index to reduce it's amount in order to bump fee
717+
change_vout: u32,
715718
/// 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`
716719
#[structopt(short = "all", long = "send_all")]
717720
send_all: bool,
@@ -925,6 +928,7 @@ where
925928
}
926929
BumpFee {
927930
txid,
931+
change_vout,
928932
send_all,
929933
offline_signer,
930934
utxos,
@@ -933,12 +937,18 @@ where
933937
} => {
934938
let txid = Txid::from_str(txid.as_str()).map_err(|s| Error::Generic(s.to_string()))?;
935939

940+
let outpoint = OutPoint::new(txid, change_vout);
941+
let script_pubey = match wallet.get_utxo(outpoint) {
942+
Ok(Some(utxo)) => utxo.txout.script_pubkey,
943+
_ => return Err(Error::UnknownUtxo),
944+
};
945+
936946
let mut tx_builder = wallet.build_fee_bump(txid)?;
937947
tx_builder.fee_rate(FeeRate::from_sat_per_vb(fee_rate));
938948

939949
if send_all {
940950
// TODO: Find a way to get the recipient scriptpubkey to allow shrinking
941-
//tx_builder.allow_shrinking()
951+
tx_builder.allow_shrinking(script_pubey)?;
942952
}
943953

944954
if offline_signer {

0 commit comments

Comments
 (0)