mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 10:28:10 +01:00
prepare: reuse Particl daemon when adding coins.
This commit is contained in:
@@ -1768,7 +1768,7 @@ def finalise_daemon(d):
|
|||||||
fp.close()
|
fp.close()
|
||||||
|
|
||||||
|
|
||||||
def test_particl_encryption(data_dir, settings, chain, use_tor_proxy):
|
def test_particl_encryption(data_dir, settings, chain, use_tor_proxy, extra_opts):
|
||||||
swap_client = None
|
swap_client = None
|
||||||
daemons = []
|
daemons = []
|
||||||
daemon_args = ["-noconnect", "-nodnsseed", "-nofindpeers", "-nostaking"]
|
daemon_args = ["-noconnect", "-nodnsseed", "-nofindpeers", "-nostaking"]
|
||||||
@@ -1805,10 +1805,12 @@ def test_particl_encryption(data_dir, settings, chain, use_tor_proxy):
|
|||||||
"Must set WALLET_ENCRYPTION_PWD to add coin when Particl wallet is encrypted"
|
"Must set WALLET_ENCRYPTION_PWD to add coin when Particl wallet is encrypted"
|
||||||
)
|
)
|
||||||
swap_client.ci(c).unlockWallet(WALLET_ENCRYPTION_PWD)
|
swap_client.ci(c).unlockWallet(WALLET_ENCRYPTION_PWD)
|
||||||
|
extra_opts["particl_daemon"] = daemons[-1]
|
||||||
finally:
|
finally:
|
||||||
if swap_client:
|
if swap_client:
|
||||||
swap_client.finalise()
|
swap_client.finalise()
|
||||||
del swap_client
|
del swap_client
|
||||||
|
if "particl_daemon" not in extra_opts:
|
||||||
for d in daemons:
|
for d in daemons:
|
||||||
finalise_daemon(d)
|
finalise_daemon(d)
|
||||||
|
|
||||||
@@ -1904,6 +1906,11 @@ def initialise_wallets(
|
|||||||
]
|
]
|
||||||
|
|
||||||
extra_config = {"stdout_to_file": True, "coin_name": coin_name}
|
extra_config = {"stdout_to_file": True, "coin_name": coin_name}
|
||||||
|
|
||||||
|
if c == Coins.PART and "particl_daemon" in extra_opts:
|
||||||
|
daemons.append(extra_opts["particl_daemon"])
|
||||||
|
del extra_opts["particl_daemon"]
|
||||||
|
else:
|
||||||
daemons.append(
|
daemons.append(
|
||||||
startDaemon(
|
startDaemon(
|
||||||
coin_settings["datadir"],
|
coin_settings["datadir"],
|
||||||
@@ -2973,14 +2980,20 @@ def main():
|
|||||||
"tor_control_password", None
|
"tor_control_password", None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
if particl_wallet_mnemonic != "none":
|
if particl_wallet_mnemonic != "none":
|
||||||
# Ensure Particl wallet is unencrypted or correct password is supplied
|
# Ensure Particl wallet is unencrypted or correct password is supplied
|
||||||
test_particl_encryption(data_dir, settings, chain, use_tor_proxy)
|
# Keep daemon running to use in initialise_wallets
|
||||||
|
test_particl_encryption(
|
||||||
|
data_dir, settings, chain, use_tor_proxy, extra_opts
|
||||||
|
)
|
||||||
|
|
||||||
settings["chainclients"][add_coin] = chainclients[add_coin]
|
settings["chainclients"][add_coin] = chainclients[add_coin]
|
||||||
|
|
||||||
if not no_cores:
|
if not no_cores:
|
||||||
prepareCore(add_coin, known_coins[add_coin], settings, data_dir, extra_opts)
|
prepareCore(
|
||||||
|
add_coin, known_coins[add_coin], settings, data_dir, extra_opts
|
||||||
|
)
|
||||||
|
|
||||||
if not (prepare_bin_only or upgrade_cores):
|
if not (prepare_bin_only or upgrade_cores):
|
||||||
prepareDataDir(
|
prepareDataDir(
|
||||||
@@ -3001,6 +3014,10 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
save_config(config_path, settings)
|
save_config(config_path, settings)
|
||||||
|
finally:
|
||||||
|
if "particl_daemon" in extra_opts:
|
||||||
|
finalise_daemon(extra_opts["particl_daemon"])
|
||||||
|
del extra_opts["particl_daemon"]
|
||||||
|
|
||||||
logger.info(f"Done. Coin {add_coin} successfully added.")
|
logger.info(f"Done. Coin {add_coin} successfully added.")
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user