aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2017-02-02 17:34:22 -0500
committerRussell Yanofsky <russ@yanofsky.org>2017-02-02 17:34:22 -0500
commit4ec057dfa72fbb910fec69305af1ff6d5e03ca30 (patch)
tree5af99d42db58e14be8b403783411c0af67dfd3c3
parent1c2edd9f6707d16c03ecfba094b1cfec2ddc4dce (diff)
downloadbitcoin-4ec057dfa72fbb910fec69305af1ff6d5e03ca30.tar.xz
[wallet] Set correct metadata on bumpfee wallet transactions
Preserve comment, order form, and account strings from the original wallet transaction. Also set fTimeReceivedIsTxTime and fFromMe fields for consistency with CWallet::CreateTransaction. The latter two fields don't influence current wallet behavior, but do record that the transaction originated in the wallet instead of coming from the network or sendrawtransaction.
-rwxr-xr-xqa/rpc-tests/bumpfee.py9
-rw-r--r--src/wallet/rpcwallet.cpp5
2 files changed, 14 insertions, 0 deletions
diff --git a/qa/rpc-tests/bumpfee.py b/qa/rpc-tests/bumpfee.py
index 0ebd79f7f3..ac282796c1 100755
--- a/qa/rpc-tests/bumpfee.py
+++ b/qa/rpc-tests/bumpfee.py
@@ -69,6 +69,7 @@ class BumpFeeTest(BitcoinTestFramework):
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")
@@ -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()
diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp
index 36753d1116..45b572aa2e 100644
--- a/src/wallet/rpcwallet.cpp
+++ b/src/wallet/rpcwallet.cpp
@@ -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.