Creates a multisig address from a given list of public keys, number of signatures required, and the address type
| 233 | |
| 234 | // Creates a multisig address from a given list of public keys, number of signatures required, and the address type |
| 235 | CTxDestination AddAndGetMultisigDestination(const int required, const std::vector<CPubKey>& pubkeys, OutputType type, FlatSigningProvider& keystore, CScript& script_out) |
| 236 | { |
| 237 | // Gather public keys |
| 238 | if (required < 1) { |
| 239 | throw JSONRPCError(RPC_INVALID_PARAMETER, "a multisignature address must require at least one key to redeem"); |
| 240 | } |
| 241 | if ((int)pubkeys.size() < required) { |
| 242 | throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("not enough keys supplied (got %u keys, but need at least %d to redeem)", pubkeys.size(), required)); |
| 243 | } |
| 244 | if (pubkeys.size() > MAX_PUBKEYS_PER_MULTISIG) { |
| 245 | throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Number of keys involved in the multisignature address creation > %d\nReduce the number", MAX_PUBKEYS_PER_MULTISIG)); |
| 246 | } |
| 247 | |
| 248 | script_out = GetScriptForMultisig(required, pubkeys); |
| 249 | |
| 250 | // Check if any keys are uncompressed. If so, the type is legacy |
| 251 | for (const CPubKey& pk : pubkeys) { |
| 252 | if (!pk.IsCompressed()) { |
| 253 | type = OutputType::LEGACY; |
| 254 | break; |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | if (type == OutputType::LEGACY && script_out.size() > MAX_SCRIPT_ELEMENT_SIZE) { |
| 259 | throw JSONRPCError(RPC_INVALID_PARAMETER, (strprintf("redeemScript exceeds size limit: %d > %d", script_out.size(), MAX_SCRIPT_ELEMENT_SIZE))); |
| 260 | } |
| 261 | |
| 262 | // Make the address |
| 263 | CTxDestination dest = AddAndGetDestinationForScript(keystore, script_out, type); |
| 264 | |
| 265 | return dest; |
| 266 | } |
| 267 | |
| 268 | class DescribeAddressVisitor |
| 269 | { |
no test coverage detected