aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_importmulti.py
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2018-12-13 12:43:35 -0500
committerAmiti Uttarwar <amiti.uttarwar@coinbase.com>2019-01-04 17:49:17 -0800
commit2d5f1ea2e3f9629d313f1d2aff94a15ef8e1128a (patch)
tree2751d6539da4cc3b350da333f5a5214e3d1dd2d7 /test/functional/wallet_importmulti.py
parent6be64ef02ca0832dfb74f74e5b026ead4cd7ef72 (diff)
downloadbitcoin-2d5f1ea2e3f9629d313f1d2aff94a15ef8e1128a.tar.xz
[tests] move wallet util functions to wallet_util.py
Adds a new wallet_util.py module and moves generic helper functions there: - get_key - get_multisig - test_address
Diffstat (limited to 'test/functional/wallet_importmulti.py')
-rwxr-xr-xtest/functional/wallet_importmulti.py410
1 files changed, 177 insertions, 233 deletions
diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py
index 4de459d99b..f122f19e3a 100755
--- a/test/functional/wallet_importmulti.py
+++ b/test/functional/wallet_importmulti.py
@@ -14,30 +14,10 @@ variants.
success, and (if unsuccessful) test the error code and error message returned.
- `test_address()` is called to call getaddressinfo for an address on node1
and test the values returned."""
-from collections import namedtuple
-
-from test_framework.address import (
- key_to_p2pkh,
- key_to_p2sh_p2wpkh,
- key_to_p2wpkh,
- script_to_p2sh,
- script_to_p2sh_p2wsh,
- script_to_p2wsh,
-)
+
from test_framework.script import (
CScript,
- OP_0,
- OP_2,
- OP_3,
- OP_CHECKMULTISIG,
- OP_CHECKSIG,
- OP_DUP,
- OP_EQUAL,
- OP_EQUALVERIFY,
- OP_HASH160,
OP_NOP,
- hash160,
- sha256,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
@@ -45,28 +25,12 @@ from test_framework.util import (
assert_greater_than,
assert_raises_rpc_error,
bytes_to_hex_str,
- hex_str_to_bytes
)
-
-Key = namedtuple('Key', ['privkey',
- 'pubkey',
- 'p2pkh_script',
- 'p2pkh_addr',
- 'p2wpkh_script',
- 'p2wpkh_addr',
- 'p2sh_p2wpkh_script',
- 'p2sh_p2wpkh_redeem_script',
- 'p2sh_p2wpkh_addr'])
-
-Multisig = namedtuple('Multisig', ['privkeys',
- 'pubkeys',
- 'p2sh_script',
- 'p2sh_addr',
- 'redeem_script',
- 'p2wsh_script',
- 'p2wsh_addr',
- 'p2sh_p2wsh_script',
- 'p2sh_p2wsh_addr'])
+from test_framework.wallet_util import (
+ get_key,
+ get_multisig,
+ test_address,
+)
class ImportMultiTest(BitcoinTestFramework):
def set_test_params(self):
@@ -80,45 +44,6 @@ class ImportMultiTest(BitcoinTestFramework):
def setup_network(self):
self.setup_nodes()
- def get_key(self):
- """Generate a fresh key on node0
-
- Returns a named tuple of privkey, pubkey and all address and scripts."""
- addr = self.nodes[0].getnewaddress()
- pubkey = self.nodes[0].getaddressinfo(addr)['pubkey']
- pkh = hash160(hex_str_to_bytes(pubkey))
- return Key(privkey=self.nodes[0].dumpprivkey(addr),
- pubkey=pubkey,
- p2pkh_script=CScript([OP_DUP, OP_HASH160, pkh, OP_EQUALVERIFY, OP_CHECKSIG]).hex(),
- p2pkh_addr=key_to_p2pkh(pubkey),
- p2wpkh_script=CScript([OP_0, pkh]).hex(),
- p2wpkh_addr=key_to_p2wpkh(pubkey),
- p2sh_p2wpkh_script=CScript([OP_HASH160, hash160(CScript([OP_0, pkh])), OP_EQUAL]).hex(),
- p2sh_p2wpkh_redeem_script=CScript([OP_0, pkh]).hex(),
- p2sh_p2wpkh_addr=key_to_p2sh_p2wpkh(pubkey))
-
- def get_multisig(self):
- """Generate a fresh 2-of-3 multisig on node0
-
- Returns a named tuple of privkeys, pubkeys and all address and scripts."""
- addrs = []
- pubkeys = []
- for _ in range(3):
- addr = self.nodes[0].getaddressinfo(self.nodes[0].getnewaddress())
- addrs.append(addr['address'])
- pubkeys.append(addr['pubkey'])
- script_code = CScript([OP_2] + [hex_str_to_bytes(pubkey) for pubkey in pubkeys] + [OP_3, OP_CHECKMULTISIG])
- witness_script = CScript([OP_0, sha256(script_code)])
- return Multisig(privkeys=[self.nodes[0].dumpprivkey(addr) for addr in addrs],
- pubkeys=pubkeys,
- p2sh_script=CScript([OP_HASH160, hash160(script_code), OP_EQUAL]).hex(),
- p2sh_addr=script_to_p2sh(script_code),
- redeem_script=script_code.hex(),
- p2wsh_script=witness_script.hex(),
- p2wsh_addr=script_to_p2wsh(script_code),
- p2sh_p2wsh_script=CScript([OP_HASH160, witness_script, OP_EQUAL]).hex(),
- p2sh_p2wsh_addr=script_to_p2sh_p2wsh(script_code))
-
def test_importmulti(self, req, success, error_code=None, error_message=None, warnings=[]):
"""Run importmulti and assert success"""
result = self.nodes[1].importmulti([req])
@@ -131,16 +56,6 @@ class ImportMultiTest(BitcoinTestFramework):
assert_equal(result[0]['error']['code'], error_code)
assert_equal(result[0]['error']['message'], error_message)
- def test_address(self, address, **kwargs):
- """Get address info for `address` and test whether the returned values are as expected."""
- addr_info = self.nodes[1].getaddressinfo(address)
- for key, value in kwargs.items():
- if value is None:
- if key in addr_info.keys():
- raise AssertionError("key {} unexpectedly returned in getaddressinfo.".format(key))
- elif addr_info[key] != value:
- raise AssertionError("key {} value {} did not match expected value {}".format(key, addr_info[key], value))
-
def run_test(self):
self.log.info("Mining blocks...")
self.nodes[0].generate(1)
@@ -164,15 +79,16 @@ class ImportMultiTest(BitcoinTestFramework):
# Bitcoin Address (implicit non-internal)
self.log.info("Should import an address")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr},
"timestamp": "now"},
success=True)
- self.test_address(key.p2pkh_addr,
- iswatchonly=True,
- ismine=False,
- timestamp=timestamp,
- ischange=False)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=True,
+ ismine=False,
+ timestamp=timestamp,
+ ischange=False)
watchonly_address = key.p2pkh_addr
watchonly_timestamp = timestamp
@@ -185,20 +101,21 @@ class ImportMultiTest(BitcoinTestFramework):
# ScriptPubKey + internal
self.log.info("Should import a scriptPubKey with internal flag")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": key.p2pkh_script,
"timestamp": "now",
"internal": True},
success=True)
- self.test_address(key.p2pkh_addr,
- iswatchonly=True,
- ismine=False,
- timestamp=timestamp,
- ischange=True)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=True,
+ ismine=False,
+ timestamp=timestamp,
+ ischange=True)
# ScriptPubKey + internal + label
self.log.info("Should not allow a label to be specified when internal is true")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": key.p2pkh_script,
"timestamp": "now",
"internal": True,
@@ -210,70 +127,75 @@ class ImportMultiTest(BitcoinTestFramework):
# Nonstandard scriptPubKey + !internal
self.log.info("Should not import a nonstandard scriptPubKey without internal flag")
nonstandardScriptPubKey = key.p2pkh_script + bytes_to_hex_str(CScript([OP_NOP]))
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": nonstandardScriptPubKey,
"timestamp": "now"},
success=False,
error_code=-8,
error_message='Internal must be set to true for nonstandard scriptPubKey imports.')
- self.test_address(key.p2pkh_addr,
- iswatchonly=False,
- ismine=False,
- timestamp=None)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=False,
+ ismine=False,
+ timestamp=None)
# Address + Public key + !Internal(explicit)
self.log.info("Should import an address with public key")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr},
"timestamp": "now",
"pubkeys": [key.pubkey],
"internal": False},
success=True,
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(key.p2pkh_addr,
- iswatchonly=True,
- ismine=False,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=True,
+ ismine=False,
+ timestamp=timestamp)
# ScriptPubKey + Public key + internal
self.log.info("Should import a scriptPubKey with internal and with public key")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": key.p2pkh_script,
"timestamp": "now",
"pubkeys": [key.pubkey],
"internal": True},
success=True,
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(key.p2pkh_addr,
- iswatchonly=True,
- ismine=False,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=True,
+ ismine=False,
+ timestamp=timestamp)
# Nonstandard scriptPubKey + Public key + !internal
self.log.info("Should not import a nonstandard scriptPubKey without internal and with public key")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": nonstandardScriptPubKey,
"timestamp": "now",
"pubkeys": [key.pubkey]},
success=False,
error_code=-8,
error_message='Internal must be set to true for nonstandard scriptPubKey imports.')
- self.test_address(key.p2pkh_addr,
- iswatchonly=False,
- ismine=False,
- timestamp=None)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=False,
+ ismine=False,
+ timestamp=None)
# Address + Private key + !watchonly
self.log.info("Should import an address with private key")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr},
"timestamp": "now",
"keys": [key.privkey]},
success=True)
- self.test_address(key.p2pkh_addr,
- iswatchonly=False,
- ismine=True,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=False,
+ ismine=True,
+ timestamp=timestamp)
self.log.info("Should not import an address with private key if is already imported")
self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr},
@@ -285,47 +207,50 @@ class ImportMultiTest(BitcoinTestFramework):
# Address + Private key + watchonly
self.log.info("Should import an address with private key and with watchonly")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr},
"timestamp": "now",
"keys": [key.privkey],
"watchonly": True},
success=True,
warnings=["All private keys are provided, outputs will be considered spendable. If this is intentional, do not specify the watchonly flag."])
- self.test_address(key.p2pkh_addr,
- iswatchonly=False,
- ismine=True,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=False,
+ ismine=True,
+ timestamp=timestamp)
# ScriptPubKey + Private key + internal
self.log.info("Should import a scriptPubKey with internal and with private key")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": key.p2pkh_script,
"timestamp": "now",
"keys": [key.privkey],
"internal": True},
success=True)
- self.test_address(key.p2pkh_addr,
- iswatchonly=False,
- ismine=True,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=False,
+ ismine=True,
+ timestamp=timestamp)
# Nonstandard scriptPubKey + Private key + !internal
self.log.info("Should not import a nonstandard scriptPubKey without internal and with private key")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": nonstandardScriptPubKey,
"timestamp": "now",
"keys": [key.privkey]},
success=False,
error_code=-8,
error_message='Internal must be set to true for nonstandard scriptPubKey imports.')
- self.test_address(key.p2pkh_addr,
- iswatchonly=False,
- ismine=False,
- timestamp=None)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=False,
+ ismine=False,
+ timestamp=None)
# P2SH address
- multisig = self.get_multisig()
+ multisig = get_multisig(self.nodes[0])
self.nodes[1].generate(100)
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1)
@@ -335,16 +260,17 @@ class ImportMultiTest(BitcoinTestFramework):
self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_addr},
"timestamp": "now"},
success=True)
- self.test_address(multisig.p2sh_addr,
- isscript=True,
- iswatchonly=True,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ multisig.p2sh_addr,
+ isscript=True,
+ iswatchonly=True,
+ timestamp=timestamp)
p2shunspent = self.nodes[1].listunspent(0, 999999, [multisig.p2sh_addr])[0]
assert_equal(p2shunspent['spendable'], False)
assert_equal(p2shunspent['solvable'], False)
# P2SH + Redeem script
- multisig = self.get_multisig()
+ multisig = get_multisig(self.nodes[0])
self.nodes[1].generate(100)
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1)
@@ -356,14 +282,15 @@ class ImportMultiTest(BitcoinTestFramework):
"redeemscript": multisig.redeem_script},
success=True,
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(multisig.p2sh_addr, timestamp=timestamp, iswatchonly=True, ismine=False, solvable=True)
+ test_address(self.nodes[1],
+ multisig.p2sh_addr, timestamp=timestamp, iswatchonly=True, ismine=False, solvable=True)
p2shunspent = self.nodes[1].listunspent(0, 999999, [multisig.p2sh_addr])[0]
assert_equal(p2shunspent['spendable'], False)
assert_equal(p2shunspent['solvable'], True)
# P2SH + Redeem script + Private Keys + !Watchonly
- multisig = self.get_multisig()
+ multisig = get_multisig(self.nodes[0])
self.nodes[1].generate(100)
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1)
@@ -376,18 +303,19 @@ class ImportMultiTest(BitcoinTestFramework):
"keys": multisig.privkeys[0:2]},
success=True,
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(multisig.p2sh_addr,
- timestamp=timestamp,
- ismine=False,
- iswatchonly=True,
- solvable=True)
+ test_address(self.nodes[1],
+ multisig.p2sh_addr,
+ timestamp=timestamp,
+ ismine=False,
+ iswatchonly=True,
+ solvable=True)
p2shunspent = self.nodes[1].listunspent(0, 999999, [multisig.p2sh_addr])[0]
assert_equal(p2shunspent['spendable'], False)
assert_equal(p2shunspent['solvable'], True)
# P2SH + Redeem script + Private Keys + Watchonly
- multisig = self.get_multisig()
+ multisig = get_multisig(self.nodes[0])
self.nodes[1].generate(100)
self.nodes[1].sendtoaddress(multisig.p2sh_addr, 10.00)
self.nodes[1].generate(1)
@@ -400,73 +328,78 @@ class ImportMultiTest(BitcoinTestFramework):
"keys": multisig.privkeys[0:2],
"watchonly": True},
success=True)
- self.test_address(multisig.p2sh_addr,
- iswatchonly=True,
- ismine=False,
- solvable=True,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ multisig.p2sh_addr,
+ iswatchonly=True,
+ ismine=False,
+ solvable=True,
+ timestamp=timestamp)
# Address + Public key + !Internal + Wrong pubkey
self.log.info("Should not import an address with the wrong public key as non-solvable")
- key = self.get_key()
- wrong_key = self.get_key().pubkey
+ key = get_key(self.nodes[0])
+ wrong_key = get_key(self.nodes[0]).pubkey
self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr},
"timestamp": "now",
"pubkeys": [wrong_key]},
success=True,
warnings=["Importing as non-solvable: some required keys are missing. If this is intentional, don't provide any keys, pubkeys, witnessscript, or redeemscript.", "Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(key.p2pkh_addr,
- iswatchonly=True,
- ismine=False,
- solvable=False,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=True,
+ ismine=False,
+ solvable=False,
+ timestamp=timestamp)
# ScriptPubKey + Public key + internal + Wrong pubkey
self.log.info("Should import a scriptPubKey with internal and with a wrong public key as non-solvable")
- key = self.get_key()
- wrong_key = self.get_key().pubkey
+ key = get_key(self.nodes[0])
+ wrong_key = get_key(self.nodes[0]).pubkey
self.test_importmulti({"scriptPubKey": key.p2pkh_script,
"timestamp": "now",
"pubkeys": [wrong_key],
"internal": True},
success=True,
warnings=["Importing as non-solvable: some required keys are missing. If this is intentional, don't provide any keys, pubkeys, witnessscript, or redeemscript.", "Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(key.p2pkh_addr,
- iswatchonly=True,
- ismine=False,
- solvable=False,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=True,
+ ismine=False,
+ solvable=False,
+ timestamp=timestamp)
# Address + Private key + !watchonly + Wrong private key
self.log.info("Should import an address with a wrong private key as non-solvable")
- key = self.get_key()
- wrong_privkey = self.get_key().privkey
+ key = get_key(self.nodes[0])
+ wrong_privkey = get_key(self.nodes[0]).privkey
self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr},
"timestamp": "now",
"keys": [wrong_privkey]},
success=True,
warnings=["Importing as non-solvable: some required keys are missing. If this is intentional, don't provide any keys, pubkeys, witnessscript, or redeemscript.", "Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(key.p2pkh_addr,
- iswatchonly=True,
- ismine=False,
- solvable=False,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=True,
+ ismine=False,
+ solvable=False,
+ timestamp=timestamp)
# ScriptPubKey + Private key + internal + Wrong private key
self.log.info("Should import a scriptPubKey with internal and with a wrong private key as non-solvable")
- key = self.get_key()
- wrong_privkey = self.get_key().privkey
+ key = get_key(self.nodes[0])
+ wrong_privkey = get_key(self.nodes[0]).privkey
self.test_importmulti({"scriptPubKey": key.p2pkh_script,
"timestamp": "now",
"keys": [wrong_privkey],
"internal": True},
success=True,
warnings=["Importing as non-solvable: some required keys are missing. If this is intentional, don't provide any keys, pubkeys, witnessscript, or redeemscript.", "Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(key.p2pkh_addr,
- iswatchonly=True,
- ismine=False,
- solvable=False,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ key.p2pkh_addr,
+ iswatchonly=True,
+ ismine=False,
+ solvable=False,
+ timestamp=timestamp)
# Importing existing watch only address with new timestamp should replace saved timestamp.
assert_greater_than(timestamp, watchonly_timestamp)
@@ -474,19 +407,21 @@ class ImportMultiTest(BitcoinTestFramework):
self.test_importmulti({"scriptPubKey": {"address": watchonly_address},
"timestamp": "now"},
success=True)
- self.test_address(watchonly_address,
- iswatchonly=True,
- ismine=False,
- timestamp=timestamp)
+ test_address(self.nodes[1],
+ watchonly_address,
+ iswatchonly=True,
+ ismine=False,
+ timestamp=timestamp)
watchonly_timestamp = timestamp
# restart nodes to check for proper serialization/deserialization of watch only address
self.stop_nodes()
self.start_nodes()
- self.test_address(watchonly_address,
- iswatchonly=True,
- ismine=False,
- timestamp=watchonly_timestamp)
+ test_address(self.nodes[1],
+ watchonly_address,
+ iswatchonly=True,
+ ismine=False,
+ timestamp=watchonly_timestamp)
# Bad or missing timestamps
self.log.info("Should throw on invalid or missing timestamp values")
@@ -500,45 +435,49 @@ class ImportMultiTest(BitcoinTestFramework):
# Import P2WPKH address as watch only
self.log.info("Should import a P2WPKH address as watch only")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": {"address": key.p2wpkh_addr},
"timestamp": "now"},
success=True)
- self.test_address(key.p2wpkh_addr,
- iswatchonly=True,
- solvable=False)
+ test_address(self.nodes[1],
+ key.p2wpkh_addr,
+ iswatchonly=True,
+ solvable=False)
# Import P2WPKH address with public key but no private key
self.log.info("Should import a P2WPKH address and public key as solvable but not spendable")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": {"address": key.p2wpkh_addr},
"timestamp": "now",
"pubkeys": [key.pubkey]},
success=True,
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(key.p2wpkh_addr,
- ismine=False,
- solvable=True)
+ test_address(self.nodes[1],
+ key.p2wpkh_addr,
+ ismine=False,
+ solvable=True)
# Import P2WPKH address with key and check it is spendable
self.log.info("Should import a P2WPKH address with key")
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.test_importmulti({"scriptPubKey": {"address": key.p2wpkh_addr},
"timestamp": "now",
"keys": [key.privkey]},
success=True)
- self.test_address(key.p2wpkh_addr,
- iswatchonly=False,
- ismine=True)
+ test_address(self.nodes[1],
+ key.p2wpkh_addr,
+ iswatchonly=False,
+ ismine=True)
# P2WSH multisig address without scripts or keys
- multisig = self.get_multisig()
+ multisig = get_multisig(self.nodes[0])
self.log.info("Should import a p2wsh multisig as watch only without respective redeem script and private keys")
self.test_importmulti({"scriptPubKey": {"address": multisig.p2wsh_addr},
"timestamp": "now"},
success=True)
- self.test_address(multisig.p2sh_addr,
- solvable=False)
+ test_address(self.nodes[1],
+ multisig.p2sh_addr,
+ solvable=False)
# Same P2WSH multisig address as above, but now with witnessscript + private keys
self.log.info("Should import a p2wsh with respective witness script and private keys")
@@ -547,20 +486,22 @@ class ImportMultiTest(BitcoinTestFramework):
"witnessscript": multisig.redeem_script,
"keys": multisig.privkeys},
success=True)
- self.test_address(multisig.p2sh_addr,
- solvable=True,
- ismine=True,
- sigsrequired=2)
+ test_address(self.nodes[1],
+ multisig.p2sh_addr,
+ solvable=True,
+ ismine=True,
+ sigsrequired=2)
# P2SH-P2WPKH address with no redeemscript or public or private key
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.log.info("Should import a p2sh-p2wpkh without redeem script or keys")
self.test_importmulti({"scriptPubKey": {"address": key.p2sh_p2wpkh_addr},
"timestamp": "now"},
success=True)
- self.test_address(key.p2sh_p2wpkh_addr,
- solvable=False,
- ismine=False)
+ test_address(self.nodes[1],
+ key.p2sh_p2wpkh_addr,
+ solvable=False,
+ ismine=False)
# P2SH-P2WPKH address + redeemscript + public key with no private key
self.log.info("Should import a p2sh-p2wpkh with respective redeem script and pubkey as solvable")
@@ -570,24 +511,26 @@ class ImportMultiTest(BitcoinTestFramework):
"pubkeys": [key.pubkey]},
success=True,
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(key.p2sh_p2wpkh_addr,
- solvable=True,
- ismine=False)
+ test_address(self.nodes[1],
+ key.p2sh_p2wpkh_addr,
+ solvable=True,
+ ismine=False)
# P2SH-P2WPKH address + redeemscript + private key
- key = self.get_key()
+ key = get_key(self.nodes[0])
self.log.info("Should import a p2sh-p2wpkh with respective redeem script and private keys")
self.test_importmulti({"scriptPubKey": {"address": key.p2sh_p2wpkh_addr},
"timestamp": "now",
"redeemscript": key.p2sh_p2wpkh_redeem_script,
"keys": [key.privkey]},
success=True)
- self.test_address(key.p2sh_p2wpkh_addr,
- solvable=True,
- ismine=True)
+ test_address(self.nodes[1],
+ key.p2sh_p2wpkh_addr,
+ solvable=True,
+ ismine=True)
# P2SH-P2WSH multisig + redeemscript with no private key
- multisig = self.get_multisig()
+ multisig = get_multisig(self.nodes[0])
self.log.info("Should import a p2sh-p2wsh with respective redeem script but no private key")
self.test_importmulti({"scriptPubKey": {"address": multisig.p2sh_p2wsh_addr},
"timestamp": "now",
@@ -595,9 +538,10 @@ class ImportMultiTest(BitcoinTestFramework):
"witnessscript": multisig.redeem_script},
success=True,
warnings=["Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag."])
- self.test_address(multisig.p2sh_p2wsh_addr,
- solvable=True,
- ismine=False)
+ test_address(self.nodes[1],
+ multisig.p2sh_p2wsh_addr,
+ solvable=True,
+ ismine=False)
if __name__ == '__main__':
ImportMultiTest().main()