From 5805d6fead8d54ec14bfc89991d692bd75940d56 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Wed, 21 Mar 2018 15:29:23 -0400 Subject: [PATCH 1/2] feebumper: discard change outputs below discard rate --- src/wallet/feebumper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/feebumper.cpp b/src/wallet/feebumper.cpp index 82a5017de..5c34b39ec 100644 --- a/src/wallet/feebumper.cpp +++ b/src/wallet/feebumper.cpp @@ -194,7 +194,7 @@ Result CreateTransaction(const CWallet* wallet, const uint256& txid, const CCoin // If the output would become dust, discard it (converting the dust to fee) poutput->nValue -= nDelta; - if (poutput->nValue <= GetDustThreshold(*poutput, ::dustRelayFee)) { + if (poutput->nValue <= GetDustThreshold(*poutput, GetDiscardRate(::feeEstimator))) { LogPrint(BCLog::RPC, "Bumping fee and discarding dust output\n"); new_fee += poutput->nValue; mtx.vout.erase(mtx.vout.begin() + nOutput); From f526046ef5d8300eab6f112f56f59fd3b7e11d33 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Wed, 28 Mar 2018 15:39:26 -0400 Subject: [PATCH 2/2] adapt bumpfee change discard test to be more strict and add note on p2sh discrep --- test/functional/wallet_bumpfee.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py index 3e496248f..f036481c3 100755 --- a/test/functional/wallet_bumpfee.py +++ b/test/functional/wallet_bumpfee.py @@ -181,7 +181,10 @@ def test_dust_to_fee(rbf_node, dest_address): # the bumped tx sets fee=49,900, but it converts to 50,000 rbfid = spend_one_input(rbf_node, dest_address) fulltx = rbf_node.getrawtransaction(rbfid, 1) - bumped_tx = rbf_node.bumpfee(rbfid, {"totalFee": 49900}) + # (32-byte p2sh-pwpkh output size + 148 p2pkh spend estimate) * 10k(discard_rate) / 1000 = 1800 + # P2SH outputs are slightly "over-discarding" due to the IsDust calculation assuming it will + # be spent as a P2PKH. + bumped_tx = rbf_node.bumpfee(rbfid, {"totalFee": 50000-1800}) full_bumped_tx = rbf_node.getrawtransaction(bumped_tx["txid"], 1) assert_equal(bumped_tx["fee"], Decimal("0.00050000")) assert_equal(len(fulltx["vout"]), 2)