Skip to content

Commit 54d9e8f

Browse files
committed
segwit check fixes
1 parent b9cf796 commit 54d9e8f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/ScriptPubKey.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ public function isPayToWitnessPubKeyHash(): bool
8484
{
8585
$operations = $this->parse();
8686

87-
return (count($operations) == 2) &&
88-
ord($operations[0]->data) == 0 &&
87+
return count($operations) == 2 &&
88+
$operations[0]->code >= Opcodes::OP_0 &&
89+
$operations[0]->code <= Opcodes::OP_16 &&
8990
$operations[1]->size == 20;
9091
}
9192

@@ -96,8 +97,9 @@ public function isPayToWitnessScriptHash(): bool
9697
{
9798
$operations = $this->parse();
9899

99-
return (count($operations) == 2) &&
100-
ord($operations[0]->data) == 0 &&
100+
return count($operations) == 2 &&
101+
$operations[0]->code >= Opcodes::OP_0 &&
102+
$operations[0]->code <= Opcodes::OP_16 &&
101103
$operations[1]->size == 32;
102104
}
103105

0 commit comments

Comments
 (0)