diff options
author | Antoine Poinsot <darosior@protonmail.com> | 2021-01-06 14:42:32 +0100 |
---|---|---|
committer | Antoine Poinsot <darosior@protonmail.com> | 2021-04-28 10:00:30 +0200 |
commit | 5aa50ab9cc7994b16cf13e4c73af80f0098f1bea (patch) | |
tree | c4511ab32c77faa281a6000973f58756e6886c9d /src | |
parent | 063df9e89730fd2c92646577e2fab894e1692130 (diff) | |
download | bitcoin-5aa50ab9cc7994b16cf13e4c73af80f0098f1bea.tar.xz |
rpc/util: multisig: only check redeemScript size is <= 520 for P2SH
This increase the maximum number of pubkeys to 20 (valid in P2WSH and
P2SH-P2WSH) and only checks the redeemScript doesn't exceed
MAX_SCRIPT_ELEMENT_SIZE for P2SH, as this checked is removed under
Segwit context.
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/util.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index df3ee9f007..069669bb3b 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -231,16 +231,12 @@ CTxDestination AddAndGetMultisigDestination(const int required, const std::vecto if ((int)pubkeys.size() < required) { throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("not enough keys supplied (got %u keys, but need at least %d to redeem)", pubkeys.size(), required)); } - if (pubkeys.size() > 16) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Number of keys involved in the multisignature address creation > 16\nReduce the number"); + if (pubkeys.size() > MAX_PUBKEYS_PER_MULTISIG) { + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Number of keys involved in the multisignature address creation > %d\nReduce the number", MAX_PUBKEYS_PER_MULTISIG)); } script_out = GetScriptForMultisig(required, pubkeys); - if (script_out.size() > MAX_SCRIPT_ELEMENT_SIZE) { - throw JSONRPCError(RPC_INVALID_PARAMETER, (strprintf("redeemScript exceeds size limit: %d > %d", script_out.size(), MAX_SCRIPT_ELEMENT_SIZE))); - } - // Check if any keys are uncompressed. If so, the type is legacy for (const CPubKey& pk : pubkeys) { if (!pk.IsCompressed()) { @@ -249,6 +245,10 @@ CTxDestination AddAndGetMultisigDestination(const int required, const std::vecto } } + if (type == OutputType::LEGACY && script_out.size() > MAX_SCRIPT_ELEMENT_SIZE) { + throw JSONRPCError(RPC_INVALID_PARAMETER, (strprintf("redeemScript exceeds size limit: %d > %d", script_out.size(), MAX_SCRIPT_ELEMENT_SIZE))); + } + // Make the address CTxDestination dest = AddAndGetDestinationForScript(keystore, script_out, type); |