Skip to content

Commit

Permalink
Merge bitcoin#14023: Remove accounts rpcs
Browse files Browse the repository at this point in the history
bb08423 [doc] Add release notes for 'account' API removal (John Newbery)
1f4b865 [wallet] Re-sort wallet RPC commands (John Newbery)
f0dc850 [wallet] Remove wallet account RPCs (John Newbery)
c410f41 [tests] Remove wallet accounts test (John Newbery)

Pull request description:

  This is the first part of bitcoin#13825. It simply removes the RPC methods and tests.

  bitcoin#13825 touches lots of files and will require frequent rebasing.

  Breaking it down for easier reviewing and fewer rebases.

Tree-SHA512: d29af8e7a035e4484e6b9bb56cb86592be0ec112d8ba4ce19c15d15366ff3086e89e99fca26b90c9d66f6d3e06894486d0f29948df0bb7dcb1e2c49c6887a85a
  • Loading branch information
laanwj authored and UdjinM6 committed Aug 7, 2021
1 parent fbfc4ac commit a15815c
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 1,014 deletions.
1 change: 0 additions & 1 deletion src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ BITCOIN_TESTS =\
if ENABLE_WALLET
BITCOIN_TESTS += \
wallet/test/coinjoin_tests.cpp \
wallet/test/accounting_tests.cpp \
wallet/test/db_tests.cpp \
wallet/test/psbt_wallet_tests.cpp \
wallet/test/wallet_tests.cpp \
Expand Down
12 changes: 0 additions & 12 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "listreceivedbyaddress", 2, "include_empty" },
{ "listreceivedbyaddress", 3, "include_watchonly" },
{ "listreceivedbyaddress", 4, "address_filter" },
{ "listreceivedbyaccount", 0, "minconf" },
{ "listreceivedbyaccount", 1, "addlocked" },
{ "listreceivedbyaccount", 2, "include_empty" },
{ "listreceivedbyaccount", 3, "include_watchonly" },
{ "listreceivedbylabel", 0, "minconf" },
{ "listreceivedbylabel", 1, "addlocked" },
{ "listreceivedbylabel", 2, "include_empty" },
Expand All @@ -73,17 +69,9 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "waitforblockheight", 1, "timeout" },
{ "waitforblock", 1, "timeout" },
{ "waitfornewblock", 0, "timeout" },
{ "move", 2, "amount" },
{ "move", 3, "minconf" },
{ "sendfrom", 2, "amount" },
{ "sendfrom", 3, "minconf" },
{ "sendfrom", 4, "addlocked" },
{ "listtransactions", 1, "count" },
{ "listtransactions", 2, "skip" },
{ "listtransactions", 3, "include_watchonly" },
{ "listaccounts", 0, "minconf" },
{ "listaccounts", 1, "addlocked" },
{ "listaccounts", 2, "include_watchonly" },
{ "walletpassphrase", 1, "timeout" },
{ "walletpassphrase", 2, "mixingonly" },
{ "getblocktemplate", 0, "template_request" },
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/rpcdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ UniValue importmulti(const JSONRPCRequest& mainRequest)
" \"keys\": [\"<key>\", ... ] , (array, optional) Array of strings giving private keys whose corresponding public keys must occur in the output or redeemscript\n"
" \"internal\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be treated as not incoming payments\n"
" \"watchonly\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be considered watched even when they're not spendable, only allowed if keys are empty\n"
" \"label\": <label> , (string, optional, default: '') Label to assign to the address (aka account name, for now), only allowed with internal=false\n"
" \"label\": <label> , (string, optional, default: '') Label to assign to the address, only allowed with internal=false\n"
" }\n"
" ,...\n"
" ]\n"
Expand Down
762 changes: 84 additions & 678 deletions src/wallet/rpcwallet.cpp

Large diffs are not rendered by default.

137 changes: 0 additions & 137 deletions src/wallet/test/accounting_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,137 +0,0 @@
// Copyright (c) 2012-2015 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <wallet/wallet.h>
#include <validation.h> // for cs_main because of AddToWallet

#include <wallet/test/wallet_test_fixture.h>

#include <stdint.h>

#include <boost/test/unit_test.hpp>

BOOST_FIXTURE_TEST_SUITE(accounting_tests, WalletTestingSetup)

static void
GetResults(CWallet& wallet, std::map<CAmount, CAccountingEntry>& results)
{
std::list<CAccountingEntry> aes;

results.clear();
BOOST_CHECK(wallet.ReorderTransactions() == DBErrors::LOAD_OK);
wallet.ListAccountCreditDebit("", aes);
for (CAccountingEntry& ae : aes)
{
results[ae.nOrderPos] = ae;
}
}

BOOST_AUTO_TEST_CASE(acc_orderupgrade)
{
std::vector<CWalletTx*> vpwtx;
CWalletTx wtx(nullptr /* pwallet */, MakeTransactionRef());
CAccountingEntry ae;
std::map<CAmount, CAccountingEntry> results;

LOCK2(cs_main, m_wallet.cs_wallet);

ae.strAccount = "";
ae.nCreditDebit = 1;
ae.nTime = 1333333333;
ae.strOtherAccount = "b";
ae.strComment = "";
m_wallet.AddAccountingEntry(ae);

wtx.mapValue["comment"] = "z";
m_wallet.AddToWallet(wtx);
vpwtx.push_back(&m_wallet.mapWallet.at(wtx.GetHash()));
vpwtx[0]->nTimeReceived = (unsigned int)1333333335;
vpwtx[0]->nOrderPos = -1;

ae.nTime = 1333333336;
ae.strOtherAccount = "c";
m_wallet.AddAccountingEntry(ae);

GetResults(m_wallet, results);

BOOST_CHECK(m_wallet.nOrderPosNext == 3);
BOOST_CHECK(2 == results.size());
BOOST_CHECK(results[0].nTime == 1333333333);
BOOST_CHECK(results[0].strComment.empty());
BOOST_CHECK(1 == vpwtx[0]->nOrderPos);
BOOST_CHECK(results[2].nTime == 1333333336);
BOOST_CHECK(results[2].strOtherAccount == "c");


ae.nTime = 1333333330;
ae.strOtherAccount = "d";
ae.nOrderPos = m_wallet.IncOrderPosNext();
m_wallet.AddAccountingEntry(ae);

GetResults(m_wallet, results);

BOOST_CHECK(results.size() == 3);
BOOST_CHECK(m_wallet.nOrderPosNext == 4);
BOOST_CHECK(results[0].nTime == 1333333333);
BOOST_CHECK(1 == vpwtx[0]->nOrderPos);
BOOST_CHECK(results[2].nTime == 1333333336);
BOOST_CHECK(results[3].nTime == 1333333330);
BOOST_CHECK(results[3].strComment.empty());


wtx.mapValue["comment"] = "y";
{
CMutableTransaction tx(*wtx.tx);
++tx.nLockTime; // Just to change the hash :)
wtx.SetTx(MakeTransactionRef(std::move(tx)));
}
m_wallet.AddToWallet(wtx);
vpwtx.push_back(&m_wallet.mapWallet.at(wtx.GetHash()));
vpwtx[1]->nTimeReceived = (unsigned int)1333333336;

wtx.mapValue["comment"] = "x";
{
CMutableTransaction tx(*wtx.tx);
++tx.nLockTime; // Just to change the hash :)
wtx.SetTx(MakeTransactionRef(std::move(tx)));
}
m_wallet.AddToWallet(wtx);
vpwtx.push_back(&m_wallet.mapWallet.at(wtx.GetHash()));
vpwtx[2]->nTimeReceived = (unsigned int)1333333329;
vpwtx[2]->nOrderPos = -1;

GetResults(m_wallet, results);

BOOST_CHECK(results.size() == 3);
BOOST_CHECK(m_wallet.nOrderPosNext == 6);
BOOST_CHECK(0 == vpwtx[2]->nOrderPos);
BOOST_CHECK(results[1].nTime == 1333333333);
BOOST_CHECK(2 == vpwtx[0]->nOrderPos);
BOOST_CHECK(results[3].nTime == 1333333336);
BOOST_CHECK(results[4].nTime == 1333333330);
BOOST_CHECK(results[4].strComment.empty());
BOOST_CHECK(5 == vpwtx[1]->nOrderPos);


ae.nTime = 1333333334;
ae.strOtherAccount = "e";
ae.nOrderPos = -1;
m_wallet.AddAccountingEntry(ae);

GetResults(m_wallet, results);

BOOST_CHECK(results.size() == 4);
BOOST_CHECK(m_wallet.nOrderPosNext == 7);
BOOST_CHECK(0 == vpwtx[2]->nOrderPos);
BOOST_CHECK(results[1].nTime == 1333333333);
BOOST_CHECK(2 == vpwtx[0]->nOrderPos);
BOOST_CHECK(results[3].nTime == 1333333336);
BOOST_CHECK(results[3].strComment.empty());
BOOST_CHECK(results[4].nTime == 1333333330);
BOOST_CHECK(results[4].strComment.empty());
BOOST_CHECK(results[5].nTime == 1333333334);
BOOST_CHECK(6 == vpwtx[1]->nOrderPos);
}

BOOST_AUTO_TEST_SUITE_END()
2 changes: 1 addition & 1 deletion src/wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class CWalletTx : public CMerkleTx
* serialized in the wallet database:
*
* "comment", "to" - comment strings provided to sendtoaddress,
* sendfrom, sendmany wallet RPCs
* and sendmany wallet RPCs
* "replaces_txid" - txid (as HexStr) of transaction replaced by
* bumpfee on transaction created by bumpfee
* "replaced_by_txid" - txid (as HexStr) of transaction created by
Expand Down
80 changes: 1 addition & 79 deletions test/functional/rpc_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test deprecation of RPC calls."""
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_raises_rpc_error

class DeprecatedRpcTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.setup_clean_chain = True
self.extra_args = [[], ["-deprecatedrpc=validateaddress", "-deprecatedrpc=accounts"]]
self.extra_args = [[], ["-deprecatedrpc=validateaddress"]]

def run_test(self):
# This test should be used to verify correct behaviour of deprecated
Expand All @@ -27,82 +26,5 @@ def run_test(self):
not_dep_val = self.nodes[1].validateaddress(SOME_ADDRESS)
assert "ismine" in not_dep_val

self.log.info("Test accounts deprecation")
# The following account RPC methods are deprecated:
# - getaccount
# - getaccountaddress
# - getaddressesbyaccount
# - getreceivedbyaccount
# - listaccouts
# - listreceivedbyaccount
# - move
# - setaccount
#
# The following 'label' RPC methods are usable both with and without the
# -deprecatedrpc=accounts switch enabled.
# - getaddressesbylabel
# - getreceivedbylabel
# - listlabels
# - listreceivedbylabel
# - setlabel
#
address0 = self.nodes[0].getnewaddress()
self.nodes[0].generatetoaddress(101, address0)
self.sync_all()
address1 = self.nodes[1].getnewaddress()
self.nodes[1].generatetoaddress(101, address1)

self.log.info("- getaccount")
assert_raises_rpc_error(-32, "getaccount is deprecated", self.nodes[0].getaccount, address0)
self.nodes[1].getaccount(address1)

self.log.info("- setaccount")
assert_raises_rpc_error(-32, "setaccount is deprecated", self.nodes[0].setaccount, address0, "label0")
self.nodes[1].setaccount(address1, "label1")

self.log.info("- setlabel")
self.nodes[0].setlabel(address0, "label0")
self.nodes[1].setlabel(address1, "label1")

self.log.info("- getaccountaddress")
assert_raises_rpc_error(-32, "getaccountaddress is deprecated", self.nodes[0].getaccountaddress, "label0")
self.nodes[1].getaccountaddress("label1")

self.log.info("- getaddressesbyaccount")
assert_raises_rpc_error(-32, "getaddressesbyaccount is deprecated", self.nodes[0].getaddressesbyaccount, "label0")
self.nodes[1].getaddressesbyaccount("label1")

self.log.info("- getaddressesbylabel")
self.nodes[0].getaddressesbylabel("label0")
self.nodes[1].getaddressesbylabel("label1")

self.log.info("- getreceivedbyaccount")
assert_raises_rpc_error(-32, "getreceivedbyaccount is deprecated", self.nodes[0].getreceivedbyaccount, "label0")
self.nodes[1].getreceivedbyaccount("label1")

self.log.info("- getreceivedbylabel")
self.nodes[0].getreceivedbylabel("label0")
self.nodes[1].getreceivedbylabel("label1")

self.log.info("- listaccounts")
assert_raises_rpc_error(-32, "listaccounts is deprecated", self.nodes[0].listaccounts)
self.nodes[1].listaccounts()

self.log.info("- listlabels")
self.nodes[0].listlabels()
self.nodes[1].listlabels()

self.log.info("- listreceivedbyaccount")
assert_raises_rpc_error(-32, "listreceivedbyaccount is deprecated", self.nodes[0].listreceivedbyaccount)
self.nodes[1].listreceivedbyaccount()

self.log.info("- listreceivedbylabel")
self.nodes[0].listreceivedbylabel()
self.nodes[1].listreceivedbylabel()

self.log.info("- move")
assert_raises_rpc_error(-32, "move is deprecated", self.nodes[0].move, "label0", "label0b", 10)
self.nodes[1].move("label1", "label1b", 10)

if __name__ == '__main__':
DeprecatedRpcTest().main()
Loading

0 comments on commit a15815c

Please sign in to comment.