From c449e4d4d94c0ed8a4a6e4053ce8190bb2c95854 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 27 Apr 2025 11:53:44 +0000 Subject: [PATCH] tx: helpscreen fixes --- mmgen/help/help_notes.py | 48 +++++++++++++++++++---------- mmgen/help/swaptxcreate.py | 6 ++-- mmgen/help/swaptxcreate_examples.py | 4 +++ mmgen/help/txsign.py | 4 +-- mmgen/main_txbump.py | 3 +- mmgen/main_txcreate.py | 6 ++-- mmgen/main_txdo.py | 1 + 7 files changed, 46 insertions(+), 26 deletions(-) diff --git a/mmgen/help/help_notes.py b/mmgen/help/help_notes.py index 66efc4e1..b27f5041 100755 --- a/mmgen/help/help_notes.py +++ b/mmgen/help/help_notes.py @@ -30,14 +30,18 @@ class help_notes: def account_info_desc(self): return 'unspent outputs' if self.proto.base_proto == 'Bitcoin' else 'account info' - def fee_spec_letters(self, *, use_quotes=False): - cu = self.proto.coin_amt.units - sep, conj = ((',', ' or '), ("','", "' or '"))[use_quotes] - return sep.join(u[0] for u in cu[:-1]) + ('', conj)[len(cu)>1] + cu[-1][0] + def fee_spec_letters(self, *, use_quotes=False, proto=None): + cu = (proto or self.proto).coin_amt.units + pfx, sfx, sep, conj = (('', '', ',', ' or '), ("‘", "’", "’,‘", "’ or ‘"))[use_quotes] + return pfx + sep.join(u[0] for u in cu[:-1]) + ('', conj)[len(cu)>1] + cu[-1][0] + sfx - def fee_spec_names(self): - cu = self.proto.coin_amt.units - return ', '.join(cu[:-1]) + ('', ' and ')[len(cu)>1] + cu[-1] + ('', ',\nrespectively')[len(cu)>1] + def fee_spec_names(self, *, proto=None, linebreak=' '): + cu = (proto or self.proto).coin_amt.units + return ( + ', '.join(cu[:-1]) + + ('', ' and ')[len(cu)>1] + + cu[-1] + + (f',{linebreak}respectively' if len(cu) > 1 else '')) def dfl_twname(self): from ..proto.btc.rpc import BitcoinRPCClient @@ -114,19 +118,31 @@ FMT CODES: from ..tx import BaseTX return BaseTX(cfg=self.cfg, proto=self.proto).rel_fee_desc - def fee(self): + def fee(self, all_coins=False): from ..tx import BaseTX - return """ + text = """ 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 = self.proto.coin, - r = BaseTX(cfg=self.cfg, proto=self.proto).rel_fee_desc, - l = self.fee_spec_letters(use_quotes=True), - u = self.fee_spec_names()) +be specified as either absolute coin amounts, using a plain decimal number, or +as {r}, using an integer followed by {l}, for{s}{u}""".format( + r = BaseTX(cfg=self.cfg, proto=self.proto).rel_fee_desc, + l = self.fee_spec_letters(use_quotes=True), + s = '\n' if self.proto.base_coin == 'ETH' else ' ', + u = self.fee_spec_names()) + + if all_coins: + from ..protocol import init_proto + eth_proto = init_proto(self.cfg, 'eth', need_amt=True) + return text + ( + ' (for\nBitcoin, Litecoin and Bitcoin Cash)' + + ", or {r}, using an integer followed\nby {l}, for {u}".format( + r = BaseTX(cfg=self.cfg, proto=eth_proto).rel_fee_desc, + l = self.fee_spec_letters(use_quotes=True, proto=eth_proto), + u = self.fee_spec_names(proto=eth_proto, linebreak='\n')) + + ' (for Ethereum)') + else: + return text + '.' def passwd(self): return """ diff --git a/mmgen/help/swaptxcreate.py b/mmgen/help/swaptxcreate.py index b0e9740a..f62a0f4d 100755 --- a/mmgen/help/swaptxcreate.py +++ b/mmgen/help/swaptxcreate.py @@ -68,15 +68,15 @@ does this automatically) and then adjust the fee interactively if desired. When choosing a fee, bear in mind that the longer the transaction remains unconfirmed, the greater the risk that the vault address will expire, leading -to loss of funds. It’s therefore advisable to learn how to create, sign and +to loss of funds. It’s therefore recommended to learn how to create, sign and send replacement transactions with ‘mmgen-txbump’ before performing a swap with this script. When bumping a stuck swap transaction, the safest option is to create a replacement transaction with one output that returns funds back to the originating tracking wallet, thus aborting the swap, rather than one that merely increases the fee (see EXAMPLES below). -Before broadcasting the transaction, it’s advisable to double-check the vault -address on a block explorer such as thorchain.net or runescan.io. +Before broadcasting the transaction, it’s a good idea to double-check the +vault address on a block explorer such as thorchain.net or runescan.io. The MMGen Node Tools suite contains two useful tools to help with fine-tuning transaction fees, ‘mmnode-feeview’ and ‘mmnode-blocks-info’, in addition to diff --git a/mmgen/help/swaptxcreate_examples.py b/mmgen/help/swaptxcreate_examples.py index 6b5fda37..e37f192f 100755 --- a/mmgen/help/swaptxcreate_examples.py +++ b/mmgen/help/swaptxcreate_examples.py @@ -19,6 +19,10 @@ def help(proto, cfg): return f""" EXAMPLES: + Display available swap assets: + + $ {gc.prog_name} -S + Create a BTC-to-LTC swap transaction, prompting the user for transaction inputs. The full value of the inputs, minus miner fees, will be swapped and sent to an unused address in the user’s LTC tracking wallet: diff --git a/mmgen/help/txsign.py b/mmgen/help/txsign.py index db719958..8af86323 100755 --- a/mmgen/help/txsign.py +++ b/mmgen/help/txsign.py @@ -13,7 +13,6 @@ help.txsign: txsign help notes for the MMGen Wallet suite """ from ..cfg import gc -from ..proto.btc.params import mainnet from ..daemon import CoinDaemon def help(proto, cfg): @@ -24,7 +23,7 @@ def help(proto, cfg): return """ Transactions may contain both {pnm} or non-{pnm} input addresses. -To sign non-{pnm} inputs, a {wd}flat key list is used +To sign non-{pnm} inputs, a coin daemon wallet dump or 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 @@ -42,7 +41,6 @@ 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( - wd = f'{coind_exec()} wallet dump or ' if isinstance(proto, mainnet) else '', pnm = gc.proj_name, pnu = proto.name, pnl = gc.proj_name.lower()) diff --git a/mmgen/main_txbump.py b/mmgen/main_txbump.py index 7e0e8544..6f527d28 100755 --- a/mmgen/main_txbump.py +++ b/mmgen/main_txbump.py @@ -53,7 +53,7 @@ opts_data = { -- -d, --outdir= d Specify an alternate directory 'd' for output -- -e, --echo-passphrase Print passphrase to screen when typing it -- -f, --fee= f Transaction fee, as a decimal {cu} amount or as - + {fu} (an integer followed by {fl!r}). + + {fu} (an integer followed by {fl}). + See FEE SPECIFICATION below. -- -H, --hidden-incog-input-params=f,o Read hidden incognito data from file + 'f' at offset 'o' (comma-separated) @@ -107,6 +107,7 @@ with the --proxy option. To improve privacy, it’s recommended to proxy requests to the quote server via Tor or some other anonymity network. {e} + {s} Seed source files must have the canonical extensions listed in the 'FileExt' column below: diff --git a/mmgen/main_txcreate.py b/mmgen/main_txcreate.py index a99e45fa..1aa8a004 100755 --- a/mmgen/main_txcreate.py +++ b/mmgen/main_txcreate.py @@ -54,7 +54,7 @@ opts_data = { b- -E, --fee-estimate-mode=M Specify the network fee estimate mode. Choices: + {fe_all}. Default: {fe_dfl!r} -- -f, --fee= f Transaction fee, as a decimal {cu} amount or as - + {fu} (an integer followed by {fl!r}). + + {fu} (an integer followed by {fl}). + See FEE SPECIFICATION below. If omitted, fee will be + calculated using network fee estimation. e- -g, --gas= g Specify start gas amount in Wei @@ -80,7 +80,7 @@ opts_data = { -- -y, --yes Answer 'yes' to prompts, suppress non-essential output e- -X, --cached-balances Use cached balances """, - 'notes': '\n{c}\n{n_at}\n\n{F}\n{x}', + 'notes': '\n{c}\n{n_at}\n\n{F}\n\n{x}', }, 'code': { 'usage': lambda cfg, proto, help_notes, s: s.format( @@ -97,7 +97,7 @@ opts_data = { x_dfl = cfg._autoset_opts['swap_proto'].choices[0]), 'notes': lambda cfg, help_mod, help_notes, s: s.format( c = help_mod(f'{target}create'), - F = help_notes('fee'), + F = help_notes('fee', all_coins={'tx': False, 'swaptx': True}[target]), n_at = help_notes('address_types'), x = help_mod(f'{target}create_examples')) } diff --git a/mmgen/main_txdo.py b/mmgen/main_txdo.py index 5319569f..85c4a5da 100755 --- a/mmgen/main_txdo.py +++ b/mmgen/main_txdo.py @@ -109,6 +109,7 @@ opts_data = { {F} + SIGNING NOTES {s} Seed source files must have the canonical extensions listed in the 'FileExt'