Skip to content

Commit 4d32c19

Browse files
committed
test: Replace importpubkey
1 parent fe838dd commit 4d32c19

File tree

5 files changed

+8
-21
lines changed

5 files changed

+8
-21
lines changed

test/functional/test_framework/test_node.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
JSONRPCException,
2828
serialization_fallback,
2929
)
30-
from .descriptors import descsum_create
3130
from .messages import NODE_P2P_V2
3231
from .p2p import P2P_SERVICES, P2P_SUBVERSION
3332
from .util import (
@@ -930,17 +929,3 @@ def __init__(self, rpc):
930929

931930
def __getattr__(self, name):
932931
return getattr(self.rpc, name)
933-
934-
def importpubkey(self, pubkey, *, label=None, rescan=None):
935-
wallet_info = self.getwalletinfo()
936-
if 'descriptors' not in wallet_info or ('descriptors' in wallet_info and not wallet_info['descriptors']):
937-
return self.__getattr__('importpubkey')(pubkey, label, rescan)
938-
desc = descsum_create('combo(' + pubkey + ')')
939-
req = [{
940-
'desc': desc,
941-
'timestamp': 0 if rescan else 'now',
942-
'label': label if label else '',
943-
}]
944-
import_res = self.importdescriptors(req)
945-
if not import_res[0]['success']:
946-
raise JSONRPCException(import_res[0]['error'])

test/functional/wallet_createwallet.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ def run_test(self):
4242
w1 = node.get_wallet_rpc('w1')
4343
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w1.getnewaddress)
4444
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w1.getrawchangeaddress)
45-
w1.importpubkey(w0.getaddressinfo(address1)['pubkey'])
45+
import_res = w1.importdescriptors([{"desc": w0.getaddressinfo(address1)['desc'], "timestamp": "now"}])
46+
assert_equal(import_res[0]["success"], True)
4647

4748
self.log.info('Test that private keys cannot be imported')
4849
privkey, pubkey = generate_keypair(wif=True)
@@ -57,7 +58,8 @@ def run_test(self):
5758
w2 = node.get_wallet_rpc('w2')
5859
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w2.getnewaddress)
5960
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w2.getrawchangeaddress)
60-
w2.importpubkey(w0.getaddressinfo(address1)['pubkey'])
61+
import_res = w2.importdescriptors([{"desc": w0.getaddressinfo(address1)['desc'], "timestamp": "now"}])
62+
assert_equal(import_res[0]["success"], True)
6163

6264
self.log.info("Test blank creation with private keys enabled.")
6365
self.nodes[0].createwallet(wallet_name='w3', disable_private_keys=False, blank=True)

test/functional/wallet_fundrawtransaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ def test_change_position(self):
190190
self.nodes[3].createwallet(wallet_name="wwatch", disable_private_keys=True)
191191
wwatch = self.nodes[3].get_wallet_rpc('wwatch')
192192
watchonly_address = self.nodes[0].getnewaddress()
193-
watchonly_pubkey = self.nodes[0].getaddressinfo(watchonly_address)["pubkey"]
194193
self.watchonly_amount = Decimal(200)
195-
wwatch.importpubkey(watchonly_pubkey, label="", rescan=True)
194+
import_res = wwatch.importdescriptors([{"desc": self.nodes[0].getaddressinfo(watchonly_address)["desc"], "timestamp": "now"}])
195+
assert_equal(import_res[0]["success"], True)
196196
self.watchonly_utxo = self.create_outpoints(self.nodes[0], outputs=[{watchonly_address: self.watchonly_amount}])[0]
197197

198198
# Lock UTXO so nodes[0] doesn't accidentally spend it

test/functional/wallet_labels.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def invalid_label_name_test(self):
3434
[node.getnewaddress],
3535
[node.setlabel, address],
3636
[node.getaddressesbylabel],
37-
[node.importpubkey, pubkey],
3837
[node.getreceivedbylabel],
3938
[node.listsinceblock, node.getblockhash(0), 1, False, True, False],
4039
]

test/functional/wallet_simulaterawtx.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def run_test(self):
4545
address2 = w1.getnewaddress()
4646

4747
# Add address1 as watch-only to w2
48-
w2.importpubkey(pubkey=w1.getaddressinfo(address1)["pubkey"])
48+
import_res = w2.importdescriptors([{"desc": w1.getaddressinfo(address1)["desc"], "timestamp": "now"}])
49+
assert_equal(import_res[0]["success"], True)
4950

5051
tx1 = node.createrawtransaction([], [{address1: 5.0}])
5152
tx2 = node.createrawtransaction([], [{address2: 10.0}])

0 commit comments

Comments
 (0)