From 7f858222c479d6a91697ececc8839b3c08d7bed1 Mon Sep 17 00:00:00 2001 From: Kristaps Kaupe Date: Mon, 19 Apr 2021 17:45:10 +0300 Subject: [PATCH] Try load RPC wallet on start-up if it's not loaded --- jmclient/jmclient/jsonrpc.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/jmclient/jmclient/jsonrpc.py b/jmclient/jmclient/jsonrpc.py index 436f1dc..127d43b 100644 --- a/jmclient/jmclient/jsonrpc.py +++ b/jmclient/jmclient/jsonrpc.py @@ -54,17 +54,22 @@ class JsonRpc(object): to connect to Bitcoin. """ - def __init__(self, host, port, user, password, wallet_file=""): + def __init__(self, host, port, user, password, wallet_name=""): self.host = host self.port = int(port) self.conn = http.client.HTTPConnection(self.host, self.port) self.authstr = "%s:%s" % (user, password) - if len(wallet_file) > 0: - self.url = "/wallet/" + wallet_file + if len(wallet_name) > 0: + self.url = "/wallet/" + wallet_name else: self.url = "" self.queryId = 1 + # Check that RPC wallet is loaded. If not, try to load it. + loaded_wallets = self.call("listwallets", []) + if not wallet_name in loaded_wallets: + self.call("loadwallet", [wallet_name]) + def queryHTTP(self, obj): """ Send an appropriate HTTP query to the server. The JSON-RPC