Skip to content

Commit 9dda5fd

Browse files
author
MarcoFalke
committed
Merge #14296: [wallet] Remove addwitnessaddress
2b91e42 [docs] Add release note for removing getwitnessaddress (John Newbery) ebec90a [wallet] Remove deprecated addwitnessaddress RPC method (John Newbery) 07e3f58 [test] Remove deprecated addwitnessaddress from feature_segwit.py (John Newbery) 82f2fa0 [test] Remove deprecated addwitnessaddress from wallet_bumpfee.py (John Newbery) 9d7ee18 [test] Remove deprecated addwitnessaddress from p2p_compactblocks.py (John Newbery) 3cf77f0 [tests] Remove deprecated addwitnessaddress call from wallet_dump.py (John Newbery) bdefc97 [tests] Remove deprecated addwitnessaddress call from feature_nulldummy (John Newbery) 67d7d67 [test] Fix flake8 warnings in tests (John Newbery) Pull request description: Fully removes the `addwitnessaddress` RPC method, which was deprecated in V0.17 Tree-SHA512: 8fa8a2a721a81262fbdedbe1cef031e6a07aa6abbc9760dbc62738fc4f688b44bd737d0f3cdb1aec046866a6395befbfecde0f34e76a99e11d3cf566cad1d0de
2 parents e895fdc + 2b91e42 commit 9dda5fd

File tree

8 files changed

+130
-306
lines changed

8 files changed

+130
-306
lines changed

doc/release-notes-14296.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
addwitnessaddress RPC method removed
2+
------------------------------------
3+
4+
The `addwitnessaddress` RPC was added for segwit testing in version 0.13.0. It
5+
was deprecated in version 0.16.0. This version fully removes the RPC method.

src/rpc/client.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ static const CRPCConvertParam vRPCConvertParams[] =
147147
{ "logging", 0, "include" },
148148
{ "logging", 1, "exclude" },
149149
{ "disconnectnode", 1, "nodeid" },
150-
{ "addwitnessaddress", 1, "p2sh" },
151150
// Echo with conversion (For testing only)
152151
{ "echojson", 0, "arg0" },
153152
{ "echojson", 1, "arg1" },

src/wallet/rpcwallet.cpp

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -982,131 +982,6 @@ static UniValue addmultisigaddress(const JSONRPCRequest& request)
982982
return result;
983983
}
984984

985-
class Witnessifier : public boost::static_visitor<bool>
986-
{
987-
public:
988-
CWallet * const pwallet;
989-
CTxDestination result;
990-
bool already_witness;
991-
992-
explicit Witnessifier(CWallet *_pwallet) : pwallet(_pwallet), already_witness(false) {}
993-
994-
bool operator()(const CKeyID &keyID) {
995-
if (pwallet) {
996-
CScript basescript = GetScriptForDestination(keyID);
997-
CScript witscript = GetScriptForWitness(basescript);
998-
if (!IsSolvable(*pwallet, witscript)) {
999-
return false;
1000-
}
1001-
return ExtractDestination(witscript, result);
1002-
}
1003-
return false;
1004-
}
1005-
1006-
bool operator()(const CScriptID &scriptID) {
1007-
CScript subscript;
1008-
if (pwallet && pwallet->GetCScript(scriptID, subscript)) {
1009-
int witnessversion;
1010-
std::vector<unsigned char> witprog;
1011-
if (subscript.IsWitnessProgram(witnessversion, witprog)) {
1012-
ExtractDestination(subscript, result);
1013-
already_witness = true;
1014-
return true;
1015-
}
1016-
CScript witscript = GetScriptForWitness(subscript);
1017-
if (!IsSolvable(*pwallet, witscript)) {
1018-
return false;
1019-
}
1020-
return ExtractDestination(witscript, result);
1021-
}
1022-
return false;
1023-
}
1024-
1025-
bool operator()(const WitnessV0KeyHash& id)
1026-
{
1027-
already_witness = true;
1028-
result = id;
1029-
return true;
1030-
}
1031-
1032-
bool operator()(const WitnessV0ScriptHash& id)
1033-
{
1034-
already_witness = true;
1035-
result = id;
1036-
return true;
1037-
}
1038-
1039-
template<typename T>
1040-
bool operator()(const T& dest) { return false; }
1041-
};
1042-
1043-
static UniValue addwitnessaddress(const JSONRPCRequest& request)
1044-
{
1045-
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
1046-
CWallet* const pwallet = wallet.get();
1047-
1048-
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
1049-
return NullUniValue;
1050-
}
1051-
1052-
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
1053-
{
1054-
std::string msg = "addwitnessaddress \"address\" ( p2sh )\n"
1055-
"\nDEPRECATED: set the address_type argument of getnewaddress, or option -addresstype=[bech32|p2sh-segwit] instead.\n"
1056-
"Add a witness address for a script (with pubkey or redeemscript known). Requires a new wallet backup.\n"
1057-
"It returns the witness script.\n"
1058-
1059-
"\nArguments:\n"
1060-
"1. \"address\" (string, required) An address known to the wallet\n"
1061-
"2. p2sh (bool, optional, default=true) Embed inside P2SH\n"
1062-
1063-
"\nResult:\n"
1064-
"\"witnessaddress\", (string) The value of the new address (P2SH or BIP173).\n"
1065-
"}\n"
1066-
;
1067-
throw std::runtime_error(msg);
1068-
}
1069-
1070-
if (!IsDeprecatedRPCEnabled("addwitnessaddress")) {
1071-
throw JSONRPCError(RPC_METHOD_DEPRECATED, "addwitnessaddress is deprecated and will be fully removed in v0.17. "
1072-
"To use addwitnessaddress in v0.16, restart bitcoind with -deprecatedrpc=addwitnessaddress.\n"
1073-
"Projects should transition to using the address_type argument of getnewaddress, or option -addresstype=[bech32|p2sh-segwit] instead.\n");
1074-
}
1075-
1076-
CTxDestination dest = DecodeDestination(request.params[0].get_str());
1077-
if (!IsValidDestination(dest)) {
1078-
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
1079-
}
1080-
1081-
bool p2sh = true;
1082-
if (!request.params[1].isNull()) {
1083-
p2sh = request.params[1].get_bool();
1084-
}
1085-
1086-
Witnessifier w(pwallet);
1087-
bool ret = boost::apply_visitor(w, dest);
1088-
if (!ret) {
1089-
throw JSONRPCError(RPC_WALLET_ERROR, "Public key or redeemscript not known to wallet, or the key is uncompressed");
1090-
}
1091-
1092-
CScript witprogram = GetScriptForDestination(w.result);
1093-
1094-
if (p2sh) {
1095-
w.result = CScriptID(witprogram);
1096-
}
1097-
1098-
if (w.already_witness) {
1099-
if (!(dest == w.result)) {
1100-
throw JSONRPCError(RPC_WALLET_ERROR, "Cannot convert between witness address types");
1101-
}
1102-
} else {
1103-
pwallet->AddCScript(witprogram); // Implicit for single-key now, but necessary for multisig and for compatibility with older software
1104-
pwallet->SetAddressBook(w.result, "", "receive");
1105-
}
1106-
1107-
return EncodeDestination(w.result);
1108-
}
1109-
1110985
struct tallyitem
1111986
{
1112987
CAmount nAmount;
@@ -4097,7 +3972,6 @@ static const CRPCCommand commands[] =
40973972
{ // category name actor (function) argNames
40983973
// --------------------- ------------------------ ----------------------- ----------
40993974
{ "generating", "generate", &generate, {"nblocks","maxtries"} },
4100-
{ "hidden", "addwitnessaddress", &addwitnessaddress, {"address","p2sh"} },
41013975
{ "hidden", "resendwallettransactions", &resendwallettransactions, {} },
41023976
{ "rawtransactions", "fundrawtransaction", &fundrawtransaction, {"hexstring","options","iswitness"} },
41033977
{ "wallet", "abandontransaction", &abandontransaction, {"txid"} },

test/functional/feature_nulldummy.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@
1212
[Consensus] Check that the new NULLDUMMY rules are not enforced on the 431st block.
1313
[Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block.
1414
"""
15+
import time
1516

1617
from test_framework.blocktools import create_coinbase, create_block, create_transaction, add_witness_commitment
1718
from test_framework.messages import CTransaction
1819
from test_framework.script import CScript
1920
from test_framework.test_framework import BitcoinTestFramework
2021
from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str
2122

22-
import time
23-
2423
NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero) (code 64)"
2524

2625
def trueDummy(tx):
@@ -42,22 +41,22 @@ def set_test_params(self):
4241
self.setup_clean_chain = True
4342
# This script tests NULLDUMMY activation, which is part of the 'segwit' deployment, so we go through
4443
# normal segwit activation here (and don't use the default always-on behaviour).
45-
self.extra_args = [['-whitelist=127.0.0.1', '-vbparams=segwit:0:999999999999', '-addresstype=legacy', "-deprecatedrpc=addwitnessaddress"]]
44+
self.extra_args = [['-whitelist=127.0.0.1', '-vbparams=segwit:0:999999999999', '-addresstype=legacy']]
4645

4746
def skip_test_if_missing_module(self):
4847
self.skip_if_no_wallet()
4948

5049
def run_test(self):
5150
self.address = self.nodes[0].getnewaddress()
5251
self.ms_address = self.nodes[0].addmultisigaddress(1, [self.address])['address']
53-
self.wit_address = self.nodes[0].addwitnessaddress(self.address)
52+
self.wit_address = self.nodes[0].getnewaddress(address_type='p2sh-segwit')
5453
self.wit_ms_address = self.nodes[0].addmultisigaddress(1, [self.address], '', 'p2sh-segwit')['address']
5554

56-
self.coinbase_blocks = self.nodes[0].generate(2) # Block 2
55+
self.coinbase_blocks = self.nodes[0].generate(2) # Block 2
5756
coinbase_txid = []
5857
for i in self.coinbase_blocks:
5958
coinbase_txid.append(self.nodes[0].getblock(i)['tx'][0])
60-
self.nodes[0].generate(427) # Block 429
59+
self.nodes[0].generate(427) # Block 429
6160
self.lastblockhash = self.nodes[0].getbestblockhash()
6261
self.tip = int("0x" + self.lastblockhash, 0)
6362
self.lastblockheight = 429
@@ -82,7 +81,7 @@ def run_test(self):
8281

8382
self.log.info("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation")
8483
test4tx = create_transaction(self.nodes[0], test2tx.hash, self.address, amount=46)
85-
test6txs=[CTransaction(test4tx)]
84+
test6txs = [CTransaction(test4tx)]
8685
trueDummy(test4tx)
8786
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, bytes_to_hex_str(test4tx.serialize_with_witness()), True)
8887
self.block_submit(self.nodes[0], [test4tx])
@@ -99,8 +98,7 @@ def run_test(self):
9998
self.nodes[0].sendrawtransaction(bytes_to_hex_str(i.serialize_with_witness()), True)
10099
self.block_submit(self.nodes[0], test6txs, True, True)
101100

102-
103-
def block_submit(self, node, txs, witness = False, accept = False):
101+
def block_submit(self, node, txs, witness=False, accept=False):
104102
block = create_block(self.tip, create_coinbase(self.lastblockheight + 1), self.lastblocktime + 1)
105103
block.nVersion = 4
106104
for tx in txs:

0 commit comments

Comments
 (0)