From 886f8e30296e86fccc326eaf8632f945250f8be8 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 15 Mar 2025 18:24:53 +0000 Subject: [PATCH] make --daemon-id a coin-specific cfg file option --- mmgen/cfg.py | 1 + mmgen/daemon.py | 6 +++++- mmgen/data/mmgen.cfg | 4 ++++ mmgen/opts.py | 1 + mmgen/proto/btc/params.py | 1 + mmgen/proto/eth/params.py | 1 + mmgen/protocol.py | 1 + 7 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mmgen/cfg.py b/mmgen/cfg.py index 8f7a6e3f..fa88721b 100755 --- a/mmgen/cfg.py +++ b/mmgen/cfg.py @@ -292,6 +292,7 @@ class Config(Lockable): 'autosign', 'color', 'daemon_data_dir', + 'daemon_id', # also coin-specific 'debug', 'fee_adjust', 'force_256_color', diff --git a/mmgen/daemon.py b/mmgen/daemon.py index 031133ce..9fd6ec0e 100755 --- a/mmgen/daemon.py +++ b/mmgen/daemon.py @@ -367,7 +367,11 @@ class CoinDaemon(Daemon): daemon_ids = cls.get_daemon_ids(cfg, coin) if not daemon_ids: die(1, f'No configured daemons for coin {coin}!') - daemon_id = daemon_id or cfg.daemon_id or daemon_ids[0] + daemon_id = ( + daemon_id + or getattr(cfg, f'{coin.lower()}_daemon_id', None) + or cfg.daemon_id + or daemon_ids[0]) if daemon_id not in daemon_ids: die(1, f'{daemon_id!r}: invalid daemon_id - valid choices: {fmt_list(daemon_ids)}') diff --git a/mmgen/data/mmgen.cfg b/mmgen/data/mmgen.cfg index f6fd2e85..f30dfcfa 100644 --- a/mmgen/data/mmgen.cfg +++ b/mmgen/data/mmgen.cfg @@ -77,6 +77,10 @@ # setups with unusually large Monero wallets: # macos_autosign_ramdisk_size 10 +# Specify the daemon ID. This option also has coin-specific variants (see +# below): +# daemon_id bitcoin_core + # Ignore coin daemon version. This option also has coin-specific variants # (see below): # ignore_daemon_version false diff --git a/mmgen/opts.py b/mmgen/opts.py index 30bf17a7..086361c4 100755 --- a/mmgen/opts.py +++ b/mmgen/opts.py @@ -337,6 +337,7 @@ class UserOpts(Opts): rr For descriptions, refer to the non-prefixed versions of these options above rr Prefixed options override their non-prefixed counterparts rr OPTION SUPPORTED PREFIXES + Rr --PREFIX-daemon-id btc ltc bch eth etc rr --PREFIX-ignore-daemon-version btc ltc bch eth etc xmr br --PREFIX-tw-name btc ltc bch Rr --PREFIX-rpc-host btc ltc bch eth etc diff --git a/mmgen/proto/btc/params.py b/mmgen/proto/btc/params.py index f90bdb4b..02e0dbf0 100755 --- a/mmgen/proto/btc/params.py +++ b/mmgen/proto/btc/params.py @@ -55,6 +55,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp max_op_return_data_len = 80 coin_cfg_opts = ( + 'daemon_id', 'ignore_daemon_version', 'rpc_host', 'rpc_port', diff --git a/mmgen/proto/eth/params.py b/mmgen/proto/eth/params.py index 748a2b98..59c20b18 100755 --- a/mmgen/proto/eth/params.py +++ b/mmgen/proto/eth/params.py @@ -55,6 +55,7 @@ class mainnet(CoinProtocol.DummyWIF, CoinProtocol.Secp256k1): } coin_cfg_opts = ( + 'daemon_id', 'ignore_daemon_version', 'rpc_host', 'rpc_port', diff --git a/mmgen/protocol.py b/mmgen/protocol.py index 067badd9..4b5a4e38 100755 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -212,6 +212,7 @@ class CoinProtocol(MMGenObject): rpc_user = '' rpc_password = '' tw_name = '' + daemon_id = '' @classmethod def get_opt_clsval(cls, cfg, opt):