CoinProtocol: remove 'daemon_name' attr

This commit is contained in:
The MMGen Project 2020-06-13 10:21:01 +00:00
commit b27da5d90e
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
8 changed files with 23 additions and 19 deletions

View file

@ -32,8 +32,17 @@ def help_notes_func(proto,k):
cu = proto.coin_amt.units
return ', '.join(cu[:-1]) + ('',' and ')[len(cu)>1] + cu[-1] + ('',',\nrespectively')[len(cu)>1]
def coind_exec():
from .daemon import CoinDaemon
return (
CoinDaemon(proto.coin).coind_exec if proto.coin.lower() in CoinDaemon.daemon_ids else
'bitcoind' )
class help_notes:
def coind_exec():
return coind_exec()
def rel_fee_desc():
from .tx import MMGenTX
return MMGenTX.Base().rel_fee_desc
@ -96,10 +105,11 @@ one address with no amount on the command line.
"""
def txsign():
from .protocol import CoinProtocol
return """
Transactions may contain both {pnm} or non-{pnm} input addresses.
To sign non-{pnm} inputs, a {dn} wallet dump or flat key list is used
To sign non-{pnm} inputs, a {wd}flat key list is used
as the key source ('--keys-from-file' option).
To sign {pnm} inputs, key data is generated from a seed as with the
@ -117,7 +127,7 @@ source. Therefore, seed files or a key-address file for all {pnm} outputs
must also be supplied on the command line if the data can't be found in the
default wallet.
""".format(
dn = proto.daemon_name,
wd = (f'{coind_exec()} wallet dump or ' if isinstance(proto,CoinProtocol.Bitcoin) else ''),
pnm = g.proj_name,
pnu = proto.name,
pnl = g.proj_name.lower() )

View file

@ -64,7 +64,7 @@ opts_data = {
-O, --old-incog-fmt Specify old-format incognito input
-p, --hash-preset= p Use the scrypt hash parameters defined by preset 'p'
for password hashing (default: '{g.dfl_hash_preset}')
-P, --passwd-file= f Get {pnm} wallet or {dn} passphrase from file 'f'
-P, --passwd-file= f Get {pnm} wallet passphrase from file 'f'
-q, --quiet Suppress warnings; overwrite files without prompting
-s, --send Sign and send the transaction (the default if seed
data is provided)
@ -85,8 +85,8 @@ column below:
g=g,
pnm=g.proj_name,
pnl=g.proj_name.lower(),
dn=proto.daemon_name,
fu=help_notes('rel_fee_desc'),fl=help_notes('fee_spec_letters'),
fu=help_notes('rel_fee_desc'),
fl=help_notes('fee_spec_letters'),
kgs=' '.join(['{}:{}'.format(n,k) for n,k in enumerate(g.key_generators,1)]),
kg=g.key_generator,
cu=proto.coin),

View file

@ -57,7 +57,7 @@ opts_data = {
online signing without an {pnm} seed source. The
key-address file is also used to verify {pnm}-to-{cu}
mappings, so the user should record its checksum.
-P, --passwd-file= f Get {pnm} wallet or {dn} passphrase from file 'f'
-P, --passwd-file= f Get {pnm} wallet passphrase from file 'f'
-q, --quiet Suppress warnings; overwrite files without prompting
-I, --info Display information about the transaction and exit
-t, --terse-info Like '--info', but produce more concise output
@ -81,7 +81,6 @@ column below:
g=g,
pnm=g.proj_name,
pnl=g.proj_name.lower(),
dn=proto.daemon_name,
kgs=' '.join(['{}:{}'.format(n,k) for n,k in enumerate(g.key_generators,1)]),
kg=g.key_generator,
ss=g.subseeds,

View file

@ -214,9 +214,9 @@ common_opts_data = {
--, --bob Switch to user "Bob" in MMGen regtest setup
--, --alice Switch to user "Alice" in MMGen regtest setup
""",
'code': lambda proto,s: s.format(
'code': lambda help_notes,proto,s: s.format(
pnm = g.proj_name,
dn = proto.daemon_name,
dn = help_notes('coind_exec'),
cu_dfl = proto.coin,
)
}

View file

@ -84,6 +84,7 @@ class CoinProtocol(MMGenObject):
core_coins = tuple(coins.keys()) # coins may be added by init_genonly_altcoins(), so save
class Base(MMGenObject):
base_proto = None
is_fork_of = None
networks = ('mainnet','testnet','regtest')
@ -201,7 +202,6 @@ class CoinProtocol(MMGenObject):
All Bitcoin code and chain forks inherit from this class
"""
mod_clsname = 'Bitcoin'
daemon_name = 'bitcoind'
daemon_family = 'bitcoind'
addr_ver_bytes = { '00': 'p2pkh', '05': 'p2sh' }
addr_len = 20
@ -303,7 +303,6 @@ class CoinProtocol(MMGenObject):
class BitcoinCash(Bitcoin):
is_fork_of = 'Bitcoin'
# TODO: assumes MSWin user installs in custom dir 'Bitcoin_ABC'
daemon_name = 'bitcoind-abc'
mmtypes = ('L','C')
sighash_type = 'ALL|FORKID'
forks = [
@ -325,7 +324,6 @@ class CoinProtocol(MMGenObject):
class B2X(Bitcoin):
is_fork_of = 'Bitcoin'
daemon_name = 'bitcoind-2x'
coin_amt = B2XAmt
max_tx_fee = B2XAmt('0.1')
forks = [
@ -338,7 +336,6 @@ class CoinProtocol(MMGenObject):
class Litecoin(Bitcoin):
block0 = '12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2'
daemon_name = 'litecoind'
addr_ver_bytes = { '30': 'p2pkh', '32': 'p2sh', '05': 'p2sh' } # new p2sh ver 0x32 must come first
wif_ver_num = { 'std': 'b0' }
mmtypes = ('L','C','S','B')
@ -378,7 +375,6 @@ class CoinProtocol(MMGenObject):
base_coin = 'ETH'
pubkey_type = 'std' # required by DummyWIF
daemon_name = 'parity'
daemon_family = 'parity'
coin_amt = ETHAmt
max_tx_fee = ETHAmt('0.005')

View file

@ -159,7 +159,7 @@ class MMGenRegtest(MMGenObject):
msg(err)
def current_user_unix(self,quiet=False):
cmd = ['pgrep','-af','{}.*--rpcport={}.*'.format(self.proto.daemon_name,self.d.rpc_port)]
cmd = ['pgrep','-af','{}.*--rpcport={}.*'.format(self.d.coind_exec,self.d.rpc_port)]
cmdout = run(cmd,stdout=PIPE).stdout.decode()
if cmdout:
for k in self.users:

View file

@ -1203,7 +1203,7 @@ class MMGenTX:
self.check_pubkey_scripts()
qmsg(f'Passing {len(keys)} key{suf(keys)} to {self.proto.daemon_name}')
qmsg(f'Passing {len(keys)} key{suf(keys)} to {self.rpc.daemon.coind_exec}')
if self.has_segwit_inputs():
from .addr import KeyGenerator,AddrGenerator

View file

@ -78,7 +78,7 @@ EXAMPLES:
Test speed of mmgen-secp256k1 address generation, 10,000 rounds:
$ {prog} 2 10000
Compare mmgen-secp256k1-generated bech32 addrs to {dn} wallet dump:
Compare mmgen-secp256k1-generated bech32 addrs to coin daemon wallet dump:
$ {prog} --type=bech32 2 bech32wallet.dump
Supported external tools:
@ -105,8 +105,7 @@ Supported external tools:
'notes': lambda s: s.format(
prog='test/gentest.py',
pnm=g.proj_name,
snum=rounds,
dn=proto.daemon_name)
snum=rounds )
}
}