@@ -22,7 +22,7 @@ public function testReturn()
2222 // [pubkey] OP_CHECKSIG
2323 public function testParseP2PK ()
2424 {
25- $ hex = '41 ' ; // OP_PUSHDATA
25+ $ hex = '41 ' ; // 65
2626 $ hex .= '0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 ' ; // pubkey
2727 $ hex .= 'ac ' ; // OP_CHECKSIG
2828
@@ -35,7 +35,7 @@ public function testParseP2PK()
3535 // [pubkey] OP_CHECKSIG
3636 public function testParseP2PKCompressed ()
3737 {
38- $ hex = '21 ' ; // OP_PUSHDATA
38+ $ hex = '21 ' ; // 33
3939 $ hex .= '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 ' ; // pubkey
4040 $ hex .= 'ac ' ; // OP_CHECKSIG
4141
@@ -50,7 +50,7 @@ public function testParseP2PKH()
5050 {
5151 $ hex = '76 ' ; // OP_DUP
5252 $ hex .= 'a9 ' ; // OP_HASH160
53- $ hex .= '14 ' ; // OP_PUSHDATA
53+ $ hex .= '14 ' ; // 20
5454 $ hex .= '91b24bf9f5288532960ac687abb035127b1d28a5 ' ; // pubkey hash
5555 $ hex .= '88 ' ; // OP_EQUALVERIFY
5656 $ hex .= 'ac ' ; // OP_CHECKSIG
@@ -61,11 +61,26 @@ public function testParseP2PKH()
6161 $ this ->assertEquals ($ script ->getOutputAddress (), '1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm ' );
6262 }
6363
64+ public function testParseP2PKHAlt ()
65+ {
66+ $ hex = '76 ' ; // OP_DUP
67+ $ hex .= 'a9 ' ; // OP_HASH160
68+ $ hex .= '4c ' ; // OP_PUSHDATA1
69+ $ hex .= '14 ' ; // 20
70+ $ hex .= 'cd4967766b612eb44345fb00f316d890cd3d508688 ' ; // pubkey hash
71+ $ hex .= 'ac ' ; // OP_CHECKSIG
72+
73+ $ script = new ScriptPubKey (hex2bin ($ hex ));
74+
75+ $ this ->assertTrue ($ script ->isPayToPubKeyHashAlt ());
76+ $ this ->assertEquals ($ script ->getOutputAddress (), '1KiTTY2sRjPRdobHdNTzBVv7rBiNG1tX2E ' );
77+ }
78+
6479 // OP_HASH160 [hash] OP_EQUAL
6580 public function testParseP2SH ()
6681 {
6782 $ hex = 'a9 ' ; // OP_HASH160
68- $ hex .= '14 ' ; // OP_PUSHDATA
83+ $ hex .= '14 ' ; // 20
6984 $ hex .= '91b24bf9f5288532960ac687abb035127b1d28a5 ' ; // script hash
7085 $ hex .= '87 ' ; // OP_EQUAL
7186
@@ -78,14 +93,14 @@ public function testParseP2SH()
7893 // [numsigs] [...pubkeys...] [numpubkeys] OP_CHECKMULTISIG
7994 public function testParseMultisig ()
8095 {
81- $ hex = '53 ' ; // OP_3
82- $ hex .= '14 ' ; // OP_PUSHDATA
96+ $ hex = '53 ' ; // 3
97+ $ hex .= '14 ' ; // 20
8398 $ hex .= '91b24bf9f5288532960ac687abb035127b1d28a5 ' ; // pubkey hash
84- $ hex .= '14 ' ; // OP_PUSHDATA
99+ $ hex .= '14 ' ; // 20
85100 $ hex .= 'd6c8e828c1eca1bba065e1b83e1dc2a36e387a42 ' ; // pubkey hash
86- $ hex .= '14 ' ; // OP_PUSHDATA
101+ $ hex .= '14 ' ; // 20
87102 $ hex .= 'ec7eced2c57ed1292bc4eb9bfd13c9f7603bc338 ' ; // pubkey hash
88- $ hex .= '52 ' ; // OP_2
103+ $ hex .= '52 ' ; // 2
89104 $ hex .= 'ae ' ; // OP_CHECKMULTISIG
90105
91106 $ script = new ScriptPubKey (hex2bin ($ hex ));
@@ -97,7 +112,7 @@ public function testParseMultisig()
97112 public function testParseP2WPKH ()
98113 {
99114 $ hex = '00 ' ; // segwit version
100- $ hex .= '14 ' ; // OP_PUSHDATA
115+ $ hex .= '14 ' ; // 20
101116 $ hex .= '536523b38a207338740797cd03c3312e81408d53 ' ; // pubkey hash
102117
103118 $ script = new ScriptPubKey (hex2bin ($ hex ));
@@ -110,7 +125,7 @@ public function testParseP2WPKH()
110125 public function testParseP2WSH ()
111126 {
112127 $ hex = '00 ' ; // segwit version
113- $ hex .= '20 ' ; // OP_PUSHDATA
128+ $ hex .= '20 ' ; // 20
114129 $ hex .= '701a8d401c84fb13e6baf169d59684e17abd9fa216c8cc5b9fc63d622ff8c58d ' ; // hash
115130
116131 $ script = new ScriptPubKey (hex2bin ($ hex ));
0 commit comments