Skip to content

Commit

Permalink
rpc: test bumpfee feeRate argument
Browse files Browse the repository at this point in the history
  • Loading branch information
ezegom committed Aug 2, 2019
1 parent 1498689 commit e1fd79a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3361,7 +3361,7 @@ static UniValue bumpfee(const JSONRPCRequest& request)
if (fee_rate <= 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid feeRate %s (must be greater than 0)", fee_rate.ToString()));
}
coin_control.m_feerate = fee_rate;
coin_control.m_feerate = fee_rate;
}

if (options.exists("replaceable")) {
Expand Down
14 changes: 13 additions & 1 deletion test/functional/wallet_bumpfee.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def run_test(self):
self.log.info("Running tests")
dest_address = peer_node.getnewaddress()
test_simple_bumpfee_succeeds(self, rbf_node, peer_node, dest_address)
test_bumpfee_feerate(self, rbf_node, peer_node, dest_address)
test_segwit_bumpfee_succeeds(rbf_node, dest_address)
test_nonrbf_bumpfee_fails(peer_node, dest_address)
test_notmine_bumpfee_fails(rbf_node, peer_node, dest_address)
Expand All @@ -87,7 +88,6 @@ def run_test(self):
test_no_more_inputs_fails(rbf_node, dest_address)
self.log.info("Success")


def test_simple_bumpfee_succeeds(self, rbf_node, peer_node, dest_address):
rbfid = spend_one_input(rbf_node, dest_address)
rbftx = rbf_node.gettransaction(rbfid)
Expand All @@ -109,6 +109,18 @@ def test_simple_bumpfee_succeeds(self, rbf_node, peer_node, dest_address):
assert_equal(oldwtx["replaced_by_txid"], bumped_tx["txid"])
assert_equal(bumpedwtx["replaces_txid"], rbfid)

def test_bumpfee_feerate(self, rbf_node, peer_node, dest_address):
rbfid = spend_one_input(rbf_node, dest_address)
self.sync_mempools((rbf_node, peer_node))
requested_feerate = Decimal("0.00015") # 15000 satoshis per KB (0.00015 BTC per KB)
bumped_tx = rbf_node.bumpfee(rbfid, {"feeRate": requested_feerate})
# check that bumped_tx propagates, original tx was evicted and has a wallet conflict
self.sync_mempools((rbf_node, peer_node))
assert bumped_tx["txid"] in rbf_node.getrawmempool() and bumped_tx["txid"] in peer_node.getrawmempool()
assert rbfid not in rbf_node.getrawmempool() and rbfid not in peer_node.getrawmempool()
actual_feerate = bumped_tx["fee"] * 1000 / rbf_node.getrawtransaction(bumped_tx["txid"], True)["vsize"]
# Make sure the difference between the actual feeRate and the requested feeRate is small.
assert_greater_than(Decimal("0.00001000"), abs(requested_feerate - actual_feerate))

def test_segwit_bumpfee_succeeds(rbf_node, dest_address):
# Create a transaction with segwit output, then create an RBF transaction
Expand Down

0 comments on commit e1fd79a

Please sign in to comment.