@@ -67,14 +67,17 @@ def decodescript_script_pub_key(self):
6767 # <pubkey> OP_CHECKSIG
6868 rpc_result = self .nodes [0 ].decodescript (push_public_key + 'ac' )
6969 assert_equal (public_key + ' OP_CHECKSIG' , rpc_result ['asm' ])
70+ assert_equal ('pubkey' , rpc_result ['type' ])
7071 # P2PK is translated to P2WPKH
7172 assert_equal ('0 ' + public_key_hash , rpc_result ['segwit' ]['asm' ])
7273
7374 self .log .info ("- P2PKH" )
7475 # OP_DUP OP_HASH160 <PubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
7576 rpc_result = self .nodes [0 ].decodescript ('76a9' + push_public_key_hash + '88ac' )
77+ assert_equal ('pubkeyhash' , rpc_result ['type' ])
7678 assert_equal ('OP_DUP OP_HASH160 ' + public_key_hash + ' OP_EQUALVERIFY OP_CHECKSIG' , rpc_result ['asm' ])
7779 # P2PKH is translated to P2WPKH
80+ assert_equal ('witness_v0_keyhash' , rpc_result ['segwit' ]['type' ])
7881 assert_equal ('0 ' + public_key_hash , rpc_result ['segwit' ]['asm' ])
7982
8083 self .log .info ("- multisig" )
@@ -83,16 +86,19 @@ def decodescript_script_pub_key(self):
8386 # for our purposes here it does not matter that they are the same even though it is unrealistic.
8487 multisig_script = '52' + push_public_key + push_public_key + push_public_key + '53ae'
8588 rpc_result = self .nodes [0 ].decodescript (multisig_script )
89+ assert_equal ('multisig' , rpc_result ['type' ])
8690 assert_equal ('2 ' + public_key + ' ' + public_key + ' ' + public_key + ' 3 OP_CHECKMULTISIG' , rpc_result ['asm' ])
8791 # multisig in P2WSH
8892 multisig_script_hash = sha256 (bytes .fromhex (multisig_script )).hex ()
93+ assert_equal ('witness_v0_scripthash' , rpc_result ['segwit' ]['type' ])
8994 assert_equal ('0 ' + multisig_script_hash , rpc_result ['segwit' ]['asm' ])
9095
9196 self .log .info ("- P2SH" )
9297 # OP_HASH160 <Hash160(redeemScript)> OP_EQUAL.
9398 # push_public_key_hash here should actually be the hash of a redeem script.
9499 # but this works the same for purposes of this test.
95100 rpc_result = self .nodes [0 ].decodescript ('a9' + push_public_key_hash + '87' )
101+ assert_equal ('scripthash' , rpc_result ['type' ])
96102 assert_equal ('OP_HASH160 ' + public_key_hash + ' OP_EQUAL' , rpc_result ['asm' ])
97103 # P2SH does not work in segwit secripts. decodescript should not return a result for it.
98104 assert 'segwit' not in rpc_result
@@ -104,6 +110,7 @@ def decodescript_script_pub_key(self):
104110 signature_imposter = '48304502207fa7a6d1e0ee81132a269ad84e68d695483745cde8b541e3bf630749894e342a022100c1f7ab20e13e22fb95281a870f3dcf38d782e53023ee313d741ad0cfbc0c509001'
105111 # OP_RETURN <data>
106112 rpc_result = self .nodes [0 ].decodescript ('6a' + signature_imposter )
113+ assert_equal ('nulldata' , rpc_result ['type' ])
107114 assert_equal ('OP_RETURN ' + signature_imposter [2 :], rpc_result ['asm' ])
108115
109116 self .log .info ("- CLTV redeem script" )
@@ -122,6 +129,7 @@ def decodescript_script_pub_key(self):
122129 # lock until block 500,000
123130 cltv_script = '63' + push_public_key + 'ad670320a107b17568' + push_public_key + 'ac'
124131 rpc_result = self .nodes [0 ].decodescript (cltv_script )
132+ assert_equal ('nonstandard' , rpc_result ['type' ])
125133 assert_equal ('OP_IF ' + public_key + ' OP_CHECKSIGVERIFY OP_ELSE 500000 OP_CHECKLOCKTIMEVERIFY OP_DROP OP_ENDIF ' + public_key + ' OP_CHECKSIG' , rpc_result ['asm' ])
126134 # CLTV script in P2WSH
127135 cltv_script_hash = sha256 (bytes .fromhex (cltv_script )).hex ()
@@ -130,6 +138,7 @@ def decodescript_script_pub_key(self):
130138 self .log .info ("- P2PK with uncompressed pubkey" )
131139 # <pubkey> OP_CHECKSIG
132140 rpc_result = self .nodes [0 ].decodescript (push_uncompressed_public_key + 'ac' )
141+ assert_equal ('pubkey' , rpc_result ['type' ])
133142 assert_equal (uncompressed_public_key + ' OP_CHECKSIG' , rpc_result ['asm' ])
134143 # uncompressed pubkeys are invalid for checksigs in segwit scripts.
135144 # decodescript should not return a P2WPKH equivalent.
@@ -141,6 +150,7 @@ def decodescript_script_pub_key(self):
141150 # the purpose of this test is to check that a segwit script is not returned for bare multisig scripts
142151 # with an uncompressed pubkey in them.
143152 rpc_result = self .nodes [0 ].decodescript ('52' + push_public_key + push_uncompressed_public_key + '52ae' )
153+ assert_equal ('multisig' , rpc_result ['type' ])
144154 assert_equal ('2 ' + public_key + ' ' + uncompressed_public_key + ' 2 OP_CHECKMULTISIG' , rpc_result ['asm' ])
145155 # uncompressed pubkeys are invalid for checksigs in segwit scripts.
146156 # decodescript should not return a P2WPKH equivalent.
@@ -149,6 +159,7 @@ def decodescript_script_pub_key(self):
149159 self .log .info ("- P2WPKH" )
150160 # 0 <PubKeyHash>
151161 rpc_result = self .nodes [0 ].decodescript ('00' + push_public_key_hash )
162+ assert_equal ('witness_v0_keyhash' , rpc_result ['type' ])
152163 assert_equal ('0 ' + public_key_hash , rpc_result ['asm' ])
153164 # segwit scripts do not work nested into each other.
154165 # a nested segwit script should not be returned in the results.
@@ -159,6 +170,7 @@ def decodescript_script_pub_key(self):
159170 # even though this hash is of a P2PK script which is better used as bare P2WPKH, it should not matter
160171 # for the purpose of this test.
161172 rpc_result = self .nodes [0 ].decodescript ('0020' + p2wsh_p2pk_script_hash )
173+ assert_equal ('witness_v0_scripthash' , rpc_result ['type' ])
162174 assert_equal ('0 ' + p2wsh_p2pk_script_hash , rpc_result ['asm' ])
163175 # segwit scripts do not work nested into each other.
164176 # a nested segwit script should not be returned in the results.
0 commit comments