From 1390ee12ec66770f71dd14ec29d419e0bb1fbe47 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 11 Jul 2022 09:42:55 +1000 Subject: [PATCH] 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`. --- src/blockdata/constants.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/blockdata/constants.rs b/src/blockdata/constants.rs index 0e03ae5a..64162d54 100644 --- a/src/blockdata/constants.rs +++ b/src/blockdata/constants.rs @@ -53,6 +53,8 @@ pub const SCRIPT_ADDRESS_PREFIX_TEST: u8 = 196; // 0xc4 pub const MAX_SCRIPT_ELEMENT_SIZE: usize = 520; /// How may blocks between halvings. pub const SUBSIDY_HALVING_INTERVAL: u32 = 210_000; +/// Maximum allowed value for an integer in Script. +pub const MAX_SCRIPTNUM_VALUE: u32 = 0x80000000; // 2^31 /// In Bitcoind this is insanely described as ~((u256)0 >> 32) pub fn max_target(_: Network) -> Uint256 {