From 1e79c055cd30d21ba5f8c7f81ef911d5d4e295a8 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 12 Jun 2017 12:23:02 -0700 Subject: [PATCH] Split signrawtransaction into wallet and non-wallet Splits signrwatransaction into a wallet version (signrawtransactionwithwallet) and non-wallet version (signrawtransactionwithkey). signrawtransaction is marked as DEPRECATED and will call the right signrawtransaction* command as per the parameters in order to maintain compatibility. Updated signrawtransactions test to use new RPCs --- src/Makefile.am | 1 + src/qt/rpcconsole.cpp | 9 +- src/qt/test/rpcnestedtests.cpp | 4 +- src/rpc/client.cpp | 3 + src/rpc/rawtransaction.cpp | 473 +++++++++++++--------- src/rpc/rawtransaction.h | 15 + src/test/rpc_tests.cpp | 12 +- src/wallet/rpcwallet.cpp | 181 ++++++--- src/wallet/rpcwallet.h | 2 +- test/functional/rpc_signrawtransaction.py | 8 +- test/functional/test_framework/util.py | 4 +- test/functional/wallet_txn_clone.py | 2 +- 12 files changed, 440 insertions(+), 274 deletions(-) create mode 100644 src/rpc/rawtransaction.h diff --git a/src/Makefile.am b/src/Makefile.am index 9ca2b2c82..ac822d6c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -132,6 +132,7 @@ BITCOIN_CORE_H = \ rpc/protocol.h \ rpc/safemode.h \ rpc/server.h \ + rpc/rawtransaction.h \ rpc/register.h \ rpc/util.h \ scheduler.h \ diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index c4b209a88..1aa4de03c 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -70,6 +70,7 @@ const QStringList historyFilter = QStringList() << "importmulti" << "signmessagewithprivkey" << "signrawtransaction" + << "signrawtransactionwithkey" << "walletpassphrase" << "walletpassphrasechange" << "encryptwallet"; @@ -624,7 +625,7 @@ void RPCConsole::setClientModel(ClientModel *model) connect(model->getPeerTableModel(), SIGNAL(layoutChanged()), this, SLOT(peerLayoutChanged())); // peer table signal handling - cache selected node ids connect(model->getPeerTableModel(), SIGNAL(layoutAboutToBeChanged()), this, SLOT(peerLayoutAboutToChange())); - + // set up ban table ui->banlistWidget->setModel(model->getBanTableModel()); ui->banlistWidget->verticalHeader()->hide(); @@ -772,7 +773,7 @@ void RPCConsole::clear(bool clearHistory) #else QString clsKey = "Ctrl-L"; #endif - + message(CMD_REPLY, (tr("Welcome to the %1 RPC console.").arg(tr(PACKAGE_NAME)) + "
" + tr("Use up and down arrows to navigate history, and %1 to clear screen.").arg(""+clsKey+"") + "
" + tr("Type %1 for an overview of available commands.").arg("help") + "
" + @@ -1144,7 +1145,7 @@ void RPCConsole::disconnectSelectedNode() { if(!g_connman) return; - + // Get selected peer addresses QList nodes = GUIUtil::getEntryData(ui->peerWidget, PeerTableModel::NetNodeId); for(int i = 0; i < nodes.count(); i++) @@ -1161,7 +1162,7 @@ void RPCConsole::banSelectedNode(int bantime) { if (!clientModel || !g_connman) return; - + // Get selected peer addresses QList nodes = GUIUtil::getEntryData(ui->peerWidget, PeerTableModel::NetNodeId); for(int i = 0; i < nodes.count(); i++) diff --git a/src/qt/test/rpcnestedtests.cpp b/src/qt/test/rpcnestedtests.cpp index aaec15cc1..9d0e0b97d 100644 --- a/src/qt/test/rpcnestedtests.cpp +++ b/src/qt/test/rpcnestedtests.cpp @@ -82,8 +82,8 @@ void RPCNestedTests::rpcNestedTests() QVERIFY(filtered == "signmessagewithprivkey(…)"); RPCConsole::RPCParseCommandLine(result, "signmessagewithprivkey abc,def", false, &filtered); QVERIFY(filtered == "signmessagewithprivkey(…)"); - RPCConsole::RPCParseCommandLine(result, "signrawtransaction(abc)", false, &filtered); - QVERIFY(filtered == "signrawtransaction(…)"); + RPCConsole::RPCParseCommandLine(result, "signrawtransactionwithkey(abc)", false, &filtered); + QVERIFY(filtered == "signrawtransactionwithkey(…)"); RPCConsole::RPCParseCommandLine(result, "walletpassphrase(help())", false, &filtered); QVERIFY(filtered == "walletpassphrase(…)"); RPCConsole::RPCParseCommandLine(result, "walletpassphrasechange(help(walletpassphrasechange(abc)))", false, &filtered); diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 99c1242d8..a95ea0cf9 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -94,6 +94,9 @@ static const CRPCConvertParam vRPCConvertParams[] = { "decoderawtransaction", 1, "iswitness" }, { "signrawtransaction", 1, "prevtxs" }, { "signrawtransaction", 2, "privkeys" }, + { "signrawtransactionwithkey", 1, "privkeys" }, + { "signrawtransactionwithkey", 2, "prevtxs" }, + { "signrawtransactionwithwallet", 1, "prevtxs" }, { "sendrawtransaction", 1, "allowhighfees" }, { "combinerawtransaction", 0, "txs" }, { "fundrawtransaction", 1, "options" }, diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index ef5f04e4e..813afde4d 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include