Refactor is_provably_unspendable
Refactor with the aim of making the code easier to read. Code path is covered by current unit tests. Refactor only, no logic changes.
This commit is contained in:
parent
e54a2d653b
commit
4b6e86658d
|
@ -499,14 +499,25 @@ impl Script {
|
||||||
|
|
||||||
/// Check if this is an OP_RETURN output
|
/// Check if this is an OP_RETURN output
|
||||||
pub fn is_op_return (&self) -> bool {
|
pub fn is_op_return (&self) -> bool {
|
||||||
!self.0.is_empty() && (opcodes::All::from(self.0[0]) == opcodes::all::OP_RETURN)
|
match self.0.first() {
|
||||||
|
Some(b) => *b == opcodes::all::OP_RETURN.into_u8(),
|
||||||
|
None => false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether a script can be proven to have no satisfying input
|
/// Whether a script can be proven to have no satisfying input
|
||||||
pub fn is_provably_unspendable(&self) -> bool {
|
pub fn is_provably_unspendable(&self) -> bool {
|
||||||
!self.0.is_empty() &&
|
use blockdata::opcodes::Class::{ReturnOp, IllegalOp};
|
||||||
(opcodes::All::from(self.0[0]).classify(opcodes::ClassifyContext::Legacy) == opcodes::Class::ReturnOp ||
|
|
||||||
opcodes::All::from(self.0[0]).classify(opcodes::ClassifyContext::Legacy) == opcodes::Class::IllegalOp)
|
match self.0.first() {
|
||||||
|
Some(b) => {
|
||||||
|
let first = opcodes::All::from(*b);
|
||||||
|
let class = first.classify(opcodes::ClassifyContext::Legacy);
|
||||||
|
|
||||||
|
class == ReturnOp || class == IllegalOp
|
||||||
|
},
|
||||||
|
None => false,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the minimum value an output with this script should have in order to be
|
/// Gets the minimum value an output with this script should have in order to be
|
||||||
|
|
Loading…
Reference in New Issue