Commit graph

2,768 commits

Author SHA1 Message Date
c3f185e8b0
eliminate use of global vars g.proto, g.coin, g.rpc and others
This patch eliminates nearly all the global variables that changed during the
execution of scripts.  With a few minor exceptions, global vars are now used
only during initialization or reserved for cfg file / cmdline options and other
unchanging values.

The result is a code base that's much more maintainable and extensible and less
error-prone.  The autosigning code, which supports signing of transactions for
multiple protocols and networks, has been greatly simplified.

Doing away with globals required many changes throughout the code base, and
other related (and not so related) changes and cleanups were made along the
way, resulting in an enormous patch.

Additional code changes include:

    - tx.py: complete reorganization of TX classes and use of nesting

    - protocol.py: separation of Regtest and Testnet into distinct subclasses
      with separate address and transaction files and file extensions

    - new module help.py for the help notes, loaded on demand

    - addr.py: rewrite of the address file label parsing code

    - tx.py,tw.py: use of generators to create formatted text

User-visible changes include:

    - importing of addresses for tokens not yet in the user's tracking wallet
      is now performed with the `--token-addr` option instead of `--token`

Testing:

    Testing this patch requires a full run of the test suite as described on the
    Test-Suite wiki page.
2020-05-28 09:53:34 +00:00
9489b1cb2d
string formatting, whitespace, minor cleanups throughout 2020-05-26 14:53:44 +00:00
7825a6021c
ImmutableAttr: move conversion logic from __set__() to __init__() 2020-05-20 11:09:42 +00:00
8ce3e3c7b1
protocol.py: new class: Secp256k1; formatting, whitespace 2020-05-19 09:14:13 +00:00
9f1d647f07
new class: MMGenTxFile 2020-05-18 13:25:00 +00:00
dda43d9dad
minor changes 2020-05-18 13:24:28 +00:00
144612c6fc
global rename: MMGenTXLabel -> MMGenTxLabel 2020-05-18 10:20:27 +00:00
7a0d4bf298
tx.py: string formatting, whitespace; minor code rewrites 2020-05-18 08:34:36 +00:00
be6a7ef2f5
ImmutableAttr,ListItemAttr: minor cleanups 2020-05-17 20:42:27 +00:00
28b4f56919
coin protocol, txview: minor cleanups 2020-05-16 18:46:40 +00:00
4204a32311
coin protocol: minor cleanups 2020-05-16 16:07:28 +00:00
43432327c7
global change: init_coin() -> g.proto = init_proto() 2020-05-16 12:44:43 +00:00
17ce9e54b5
opts.py: minor cleanups 2020-05-16 12:01:04 +00:00
c2cdfa429f
rpc: add BCH unit test; Daemon: move list attrs from class to instance 2020-05-16 10:47:54 +00:00
94e3b1c0b0
CoinProtocol: use capitalized 'name' attr; related cleanups, fixes 2020-05-16 10:04:03 +00:00
31f7236731
protocol.py: new coin protocol instance attrs
- add 'testnet', 'regtest' and 'dcoin' attributes to coin protocol instance,
  remove is_testnet() method

- g.testnet -> g.proto.testnet, g.regtest -> g.proto.regtest

- g.coin and g.dcoin are now read-only properties shadowing g.proto.coin
  and g.proto.dcoin, respectively
2020-05-16 09:27:13 +00:00
534f58994b
protocol.py: add Regtest coin protocols, related changes 2020-05-15 15:54:02 +00:00
819dd700b0
protocol.py: make g a class instance; minor fixes, cleanups 2020-05-15 11:49:51 +00:00
b01af014a3
opts.py: allow no-arg init() with dfl opts_data; longhelp fixes,cleanups 2020-05-15 10:13:39 +00:00
04775afb2e
protocol.py: make coin protocols attrs of CoinProtocol 2020-05-14 20:08:50 +00:00
8a4fbab48d
protocol.py: new init_proto() factory function 2020-05-14 16:40:45 +00:00
4449c23da4
make g.proto a class instance 2020-05-13 21:07:45 +00:00
95408dc8cc
rpc.py: g.proto -> self.proto 2020-05-13 21:06:02 +00:00
28538babcc
rpc.py: restore SSL to Monero wallet client, minor cleanups
Fixes a regression introduced by commit f9a483f3
2020-05-13 14:26:08 +00:00
bfc40fce4d
halving-calculator.py: a few minor fixes 2020-05-12 16:37:59 +00:00
86fd45566d
new file: examples/halving-calculator.py 2020-05-11 18:07:58 +00:00
f9a483f34f
asyncio/aiohttp support
Asynchronous HTTP significantly speeds up operations involving multiple
JSON-RPC calls to the server, such as tracking wallet views for wallets
with a large number of outputs.

This patch adds base-level asyncio infrastructure plus aiohttp support to all
applicable MMGen commands.

The aiohttp package is not currently supported by MSYS2, so Windows users will
have to choose one of the other backends ('curl' is the default).

Tested on: Linux, Armbian, Windows; Python 3.6, 3.7, 3.8

New user features:

    - configurable RPC backends via the 'rpc_backend' option.  Supported
      options are 'aiohttp' (Linux-only), 'httplib', 'requests' and 'curl'

    - configurable RPC queue size via the 'aiohttp_rpc_queue_len' option

The patch also includes a rewrite/redesign of large parts of the MMGen code
base, most importantly:

    - rpc.py - full rewrite of RPC library, new RPCBackends class
    - main_addrimport.py - full rewrite
    - main_autosign.py - LED code now handled by new LEDControl class
    - eth/tw.py, eth/tx.py - reworked logic for resolving token symbols and
      addresses
    - eth/tx.py - separate classes for signed and unsigned transactions

Testing:

    # Set a backend (choose one):
    $ export MMGEN_RPC_BACKEND='aiohttp' # Linux-only
    $ export MMGEN_RPC_BACKEND='curl'    # Windows
    $ export MMGEN_RPC_BACKEND='httplib' # compare performance with 'aiohttp'

    # Bitcoin:
    $ test/unit_tests.py rpc btc
    $ test/test.py main regtest autosign

    # Ethereum:
    $ test/unit_tests.py rpc eth
    $ test/tooltest2.py --coin=eth --testnet=1 txview
    $ test/test.py --coin=eth ethdev

    # Monero wallet:
    $ test/unit_tests.py rpc xmr_wallet
    $ test/test-release.sh -F xmr
2020-05-10 14:07:54 +00:00
5ba2f51ecd
new LEDControl class 2020-05-10 14:04:08 +00:00
78a199c1a6
global var rename: g.rpch -> g.rpc 2020-05-10 13:40:16 +00:00
57f12cd1cb
minor changes and fixes throughout 2020-05-10 13:39:53 +00:00
ef6e03d78b
add missing file wallet.py to master branch 2020-05-06 21:34:35 +00:00
2c073ac0b5
tw.py: remove 'approx' age precision for unspent outputs 2020-05-01 08:29:40 +00:00
744c7b0d54
rpc.py: new calls() method; tw.py: batch date RPC calls; related fixes/cleanups 2020-05-01 08:28:22 +00:00
05653ee47a
mmgen.share.Opts: improve opts parsing 2020-04-14 13:42:08 +00:00
da5742f667
various cleanups throughout 2020-04-12 15:02:52 +00:00
370a972b4b
obj.py, Hilite: cleanups 2020-04-11 15:51:25 +00:00
3610b3ef29
OrderedDict -> dict throughout 2020-04-09 19:34:24 +00:00
701e7a77e5
use relative imports throughout 2020-04-09 19:32:23 +00:00
ca1cdacaf1
move wallet classes from seed.py to new module wallet.py 2020-04-09 17:11:59 +00:00
4fbe2d6574
rename class: SeedSource -> Wallet 2020-04-09 16:38:26 +00:00
1f3195bfd2
rename class: Wallet -> MMGenWallet 2020-04-09 16:09:22 +00:00
f052968e21
seed.py: new SeedSourceMeta metaclass 2020-04-09 10:01:45 +00:00
f231ca6202
seed.py: make wallet classes leaf classes, minor cleanups 2020-04-09 09:55:01 +00:00
f297645796
ImmutableAttr,ListItemAttr: renamed, call signature simplified 2020-04-08 14:13:13 +00:00
090b91baa2
test.py regtest: minor fix 2020-04-08 14:10:45 +00:00
068377cf1b
tool.py: new MMGenToolCmdMeta metaclass
Testing:

    $ test/test.py tool_help
    $ test/tooltest2.py
    $ test/tooltest2.py -A
    $ test/tooltest2.py -f
    $ test/tooltest.py
    $ test/test.py tool
2020-04-08 08:51:19 +00:00
99beeb0d49
tool: minor changes 2020-04-08 08:48:52 +00:00
b671453c13
txcreate,twview,listaddresses: display transaction date
- The `mmgen-tool` `listaddresses` and `twview` commands, as well as the
  unspent outputs menu of `mmgen-txcreate`, can now display the date/time of
  each output in addition to its number of confirmations, block, or age in
  days.  Two date display precisions are available: “approx”, an estimate based
  on the historical average block confirmation interval, and “exact”, the
  timestamp of the block containing the output.  Since display of the exact
  date requires an extra RPC call per output, precision defaults to “approx”.
  The setting also affects the precision of the age-in-days output.

Usage:

    $ mmgen-txcreate -i # 'D' to cycle through display opts, 'x' for exact age
    $ mmgen-tool listaddresses age_fmt=date exact_age=1 # (or age_fmt=date_time)
    $ mmgen-tool twview age_fmt=date exact_age=1        # (or age_fmt=date_time)

Testing:

    $ test/test.py -ne regtest
    $ test/test.py -ne --coin=eth ethdev
2020-04-04 13:18:44 +00:00
de7fba0c19
test suite: relocate some modules, use relative imports 2020-03-16 10:45:00 +00:00
656bb69587
terminal-related fixes and cleanups 2020-03-15 19:45:32 +00:00