MCPcopy Create free account
hub / github.com/ElementsProject/elements / AddrToPubKey

Function AddrToPubKey

src/rpc/util.cpp:220–238  ·  view source on GitHub ↗

Retrieves a public key for an address from the given FillableSigningProvider

Source from the content-addressed store, hash-verified

218
219// Retrieves a public key for an address from the given FillableSigningProvider
220CPubKey AddrToPubKey(const FillableSigningProvider& keystore, const std::string& addr_in)
221{
222 CTxDestination dest = DecodeDestination(addr_in);
223 if (!IsValidDestination(dest)) {
224 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address: " + addr_in);
225 }
226 CKeyID key = GetKeyForDestination(keystore, dest);
227 if (key.IsNull()) {
228 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("'%s' does not refer to a key", addr_in));
229 }
230 CPubKey vchPubKey;
231 if (!keystore.GetPubKey(key, vchPubKey)) {
232 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("no full public key for address %s", addr_in));
233 }
234 if (!vchPubKey.IsFullyValid()) {
235 throw JSONRPCError(RPC_INTERNAL_ERROR, "Wallet contains an invalid public key");
236 }
237 return vchPubKey;
238}
239
240// Creates a multisig address from a given list of public keys, number of signatures required, and the address type
241CTxDestination AddAndGetMultisigDestination(const int required, const std::vector<CPubKey>& pubkeys, OutputType type, FillableSigningProvider& keystore, CScript& script_out)

Callers 2

addmultisigaddressFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls 7

DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
JSONRPCErrorFunction · 0.85
GetKeyForDestinationFunction · 0.85
IsFullyValidMethod · 0.80
IsNullMethod · 0.45
GetPubKeyMethod · 0.45

Tested by 1

FUZZ_TARGET_INITFunction · 0.68