test: Replace importprivkey with wallet_importprivkey
importprivkey was a legacy wallet only RPC which had a helper for descriptor wallets in tests. Add wallet_importprivkey helper and use it wherever importprivkey is used (other than backward compatibility tests)
This commit is contained in:
1 parent
94c87bbbd0
commit
fcc457573f
10 files changed
+33
-26
No files matched your search
@@ -35,6 +35,7 @@ from .util import (
|
||||
initialize_datadir,
|
||||
p2p_port,
|
||||
wait_until_helper_internal,
|
||||
wallet_importprivkey,
|
||||
)
|
||||
|
||||
|
||||
@@ -485,7 +486,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||
n = self.nodes[node]
|
||||
if wallet_name is not None:
|
||||
n.createwallet(wallet_name=wallet_name, load_on_startup=True)
|
||||
n.importprivkey(privkey=n.get_deterministic_priv_key().key, label='coinbase', rescan=True)
|
||||
wallet_importprivkey(n.get_wallet_rpc(wallet_name), n.get_deterministic_priv_key().key, 0, label="coinbase")
|
||||
|
||||
def run_test(self):
|
||||
"""Tests must override this method to define test logic"""
|
||||
|
||||
@@ -931,20 +931,6 @@ class RPCOverloadWrapper():
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.rpc, name)
|
||||
|
||||
def importprivkey(self, privkey, *, label=None, rescan=None):
|
||||
wallet_info = self.getwalletinfo()
|
||||
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
||||
return self.__getattr__('importprivkey')(privkey, label, rescan)
|
||||
desc = descsum_create('combo(' + privkey + ')')
|
||||
req = [{
|
||||
'desc': desc,
|
||||
'timestamp': 0 if rescan else 'now',
|
||||
'label': label if label else '',
|
||||
}]
|
||||
import_res = self.importdescriptors(req)
|
||||
if not import_res[0]['success']:
|
||||
raise JSONRPCException(import_res[0]['error'])
|
||||
|
||||
def addmultisigaddress(self, nrequired, keys, *, label=None, address_type=None):
|
||||
wallet_info = self.getwalletinfo()
|
||||
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
|
||||
|
||||
@@ -20,6 +20,7 @@ import time
|
||||
|
||||
from . import coverage
|
||||
from .authproxy import AuthServiceProxy, JSONRPCException
|
||||
from .descriptors import descsum_create
|
||||
from collections.abc import Callable
|
||||
from typing import Optional, Union
|
||||
|
||||
@@ -609,3 +610,13 @@ def sync_txindex(test_framework, node):
|
||||
sync_start = int(time.time())
|
||||
test_framework.wait_until(lambda: node.getindexinfo("txindex")["txindex"]["synced"])
|
||||
test_framework.log.debug(f"Synced in {time.time() - sync_start} seconds")
|
||||
|
||||
def wallet_importprivkey(wallet_rpc, privkey, timestamp, *, label=""):
|
||||
desc = descsum_create("combo(" + privkey + ")")
|
||||
req = [{
|
||||
"desc": desc,
|
||||
"timestamp": timestamp,
|
||||
"label": label,
|
||||
}]
|
||||
import_res = wallet_rpc.importdescriptors(req)
|
||||
assert_equal(import_res[0]["success"], True)
|
||||
Reference in new issue
Block a user