add wallet restart API
This commit is contained in:
parent
af7c20e440
commit
0bf1be6198
3 changed files with 33 additions and 1 deletions
|
@ -1096,6 +1096,19 @@ class Daemon(metaclass=JSONRPCServerType):
|
|||
return paginate_list([self.wallet_manager.get_wallet_or_error(wallet_id)], 1, 1)
|
||||
return paginate_list(self.wallet_manager.wallets, page, page_size)
|
||||
|
||||
def jsonrpc_wallet_restart(self):
|
||||
"""
|
||||
Restarts ledger, applying new configurations.
|
||||
|
||||
Usage:
|
||||
wallet_restart
|
||||
|
||||
Options:
|
||||
|
||||
Returns: None
|
||||
"""
|
||||
return self.wallet_manager.reset()
|
||||
|
||||
@requires("wallet")
|
||||
async def jsonrpc_wallet_create(
|
||||
self, wallet_id, skip_on_startup=False, create_account=False, single_key=False):
|
||||
|
|
|
@ -145,6 +145,21 @@ class LbryWalletManager(BaseWalletManager):
|
|||
await ledger.db.close()
|
||||
return manager
|
||||
|
||||
async def reset(self):
|
||||
ledger_id = {
|
||||
'lbrycrd_main': 'lbc_mainnet',
|
||||
'lbrycrd_testnet': 'lbc_testnet',
|
||||
'lbrycrd_regtest': 'lbc_regtest'
|
||||
}[self.config.blockchain_name]
|
||||
ledger = self.get_or_create_ledger(ledger_id)
|
||||
ledger.config = {
|
||||
'auto_connect': True,
|
||||
'default_servers': self.config.lbryum_servers,
|
||||
'data_path': self.config.wallet_dir,
|
||||
}
|
||||
await self.ledger.stop()
|
||||
await self.ledger.start()
|
||||
|
||||
async def _migrate_addresses(self, receiving_addresses: set, change_addresses: set):
|
||||
async with self.default_account.receiving.address_generator_lock:
|
||||
migrated_receiving = set(await self.default_account.receiving._generate_keys(0, len(receiving_addresses)))
|
||||
|
|
|
@ -142,7 +142,7 @@ class BaseNetwork:
|
|||
PROTOCOL_VERSION = '1.2'
|
||||
|
||||
def __init__(self, ledger):
|
||||
self.config = ledger.config
|
||||
self.ledger = ledger
|
||||
self.session_pool = SessionPool(network=self, timeout=self.config.get('connect_timeout', 6))
|
||||
self.client: Optional[ClientSession] = None
|
||||
self._switch_task: Optional[asyncio.Task] = None
|
||||
|
@ -164,6 +164,10 @@ class BaseNetwork:
|
|||
'blockchain.address.subscribe': self._on_status_controller,
|
||||
}
|
||||
|
||||
@property
|
||||
def config(self):
|
||||
return self.ledger.config
|
||||
|
||||
async def switch_forever(self):
|
||||
while self.running:
|
||||
if self.is_connected:
|
||||
|
|
Loading…
Reference in a new issue