@@ -639,9 +639,9 @@ pub enum OfflineWalletSubCommand {
639
639
/// TXID of the transaction to update
640
640
#[ structopt( name = "TXID" , short = "txid" , long = "txid" ) ]
641
641
txid : String ,
642
- /// 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`
643
- #[ structopt( short = "all " , long = "send_all " ) ]
644
- send_all : bool ,
642
+ /// Allows the wallet to reduce the amount to the specified address in order to increase fees.
643
+ #[ structopt( name = "SHRINK_ADDRESS" , short = "s " , long = "shrink " ) ]
644
+ shrink_address : Option < Address > ,
645
645
/// Make a PSBT that can be signed by offline signers and hardware wallets. Forces the addition of `non_witness_utxo` and more details to let the signer identify the change output.
646
646
#[ structopt( long = "offline_signer" ) ]
647
647
offline_signer : bool ,
@@ -847,7 +847,7 @@ where
847
847
}
848
848
BumpFee {
849
849
txid,
850
- send_all ,
850
+ shrink_address ,
851
851
offline_signer,
852
852
utxos,
853
853
unspendable,
@@ -858,9 +858,9 @@ where
858
858
let mut tx_builder = wallet. build_fee_bump ( txid) ?;
859
859
tx_builder. fee_rate ( FeeRate :: from_sat_per_vb ( fee_rate) ) ;
860
860
861
- if send_all {
862
- // TODO: Find a way to get the recipient scriptpubkey to allow shrinking
863
- // tx_builder.allow_shrinking()
861
+ if let Some ( address ) = shrink_address {
862
+ let script_pubkey = address . script_pubkey ( ) ;
863
+ tx_builder. allow_shrinking ( script_pubkey ) ? ;
864
864
}
865
865
866
866
if offline_signer {
@@ -1143,7 +1143,7 @@ mod test {
1143
1143
use crate :: ElectrumOpts ;
1144
1144
#[ cfg( feature = "esplora" ) ]
1145
1145
use crate :: EsploraOpts ;
1146
- use crate :: OfflineWalletSubCommand :: { CreateTx , GetNewAddress } ;
1146
+ use crate :: OfflineWalletSubCommand :: { BumpFee , CreateTx , GetNewAddress } ;
1147
1147
#[ cfg( any( feature = "electrum" , feature = "esplora" , feature = "compact_filters" ) ) ]
1148
1148
use crate :: OnlineWalletSubCommand :: { Broadcast , Sync } ;
1149
1149
#[ cfg( any( feature = "compact_filters" , feature = "electrum" , feature = "esplora" ) ) ]
@@ -1513,6 +1513,71 @@ mod test {
1513
1513
assert_eq ! ( expected_cli_opts, cli_opts) ;
1514
1514
}
1515
1515
1516
+ #[ test]
1517
+ fn test_parse_wallet_bump_fee ( ) {
1518
+ let cli_args = vec ! [ "bdk-cli" , "--network" , "testnet" , "wallet" ,
1519
+ "--descriptor" , "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)" ,
1520
+ "--change_descriptor" , "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)" ,
1521
+ "bump_fee" , "--fee_rate" , "6.1" ,
1522
+ "--txid" , "35aab0d0213f8996f9e236a28630319b93109754819e8abf48a0835708d33506" ,
1523
+ "--shrink" , "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt" ] ;
1524
+
1525
+ let cli_opts = CliOpts :: from_iter ( & cli_args) ;
1526
+
1527
+ let expected_cli_opts = CliOpts {
1528
+ network : Network :: Testnet ,
1529
+ subcommand : CliSubCommand :: Wallet {
1530
+ wallet_opts : WalletOpts {
1531
+ wallet : "main" . to_string ( ) ,
1532
+ verbose : false ,
1533
+ descriptor : "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)" . to_string ( ) ,
1534
+ change_descriptor : Some ( "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)" . to_string ( ) ) ,
1535
+ #[ cfg( feature = "electrum" ) ]
1536
+ electrum_opts : ElectrumOpts {
1537
+ timeout : None ,
1538
+ server : "ssl://electrum.blockstream.info:60002" . to_string ( ) ,
1539
+ stop_gap : 10 ,
1540
+ } ,
1541
+ #[ cfg( feature = "esplora-ureq" ) ]
1542
+ esplora_opts : EsploraOpts {
1543
+ server : "https://blockstream.info/testnet/api/" . to_string ( ) ,
1544
+ read_timeout : 5 ,
1545
+ write_timeout : 5 ,
1546
+ stop_gap : 10 ,
1547
+ } ,
1548
+ #[ cfg( feature = "esplora-reqwest" ) ]
1549
+ esplora_opts : EsploraOpts {
1550
+ server : "https://blockstream.info/testnet/api/" . to_string ( ) ,
1551
+ conc : 4 ,
1552
+ stop_gap : 10 ,
1553
+ } ,
1554
+ #[ cfg( feature = "compact_filters" ) ]
1555
+ compactfilter_opts : CompactFilterOpts {
1556
+ address : vec ! [ "127.0.0.1:18444" . to_string( ) ] ,
1557
+ conn_count : 4 ,
1558
+ skip_blocks : 0 ,
1559
+ } ,
1560
+ #[ cfg( any( feature="compact_filters" , feature="electrum" , feature="esplora" ) ) ]
1561
+ proxy_opts : ProxyOpts {
1562
+ proxy : None ,
1563
+ proxy_auth : None ,
1564
+ retries : 5 ,
1565
+ }
1566
+ } ,
1567
+ subcommand : WalletSubCommand :: OfflineWalletSubCommand ( BumpFee {
1568
+ txid : "35aab0d0213f8996f9e236a28630319b93109754819e8abf48a0835708d33506" . to_string ( ) ,
1569
+ shrink_address : Some ( Address :: from_str ( "tb1ql7w62elx9ucw4pj5lgw4l028hmuw80sndtntxt" ) . unwrap ( ) ) ,
1570
+ offline_signer : false ,
1571
+ utxos : None ,
1572
+ unspendable : None ,
1573
+ fee_rate : 6.1
1574
+ } ) ,
1575
+ } ,
1576
+ } ;
1577
+
1578
+ assert_eq ! ( expected_cli_opts, cli_opts) ;
1579
+ }
1580
+
1516
1581
#[ cfg( any( feature = "electrum" , feature = "esplora" , feature = "compact_filters" ) ) ]
1517
1582
#[ test]
1518
1583
fn test_parse_wallet_broadcast ( ) {
0 commit comments