From 898a56a6f291b6304e879afef6324dfc1b6241a6 Mon Sep 17 00:00:00 2001 From: Maxim <59533214+biryukovmaxim@users.noreply.github.com> Date: Mon, 11 Nov 2024 09:39:55 +0400 Subject: [PATCH] Update crypto/txscript/src/opcodes/mod.rs Fallible conversion of output amount (usize -> i64) Co-authored-by: Michael Sutton --- crypto/txscript/src/opcodes/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/txscript/src/opcodes/mod.rs b/crypto/txscript/src/opcodes/mod.rs index 762eb2c46..0db6ebe2c 100644 --- a/crypto/txscript/src/opcodes/mod.rs +++ b/crypto/txscript/src/opcodes/mod.rs @@ -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())) }