Browse Source

CoinProtocol: remove 'daemon_name' attr

The MMGen Project 5 years ago
parent
commit
b27da5d90e
8 changed files with 23 additions and 19 deletions
  1. 12 2
      mmgen/help.py
  2. 3 3
      mmgen/main_txbump.py
  3. 1 2
      mmgen/main_txsign.py
  4. 2 2
      mmgen/opts.py
  5. 1 5
      mmgen/protocol.py
  6. 1 1
      mmgen/regtest.py
  7. 1 1
      mmgen/tx.py
  8. 2 3
      test/gentest.py

+ 12 - 2
mmgen/help.py

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

+ 3 - 3
mmgen/main_txbump.py

@@ -64,7 +64,7 @@ opts_data = {
 -O, --old-incog-fmt    Specify old-format incognito input
 -O, --old-incog-fmt    Specify old-format incognito input
 -p, --hash-preset=   p Use the scrypt hash parameters defined by preset 'p'
 -p, --hash-preset=   p Use the scrypt hash parameters defined by preset 'p'
                        for password hashing (default: '{g.dfl_hash_preset}')
                        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
 -q, --quiet            Suppress warnings; overwrite files without prompting
 -s, --send             Sign and send the transaction (the default if seed
 -s, --send             Sign and send the transaction (the default if seed
                        data is provided)
                        data is provided)
@@ -85,8 +85,8 @@ column below:
 			g=g,
 			g=g,
 			pnm=g.proj_name,
 			pnm=g.proj_name,
 			pnl=g.proj_name.lower(),
 			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)]),
 			kgs=' '.join(['{}:{}'.format(n,k) for n,k in enumerate(g.key_generators,1)]),
 			kg=g.key_generator,
 			kg=g.key_generator,
 			cu=proto.coin),
 			cu=proto.coin),

+ 1 - 2
mmgen/main_txsign.py

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

+ 2 - 2
mmgen/opts.py

@@ -214,9 +214,9 @@ common_opts_data = {
 --, --bob                  Switch to user "Bob" in MMGen regtest setup
 --, --bob                  Switch to user "Bob" in MMGen regtest setup
 --, --alice                Switch to user "Alice" 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,
 			pnm    = g.proj_name,
-			dn     = proto.daemon_name,
+			dn     = help_notes('coind_exec'),
 			cu_dfl = proto.coin,
 			cu_dfl = proto.coin,
 		)
 		)
 }
 }

+ 1 - 5
mmgen/protocol.py

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

+ 1 - 1
mmgen/regtest.py

@@ -159,7 +159,7 @@ class MMGenRegtest(MMGenObject):
 					msg(err)
 					msg(err)
 
 
 	def current_user_unix(self,quiet=False):
 	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()
 		cmdout = run(cmd,stdout=PIPE).stdout.decode()
 		if cmdout:
 		if cmdout:
 			for k in self.users:
 			for k in self.users:

+ 1 - 1
mmgen/tx.py

@@ -1203,7 +1203,7 @@ class MMGenTX:
 
 
 			self.check_pubkey_scripts()
 			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():
 			if self.has_segwit_inputs():
 				from .addr import KeyGenerator,AddrGenerator
 				from .addr import KeyGenerator,AddrGenerator

+ 2 - 3
test/gentest.py

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