Commit graph

2,768 commits

Author SHA1 Message Date
c7beb2e60c
test.py: add utf8 output tests 2019-05-25 15:50:09 +03:00
429ff7fa07
[msys2]: warn/exit on buggy, unsupported features 2019-05-22 12:52:31 +03:00
7ed00d98e5
test.py: add password_entry, mnemonic_entry tests 2019-05-21 16:09:33 +03:00
85236cd601
autosign: improve summary output, ts_autosign: refactor mnemonic entry code 2019-05-21 11:40:14 +03:00
13ab25764f
[msys2]: test suite fixes and additions 2019-05-20 18:44:32 +03:00
e879b7e548
minor fixes 2019-05-20 18:43:02 +03:00
1e75442bb9
eth: use local transactions module exclusively 2019-05-20 18:35:13 +03:00
5587f9f25c
regtest: support generatetoaddress RPC call 2019-05-20 18:16:32 +03:00
a59f10c841
test-release.sh: use strings instead of arrays for cmd lists 2019-05-20 18:15:14 +03:00
29cf6603af
[subseed]: include parent Seed ID in collision check 2019-05-17 14:45:11 +03:00
82086c9936
Subwallets, Part 3: transaction signing using the parent wallet
See commit 7538a94 for Part 1
See commit d1b8aef for Part 2

NOTE: to guard against Seed ID collisions, only the default or first wallet
specified in `mmgen-txsign` will be used for signing subwallet transactions.

Live example using MMGen regtest (Bob and Alice) mode:

    $ mmgen-regtest setup

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

    # Convert the wallet and make it Bob's default:
    $ mkdir -p $HOME/.mmgen/regtest/btc/bob
    $ mmgen-walletconv -d $HOME/.mmgen/regtest/btc/bob bogus.mmwords
    ...
    MMGen wallet written to file /home/user/.mmgen/regtest/btc/bob/DF449DA4-*.mmdat

    # Choose two subwallets, 1S and 2L, and get their Seed IDs:
    $ mmgen-tool --bob get_subseed 1S # ==> 930E1AD5
    $ mmgen-tool --bob get_subseed 2L # ==> 62B02F54

    # Generate five bech32 addresses each from default wallet and subwallets:
    $ mmgen-addrgen --bob --type=bech32 1-5
    $ mmgen-addrgen --bob --type=bech32 --subwallet=1S 1-5
    $ mmgen-addrgen --bob --type=bech32 --subwallet=2L 1-5

    # Import the addresses into Bob's tracking wallet:
    $ mmgen-regtest bob
    $ mmgen-addrimport --bob DF449DA4*addrs
    $ mmgen-addrimport --bob 930E1AD5*addrs
    $ mmgen-addrimport --bob 62B02F54*addrs

    # Fund addresses from each of the wallets:
    $ mmgen-regtest send bcrt1q0v8eczv37ynl9zn8w3rh53xrkyuddrunuz74rd 10 # DF449DA4:B:1
    $ mmgen-regtest send bcrt1qtzxlnng6jd7yakzp7r69y6nmh5wp0wx7xg6e9w 10 # 930E1AD5:B:1
    $ mmgen-regtest send bcrt1qxnj0wgusq357qj62hq88thrw9cwanxc7926vrz 10 # 62B02F54:B:1

    # Create a transaction spending to and from each of the wallets:
    $ mmgen-txcreate --bob --tx-fee=3s DF449DA4:B:2,1.11 930E1AD5:B:2,1.23 62B02F54:B:2
    ...
    (choose inputs 1-3)
    ...
    Transaction written to file '<MMGen txid>[2.34].testnet.rawtx'

    # Sign the transaction:
    $ mmgen-txsign --bob *\[2.34\].testnet.rawtx
    ...
    Found subseed 930E1AD5 (DF449DA4:1S)
    ...
    Found subseed 62B02F54 (DF449DA4:2L)
    ...
    Signed transaction written to file '<MMGen txid>[2.34].testnet.sigtx'

    # Send the transaction:
    $ mmgen-txsend -q --bob *\[2.34\].testnet.sigtx
    Transaction sent: <BTC txid>

    # Mine a block and view the result:
    $ mmgen-regtest generate
    $ mmgen-tool --bob twview
2019-05-16 12:48:12 +03:00
83e54ccb6e
objtest.py: separate test vectors for coin,network pairs 2019-05-16 12:45:52 +03:00
2a880e7a93
various cleanups and fixes 2019-05-16 12:43:34 +03:00
af564ba7a6
Support bitcoin-abc v0.19.6 2019-05-16 12:41:50 +03:00
d1b8aefde6
Subwallets, Part 2: key/address generation using the parent wallet
See commit 7538a94 for Part 1

Examples:

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

    # Get the Seed ID of the wallet's 5th short (128-bit) subwallet:
    $ mmgen-tool get_subseed 5S wallet=bogus.mmwords
    30D66FF5

    # Generate ten bech32 addresses from that subwallet:
    $ mmgen-addrgen --type=bech32 --subwallet=5S bogus.mmwords 1-10
    ...
    Addresses written to file '30D66FF5-B[1-10].addrs'

    # Same as above, but generate secret keys too:
    $ mmgen-keygen --type=bech32 --subwallet=5S bogus.mmwords 1-10
    ...
    Secret keys written to file '30D66FF5-B[1-10].akeys'
2019-05-14 13:45:53 +03:00
ab8b5d053e
modularize unit_tests.py 2019-05-14 10:42:06 +03:00
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