Creates a multisig redeemscript from a given list of public keys and number required.
| 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) |
| 48 | { |
| 49 | // Gather public keys |
| 50 | if (required < 1) { |
| 51 | throw JSONRPCError(RPC_INVALID_PARAMETER, "a multisignature address must require at least one key to redeem"); |
| 52 | } |
| 53 | if ((int)pubkeys.size() < required) { |
| 54 | throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("not enough keys supplied (got %u keys, but need at least %d to redeem)", pubkeys.size(), required)); |
| 55 | } |
| 56 | if (pubkeys.size() > 16) { |
| 57 | throw JSONRPCError(RPC_INVALID_PARAMETER, "Number of keys involved in the multisignature address creation > 16\nReduce the number"); |
| 58 | } |
| 59 | |
| 60 | CScript result = GetScriptForMultisig(required, pubkeys); |
| 61 | |
| 62 | if (result.size() > MAX_SCRIPT_ELEMENT_SIZE) { |
| 63 | throw JSONRPCError(RPC_INVALID_PARAMETER, (strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE))); |
| 64 | } |
| 65 | |
| 66 | return result; |
| 67 | } |
| 68 | |
| 69 | class DescribeAddressVisitor : public boost::static_visitor<UniValue> |
| 70 | { |
no test coverage detected