Merge #17584: wallet: replace raw pointer with const reference in AddrToPubKey
1a3a256d5e
wallet: replace raw pointer with const reference in AddrToPubKey (Harris) Pull request description: This PR replaces a redundant reference-to-pointer conversion in **addmultisigaddress** from *wallet/rpcwallet.cpp*. It also makes the API from *rpc/util.h* look more straightforward as **AddrToPubKey** now uses const references like other functions from there. I am not sure why there is a ref-to-ptr conversion in addmultisignatures, so I can only speculate that this is because of "historical reasons". The ref-to-ptr conversion happens here: https://github.com/bitcoin/bitcoin/blob/master/src/wallet/rpcwallet.cpp#L1001 There, the address of LegacyScriptPubKeyMan& is given to AddrToPubKey. Later, in AddrToPubKey, it gets converted back to a reference, because GetKeyForDestination in rpc/util.cpp expects a const ref: https://github.com/bitcoin/bitcoin/blob/master/src/rpc/util.cpp#L140 Regards, ACKs for top commit: achow101: ACK1a3a256d5e
meshcollider: utACK1a3a256d5e
promag: Code review ACK1a3a256d5e
. hebasto: ACK1a3a256d5e
, I have not tested the code, but I have reviewed it and it looks OK, I agree it can be merged. Tree-SHA512: 1a2b8ddab5694ef4c65fac69f011e38dd03a634e84a35857e13bd05ad99fe42af22ee0af6230865e3d2c725693512f3336acb055ede19c958424283e7a3856c4
This commit is contained in:
commit
0ee914ba9e
3 changed files with 5 additions and 5 deletions
|
@ -131,18 +131,18 @@ CPubKey HexToPubKey(const std::string& hex_in)
|
|||
}
|
||||
|
||||
// Retrieves a public key for an address from the given FillableSigningProvider
|
||||
CPubKey AddrToPubKey(FillableSigningProvider* const keystore, const std::string& addr_in)
|
||||
CPubKey AddrToPubKey(const FillableSigningProvider& keystore, const std::string& addr_in)
|
||||
{
|
||||
CTxDestination dest = DecodeDestination(addr_in);
|
||||
if (!IsValidDestination(dest)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address: " + addr_in);
|
||||
}
|
||||
CKeyID key = GetKeyForDestination(*keystore, dest);
|
||||
CKeyID key = GetKeyForDestination(keystore, dest);
|
||||
if (key.IsNull()) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("%s does not refer to a key", addr_in));
|
||||
}
|
||||
CPubKey vchPubKey;
|
||||
if (!keystore->GetPubKey(key, vchPubKey)) {
|
||||
if (!keystore.GetPubKey(key, vchPubKey)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("no full public key for address %s", addr_in));
|
||||
}
|
||||
if (!vchPubKey.IsFullyValid()) {
|
||||
|
|
|
@ -69,7 +69,7 @@ extern std::string HelpExampleCli(const std::string& methodname, const std::stri
|
|||
extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args);
|
||||
|
||||
CPubKey HexToPubKey(const std::string& hex_in);
|
||||
CPubKey AddrToPubKey(FillableSigningProvider* const keystore, const std::string& addr_in);
|
||||
CPubKey AddrToPubKey(const FillableSigningProvider& keystore, const std::string& addr_in);
|
||||
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector<CPubKey>& pubkeys, OutputType type, FillableSigningProvider& keystore, CScript& script_out);
|
||||
|
||||
UniValue DescribeAddress(const CTxDestination& dest);
|
||||
|
|
|
@ -998,7 +998,7 @@ static UniValue addmultisigaddress(const JSONRPCRequest& request)
|
|||
if (IsHex(keys_or_addrs[i].get_str()) && (keys_or_addrs[i].get_str().length() == 66 || keys_or_addrs[i].get_str().length() == 130)) {
|
||||
pubkeys.push_back(HexToPubKey(keys_or_addrs[i].get_str()));
|
||||
} else {
|
||||
pubkeys.push_back(AddrToPubKey(&spk_man, keys_or_addrs[i].get_str()));
|
||||
pubkeys.push_back(AddrToPubKey(spk_man, keys_or_addrs[i].get_str()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue