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 input amount (usize -> i64)

Co-authored-by: Michael Sutton <[email protected]>
  • Loading branch information
biryukovmaxim and michaelsutton authored Nov 11, 2024
1 parent 898a56a commit 3af28ed
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 @@ -930,7 +930,7 @@ opcode_list! {
let utxo = usize::try_from(idx).ok()
.and_then(|idx| tx.utxo(idx))
.ok_or_else(|| TxScriptError::InvalidInputIndex(idx, tx.inputs().len()))?;
push_number(utxo.amount as i64, vm)
push_number(utxo.amount.try_into().map_err(|e: TryFromIntError| TxScriptError::NumberTooBig(e.to_string()))?, vm)
},
_ => Err(TxScriptError::InvalidSource("OpInputAmount only applies to transaction inputs".to_string()))
}
Expand Down

0 comments on commit 3af28ed

Please sign in to comment.