mmgen-wallet/setup.py
MMGen 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

176 lines
5.1 KiB
Python
Executable file

#!/usr/bin/env python3
#
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
# Copyright (C)2013-2019 The MMGen Project <mmgen@tuta.io>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys,os,subprocess
from shutil import copy2
ver = sys.version_info[:2]
min_ver = (3,5)
if ver[0] < min_ver[0] or ver[1] < min_ver[1]:
m = '{}.{}: wrong Python version. MMGen requires Python {M}.{m} or greater\n'
sys.stderr.write(m.format(*ver,M=min_ver[0],m=min_ver[1]))
sys.exit(1)
have_arm = subprocess.check_output(['uname','-m']).strip() == b'aarch64'
have_msys2 = subprocess.check_output(['uname','-s']).strip()[:7] == b'MSYS_NT'
from distutils.core import setup,Extension
from distutils.command.build_ext import build_ext
from distutils.command.install_data import install_data
# install extension module in repository after building
class my_build_ext(build_ext):
def build_extension(self,ext):
build_ext.build_extension(self,ext)
ext_src = self.get_ext_fullpath(ext.name)
ext_dest = os.path.join('mmgen','secp256k1.so')
try: os.unlink(ext_dest)
except: pass
os.chmod(ext_src,0o755)
print('copying {} to {}'.format(ext_src,ext_dest))
copy2(ext_src,ext_dest)
class my_install_data(install_data):
def run(self):
for f in 'mmgen.cfg','mnemonic.py','mn_wordlist.c':
os.chmod(os.path.join('data_files',f),0o644)
install_data.run(self)
module1 = Extension(
name = 'mmgen.secp256k1',
sources = ['extmod/secp256k1mod.c'],
libraries = ['secp256k1'],
library_dirs = ['/usr/local/lib',r'c:\msys\local\lib'],
# mingw32 needs this, Linux can use it, but it breaks mingw64
include_dirs = ['/usr/local/include',r'c:\msys\local\include'],
)
from mmgen.globalvars import g
setup(
name = 'mmgen',
description = 'A complete Bitcoin offline/online wallet solution for the command line',
version = g.version,
author = g.author,
author_email = g.email,
url = g.proj_url,
license = 'GNU GPL v3',
platforms = 'Linux, MS Windows, Raspberry Pi/Raspbian, Orange Pi/Armbian',
keywords = g.keywords,
cmdclass = { 'build_ext': my_build_ext, 'install_data': my_install_data },
ext_modules = [] if have_msys2 else [module1],
data_files = [('share/mmgen', [
'data_files/mmgen.cfg', # source files must have 0644 mode
'data_files/mn_wordlist.c',
'data_files/mnemonic.py'
]),],
py_modules = [
'mmgen.__init__',
'mmgen.addr',
'mmgen.altcoin',
'mmgen.bech32',
'mmgen.color',
'mmgen.common',
'mmgen.crypto',
'mmgen.ed25519',
'mmgen.ed25519ll_djbec',
'mmgen.exception',
'mmgen.filename',
'mmgen.globalvars',
'mmgen.keccak',
'mmgen.license',
'mmgen.mn_electrum',
'mmgen.mn_tirosh',
'mmgen.obj',
'mmgen.opts',
'mmgen.protocol',
'mmgen.regtest',
'mmgen.rpc',
'mmgen.seed',
'mmgen.sha2',
'mmgen.term',
'mmgen.tool',
'mmgen.tw',
'mmgen.tx',
'mmgen.util',
'mmgen.altcoins.__init__',
'mmgen.altcoins.eth.__init__',
'mmgen.altcoins.eth.contract',
'mmgen.altcoins.eth.obj',
'mmgen.altcoins.eth.tx',
'mmgen.altcoins.eth.tw',
'mmgen.altcoins.eth.pyethereum.__init__',
'mmgen.altcoins.eth.pyethereum.transactions',
'mmgen.altcoins.eth.pyethereum.utils',
'mmgen/altcoins/eth/rlp/__init__',
'mmgen/altcoins/eth/rlp/atomic',
'mmgen/altcoins/eth/rlp/codec',
'mmgen/altcoins/eth/rlp/exceptions',
'mmgen/altcoins/eth/rlp/sedes/__init__',
'mmgen/altcoins/eth/rlp/sedes/big_endian_int',
'mmgen/altcoins/eth/rlp/sedes/binary',
'mmgen/altcoins/eth/rlp/sedes/boolean',
'mmgen/altcoins/eth/rlp/sedes/lists',
'mmgen/altcoins/eth/rlp/sedes/raw',
'mmgen/altcoins/eth/rlp/sedes/serializable',
'mmgen/altcoins/eth/rlp/sedes/text',
'mmgen.main',
'mmgen.main_addrgen',
'mmgen.main_addrimport',
'mmgen.main_autosign',
'mmgen.main_passgen',
'mmgen.main_regtest',
'mmgen.main_split',
'mmgen.main_tool',
'mmgen.main_txbump',
'mmgen.main_txcreate',
'mmgen.main_txdo',
'mmgen.main_txsend',
'mmgen.main_txsign',
'mmgen.main_wallet',
'mmgen.txsign',
'mmgen.share.__init__',
'mmgen.share.Opts',
],
scripts = [
'cmds/mmgen-addrgen',
'cmds/mmgen-keygen',
'cmds/mmgen-passgen',
'cmds/mmgen-addrimport',
'cmds/mmgen-passchg',
'cmds/mmgen-regtest',
'cmds/mmgen-subwalletgen',
'cmds/mmgen-walletchk',
'cmds/mmgen-walletconv',
'cmds/mmgen-walletgen',
'cmds/mmgen-split',
'cmds/mmgen-txcreate',
'cmds/mmgen-txbump',
'cmds/mmgen-txsign',
'cmds/mmgen-txsend',
'cmds/mmgen-txdo',
'cmds/mmgen-tool',
'cmds/mmgen-autosign'
]
)