Skip to content

Commit 17180fa

Browse files
committed
Merge #12210: wallet: Deprecate addwitnessaddress
cdf3e03 wallet: Deprecate addwitnessaddress (Wladimir J. van der Laan) Pull request description: Now that segwit is natively supported by the wallet, deprecate the hack `addwitnessaddress`. Tree-SHA512: f33b1c33d200fa8f1a0fba424b30e9c2a78147cde8bb0a3fd41194b77980454cddfb23da256cd6fe78726e87161deaa23357d0764e74c3eb83177cc518afa49c
2 parents c7978be + cdf3e03 commit 17180fa

File tree

7 files changed

+18
-9
lines changed

7 files changed

+18
-9
lines changed

doc/release-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ Low-level RPC changes
9797
* `getwalletinfo`
9898
* `getmininginfo`
9999
- The wallet RPC `getreceivedbyaddress` will return an error if called with an address not in the wallet.
100+
- The wallet RPC `addwitnessaddress` was deprecated and will be removed in version 0.17,
101+
set the `address_type` argument of `getnewaddress`, or option `-addresstype=[bech32|p2sh-segwit]` instead.
100102

101103
Changed command-line options
102104
-----------------------------

src/wallet/rpcwallet.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,8 @@ UniValue addwitnessaddress(const JSONRPCRequest& request)
12851285
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
12861286
{
12871287
std::string msg = "addwitnessaddress \"address\" ( p2sh )\n"
1288-
"\nAdd a witness address for a script (with pubkey or redeemscript known). Requires a new wallet backup.\n"
1288+
"\nDEPRECATED: set the address_type argument of getnewaddress, or option -addresstype=[bech32|p2sh-segwit] instead.\n"
1289+
"Add a witness address for a script (with pubkey or redeemscript known). Requires a new wallet backup.\n"
12891290
"It returns the witness script.\n"
12901291

12911292
"\nArguments:\n"
@@ -1299,6 +1300,12 @@ UniValue addwitnessaddress(const JSONRPCRequest& request)
12991300
throw std::runtime_error(msg);
13001301
}
13011302

1303+
if (!IsDeprecatedRPCEnabled("addwitnessaddress")) {
1304+
throw JSONRPCError(RPC_METHOD_DEPRECATED, "addwitnessaddress is deprecated and will be fully removed in v0.17. "
1305+
"To use addwitnessaddress in v0.16, restart bitcoind with -deprecatedrpc=addwitnessaddress.\n"
1306+
"Projects should transition to using the address_type argument of getnewaddress, or option -addresstype=[bech32|p2sh-segwit] instead.\n");
1307+
}
1308+
13021309
{
13031310
LOCK(cs_main);
13041311
if (!IsWitnessEnabled(chainActive.Tip(), Params().GetConsensus()) && !gArgs.GetBoolArg("-walletprematurewitness", false)) {
@@ -3479,7 +3486,7 @@ static const CRPCCommand commands[] =
34793486
{ "wallet", "abandontransaction", &abandontransaction, {"txid"} },
34803487
{ "wallet", "abortrescan", &abortrescan, {} },
34813488
{ "wallet", "addmultisigaddress", &addmultisigaddress, {"nrequired","keys","account"} },
3482-
{ "wallet", "addwitnessaddress", &addwitnessaddress, {"address","p2sh"} },
3489+
{ "hidden", "addwitnessaddress", &addwitnessaddress, {"address","p2sh"} },
34833490
{ "wallet", "backupwallet", &backupwallet, {"destination"} },
34843491
{ "wallet", "bumpfee", &bumpfee, {"txid", "options"} },
34853492
{ "wallet", "dumpprivkey", &dumpprivkey, {"address"} },

test/functional/bumpfee.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BumpFeeTest(BitcoinTestFramework):
3333
def set_test_params(self):
3434
self.num_nodes = 2
3535
self.setup_clean_chain = True
36-
self.extra_args = [["-prematurewitness", "-walletprematurewitness", "-walletrbf={}".format(i)]
36+
self.extra_args = [["-prematurewitness", "-walletprematurewitness", "-deprecatedrpc=addwitnessaddress", "-walletrbf={}".format(i)]
3737
for i in range(self.num_nodes)]
3838

3939
def run_test(self):

test/functional/nulldummy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def set_test_params(self):
4242
self.setup_clean_chain = True
4343
# This script tests NULLDUMMY activation, which is part of the 'segwit' deployment, so we go through
4444
# normal segwit activation here (and don't use the default always-on behaviour).
45-
self.extra_args = [['-whitelist=127.0.0.1', '-walletprematurewitness', '-vbparams=segwit:0:999999999999', '-addresstype=legacy']]
45+
self.extra_args = [['-whitelist=127.0.0.1', '-walletprematurewitness', '-vbparams=segwit:0:999999999999', '-addresstype=legacy', "-deprecatedrpc=addwitnessaddress"]]
4646

4747
def run_test(self):
4848
self.address = self.nodes[0].getnewaddress()

test/functional/p2p-compactblocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def set_test_params(self):
9595
self.num_nodes = 2
9696
# This test was written assuming SegWit is activated using BIP9 at height 432 (3x confirmation window).
9797
# TODO: Rewrite this test to support SegWit being always active.
98-
self.extra_args = [["-vbparams=segwit:0:0"], ["-vbparams=segwit:0:999999999999", "-txindex"]]
98+
self.extra_args = [["-vbparams=segwit:0:0"], ["-vbparams=segwit:0:999999999999", "-txindex", "-deprecatedrpc=addwitnessaddress"]]
9999
self.utxos = []
100100

101101
def build_block_on_tip(self, node, segwit=False):

test/functional/segwit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ def set_test_params(self):
4040
self.setup_clean_chain = True
4141
self.num_nodes = 3
4242
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
43-
self.extra_args = [["-walletprematurewitness", "-rpcserialversion=0", "-vbparams=segwit:0:999999999999", "-addresstype=legacy"],
44-
["-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-rpcserialversion=1", "-vbparams=segwit:0:999999999999", "-addresstype=legacy"],
45-
["-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-vbparams=segwit:0:999999999999", "-addresstype=legacy"]]
43+
self.extra_args = [["-walletprematurewitness", "-rpcserialversion=0", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"],
44+
["-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-rpcserialversion=1", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"],
45+
["-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"]]
4646

4747
def setup_network(self):
4848
super().setup_network()

test/functional/wallet-dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old):
6969
class WalletDumpTest(BitcoinTestFramework):
7070
def set_test_params(self):
7171
self.num_nodes = 1
72-
self.extra_args = [["-keypool=90", "-addresstype=legacy"]]
72+
self.extra_args = [["-keypool=90", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"]]
7373

7474
def setup_network(self, split=False):
7575
# Use 1 minute timeout because the initial getnewaddress RPC can take

0 commit comments

Comments
 (0)