Retrieves a public key for an address from the given CKeyStore
| 24 | |
| 25 | // Retrieves a public key for an address from the given CKeyStore |
| 26 | CPubKey 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. |
| 47 | CScript CreateMultisigRedeemscript(const int required, const std::vector<CPubKey>& pubkeys) |
no test coverage detected