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`.
This commit is contained in:
Tobin C. Harding 2022-07-11 09:42:55 +10:00
parent 7a346970d0
commit 1390ee12ec
1 changed files with 2 additions and 0 deletions

View File

@ -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 {