proto.btc.rpc: add tracking_wallet_exists property
This commit is contained in:
parent
a67f991b03
commit
77d313e2e7
3 changed files with 9 additions and 3 deletions
|
|
@ -24,7 +24,6 @@ class bitcoin_core_daemon(CoinDaemon):
|
|||
cli_fn = 'bitcoin-cli'
|
||||
testnet_dir = 'testnet3'
|
||||
cfg_file_hdr = '# Bitcoin Core config file\n'
|
||||
tracking_wallet_name = 'mmgen-tracking-wallet'
|
||||
rpc_ports = _nw(8332, 18332, 18443)
|
||||
cfg_file = 'bitcoin.conf'
|
||||
nonstd_datadir = False
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ class BitcoinRPCClient(RPCClient,metaclass=AsyncInit):
|
|||
auth_type = 'basic'
|
||||
has_auth_cookie = True
|
||||
wallet_path = '/'
|
||||
twname = 'mmgen-tracking-wallet'
|
||||
|
||||
async def __init__(
|
||||
self,
|
||||
|
|
@ -216,6 +217,12 @@ class BitcoinRPCClient(RPCClient,metaclass=AsyncInit):
|
|||
def make_host_path(self,wallet):
|
||||
return f'/wallet/{wallet}' if wallet else self.wallet_path
|
||||
|
||||
@property
|
||||
async def tracking_wallet_exists(self):
|
||||
twname = self.cfg.regtest_user or self.twname
|
||||
wnames = [i['name'] for i in (await self.call('listwalletdir'))['wallets']]
|
||||
return twname in wnames
|
||||
|
||||
async def check_or_create_daemon_wallet(self,called=[],wallet_create=True):
|
||||
"""
|
||||
Returns True if the correct tracking wallet is currently loaded or if a new one
|
||||
|
|
@ -225,7 +232,7 @@ class BitcoinRPCClient(RPCClient,metaclass=AsyncInit):
|
|||
if called or (self.chain == 'regtest' and self.cfg.regtest_user != 'carol'):
|
||||
return False
|
||||
|
||||
twname = self.daemon.tracking_wallet_name
|
||||
twname = self.twname
|
||||
loaded_wnames = await self.call('listwallets')
|
||||
wnames = [i['name'] for i in (await self.call('listwalletdir'))['wallets']]
|
||||
m = f'Please fix your {self.daemon.desc} wallet installation or cmdline options'
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class BitcoinTwJSON(TwJSON):
|
|||
|
||||
@property
|
||||
async def tracking_wallet_exists(self):
|
||||
return await self.twctl.rpc.check_or_create_daemon_wallet(wallet_create=False)
|
||||
return await self.twctl.rpc.tracking_wallet_exists
|
||||
|
||||
async def create_tracking_wallet(self):
|
||||
return await self.twctl.rpc.check_or_create_daemon_wallet(wallet_create=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue