aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_importmulti.py
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2016-11-28 17:19:27 -0500
committerRussell Yanofsky <russ@yanofsky.org>2018-02-22 10:04:42 -0500
commit98ea64cf232c34d4b1aebe738b3956191667cd76 (patch)
treefa5a3e1778d190b28b57e77b2324bd651116684f /test/functional/wallet_importmulti.py
parentaae64a21ba25ca86fe2bbb581681dc20d613fb44 (diff)
downloadbitcoin-98ea64cf232c34d4b1aebe738b3956191667cd76.tar.xz
Let wallet importmulti RPC accept labels for standard scriptPubKeys
Allow importmulti RPC to apply address labels when importing standard scriptPubKeys. This makes the importmulti RPC less finnicky about import formats and also simpler internally.
Diffstat (limited to 'test/functional/wallet_importmulti.py')
-rwxr-xr-xtest/functional/wallet_importmulti.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py
index 56ebc2622a..0b4065ed7e 100755
--- a/test/functional/wallet_importmulti.py
+++ b/test/functional/wallet_importmulti.py
@@ -3,6 +3,8 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the importmulti RPC."""
+
+from test_framework import script
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import *
@@ -79,16 +81,17 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal(address_assert['ismine'], False)
assert_equal(address_assert['timestamp'], timestamp)
- # ScriptPubKey + !internal
- self.log.info("Should not import a scriptPubKey without internal flag")
+ # Nonstandard scriptPubKey + !internal
+ self.log.info("Should not import a nonstandard scriptPubKey without internal flag")
+ nonstandardScriptPubKey = address['scriptPubKey'] + bytes_to_hex_str(script.CScript([script.OP_NOP]))
address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
- "scriptPubKey": address['scriptPubKey'],
+ "scriptPubKey": nonstandardScriptPubKey,
"timestamp": "now",
}])
assert_equal(result[0]['success'], False)
assert_equal(result[0]['error']['code'], -8)
- assert_equal(result[0]['error']['message'], 'Internal must be set for hex scriptPubKey')
+ assert_equal(result[0]['error']['message'], 'Internal must be set to true for nonstandard scriptPubKey imports.')
address_assert = self.nodes[1].getaddressinfo(address['address'])
assert_equal(address_assert['iswatchonly'], False)
assert_equal(address_assert['ismine'], False)
@@ -128,18 +131,18 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal(address_assert['ismine'], False)
assert_equal(address_assert['timestamp'], timestamp)
- # ScriptPubKey + Public key + !internal
- self.log.info("Should not import a scriptPubKey without internal and with public key")
+ # Nonstandard scriptPubKey + Public key + !internal
+ self.log.info("Should not import a nonstandard scriptPubKey without internal and with public key")
address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
request = [{
- "scriptPubKey": address['scriptPubKey'],
+ "scriptPubKey": nonstandardScriptPubKey,
"timestamp": "now",
"pubkeys": [ address['pubkey'] ]
}]
result = self.nodes[1].importmulti(request)
assert_equal(result[0]['success'], False)
assert_equal(result[0]['error']['code'], -8)
- assert_equal(result[0]['error']['message'], 'Internal must be set for hex scriptPubKey')
+ assert_equal(result[0]['error']['message'], 'Internal must be set to true for nonstandard scriptPubKey imports.')
address_assert = self.nodes[1].getaddressinfo(address['address'])
assert_equal(address_assert['iswatchonly'], False)
assert_equal(address_assert['ismine'], False)
@@ -207,17 +210,17 @@ class ImportMultiTest (BitcoinTestFramework):
assert_equal(address_assert['ismine'], True)
assert_equal(address_assert['timestamp'], timestamp)
- # ScriptPubKey + Private key + !internal
- self.log.info("Should not import a scriptPubKey without internal and with private key")
+ # Nonstandard scriptPubKey + Private key + !internal
+ self.log.info("Should not import a nonstandard scriptPubKey without internal and with private key")
address = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
result = self.nodes[1].importmulti([{
- "scriptPubKey": address['scriptPubKey'],
+ "scriptPubKey": nonstandardScriptPubKey,
"timestamp": "now",
"keys": [ self.nodes[0].dumpprivkey(address['address']) ]
}])
assert_equal(result[0]['success'], False)
assert_equal(result[0]['error']['code'], -8)
- assert_equal(result[0]['error']['message'], 'Internal must be set for hex scriptPubKey')
+ assert_equal(result[0]['error']['message'], 'Internal must be set to true for nonstandard scriptPubKey imports.')
address_assert = self.nodes[1].getaddressinfo(address['address'])
assert_equal(address_assert['iswatchonly'], False)
assert_equal(address_assert['ismine'], False)