mirror of https://github.com/bitcoin/bitcoin.git
test: Replace importpubkey
This commit is contained in:
parent
fe838dd391
commit
4d32c19516
|
@ -27,7 +27,6 @@ from .authproxy import (
|
|||
JSONRPCException,
|
||||
serialization_fallback,
|
||||
)
|
||||
from .descriptors import descsum_create
|
||||
from .messages import NODE_P2P_V2
|
||||
from .p2p import P2P_SERVICES, P2P_SUBVERSION
|
||||
from .util import (
|
||||
|
@ -930,17 +929,3 @@ class RPCOverloadWrapper():
|
|||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.rpc, name)
|
||||
|
||||
def importpubkey(self, pubkey, *, 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__('importpubkey')(pubkey, label, rescan)
|
||||
desc = descsum_create('combo(' + pubkey + ')')
|
||||
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'])
|
||||
|
|
|
@ -42,7 +42,8 @@ class CreateWalletTest(BitcoinTestFramework):
|
|||
w1 = node.get_wallet_rpc('w1')
|
||||
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w1.getnewaddress)
|
||||
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w1.getrawchangeaddress)
|
||||
w1.importpubkey(w0.getaddressinfo(address1)['pubkey'])
|
||||
import_res = w1.importdescriptors([{"desc": w0.getaddressinfo(address1)['desc'], "timestamp": "now"}])
|
||||
assert_equal(import_res[0]["success"], True)
|
||||
|
||||
self.log.info('Test that private keys cannot be imported')
|
||||
privkey, pubkey = generate_keypair(wif=True)
|
||||
|
@ -57,7 +58,8 @@ class CreateWalletTest(BitcoinTestFramework):
|
|||
w2 = node.get_wallet_rpc('w2')
|
||||
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w2.getnewaddress)
|
||||
assert_raises_rpc_error(-4, "Error: This wallet has no available keys", w2.getrawchangeaddress)
|
||||
w2.importpubkey(w0.getaddressinfo(address1)['pubkey'])
|
||||
import_res = w2.importdescriptors([{"desc": w0.getaddressinfo(address1)['desc'], "timestamp": "now"}])
|
||||
assert_equal(import_res[0]["success"], True)
|
||||
|
||||
self.log.info("Test blank creation with private keys enabled.")
|
||||
self.nodes[0].createwallet(wallet_name='w3', disable_private_keys=False, blank=True)
|
||||
|
|
|
@ -190,9 +190,9 @@ class RawTransactionsTest(BitcoinTestFramework):
|
|||
self.nodes[3].createwallet(wallet_name="wwatch", disable_private_keys=True)
|
||||
wwatch = self.nodes[3].get_wallet_rpc('wwatch')
|
||||
watchonly_address = self.nodes[0].getnewaddress()
|
||||
watchonly_pubkey = self.nodes[0].getaddressinfo(watchonly_address)["pubkey"]
|
||||
self.watchonly_amount = Decimal(200)
|
||||
wwatch.importpubkey(watchonly_pubkey, label="", rescan=True)
|
||||
import_res = wwatch.importdescriptors([{"desc": self.nodes[0].getaddressinfo(watchonly_address)["desc"], "timestamp": "now"}])
|
||||
assert_equal(import_res[0]["success"], True)
|
||||
self.watchonly_utxo = self.create_outpoints(self.nodes[0], outputs=[{watchonly_address: self.watchonly_amount}])[0]
|
||||
|
||||
# Lock UTXO so nodes[0] doesn't accidentally spend it
|
||||
|
|
|
@ -34,7 +34,6 @@ class WalletLabelsTest(BitcoinTestFramework):
|
|||
[node.getnewaddress],
|
||||
[node.setlabel, address],
|
||||
[node.getaddressesbylabel],
|
||||
[node.importpubkey, pubkey],
|
||||
[node.getreceivedbylabel],
|
||||
[node.listsinceblock, node.getblockhash(0), 1, False, True, False],
|
||||
]
|
||||
|
|
|
@ -45,7 +45,8 @@ class SimulateTxTest(BitcoinTestFramework):
|
|||
address2 = w1.getnewaddress()
|
||||
|
||||
# Add address1 as watch-only to w2
|
||||
w2.importpubkey(pubkey=w1.getaddressinfo(address1)["pubkey"])
|
||||
import_res = w2.importdescriptors([{"desc": w1.getaddressinfo(address1)["desc"], "timestamp": "now"}])
|
||||
assert_equal(import_res[0]["success"], True)
|
||||
|
||||
tx1 = node.createrawtransaction([], [{address1: 5.0}])
|
||||
tx2 = node.createrawtransaction([], [{address2: 10.0}])
|
||||
|
|
Loading…
Reference in New Issue