Skip to content

Commit

Permalink
Fix ToUsize on 32-bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandudey committed Dec 12, 2024
1 parent 5c0aa8d commit e663615
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions psbt/src/parser/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -37,7 +39,7 @@ where
+ InputIter<Item = u8>
+ Slice<core::ops::RangeFrom<usize>>
+ InputTake,
E: ParseError<I>,
E: ParseError<I> + FromExternalError<I, TryFromIntError>,
{
map(
tuple((le_i32, inputs, outputs, le_u32)),
Expand All @@ -59,7 +61,7 @@ where
+ InputIter<Item = u8>
+ Slice<core::ops::RangeFrom<usize>>
+ InputTake,
E: ParseError<I>,
E: ParseError<I> + FromExternalError<I, TryFromIntError>,
{
let (inputs_start, len) = compact_size(i)?;

Expand Down Expand Up @@ -95,10 +97,10 @@ where
+ InputIter<Item = u8>
+ Slice<core::ops::RangeFrom<usize>>
+ InputTake,
E: ParseError<I>,
E: ParseError<I> + FromExternalError<I, TryFromIntError>,
{
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));

Expand Down

0 comments on commit e663615

Please sign in to comment.