Skip to content

Commit b4338c1

Browse files
committed
[rpc] Remove the addresses field from the getaddressinfo return object
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.
1 parent 0e9cb2d commit b4338c1

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
@@ -3408,7 +3408,7 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
34083408
public:
34093409
CWallet * const pwallet;
34103410

3411-
void ProcessSubScript(const CScript& subscript, UniValue& obj, bool include_addresses = false) const
3411+
void ProcessSubScript(const CScript& subscript, UniValue& obj) const
34123412
{
34133413
// Always present: script type and redeemscript
34143414
std::vector<std::vector<unsigned char>> solutions_data;
@@ -3417,7 +3417,6 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
34173417
obj.pushKV("hex", HexStr(subscript.begin(), subscript.end()));
34183418

34193419
CTxDestination embedded;
3420-
UniValue a(UniValue::VARR);
34213420
if (ExtractDestination(subscript, embedded)) {
34223421
// Only when the script corresponds to an address.
34233422
UniValue subobj(UniValue::VOBJ);
@@ -3430,25 +3429,17 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
34303429
// Always report the pubkey at the top level, so that `getnewaddress()['pubkey']` always works.
34313430
if (subobj.exists("pubkey")) obj.pushKV("pubkey", subobj["pubkey"]);
34323431
obj.pushKV("embedded", std::move(subobj));
3433-
if (include_addresses) a.push_back(EncodeDestination(embedded));
34343432
} else if (which_type == TX_MULTISIG) {
34353433
// Also report some information on multisig scripts (which do not have a corresponding address).
34363434
// TODO: abstract out the common functionality between this logic and ExtractDestinations.
34373435
obj.pushKV("sigsrequired", solutions_data[0][0]);
34383436
UniValue pubkeys(UniValue::VARR);
34393437
for (size_t i = 1; i < solutions_data.size() - 1; ++i) {
34403438
CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3441-
if (include_addresses) a.push_back(EncodeDestination(key.GetID()));
34423439
pubkeys.push_back(HexStr(key.begin(), key.end()));
34433440
}
34443441
obj.pushKV("pubkeys", std::move(pubkeys));
34453442
}
3446-
3447-
// The "addresses" field is confusing because it refers to public keys using their P2PKH address.
3448-
// For that reason, only add the 'addresses' field when needed for backward compatibility. New applications
3449-
// can use the 'embedded'->'address' field for P2SH or P2WSH wrapped addresses, and 'pubkeys' for
3450-
// inspecting multisig participants.
3451-
if (include_addresses) obj.pushKV("addresses", std::move(a));
34523443
}
34533444

34543445
explicit DescribeWalletAddressVisitor(CWallet* _pwallet) : pwallet(_pwallet) {}
@@ -3471,7 +3462,7 @@ class DescribeWalletAddressVisitor : public boost::static_visitor<UniValue>
34713462
UniValue obj(UniValue::VOBJ);
34723463
CScript subscript;
34733464
if (pwallet && pwallet->GetCScript(scriptID, subscript)) {
3474-
ProcessSubScript(subscript, obj, pwallet->chain().rpcEnableDeprecated("validateaddress"));
3465+
ProcessSubScript(subscript, obj);
34753466
}
34763467
return obj;
34773468
}

0 commit comments

Comments
 (0)