mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
refactor: replace hardcoded number, introduce 'MAX_BARE_MULTISIG_PUBKEYS_NUM'
This commit is contained in:
parent
dbc8ba12f3
commit
088bbb81e3
3 changed files with 5 additions and 3 deletions
|
@ -87,7 +87,7 @@ bool IsStandard(const CScript& scriptPubKey, const std::optional<unsigned>& max_
|
||||||
unsigned char m = vSolutions.front()[0];
|
unsigned char m = vSolutions.front()[0];
|
||||||
unsigned char n = vSolutions.back()[0];
|
unsigned char n = vSolutions.back()[0];
|
||||||
// Support up to x-of-3 multisig txns as standard
|
// Support up to x-of-3 multisig txns as standard
|
||||||
if (n < 1 || n > 3)
|
if (n < 1 || n > MAX_BARE_MULTISIG_PUBKEYS_NUM)
|
||||||
return false;
|
return false;
|
||||||
if (m < 1 || m > n)
|
if (m < 1 || m > n)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -37,6 +37,8 @@ static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{1000};
|
||||||
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};
|
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};
|
||||||
/** Default for -permitbaremultisig */
|
/** Default for -permitbaremultisig */
|
||||||
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true};
|
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true};
|
||||||
|
/** The maximum number of pubkeys in a bare multisig output script */
|
||||||
|
static constexpr unsigned int MAX_BARE_MULTISIG_PUBKEYS_NUM{3};
|
||||||
/** The maximum number of witness stack items in a standard P2WSH script */
|
/** The maximum number of witness stack items in a standard P2WSH script */
|
||||||
static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100};
|
static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100};
|
||||||
/** The maximum size in bytes of each witness stack item in a standard P2WSH script */
|
/** The maximum size in bytes of each witness stack item in a standard P2WSH script */
|
||||||
|
|
|
@ -1852,8 +1852,8 @@ std::vector<std::unique_ptr<DescriptorImpl>> ParseScript(uint32_t& key_exp_index
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (ctx == ParseScriptContext::TOP) {
|
if (ctx == ParseScriptContext::TOP) {
|
||||||
if (providers.size() > 3) {
|
if (providers.size() > MAX_BARE_MULTISIG_PUBKEYS_NUM) {
|
||||||
error = strprintf("Cannot have %u pubkeys in bare multisig; only at most 3 pubkeys", providers.size());
|
error = strprintf("Cannot have %u pubkeys in bare multisig; only at most %d pubkeys", providers.size(), MAX_BARE_MULTISIG_PUBKEYS_NUM);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue