|
3 | 3 | # Distributed under the MIT software license, see the accompanying
|
4 | 4 | # file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
5 | 5 | """Test the importmulti RPC."""
|
| 6 | + |
| 7 | +from test_framework import script |
6 | 8 | from test_framework.test_framework import BitcoinTestFramework
|
7 | 9 | from test_framework.util import *
|
8 | 10 |
|
@@ -79,16 +81,17 @@ def run_test (self):
|
79 | 81 | assert_equal(address_assert['ismine'], False)
|
80 | 82 | assert_equal(address_assert['timestamp'], timestamp)
|
81 | 83 |
|
82 |
| - # ScriptPubKey + !internal |
83 |
| - self.log.info("Should not import a scriptPubKey without internal flag") |
| 84 | + # Nonstandard scriptPubKey + !internal |
| 85 | + self.log.info("Should not import a nonstandard scriptPubKey without internal flag") |
| 86 | + nonstandardScriptPubKey = address['scriptPubKey'] + bytes_to_hex_str(script.CScript([script.OP_NOP])) |
84 | 87 | address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
|
85 | 88 | result = self.nodes[1].importmulti([{
|
86 |
| - "scriptPubKey": address['scriptPubKey'], |
| 89 | + "scriptPubKey": nonstandardScriptPubKey, |
87 | 90 | "timestamp": "now",
|
88 | 91 | }])
|
89 | 92 | assert_equal(result[0]['success'], False)
|
90 | 93 | assert_equal(result[0]['error']['code'], -8)
|
91 |
| - assert_equal(result[0]['error']['message'], 'Internal must be set for hex scriptPubKey') |
| 94 | + assert_equal(result[0]['error']['message'], 'Internal must be set to true for nonstandard scriptPubKey imports.') |
92 | 95 | address_assert = self.nodes[1].getaddressinfo(address['address'])
|
93 | 96 | assert_equal(address_assert['iswatchonly'], False)
|
94 | 97 | assert_equal(address_assert['ismine'], False)
|
@@ -128,18 +131,18 @@ def run_test (self):
|
128 | 131 | assert_equal(address_assert['ismine'], False)
|
129 | 132 | assert_equal(address_assert['timestamp'], timestamp)
|
130 | 133 |
|
131 |
| - # ScriptPubKey + Public key + !internal |
132 |
| - self.log.info("Should not import a scriptPubKey without internal and with public key") |
| 134 | + # Nonstandard scriptPubKey + Public key + !internal |
| 135 | + self.log.info("Should not import a nonstandard scriptPubKey without internal and with public key") |
133 | 136 | address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
|
134 | 137 | request = [{
|
135 |
| - "scriptPubKey": address['scriptPubKey'], |
| 138 | + "scriptPubKey": nonstandardScriptPubKey, |
136 | 139 | "timestamp": "now",
|
137 | 140 | "pubkeys": [ address['pubkey'] ]
|
138 | 141 | }]
|
139 | 142 | result = self.nodes[1].importmulti(request)
|
140 | 143 | assert_equal(result[0]['success'], False)
|
141 | 144 | assert_equal(result[0]['error']['code'], -8)
|
142 |
| - assert_equal(result[0]['error']['message'], 'Internal must be set for hex scriptPubKey') |
| 145 | + assert_equal(result[0]['error']['message'], 'Internal must be set to true for nonstandard scriptPubKey imports.') |
143 | 146 | address_assert = self.nodes[1].getaddressinfo(address['address'])
|
144 | 147 | assert_equal(address_assert['iswatchonly'], False)
|
145 | 148 | assert_equal(address_assert['ismine'], False)
|
@@ -207,17 +210,17 @@ def run_test (self):
|
207 | 210 | assert_equal(address_assert['ismine'], True)
|
208 | 211 | assert_equal(address_assert['timestamp'], timestamp)
|
209 | 212 |
|
210 |
| - # ScriptPubKey + Private key + !internal |
211 |
| - self.log.info("Should not import a scriptPubKey without internal and with private key") |
| 213 | + # Nonstandard scriptPubKey + Private key + !internal |
| 214 | + self.log.info("Should not import a nonstandard scriptPubKey without internal and with private key") |
212 | 215 | address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
|
213 | 216 | result = self.nodes[1].importmulti([{
|
214 |
| - "scriptPubKey": address['scriptPubKey'], |
| 217 | + "scriptPubKey": nonstandardScriptPubKey, |
215 | 218 | "timestamp": "now",
|
216 | 219 | "keys": [ self.nodes[0].dumpprivkey(address['address']) ]
|
217 | 220 | }])
|
218 | 221 | assert_equal(result[0]['success'], False)
|
219 | 222 | assert_equal(result[0]['error']['code'], -8)
|
220 |
| - assert_equal(result[0]['error']['message'], 'Internal must be set for hex scriptPubKey') |
| 223 | + assert_equal(result[0]['error']['message'], 'Internal must be set to true for nonstandard scriptPubKey imports.') |
221 | 224 | address_assert = self.nodes[1].getaddressinfo(address['address'])
|
222 | 225 | assert_equal(address_assert['iswatchonly'], False)
|
223 | 226 | assert_equal(address_assert['ismine'], False)
|
|
0 commit comments