mirror of
https://github.com/cryptoadvance/specter-desktop.git
synced 2026-08-13 12:33:29 +02:00
rpc update also updates available wallets
This commit is contained in:
parent
f1445d7eaf
commit
d413cd4259
2 changed files with 11 additions and 13 deletions
2
rpc.py
2
rpc.py
|
|
@ -86,7 +86,6 @@ def get_configs(config=None):
|
|||
for cookie in config["cookies"]:
|
||||
o = {}
|
||||
o.update(default)
|
||||
print(cookie)
|
||||
o.update(cookie)
|
||||
confs.append(o)
|
||||
return confs
|
||||
|
|
@ -97,7 +96,6 @@ def detect_cli(config=None):
|
|||
rpcconfs = get_configs(config)
|
||||
cli_arr = []
|
||||
for conf in rpcconfs:
|
||||
print(conf)
|
||||
cli_arr.append(BitcoinCLI(**conf))
|
||||
return cli_arr
|
||||
|
||||
|
|
|
|||
22
specter.py
22
specter.py
|
|
@ -33,6 +33,7 @@ def alias(name):
|
|||
return "".join(x for x in name if x.isalnum() or x=="_").lower()
|
||||
|
||||
def get_cli(conf):
|
||||
print(conf)
|
||||
if "user" not in conf or conf["user"]=="":
|
||||
conf["autodetect"] = True
|
||||
if conf["autodetect"]:
|
||||
|
|
@ -67,7 +68,7 @@ class Specter:
|
|||
"autodetect": True,
|
||||
"user": "",
|
||||
"password": "",
|
||||
"port": RPC_PORTS["main"],
|
||||
"port": "",
|
||||
"host": "localhost", # localhost
|
||||
"protocol": "http" # https for the future
|
||||
},
|
||||
|
|
@ -78,7 +79,7 @@ class Specter:
|
|||
if not os.path.isdir(data_folder):
|
||||
os.mkdir(data_folder)
|
||||
|
||||
self._info = { "chain": None, "last_chain": None }
|
||||
self._info = { "chain": None }
|
||||
# health check: loads config and tests rpc
|
||||
self.check()
|
||||
|
||||
|
|
@ -94,7 +95,7 @@ class Specter:
|
|||
deep_update(self.config, self.arg_config) # override loaded config
|
||||
|
||||
self.cli = get_cli(self.config["rpc"])
|
||||
print(self.cli)
|
||||
print("CLI: ", self.cli)
|
||||
self._is_configured = (self.cli is not None)
|
||||
self._is_running = False
|
||||
if self._is_configured:
|
||||
|
|
@ -102,19 +103,17 @@ class Specter:
|
|||
self._info = self.cli.getmininginfo()
|
||||
self._is_running = True
|
||||
except:
|
||||
# last_chain is used to manage wallets when can't reach bitcoin-cli
|
||||
last_chain = self._info["chain"]
|
||||
if "last_chain" in self._info and last_chain is None:
|
||||
last_chain = self.info["last_chain"]
|
||||
self._info = { "chain": None, "last_chain": last_chain }
|
||||
pass
|
||||
|
||||
if not self._is_running:
|
||||
self._info["chain"] = None
|
||||
|
||||
chain = self._info["chain"]
|
||||
if chain is None:
|
||||
chain = self._info["last_chain"]
|
||||
if self.wallets is None:
|
||||
if self.wallets is None or chain is None:
|
||||
self.wallets = WalletManager(os.path.join(self.data_folder, "wallets"), self.cli, chain=chain)
|
||||
else:
|
||||
self.wallets.update(os.path.join(self.data_folder, "wallets"), self.cli, chain=chain)
|
||||
|
||||
if self.devices is None:
|
||||
self.devices = DeviceManager(os.path.join(self.data_folder, "devices"))
|
||||
else:
|
||||
|
|
@ -147,6 +146,7 @@ class Specter:
|
|||
return r
|
||||
|
||||
def update_rpc(self, **kwargs):
|
||||
print(kwargs)
|
||||
need_update = False
|
||||
for k in kwargs:
|
||||
if self.config["rpc"][k] != kwargs[k]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue