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:
Ava Chow
2025-05-08 11:26:34 -07:00
parent 94c87bbbd0
commit fcc457573f
10 changed files with 33 additions and 26 deletions

View File

@@ -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']):