From e663615ad99e6c24e1829588f63e8fee8a845de1 Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Thu, 12 Dec 2024 13:35:57 +0100 Subject: [PATCH] Fix ToUsize on 32-bit. --- psbt/src/parser/transaction.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/psbt/src/parser/transaction.rs b/psbt/src/parser/transaction.rs index 2f31a5c..8797fc1 100644 --- a/psbt/src/parser/transaction.rs +++ b/psbt/src/parser/transaction.rs @@ -14,9 +14,11 @@ //! //! Can be an interesting optimization approach once this code is in prod. +use core::num::TryFromIntError; + use nom::{ - combinator::map, - error::{ErrorKind, ParseError}, + combinator::{map, map_res}, + error::{ErrorKind, FromExternalError, ParseError}, multi::length_data, number::complete::{le_i32, le_i64, le_u32}, sequence::tuple, @@ -37,7 +39,7 @@ where + InputIter + Slice> + InputTake, - E: ParseError, + E: ParseError + FromExternalError, { map( tuple((le_i32, inputs, outputs, le_u32)), @@ -59,7 +61,7 @@ where + InputIter + Slice> + InputTake, - E: ParseError, + E: ParseError + FromExternalError, { let (inputs_start, len) = compact_size(i)?; @@ -95,10 +97,10 @@ where + InputIter + Slice> + InputTake, - E: ParseError, + E: ParseError + FromExternalError, { let previous_output = output_point; - let script_sig = length_data(compact_size); + let script_sig = length_data(map_res(compact_size, usize::try_from)); let sequence = le_u32; let fields = tuple((previous_output, script_sig, sequence));