Commit graph

502 commits

Author SHA1 Message Date
eca3007ed1
implement --fast option for unit tests 2019-05-13 12:21:01 +03:00
338cb77199
obj.py,eth/obj.py,protocol.py: exception handling cleanups 2019-05-13 11:49:35 +03:00
0bb1b3f73d
obj.py: make arg_chk a classmethod 2019-05-12 17:40:24 +03:00
7538a9460e
Subwallets, Part 1: basic framework and subwallet generation
Beginning with this commit, every MMGen wallet now has a two sets of associated
subwallets with “long“ and “short” seeds.

MMGen wallets and subwallets are functionally equivalent and externally
indistinguishable.  This has benefits, especially for real-world security, as
well as drawbacks.  For more information, see the `mmgen-subwalletgen` help
screen: https://github.com/mmgen/mmgen/wiki/subwalletgen-[MMGen-command-help]

This patch provides subwallet generation functionality and subseed display
utilities.  Support for transaction signing and address generation using a
subwallet's parent wallet will be added in a forthcoming patch.

Examples:

    # Create a bogus wallet in mnemonic format for testing purposes:
    $ echo $(yes bee | head -n24) > bogus.mmwords

    # List the wallet's first five subseed pairs:
    $ mmgen-tool list_subseeds 1-5 wallet=bogus.mmwords
    Parent Seed: DF449DA4 (256 bits)

     Long Subseeds     Short Subseeds
     -------------     --------------
      1L: FC9A8735       1S: 930E1AD5
      2L: 62B02F54       2S: DF14AB49
      3L: 9E884E99       3S: AD3ABD98
      4L: DB595AE1       4S: 3E885EC4
      5L: 36D5A0D1       5S: 30D66FF5

    # Generate the 5th short (128-bit) subwallet from the wallet:
    $ mmgen-subwalletgen bogus.mmwords 5S

    # Same as above, but output subwallet to mnemonic (seed phrase) format:
    $ mmgen-subwalletgen -o mn bogus.mmwords 5S
    ...
    Mnemonic data written to file '30D66FF5[128].mmwords'

    # View the subwallet's seed phrase:
    $ cat 30D66FF5[128].mmwords
    object capture field heart page observe road bond mother loser really army

    # Generate 10 addresses from the subwallet seed phrase:
    $ mmgen-addrgen 30D66FF5[128].mmwords 1-10
    ...
    Addresses written to file '30D66FF5[1-10].addrs'
2019-05-12 15:29:38 +03:00
2f274cba2d
new class: MMGenRange()
from mmgen.obj import MMGenRange
    r = MMGenRange('1-5') # initialize with string
    r2 = MMGenRange(1,5)  # or with integers
    assert r == r2
    assert r == (1,5)
    assert r.first == 1
    assert r.last == 5
    assert r.items == [1,2,3,4,5]

    r = MMGenRange('22') # initialize range of one item
    r2 = MMGenRange(22,22)
    assert r == r2

    r = MMGenRange('1-1000000') # memory-frugal iteration
    for n in r.iterate(): print(n)
2019-05-12 12:26:41 +03:00
3a09017804
various minor fixes and cleanups 2019-05-12 11:54:03 +03:00
11b04d4d9d
make Seed() attrs immutable 2019-05-07 13:00:36 +03:00
d558822941
autosign: print summary of non-MMGen output addresses and amounts
To allow the user to verify that transaction outputs have not been altered
by a compromised online MMGen installation, print a list of non-MMGen output
addresses and amounts for all signed transactions after every autosign run.

With --full-summary, print a full view of each signed transaction instead.
2019-04-24 17:39:22 +03:00
4a2cc07ef1
relocate test-release.sh script to test directory 2019-04-19 17:37:32 +03:00
6b2c138f09
implement BIP69 (lexicographical indexing of tx inputs and outputs) 2019-04-02 16:41:05 +03:00
00227b3d73
protocol.py: add 'base_proto' attribute; minor changes 2019-03-27 21:49:42 +03:00
105f6c3033
mmgen-tool txview: add 'sort' option, rename old sort option to 'filesort'
- filesort: sort tx files by time ('mtime', 'ctime', 'atime')
- sort: view transaction inputs and outputs either sorted by MMGen ID/address
        ('addr') or in their actual order in the transaction ('raw')
2019-03-27 21:45:37 +03:00
7c63bb1e3d
mmgen-tool: add addr2scriptpubkey, scriptpubkey2addr commands 2019-03-27 20:05:58 +03:00
823e325c6c
[msys2]: enable color output, handle exceptions in main.py 2019-03-27 19:52:29 +03:00
46b6abb3c7
use file io for terminal output 2019-03-26 16:04:48 +03:00
4240393804
minor fixes 2019-03-26 16:02:10 +03:00
017ecef3bc
[opts]: separate code from text in opts_data
- When parsing opts, opts.init() now looks only at string values from
  opts_data.  Global variables are evaluated only when printing help text,
  after the variables are initialized
2019-03-26 15:59:37 +03:00
dcab10949e
Support MSWin via MSYS2
This is a work in progress.  Currently, basic operations for BTC and ETH are
supported.

The successor to the MinGW64 project, MSYS2 features package management via
`pacman` and support for Python 3:

    https://sourceforge.net/projects/msys2
    https://www.msys2.org
2019-03-25 13:07:04 +03:00
66d0f76635
Eliminate dependencies on all ethereum packages except py_ecc
The rationale for this patch is similar to that of commit a7126ed:

- Many packages were imported for the sake of just a few trivial conversion
  functions.  These functions have been copied into the local pyethereum.utils.

- rlp has been locally copied and its import statements modified to import
  the locally-copied functions.  Unneeded classes and functions have been
  removed.

- As a result, dependencies on the following external packages have been
  eliminated:

  + rlp
  + eth-hash
  + eth-utils
  + eth-typing
  + toolz
  + cytoolz
  + setuptools
2019-03-25 12:38:49 +03:00
122ac43573
minor changes 2019-03-23 17:30:47 +03:00
a7126ede03
Remove dependencies on pysha3 and ethereum modules
- pysha3: Monero and Ethereum use the old pre-SHA3 version of the keccak
  hash function, which is not supported by hashlib.sha3.

  The pysha3 package supports the function but is not portable.

  Therefore, use the pure-Python implementation mmgen.keccak as a fallback,
  making the pysha3 package optional.

  Use of mmgen.keccak may be forced with --use-internal-keccak-module

  mmgen.keccak was ported from the Python 2 implementation at
  https://github.com/ctz/keccak

- ethereum (pyethereum): Installation of this package presents numerous
  problems due to poor maintenance and many superfluous dependencies.

  Therefore, use stripped-down and modified local versions of
  ethereum.transactions and ethereum.utils as fallbacks, making the ethereum
  package optional.

  The local pyethereum.utils uses mmgen.keccak as a fallback for pysha3's
  keccak implementation.
2019-03-23 17:21:34 +03:00
281e1f3ffb
minor fixes 2019-03-22 14:32:22 +03:00
8a3b9216f6
crypto.py: reimplement AES routines using the cryptography library
- the pycrypto library is now no longer used by MMGen
- cryptography initializes the counter with bytes instead of an int,
  leading to a small API change
2019-03-21 12:23:13 +03:00
7cc69a2725
mmgen-tool: rewrite 'rand2file', add test 2019-03-21 11:46:50 +03:00
f7b59022a4
silent -> quiet file opens + minor fixes 2019-03-20 20:10:46 +03:00
785582e30d
MMGenTxInput, MMGenTxOutput: make 'amt' attribute a property
- type checking 'amt' at runtime eliminates the need to reload tx module
  when g.proto changes
2019-03-19 15:04:18 +03:00
f08cd32e33
MMGenListItem, MMGenTxInput, MMGenTxOutput: allow inheritance of attrs 2019-03-19 11:55:49 +03:00
a8e140f6ea
Add unit_tests.py to test-release.sh; minor fixes 2019-03-19 10:44:37 +03:00
e524b660f0
New test: test/unit_tests.py, add test 'tx_deserialize' 2019-03-18 20:32:37 +03:00
f9a5077ba8
DeserializedTX(): parse transactions more efficiently
- results in a ≈50% speedup for typical transactions
2019-03-18 12:20:37 +03:00
360ef8d3c5
use hashlib.scrypt() if available, in preference to scrypt.hash() 2019-03-17 18:26:23 +03:00
27355e0b27
handle environmental vars consistently 2019-03-17 18:07:11 +03:00
2a68ee8ef4
with open('foo') as f: t = f.read() -> t = open('foo').read() 2019-03-17 14:56:04 +03:00
b5f1ebc640
py3port: make hexadecimal values be strings instead of bytes type
- binascii.hexlify(b'foo') -> b'foo'.hex()
- binascii.unhexlify('aabb') -> bytes.fromhex('aabb')
- replace HexBytes class with HexStr

This change has led to a ≈10% speedup in the full test-release.sh run
2019-03-17 13:33:55 +03:00
d7913524b2
py3port: use os.get_terminal_size() 2019-03-16 22:52:35 +03:00
4b6772dc3b
py3port: use set comprehensions where applicable 2019-03-16 22:05:25 +03:00
634fb2e444
py3port: use dictionary comprehensions where applicable 2019-03-16 20:45:44 +03:00
ae77cb4a51
remove scripts/tx-v1-to-v3.py 2019-03-16 20:41:02 +03:00
2b6dc95970
rewrite SHA2 implementation, support SHA512; update tests accordingly
- Note: the sha2 module is used by MMGen solely for generating Zcash
  addresses and viewkeys
2019-03-15 12:09:38 +03:00
4a73a0440b
minor changes; mmgen-tool: add 'redeem_script2addr' command 2019-03-13 14:06:08 +03:00
21125e389f
README.md - rewrite section devoted to BIP32 and key derivation 2019-03-08 12:06:45 +03:00
0879e53e74
tooltest2.py - add BTC test vectors
tooltest.py  - bugfixes, remove some commands covered in tooltest2.py
mmgen-tool   - bugfixes, cleanups, rename some commands, change some command
               options
			 - all commands taking binary input can now receive it from file
			   or stdin

+ numerous minor fixes throughout
2019-03-06 23:58:59 +03:00
78176a0833
test.py: tx*_ui_common(): make 'caller' a keyword arg 2019-03-04 10:02:57 +03:00
91410dd96c
test.py: refactor, modularize, cleanup code, make fully OO
- test groups are now separate classes in separate modules
- test data and code is loaded on an as-needed basis
- new TestSuiteRunner and CmdGroupMgr classes
- simplified invocation: if arguments are omitted, all default tests relevant
  for given network and option are run.  The following set of invocations
  provides nearly complete coverage of MMGen's core functionality:

    test/test.py
    test/test.py --segwit-random
    test/test.py --bech32

    test/test.py --coin=ltc
    test/test.py --coin=ltc --segwit-random
    test/test.py --coin=ltc --bech32

    test/test.py --coin=bch
    test/test.py --coin=eth
    test/test.py --coin=etc
2019-03-02 21:27:53 +03:00
b61d516acd
test-release.sh: change option names, alter behavior of '-f' (speedup) option 2019-02-28 13:57:35 +03:00
6a90340671
minor changes 2019-02-28 13:51:27 +03:00
609e4a04d2
opts.init(): delay creation of data dir, add 'parse_only' option 2019-02-28 13:48:20 +03:00
3036267c53
eth/{contract,tx}.py: delay loading of Transaction module 2019-02-28 13:42:05 +03:00
7ac23b6bf3
create new uninstall script 2019-02-28 13:38:52 +03:00
729a547c7d
tool.py, main_tool.py: major rewrite, cleanup
- group tool commands into classes
- add docstrings to command classes and methods
- annotate command method args
- generate call signatures + help and usage screens on the fly

- API changes:
  - listaddresses,twview: new 'age_fmt' option replaces 'show_days' and 'show_age'
  - addrfile_chksum and friends: 'mmtype' option removed

- tooltest.py, tooltest2.py and test.py have been updated accordingly
2019-02-22 23:23:06 +03:00