wallet: replace raw pointer with const reference in AddrToPubKey

This commit is contained in:
Harris committed 2019-11-24 22:53:42 +01:00
1 parent 239d199667
commit 1a3a256d5e
3 files changed
+5 -5

No files matched your search

+3 -3
View File
@@ -131,18 +131,18 @@ CPubKey HexToPubKey(const std::string& hex_in)
} }
// Retrieves a public key for an address from the given FillableSigningProvider // 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); CTxDestination dest = DecodeDestination(addr_in);
if (!IsValidDestination(dest)) { if (!IsValidDestination(dest)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address: " + addr_in); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address: " + addr_in);
} }
CKeyID key = GetKeyForDestination(*keystore, dest); CKeyID key = GetKeyForDestination(keystore, dest);
if (key.IsNull()) { if (key.IsNull()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("%s does not refer to a key", addr_in)); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("%s does not refer to a key", addr_in));
} }
CPubKey vchPubKey; 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)); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("no full public key for address %s", addr_in));
} }
if (!vchPubKey.IsFullyValid()) { if (!vchPubKey.IsFullyValid()) {
+1 -1
View File
@@ -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); extern std::string HelpExampleRpc(const std::string& methodname, const std::string& args);
CPubKey HexToPubKey(const std::string& hex_in); 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); CTxDestination AddAndGetMultisigDestination(const int required, const std::vector<CPubKey>& pubkeys, OutputType type, FillableSigningProvider& keystore, CScript& script_out);
UniValue DescribeAddress(const CTxDestination& dest); UniValue DescribeAddress(const CTxDestination& dest);
+1 -1
View File
@@ -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)) { 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())); pubkeys.push_back(HexToPubKey(keys_or_addrs[i].get_str()));
} else { } 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()));
} }
} }