Skip to content

Commit

Permalink
style: format combinators chain
Browse files Browse the repository at this point in the history
  • Loading branch information
biryukovmaxim committed Nov 10, 2024
1 parent da7d81b commit 4644179
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions crypto/txscript/src/opcodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand All @@ -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(())
},
Expand All @@ -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()))
Expand All @@ -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(())
},
Expand Down

0 comments on commit 4644179

Please sign in to comment.