Refactor is_p2pkh
Refactor with the aim of simplifying `is_p2kh`. This function is covered sufficiently by current unit tests. Refactor only, no logic changes.
This commit is contained in:
parent
373ea89a9a
commit
f5512c4931
|
@ -440,12 +440,17 @@ impl Script {
|
||||||
/// Checks whether a script pubkey is a p2pk output
|
/// Checks whether a script pubkey is a p2pk output
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_p2pk(&self) -> bool {
|
pub fn is_p2pk(&self) -> bool {
|
||||||
(self.0.len() == 67 &&
|
match self.len() {
|
||||||
self.0[0] == opcodes::all::OP_PUSHBYTES_65.into_u8() &&
|
67 => {
|
||||||
self.0[66] == opcodes::all::OP_CHECKSIG.into_u8())
|
self.0[0] == opcodes::all::OP_PUSHBYTES_65.into_u8()
|
||||||
|| (self.0.len() == 35 &&
|
&& self.0[66] == opcodes::all::OP_CHECKSIG.into_u8()
|
||||||
self.0[0] == opcodes::all::OP_PUSHBYTES_33.into_u8() &&
|
}
|
||||||
self.0[34] == opcodes::all::OP_CHECKSIG.into_u8())
|
35 => {
|
||||||
|
self.0[0] == opcodes::all::OP_PUSHBYTES_33.into_u8()
|
||||||
|
&& self.0[34] == opcodes::all::OP_CHECKSIG.into_u8()
|
||||||
|
}
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks whether a script pubkey is a Segregated Witness (segwit) program.
|
/// Checks whether a script pubkey is a Segregated Witness (segwit) program.
|
||||||
|
|
Loading…
Reference in New Issue