MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / AddrToPubKey

Function AddrToPubKey

src/rpc/util.cpp:26–44  ·  view source on GitHub ↗

Retrieves a public key for an address from the given CKeyStore

Source from the content-addressed store, hash-verified

24
25// Retrieves a public key for an address from the given CKeyStore
26CPubKey AddrToPubKey(CKeyStore* const keystore, const std::string& addr_in)
27{
28 CTxDestination dest = DecodeDestination(addr_in);
29 if (!IsValidDestination(dest)) {
30 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address: " + addr_in);
31 }
32 CKeyID key = GetKeyForDestination(*keystore, dest);
33 if (key.IsNull()) {
34 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("%s does not refer to a key", addr_in));
35 }
36 CPubKey vchPubKey;
37 if (!keystore->GetPubKey(key, vchPubKey)) {
38 throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("no full public key for address %s", addr_in));
39 }
40 if (!vchPubKey.IsFullyValid()) {
41 throw JSONRPCError(RPC_INTERNAL_ERROR, "Wallet contains an invalid public key");
42 }
43 return vchPubKey;
44}
45
46// Creates a multisig redeemscript from a given list of public keys and number required.
47CScript CreateMultisigRedeemscript(const int required, const std::vector<CPubKey>& pubkeys)

Callers 1

addmultisigaddressFunction · 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

no test coverage detected