Skip to content

Commit

Permalink
Update crypto/txscript/src/opcodes/mod.rs
Browse files Browse the repository at this point in the history
Fallible conversion of output amount (usize -> i64)

Co-authored-by: Michael Sutton <[email protected]>
  • Loading branch information
biryukovmaxim and michaelsutton authored Nov 11, 2024
1 parent 4fe40f8 commit 898a56a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crypto/txscript/src/opcodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ opcode_list! {
let output = usize::try_from(idx).ok()
.and_then(|idx| tx.outputs().get(idx))
.ok_or_else(|| TxScriptError::InvalidOutputIndex(idx, tx.inputs().len()))?;
push_number(output.value as i64, vm)
push_number(output.value.try_into().map_err(|e: TryFromIntError| TxScriptError::NumberTooBig(e.to_string()))?, vm)
},
_ => Err(TxScriptError::InvalidSource("OpOutputAmount only applies to transaction inputs".to_string()))
}
Expand Down

0 comments on commit 898a56a

Please sign in to comment.