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
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'
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'
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)
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.
- 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')
- 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
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/msys2https://www.msys2.org
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
- 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.
- 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
- 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