@@ -67,14 +67,17 @@ def decodescript_script_pub_key(self):
67
67
# <pubkey> OP_CHECKSIG
68
68
rpc_result = self .nodes [0 ].decodescript (push_public_key + 'ac' )
69
69
assert_equal (public_key + ' OP_CHECKSIG' , rpc_result ['asm' ])
70
+ assert_equal ('pubkey' , rpc_result ['type' ])
70
71
# P2PK is translated to P2WPKH
71
72
assert_equal ('0 ' + public_key_hash , rpc_result ['segwit' ]['asm' ])
72
73
73
74
self .log .info ("- P2PKH" )
74
75
# OP_DUP OP_HASH160 <PubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
75
76
rpc_result = self .nodes [0 ].decodescript ('76a9' + push_public_key_hash + '88ac' )
77
+ assert_equal ('pubkeyhash' , rpc_result ['type' ])
76
78
assert_equal ('OP_DUP OP_HASH160 ' + public_key_hash + ' OP_EQUALVERIFY OP_CHECKSIG' , rpc_result ['asm' ])
77
79
# P2PKH is translated to P2WPKH
80
+ assert_equal ('witness_v0_keyhash' , rpc_result ['segwit' ]['type' ])
78
81
assert_equal ('0 ' + public_key_hash , rpc_result ['segwit' ]['asm' ])
79
82
80
83
self .log .info ("- multisig" )
@@ -83,16 +86,19 @@ def decodescript_script_pub_key(self):
83
86
# for our purposes here it does not matter that they are the same even though it is unrealistic.
84
87
multisig_script = '52' + push_public_key + push_public_key + push_public_key + '53ae'
85
88
rpc_result = self .nodes [0 ].decodescript (multisig_script )
89
+ assert_equal ('multisig' , rpc_result ['type' ])
86
90
assert_equal ('2 ' + public_key + ' ' + public_key + ' ' + public_key + ' 3 OP_CHECKMULTISIG' , rpc_result ['asm' ])
87
91
# multisig in P2WSH
88
92
multisig_script_hash = sha256 (bytes .fromhex (multisig_script )).hex ()
93
+ assert_equal ('witness_v0_scripthash' , rpc_result ['segwit' ]['type' ])
89
94
assert_equal ('0 ' + multisig_script_hash , rpc_result ['segwit' ]['asm' ])
90
95
91
96
self .log .info ("- P2SH" )
92
97
# OP_HASH160 <Hash160(redeemScript)> OP_EQUAL.
93
98
# push_public_key_hash here should actually be the hash of a redeem script.
94
99
# but this works the same for purposes of this test.
95
100
rpc_result = self .nodes [0 ].decodescript ('a9' + push_public_key_hash + '87' )
101
+ assert_equal ('scripthash' , rpc_result ['type' ])
96
102
assert_equal ('OP_HASH160 ' + public_key_hash + ' OP_EQUAL' , rpc_result ['asm' ])
97
103
# P2SH does not work in segwit secripts. decodescript should not return a result for it.
98
104
assert 'segwit' not in rpc_result
@@ -104,6 +110,7 @@ def decodescript_script_pub_key(self):
104
110
signature_imposter = '48304502207fa7a6d1e0ee81132a269ad84e68d695483745cde8b541e3bf630749894e342a022100c1f7ab20e13e22fb95281a870f3dcf38d782e53023ee313d741ad0cfbc0c509001'
105
111
# OP_RETURN <data>
106
112
rpc_result = self .nodes [0 ].decodescript ('6a' + signature_imposter )
113
+ assert_equal ('nulldata' , rpc_result ['type' ])
107
114
assert_equal ('OP_RETURN ' + signature_imposter [2 :], rpc_result ['asm' ])
108
115
109
116
self .log .info ("- CLTV redeem script" )
@@ -122,6 +129,7 @@ def decodescript_script_pub_key(self):
122
129
# lock until block 500,000
123
130
cltv_script = '63' + push_public_key + 'ad670320a107b17568' + push_public_key + 'ac'
124
131
rpc_result = self .nodes [0 ].decodescript (cltv_script )
132
+ assert_equal ('nonstandard' , rpc_result ['type' ])
125
133
assert_equal ('OP_IF ' + public_key + ' OP_CHECKSIGVERIFY OP_ELSE 500000 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_ENDIF ' + public_key + ' OP_CHECKSIG' , rpc_result ['asm' ])
126
134
# CLTV script in P2WSH
127
135
cltv_script_hash = sha256 (bytes .fromhex (cltv_script )).hex ()
@@ -130,6 +138,7 @@ def decodescript_script_pub_key(self):
130
138
self .log .info ("- P2PK with uncompressed pubkey" )
131
139
# <pubkey> OP_CHECKSIG
132
140
rpc_result = self .nodes [0 ].decodescript (push_uncompressed_public_key + 'ac' )
141
+ assert_equal ('pubkey' , rpc_result ['type' ])
133
142
assert_equal (uncompressed_public_key + ' OP_CHECKSIG' , rpc_result ['asm' ])
134
143
# uncompressed pubkeys are invalid for checksigs in segwit scripts.
135
144
# decodescript should not return a P2WPKH equivalent.
@@ -141,6 +150,7 @@ def decodescript_script_pub_key(self):
141
150
# the purpose of this test is to check that a segwit script is not returned for bare multisig scripts
142
151
# with an uncompressed pubkey in them.
143
152
rpc_result = self .nodes [0 ].decodescript ('52' + push_public_key + push_uncompressed_public_key + '52ae' )
153
+ assert_equal ('multisig' , rpc_result ['type' ])
144
154
assert_equal ('2 ' + public_key + ' ' + uncompressed_public_key + ' 2 OP_CHECKMULTISIG' , rpc_result ['asm' ])
145
155
# uncompressed pubkeys are invalid for checksigs in segwit scripts.
146
156
# decodescript should not return a P2WPKH equivalent.
@@ -149,6 +159,7 @@ def decodescript_script_pub_key(self):
149
159
self .log .info ("- P2WPKH" )
150
160
# 0 <PubKeyHash>
151
161
rpc_result = self .nodes [0 ].decodescript ('00' + push_public_key_hash )
162
+ assert_equal ('witness_v0_keyhash' , rpc_result ['type' ])
152
163
assert_equal ('0 ' + public_key_hash , rpc_result ['asm' ])
153
164
# segwit scripts do not work nested into each other.
154
165
# a nested segwit script should not be returned in the results.
@@ -159,6 +170,7 @@ def decodescript_script_pub_key(self):
159
170
# even though this hash is of a P2PK script which is better used as bare P2WPKH, it should not matter
160
171
# for the purpose of this test.
161
172
rpc_result = self .nodes [0 ].decodescript ('0020' + p2wsh_p2pk_script_hash )
173
+ assert_equal ('witness_v0_scripthash' , rpc_result ['type' ])
162
174
assert_equal ('0 ' + p2wsh_p2pk_script_hash , rpc_result ['asm' ])
163
175
# segwit scripts do not work nested into each other.
164
176
# a nested segwit script should not be returned in the results.
0 commit comments