Browse Source

mmgen-{txcreate,txdo}: help screen fixes, add EXAMPLES section

The MMGen Project 2 years ago
parent
commit
f3fb91e2a7
3 changed files with 62 additions and 23 deletions
  1. 43 12
      mmgen/help.py
  2. 6 4
      mmgen/main_txcreate.py
  3. 13 7
      mmgen/main_txdo.py

+ 43 - 12
mmgen/help.py

@@ -113,10 +113,11 @@ def help_notes_func(proto,opt,k):
 		def fee():
 			from .tx import BaseTX
 			return """
-FEE SPECIFICATION: Transaction fees, both on the command line and at the
-interactive prompt, may be specified as either absolute {c} amounts, using
-a plain decimal number, or as {r}, using an integer followed by
-'{l}', for {u}.
+                               FEE SPECIFICATION
+
+Transaction fees, both on the command line and at the interactive prompt, may
+be specified as either absolute {c} amounts, using a plain decimal number, or
+as {r}, using an integer followed by '{l}', for {u}.
 """.format(
 	c = proto.coin,
 	r = BaseTX(proto=proto).rel_fee_desc,
@@ -141,24 +142,54 @@ with brainwallets.  For a brainwallet passphrase to generate the correct
 seed, the same seed length and hash preset parameters must always be used.
 """.strip()
 
+		def txcreate_examples():
+
+			mmtype = 'S' if 'segwit' in proto.caps else 'C'
+			from .tool.coin import tool_cmd
+			t = tool_cmd(mmtype=mmtype)
+			sample_addr = t.privhex2addr('bead'*16)
+
+			return f"""
+EXAMPLES:
+
+  Send 0.123 {proto.coin} to an external {proto.name} address, returning the change to a
+  specific MMGen address in the tracking wallet:
+
+    $ {g.prog_name} {sample_addr},0.123 01ABCDEF:{mmtype}:7
+
+  Same as above, but reduce verbosity and specify fee of 20 satoshis
+  per byte:
+
+    $ {g.prog_name} -q -f 20s {sample_addr},0.123 01ABCDEF:{mmtype}:7
+
+  Send entire balance of selected inputs minus fee to an external {proto.name}
+  address:
+
+    $ {g.prog_name} {sample_addr}
+"""
+
 		def txcreate():
 			return f"""
-The transaction's outputs are specified on the command line, while its inputs
-are chosen from a list of the user's unspent outputs via an interactive menu.
+The transaction’s outputs are listed on the command line, while its inputs
+are chosen from a list of the wallet’s unspent outputs via an interactive
+menu.  Alternatively, inputs may be specified using the --inputs option.
+
+All addresses on the command line can be either {proto.name} addresses or MMGen
+IDs in the form <seed ID>:<address type letter>:<index>.
+
+Outputs are specified in the form <address>,<amount>, with the change output
+specified by address only.
 
 If the transaction fee is not specified on the command line (see FEE
 SPECIFICATION below), it will be calculated dynamically using network fee
 estimation for the default (or user-specified) number of confirmations.
 If network fee estimation fails, the user will be prompted for a fee.
 
-Network-estimated fees will be multiplied by the value of '--tx-fee-adj',
-if specified.
-
-All addresses on the command line can be either {proto.name} addresses or {g.proj_name}
-addresses of the form <seed ID>:<index>.
+Network-estimated fees will be multiplied by the value of --tx-fee-adj, if
+specified.
 
 To send the value of all inputs (minus TX fee) to a single output, specify
-one address with no amount on the command line.
+a single address with no amount on the command line.
 """
 
 		def txsign():

+ 6 - 4
mmgen/main_txcreate.py

@@ -34,7 +34,8 @@ opts_data = {
 -a, --tx-fee-adj=  f  Adjust transaction fee by factor 'f' (see below)
 -B, --no-blank        Don't blank screen before displaying unspent outputs
 -c, --comment-file=f  Source the transaction's comment from file 'f'
--C, --tx-confs=    c  Desired number of confirmations (default: {g.tx_confs})
+-C, --tx-confs=    c  Desired number of confirmations for fee estimation
+                      (default: {g.tx_confs})
 -d, --outdir=      d  Specify an alternate directory 'd' for output
 -D, --contract-data=D Path to hex-encoded contract data (ETH only)
 -E, --fee-estimate-mode=M Specify the network fee estimate mode.  Choices:
@@ -58,7 +59,7 @@ opts_data = {
 -y, --yes             Answer 'yes' to prompts, suppress non-essential output
 -X, --cached-balances Use cached balances (Ethereum only)
 """,
-		'notes': '\n{}{}',
+		'notes': '\n{c}\n{F}\n{x}',
 	},
 	'code': {
 		'options': lambda proto,help_notes,s: s.format(
@@ -69,8 +70,9 @@ opts_data = {
 			cu=proto.coin,
 			g=g),
 		'notes': lambda help_notes,s: s.format(
-			help_notes('txcreate'),
-			help_notes('fee'))
+			c = help_notes('txcreate'),
+			F = help_notes('fee'),
+			x = help_notes('txcreate_examples') )
 	}
 }
 

+ 13 - 7
mmgen/main_txdo.py

@@ -37,7 +37,8 @@ opts_data = {
                        brainwallet input
 -B, --no-blank         Don't blank screen before displaying unspent outputs
 -c, --comment-file=  f Source the transaction's comment from file 'f'
--C, --tx-confs=      c Desired number of confirmations (default: {g.tx_confs})
+-C, --tx-confs=      c Desired number of confirmations for fee estimation
+                       (default: {g.tx_confs})
 -d, --outdir=        d Specify an alternate directory 'd' for output
 -D, --contract-data= D Path to hex-encoded contract data (ETH only)
 -e, --echo-passphrase  Print passphrase to screen when typing it
@@ -84,14 +85,18 @@ opts_data = {
 -z, --show-hash-presets Show information on available hash presets
 """,
 	'notes': """
-{}{}{}
+{c}\n{F}
+
+                                 SIGNING NOTES
+{s}
 Seed source files must have the canonical extensions listed in the 'FileExt'
 column below:
 
 FMT CODES:
 
   {f}
-"""
+
+{x}"""
 	},
 	'code': {
 		'options': lambda proto,help_notes,s: s.format(
@@ -107,10 +112,11 @@ FMT CODES:
 			dsl=help_notes('dfl_seed_len'),
 			cu=proto.coin),
 		'notes': lambda help_notes,s: s.format(
-			help_notes('txcreate'),
-			help_notes('fee'),
-			help_notes('txsign'),
-			f=help_notes('fmt_codes')),
+			c = help_notes('txcreate'),
+			F = help_notes('fee'),
+			s = help_notes('txsign'),
+			f = help_notes('fmt_codes'),
+			x = help_notes('txcreate_examples') ),
 	}
 }