elements_miniscript/miniscript/
limits.rs

1// SPDX-License-Identifier: CC0-1.0
2
3//! Miscellaneous constraints imposed by Bitcoin.
4//! These constraints can be either Consensus or Policy (standardness) rules, for either Segwitv0
5//! or Legacy scripts.
6
7/// Maximum operations per script
8// https://github.com/bitcoin/bitcoin/blob/875e1ccc9fe01e026e564dfd39a64d9a4b332a89/src/script/script.h#L26
9pub const MAX_OPS_PER_SCRIPT: usize = 201;
10/// Maximum p2wsh initial stack items
11// https://github.com/bitcoin/bitcoin/blob/875e1ccc9fe01e026e564dfd39a64d9a4b332a89/src/policy/policy.h#L40
12pub const MAX_STANDARD_P2WSH_STACK_ITEMS: usize = 100;
13/// Maximum script size allowed by consensus rules
14// https://github.com/bitcoin/bitcoin/blob/42b66a6b814bca130a9ccf0a3f747cf33d628232/src/script/script.h#L32
15pub const MAX_SCRIPT_SIZE: usize = 10_000;
16/// Maximum script size allowed by standardness rules
17// https://github.com/bitcoin/bitcoin/blob/283a73d7eaea2907a6f7f800f529a0d6db53d7a6/src/policy/policy.h#L44
18pub const MAX_STANDARD_P2WSH_SCRIPT_SIZE: usize = 3600;
19
20/// Maximum script element size allowed by consensus rules
21// https://github.com/bitcoin/bitcoin/blob/42b66a6b814bca130a9ccf0a3f747cf33d628232/src/script/script.h#L23
22pub const MAX_SCRIPT_ELEMENT_SIZE: usize = 520;
23/// Maximum script sig size allowed by standardness rules
24// https://github.com/bitcoin/bitcoin/blob/42b66a6b814bca130a9ccf0a3f747cf33d628232/src/policy/policy.cpp#L102
25pub const MAX_SCRIPTSIG_SIZE: usize = 1650;
26/// Maximum Initial witness size allowed
27/// `<https://github.com/bitcoin/bitcoin/blob/283a73d7eaea2907a6f7f800f529a0d6db53d7a6/src/policy/policy.h#L42>`
28pub const MAX_STANDARD_P2WSH_STACK_ITEM_SIZE: usize = 80;
29/// Maximum items during stack execution
30// This limits also applies for initial stack satisfaction
31// https://github.com/bitcoin/bitcoin/blob/3af495d6972379b07530a5fcc2665aa626d01621/src/script/script.h#L35
32pub const MAX_STACK_SIZE: usize = 1000;
33/** The maximum allowed weight for a block, see BIP 141 (network rule) */
34pub const MAX_BLOCK_WEIGHT: usize = 4000000;
35
36/// Maximum pubkeys as arguments to CHECKMULTISIG
37// https://github.com/bitcoin/bitcoin/blob/6acda4b00b3fc1bfac02f5de590e1a5386cbc779/src/script/script.h#L30
38pub const MAX_PUBKEYS_PER_MULTISIG: usize = 20;