From 46441795fbf72e0c66a9efb9fd714ea2ac4618bb Mon Sep 17 00:00:00 2001 From: max143672 Date: Sun, 10 Nov 2024 10:50:54 +0400 Subject: [PATCH] style: format combinators chain --- crypto/txscript/src/opcodes/mod.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/crypto/txscript/src/opcodes/mod.rs b/crypto/txscript/src/opcodes/mod.rs index 27eecdc16..762eb2c46 100644 --- a/crypto/txscript/src/opcodes/mod.rs +++ b/crypto/txscript/src/opcodes/mod.rs @@ -927,7 +927,9 @@ opcode_list! { match vm.script_source { ScriptSource::TxInput{tx, ..} => { let [idx]: [i32; 1] = vm.dstack.pop_items()?; - let utxo = usize::try_from(idx).ok().and_then(|idx| tx.utxo(idx)).ok_or_else(|| TxScriptError::InvalidInputIndex(idx, tx.inputs().len()))?; + 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) }, _ => Err(TxScriptError::InvalidSource("OpInputAmount only applies to transaction inputs".to_string())) @@ -941,9 +943,9 @@ opcode_list! { match vm.script_source { ScriptSource::TxInput{tx, ..} => { let [idx]: [i32; 1] = vm.dstack.pop_items()?; - let utxo = usize::try_from(idx).ok(). - and_then(|idx| tx.utxo(idx)). - ok_or_else(|| TxScriptError::InvalidInputIndex(idx, tx.inputs().len()))?; + let utxo = usize::try_from(idx).ok() + .and_then(|idx| tx.utxo(idx)) + .ok_or_else(|| TxScriptError::InvalidInputIndex(idx, tx.inputs().len()))?; vm.dstack.push(utxo.script_public_key.to_bytes()); Ok(()) }, @@ -961,9 +963,9 @@ opcode_list! { match vm.script_source { ScriptSource::TxInput{tx, ..} => { let [idx]: [i32; 1] = vm.dstack.pop_items()?; - let output = usize::try_from(idx).ok(). - and_then(|idx| tx.outputs().get(idx)). - ok_or_else(|| TxScriptError::InvalidOutputIndex(idx, tx.inputs().len()))?; + 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) }, _ => Err(TxScriptError::InvalidSource("OpOutputAmount only applies to transaction inputs".to_string())) @@ -977,9 +979,9 @@ opcode_list! { match vm.script_source { ScriptSource::TxInput{tx, ..} => { let [idx]: [i32; 1] = vm.dstack.pop_items()?; - let output = usize::try_from(idx).ok(). - and_then(|idx| tx.outputs().get(idx)). - ok_or_else(|| TxScriptError::InvalidOutputIndex(idx, tx.inputs().len()))?; + let output = usize::try_from(idx).ok() + .and_then(|idx| tx.outputs().get(idx)) + .ok_or_else(|| TxScriptError::InvalidOutputIndex(idx, tx.inputs().len()))?; vm.dstack.push(output.script_public_key.to_bytes()); Ok(()) },