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