make --daemon-id a coin-specific cfg file option

This commit is contained in:
The MMGen Project 2025-03-15 18:24:53 +00:00
commit 886f8e3029
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 14 additions and 1 deletions

View file

@ -292,6 +292,7 @@ class Config(Lockable):
'autosign',
'color',
'daemon_data_dir',
'daemon_id', # also coin-specific
'debug',
'fee_adjust',
'force_256_color',

View file

@ -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)}')

View file

@ -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

View file

@ -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

View file

@ -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',

View file

@ -55,6 +55,7 @@ class mainnet(CoinProtocol.DummyWIF, CoinProtocol.Secp256k1):
}
coin_cfg_opts = (
'daemon_id',
'ignore_daemon_version',
'rpc_host',
'rpc_port',

View file

@ -212,6 +212,7 @@ class CoinProtocol(MMGenObject):
rpc_user = ''
rpc_password = ''
tw_name = ''
daemon_id = ''
@classmethod
def get_opt_clsval(cls, cfg, opt):