Skip to content

Commit 8c8ce9e

Browse files
committed
Add a max scriptnum constant
Integers within Script can have a maximum value of 2^31 (i.e., they are signed) but we (miniscript) often uses unsigned ints, to facilitate checking the unsigned type is the correct size to fit in a signed int add a const `MAX_SCRIPTNUM_VALUE`.
1 parent 8b35d43 commit 8c8ce9e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/blockdata/constants.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub const SCRIPT_ADDRESS_PREFIX_TEST: u8 = 196; // 0xc4
5353
pub const MAX_SCRIPT_ELEMENT_SIZE: usize = 520;
5454
/// How may blocks between halvings.
5555
pub const SUBSIDY_HALVING_INTERVAL: u32 = 210_000;
56+
/// Maximum allowed value for an integer in Script.
57+
pub const MAX_SCRIPTNUM_VALUE: u32 = 0x80000000; // 2^31
5658

5759
/// In Bitcoind this is insanely described as ~((u256)0 >> 32)
5860
pub fn max_target(_: Network) -> Uint256 {

0 commit comments

Comments
 (0)