mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-06 02:38:11 +01:00
prepare: Set changetype=bech32 in BTC and LTC .conf files.
Rewrite .conf files to add changetype at startup if possible. Add combine_non_segwit_prevouts function to coin interface. Add option to list non-segwit UTXOs and combine_non_segwit_prevouts to gui. Add test for changetype and combine_non_segwit_prevouts.
This commit is contained in:
@@ -1315,7 +1315,7 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}):
|
||||
)
|
||||
wallet_conf_path = os.path.join(data_dir, wallet_conf_filename)
|
||||
if os.path.exists(wallet_conf_path):
|
||||
exitWithError("{} exists".format(wallet_conf_path))
|
||||
exitWithError(f"{wallet_conf_path} exists")
|
||||
with open(wallet_conf_path, "w") as fp:
|
||||
if chain != "mainnet":
|
||||
fp.write(chainname + "=1\n")
|
||||
@@ -1342,7 +1342,7 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}):
|
||||
core_conf_name: str = core_settings.get("config_filename", coin + ".conf")
|
||||
core_conf_path = os.path.join(data_dir, core_conf_name)
|
||||
if os.path.exists(core_conf_path):
|
||||
exitWithError("{} exists".format(core_conf_path))
|
||||
exitWithError(f"{core_conf_path} exists")
|
||||
with open(core_conf_path, "w") as fp:
|
||||
if chain != "mainnet":
|
||||
if coin in ("navcoin",):
|
||||
@@ -1393,6 +1393,7 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}):
|
||||
)
|
||||
elif coin == "litecoin":
|
||||
fp.write("prune=4000\n")
|
||||
fp.write("changetype=bech32\n")
|
||||
if LTC_RPC_USER != "":
|
||||
fp.write(
|
||||
"rpcauth={}:{}${}\n".format(
|
||||
@@ -1410,6 +1411,7 @@ def prepareDataDir(coin, settings, chain, particl_mnemonic, extra_opts={}):
|
||||
elif coin == "bitcoin":
|
||||
fp.write("deprecatedrpc=create_bdb\n")
|
||||
fp.write("prune=2000\n")
|
||||
fp.write("changetype=bech32\n")
|
||||
fp.write("fallbackfee=0.0002\n")
|
||||
if BTC_RPC_USER != "":
|
||||
fp.write(
|
||||
@@ -1784,7 +1786,7 @@ def test_particl_encryption(data_dir, settings, chain, use_tor_proxy):
|
||||
coin_name = "particl"
|
||||
coin_settings = settings["chainclients"][coin_name]
|
||||
daemon_args += getCoreBinArgs(c, coin_settings, prepare=True)
|
||||
extra_config = {"stdout_to_file": True}
|
||||
extra_config = {"stdout_to_file": True, "coin_name": coin_name}
|
||||
if coin_settings["manage_daemon"]:
|
||||
filename: str = getCoreBinName(c, coin_settings, coin_name + "d")
|
||||
daemons.append(
|
||||
@@ -1906,7 +1908,7 @@ def initialise_wallets(
|
||||
)
|
||||
]
|
||||
|
||||
extra_config = {"stdout_to_file": True}
|
||||
extra_config = {"stdout_to_file": True, "coin_name": coin_name}
|
||||
daemons.append(
|
||||
startDaemon(
|
||||
coin_settings["datadir"],
|
||||
|
||||
@@ -59,15 +59,20 @@ def signal_handler(sig, frame):
|
||||
def startDaemon(node_dir, bin_dir, daemon_bin, opts=[], extra_config={}):
|
||||
daemon_bin = os.path.expanduser(os.path.join(bin_dir, daemon_bin))
|
||||
datadir_path = os.path.expanduser(node_dir)
|
||||
coin_name = extra_config.get("coin_name", "")
|
||||
|
||||
# Rewrite litecoin.conf
|
||||
# TODO: Remove
|
||||
needs_rewrite: bool = False
|
||||
ltc_conf_path = os.path.join(datadir_path, "litecoin.conf")
|
||||
if os.path.exists(ltc_conf_path):
|
||||
needs_rewrite: bool = False
|
||||
add_changetype: bool = True
|
||||
with open(ltc_conf_path) as fp:
|
||||
for line in fp:
|
||||
line = line.strip()
|
||||
if line.startswith("changetype="):
|
||||
add_changetype = False
|
||||
break
|
||||
if line.endswith("=onion"):
|
||||
needs_rewrite = True
|
||||
break
|
||||
@@ -83,6 +88,29 @@ def startDaemon(node_dir, bin_dir, daemon_bin, opts=[], extra_config={}):
|
||||
fp_to.write(line.strip()[:-6] + "\n")
|
||||
else:
|
||||
fp_to.write(line)
|
||||
if add_changetype:
|
||||
fp_to.write("changetype=bech32\n")
|
||||
add_changetype = False
|
||||
if add_changetype:
|
||||
logger.info("Adding changetype to litecoin.conf")
|
||||
with open(ltc_conf_path, "a") as fp:
|
||||
fp.write("changetype=bech32\n")
|
||||
|
||||
# Rewrite bitcoin.conf
|
||||
# TODO: Remove
|
||||
btc_conf_path = os.path.join(datadir_path, "bitcoin.conf")
|
||||
if coin_name == "bitcoin" and os.path.exists(btc_conf_path):
|
||||
add_changetype: bool = True
|
||||
with open(btc_conf_path) as fp:
|
||||
for line in fp:
|
||||
line = line.strip()
|
||||
if line.startswith("changetype="):
|
||||
add_changetype = False
|
||||
break
|
||||
if add_changetype:
|
||||
logger.info("Adding changetype to bitcoin.conf")
|
||||
with open(btc_conf_path, "a") as fp:
|
||||
fp.write("changetype=bech32\n")
|
||||
|
||||
args = [
|
||||
daemon_bin,
|
||||
@@ -474,6 +502,7 @@ def runClient(
|
||||
"stdout_to_file": True,
|
||||
"stdout_filename": "dcrd_stdout.log",
|
||||
"use_shell": use_shell,
|
||||
"coin_name": "decred",
|
||||
}
|
||||
daemons.append(
|
||||
startDaemon(
|
||||
@@ -502,6 +531,7 @@ def runClient(
|
||||
"stdout_to_file": True,
|
||||
"stdout_filename": "dcrwallet_stdout.log",
|
||||
"use_shell": use_shell,
|
||||
"coin_name": "decred",
|
||||
}
|
||||
daemons.append(
|
||||
startDaemon(
|
||||
@@ -524,8 +554,15 @@ def runClient(
|
||||
extra_opts = getCoreBinArgs(
|
||||
coin_id, v, use_tor_proxy=swap_client.use_tor_proxy
|
||||
)
|
||||
extra_config = {"coin_name": c}
|
||||
daemons.append(
|
||||
startDaemon(v["datadir"], v["bindir"], filename, opts=extra_opts)
|
||||
startDaemon(
|
||||
v["datadir"],
|
||||
v["bindir"],
|
||||
filename,
|
||||
opts=extra_opts,
|
||||
extra_config=extra_config,
|
||||
)
|
||||
)
|
||||
pid = daemons[-1].handle.pid
|
||||
pids.append((c, pid))
|
||||
|
||||
Reference in New Issue
Block a user