Skip to content

Commit

Permalink
[wallet] Set correct metadata on bumpfee wallet transactions
Browse files Browse the repository at this point in the history
Preserves comment strings, order form and account strings from the original
wallet transaction.

Also sets fTimeReceivedIsTxTime and fFromMe fields (which are set in
CWallet::CreateTransaction) which don't actually influence wallet behavior, but
record that the transaction originated in the wallet (instead of coming from
the network or sendrawtransaction). Setting these fields also simplifies
CWalletTx cleanup in bitcoin#9381.
  • Loading branch information
ryanofsky committed Feb 2, 2017
1 parent 1c2edd9 commit dd12997
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions qa/rpc-tests/bumpfee.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def run_test(self):
test_rebumping(rbf_node, dest_address)
test_rebumping_not_replaceable(rbf_node, dest_address)
test_unconfirmed_not_spendable(rbf_node, rbf_node_address)
test_bumpfee_metadata(rbf_node, dest_address)
test_locked_wallet_fails(rbf_node, dest_address)
print("Success")

Expand Down Expand Up @@ -257,6 +258,14 @@ def test_unconfirmed_not_spendable(rbf_node, rbf_node_address):
if t["txid"] == rbfid and t["address"] == rbf_node_address and t["spendable"]), 1)


def test_bumpfee_metadata(rbf_node, dest_address):
rbfid = rbf_node.sendtoaddress(dest_address, 0.00090000, "comment value", "to value")
bumped_tx = rbf_node.bumpfee(rbfid)
bumped_wtx = rbf_node.gettransaction(bumped_tx["txid"])
assert_equal(bumped_wtx["comment"], "comment value")
assert_equal(bumped_wtx["to"], "to value")


def test_locked_wallet_fails(rbf_node, dest_address):
rbfid = create_fund_sign_send(rbf_node, {dest_address: 0.00090000})
rbf_node.walletlock()
Expand Down
5 changes: 5 additions & 0 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2944,7 +2944,12 @@ UniValue bumpfee(const JSONRPCRequest& request)
// commit/broadcast the tx
CReserveKey reservekey(pwalletMain);
CWalletTx wtxBumped(pwalletMain, MakeTransactionRef(std::move(tx)));
wtxBumped.mapValue = wtx.mapValue;
wtxBumped.mapValue["replaces_txid"] = hash.ToString();
wtxBumped.vOrderForm = wtx.vOrderForm;
wtxBumped.strFromAccount = wtx.strFromAccount;
wtxBumped.fTimeReceivedIsTxTime = true;
wtxBumped.fFromMe = true;
CValidationState state;
if (!pwalletMain->CommitTransaction(wtxBumped, reservekey, g_connman.get(), state)) {
// NOTE: CommitTransaction never returns false, so this should never happen.
Expand Down

0 comments on commit dd12997

Please sign in to comment.