Skip to content

Commit 2a854a1

Browse files
author
MarcoFalke
committed
Merge #15750: [rpc] Remove the addresses field from the getaddressinfo return object
b4338c1 [rpc] Remove the addresses field from the getaddressinfo return object (John Newbery) Pull request description: The "addresses" field was confusing because it refered to public keys using their P2PKH address. It was included in the return object when needed for backward compatibility. Remove that compatibility now that the -deprecatedrpc=validateaddress option has been removed. New applications should use the 'embedded'->'address' field for P2SH or P2WSH wrapped addresses, and 'pubkeys' for inspecting multisig participants. ACKs for commit b4338c: jonatack: ACK bitcoin/bitcoin@b4338c1. Tests [gist](https://gist.github.com/jonatack/31915e290bb1be39b9769dc9357385ca). Tree-SHA512: 2c207510e565df600428838bfc6db5211fa06aaace365e31cbd74f1d2376b598675cb90df2fc1440858d49b22095aaa9d6b9ce3de0aff22417fe72cc6a6a321f
2 parents 2a191b4 + b4338c1 commit 2a854a1

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3415,7 +3415,7 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
34153415
public:
34163416
CWallet * const pwallet;
34173417

3418-
void ProcessSubScript(const CScript& subscript, UniValue& obj, bool include_addresses = false) const
3418+
void ProcessSubScript(const CScript& subscript, UniValue& obj) const
34193419
{
34203420
// Always present: script type and redeemscript
34213421
std::vector<std::vector<unsigned char>> solutions_data;
@@ -3424,7 +3424,6 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
34243424
obj.pushKV("hex", HexStr(subscript.begin(), subscript.end()));
34253425

34263426
CTxDestination embedded;
3427-
UniValue a(UniValue::VARR);
34283427
if (ExtractDestination(subscript, embedded)) {
34293428
// Only when the script corresponds to an address.
34303429
UniValue subobj(UniValue::VOBJ);
@@ -3437,25 +3436,17 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
34373436
// Always report the pubkey at the top level, so that `getnewaddress()['pubkey']` always works.
34383437
if (subobj.exists("pubkey")) obj.pushKV("pubkey", subobj["pubkey"]);
34393438
obj.pushKV("embedded", std::move(subobj));
3440-
if (include_addresses) a.push_back(EncodeDestination(embedded));
34413439
} else if (which_type == TX_MULTISIG) {
34423440
// Also report some information on multisig scripts (which do not have a corresponding address).
34433441
// TODO: abstract out the common functionality between this logic and ExtractDestinations.
34443442
obj.pushKV("sigsrequired", solutions_data[0][0]);
34453443
UniValue pubkeys(UniValue::VARR);
34463444
for (size_t i = 1; i < solutions_data.size() - 1; ++i) {
34473445
CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3448-
if (include_addresses) a.push_back(EncodeDestination(key.GetID()));
34493446
pubkeys.push_back(HexStr(key.begin(), key.end()));
34503447
}
34513448
obj.pushKV("pubkeys", std::move(pubkeys));
34523449
}
3453-
3454-
// The "addresses" field is confusing because it refers to public keys using their P2PKH address.
3455-
// For that reason, only add the 'addresses' field when needed for backward compatibility. New applications
3456-
// can use the 'embedded'->'address' field for P2SH or P2WSH wrapped addresses, and 'pubkeys' for
3457-
// inspecting multisig participants.
3458-
if (include_addresses) obj.pushKV("addresses", std::move(a));
34593450
}
34603451

34613452
explicit DescribeWalletAddressVisitor(CWallet* _pwallet) : pwallet(_pwallet) {}
@@ -3478,7 +3469,7 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
34783469
UniValue obj(UniValue::VOBJ);
34793470
CScript subscript;
34803471
if (pwallet && pwallet->GetCScript(scriptID, subscript)) {
3481-
ProcessSubScript(subscript, obj, pwallet->chain().rpcEnableDeprecated("validateaddress"));
3472+
ProcessSubScript(subscript, obj);
34823473
}
34833474
return obj;
34843475
}

0 commit comments

Comments
 (0)