@@ -7,6 +7,10 @@ use core::fmt;
77
88use crate :: { note:: AssetBase , value:: NoteValue } ;
99
10+ /// Maximum burn value.
11+ /// Burns must fit in both u64 and i64 for value balance calculations.
12+ pub const MAX_BURN_VALUE : u64 = ( 1u64 << 63 ) - 1 ;
13+
1014/// Possible errors that can occur during bundle burn validation.
1115#[ derive( Debug ) ]
1216#[ cfg_attr( test, derive( PartialEq , Eq ) ) ]
@@ -47,7 +51,7 @@ pub fn validate_bundle_burn(burn: &[(AssetBase, NoteValue)]) -> Result<(), BurnE
4751 if value. inner ( ) == 0 {
4852 return Err ( BurnError :: ZeroAmount ) ;
4953 }
50- if value. inner ( ) >= ( 1u64 << 63 ) {
54+ if value. inner ( ) > MAX_BURN_VALUE {
5155 return Err ( BurnError :: InvalidAmount ) ;
5256 }
5357 if !burn_set. insert ( * asset) {
@@ -166,7 +170,7 @@ mod tests {
166170
167171 let bundle_burn = vec ! [
168172 burn_tuple_unique( & mut rng, & mut used, 10 ) ,
169- burn_tuple_unique( & mut rng, & mut used, 1u64 << 63 ) ,
173+ burn_tuple_unique( & mut rng, & mut used, MAX_BURN_VALUE + 1 ) ,
170174 burn_tuple_unique( & mut rng, & mut used, 10 ) ,
171175 ] ;
172176
0 commit comments