Put && operator at front of line
In an effort to make code containing multi-line logical AND clearer to read put the operator at the start of the line.
This commit is contained in:
parent
f5512c4931
commit
e54a2d653b
|
@ -195,8 +195,8 @@ impl Block {
|
||||||
// commitment is in the last output that starts with below magic
|
// commitment is in the last output that starts with below magic
|
||||||
if let Some(pos) = coinbase.output.iter()
|
if let Some(pos) = coinbase.output.iter()
|
||||||
.rposition(|o| {
|
.rposition(|o| {
|
||||||
o.script_pubkey.len () >= 38 &&
|
o.script_pubkey.len () >= 38
|
||||||
o.script_pubkey[0..6] == [0x6a, 0x24, 0xaa, 0x21, 0xa9, 0xed] }) {
|
&& o.script_pubkey[0..6] == [0x6a, 0x24, 0xaa, 0x21, 0xa9, 0xed] }) {
|
||||||
let commitment = WitnessCommitment::from_slice(&coinbase.output[pos].script_pubkey.as_bytes()[6..38]).unwrap();
|
let commitment = WitnessCommitment::from_slice(&coinbase.output[pos].script_pubkey.as_bytes()[6..38]).unwrap();
|
||||||
// witness reserved value is in coinbase input witness
|
// witness reserved value is in coinbase input witness
|
||||||
let witness_vec: Vec<_> = coinbase.input[0].witness.iter().collect();
|
let witness_vec: Vec<_> = coinbase.input[0].witness.iter().collect();
|
||||||
|
|
|
@ -420,21 +420,21 @@ impl Script {
|
||||||
/// Checks whether a script pubkey is a p2sh output
|
/// Checks whether a script pubkey is a p2sh output
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_p2sh(&self) -> bool {
|
pub fn is_p2sh(&self) -> bool {
|
||||||
self.0.len() == 23 &&
|
self.0.len() == 23
|
||||||
self.0[0] == opcodes::all::OP_HASH160.into_u8() &&
|
&& self.0[0] == opcodes::all::OP_HASH160.into_u8()
|
||||||
self.0[1] == opcodes::all::OP_PUSHBYTES_20.into_u8() &&
|
&& self.0[1] == opcodes::all::OP_PUSHBYTES_20.into_u8()
|
||||||
self.0[22] == opcodes::all::OP_EQUAL.into_u8()
|
&& self.0[22] == opcodes::all::OP_EQUAL.into_u8()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether a script pubkey is a p2pkh output
|
/// Checks whether a script pubkey is a p2pkh output
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_p2pkh(&self) -> bool {
|
pub fn is_p2pkh(&self) -> bool {
|
||||||
self.0.len() == 25 &&
|
self.0.len() == 25
|
||||||
self.0[0] == opcodes::all::OP_DUP.into_u8() &&
|
&& self.0[0] == opcodes::all::OP_DUP.into_u8()
|
||||||
self.0[1] == opcodes::all::OP_HASH160.into_u8() &&
|
&& self.0[1] == opcodes::all::OP_HASH160.into_u8()
|
||||||
self.0[2] == opcodes::all::OP_PUSHBYTES_20.into_u8() &&
|
&& self.0[2] == opcodes::all::OP_PUSHBYTES_20.into_u8()
|
||||||
self.0[23] == opcodes::all::OP_EQUALVERIFY.into_u8() &&
|
&& self.0[23] == opcodes::all::OP_EQUALVERIFY.into_u8()
|
||||||
self.0[24] == opcodes::all::OP_CHECKSIG.into_u8()
|
&& self.0[24] == opcodes::all::OP_CHECKSIG.into_u8()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether a script pubkey is a p2pk output
|
/// Checks whether a script pubkey is a p2pk output
|
||||||
|
@ -476,25 +476,25 @@ impl Script {
|
||||||
/// Checks whether a script pubkey is a p2wsh output
|
/// Checks whether a script pubkey is a p2wsh output
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_v0_p2wsh(&self) -> bool {
|
pub fn is_v0_p2wsh(&self) -> bool {
|
||||||
self.0.len() == 34 &&
|
self.0.len() == 34
|
||||||
self.witness_version() == Some(WitnessVersion::V0) &&
|
&& self.witness_version() == Some(WitnessVersion::V0)
|
||||||
self.0[1] == opcodes::all::OP_PUSHBYTES_32.into_u8()
|
&& self.0[1] == opcodes::all::OP_PUSHBYTES_32.into_u8()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether a script pubkey is a p2wpkh output
|
/// Checks whether a script pubkey is a p2wpkh output
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_v0_p2wpkh(&self) -> bool {
|
pub fn is_v0_p2wpkh(&self) -> bool {
|
||||||
self.0.len() == 22 &&
|
self.0.len() == 22
|
||||||
self.witness_version() == Some(WitnessVersion::V0) &&
|
&& self.witness_version() == Some(WitnessVersion::V0)
|
||||||
self.0[1] == opcodes::all::OP_PUSHBYTES_20.into_u8()
|
&& self.0[1] == opcodes::all::OP_PUSHBYTES_20.into_u8()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether a script pubkey is a P2TR output
|
/// Checks whether a script pubkey is a P2TR output
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_v1_p2tr(&self) -> bool {
|
pub fn is_v1_p2tr(&self) -> bool {
|
||||||
self.0.len() == 34 &&
|
self.0.len() == 34
|
||||||
self.witness_version() == Some(WitnessVersion::V1) &&
|
&& self.witness_version() == Some(WitnessVersion::V1)
|
||||||
self.0[1] == opcodes::all::OP_PUSHBYTES_32.into_u8()
|
&& self.0[1] == opcodes::all::OP_PUSHBYTES_32.into_u8()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if this is an OP_RETURN output
|
/// Check if this is an OP_RETURN output
|
||||||
|
|
Loading…
Reference in New Issue