Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/util.cpp
Show First 20 Lines • Show All 150 Lines • ▼ Show 20 Lines | CPubKey HexToPubKey(const std::string &hex_in) { | ||||
CPubKey vchPubKey(ParseHex(hex_in)); | CPubKey vchPubKey(ParseHex(hex_in)); | ||||
if (!vchPubKey.IsFullyValid()) { | if (!vchPubKey.IsFullyValid()) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid public key: " + hex_in); | "Invalid public key: " + hex_in); | ||||
} | } | ||||
return vchPubKey; | return vchPubKey; | ||||
} | } | ||||
// Retrieves a public key for an address from the given CKeyStore | // Retrieves a public key for an address from the given CBasicKeyStore | ||||
CPubKey AddrToPubKey(const CChainParams &chainparams, CKeyStore *const keystore, | CPubKey AddrToPubKey(const CChainParams &chainparams, | ||||
CBasicKeyStore *const keystore, | |||||
const std::string &addr_in) { | const std::string &addr_in) { | ||||
CTxDestination dest = DecodeDestination(addr_in, chainparams); | CTxDestination dest = DecodeDestination(addr_in, chainparams); | ||||
if (!IsValidDestination(dest)) { | if (!IsValidDestination(dest)) { | ||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
"Invalid address: " + addr_in); | "Invalid address: " + addr_in); | ||||
} | } | ||||
CKeyID key = GetKeyForDestination(*keystore, dest); | CKeyID key = GetKeyForDestination(*keystore, dest); | ||||
if (key.IsNull()) { | if (key.IsNull()) { | ||||
Show All 13 Lines | CPubKey AddrToPubKey(const CChainParams &chainparams, | ||||
return vchPubKey; | return vchPubKey; | ||||
} | } | ||||
// Creates a multisig address from a given list of public keys, number of | // Creates a multisig address from a given list of public keys, number of | ||||
// signatures required, and the address type | // signatures required, and the address type | ||||
CTxDestination AddAndGetMultisigDestination(const int required, | CTxDestination AddAndGetMultisigDestination(const int required, | ||||
const std::vector<CPubKey> &pubkeys, | const std::vector<CPubKey> &pubkeys, | ||||
OutputType type, | OutputType type, | ||||
CKeyStore &keystore, | CBasicKeyStore &keystore, | ||||
CScript &script_out) { | CScript &script_out) { | ||||
// Gather public keys | // Gather public keys | ||||
if (required < 1) { | if (required < 1) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"a multisignature address must require at least one key to redeem"); | "a multisignature address must require at least one key to redeem"); | ||||
} | } | ||||
if ((int)pubkeys.size() < required) { | if ((int)pubkeys.size() < required) { | ||||
▲ Show 20 Lines • Show All 486 Lines • Show Last 20 Lines |