mmgen-wallet/setup.py

221 lines
6 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
#
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
2021-02-19 20:09:06 +03:00
# Copyright (C)2013-2021 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
2020-03-13 19:51:08 +00:00
sys_ver = sys.version_info[:2]
2020-05-10 13:39:53 +00:00
req_ver = (3,6)
2020-03-13 19:51:08 +00:00
ver2f = lambda t: float('{}.{:03}'.format(*t))
if ver2f(sys_ver) < ver2f(req_ver):
m = '{}.{}: wrong Python version. MMGen requires Python {}.{} or greater\n'
sys.stderr.write(m.format(*sys_ver,*req_ver))
sys.exit(1)
have_msys2 = subprocess.check_output(['uname','-s']).strip()[:7] == b'MSYS_NT'
2016-08-22 14:20:46 +03:00
from distutils.core import setup,Extension
from distutils.command.build_ext import build_ext
from distutils.command.install_data import install_data
2020-06-27 10:22:01 +00:00
from distutils.command.build_py import build_py
cwd = os.getcwd()
def copy_owner(a,b):
st = os.stat(a)
try: os.chown(b,st.st_uid,st.st_gid,follow_symlinks=False)
except: pass
2016-08-22 14:20:46 +03:00
# 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)
2019-11-14 17:19:32 +00:00
ext_dest = os.path.join('mmgen',os.path.basename(ext_src))
2016-08-22 14:20:46 +03:00
try: os.unlink(ext_dest)
except: pass
os.chmod(ext_src,0o755)
2018-10-31 18:19:20 +00:00
print('copying {} to {}'.format(ext_src,ext_dest))
2016-08-22 14:20:46 +03:00
copy2(ext_src,ext_dest)
copy_owner(cwd,ext_dest)
2016-08-22 14:20:46 +03:00
def link_or_copy(tdir,a,b):
os.chdir(tdir)
try: os.unlink(b)
except FileNotFoundError: pass
copy2(a,b) if have_msys2 else os.symlink(a,b)
copy_owner(a,b)
os.chdir(cwd)
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)
2020-06-27 10:22:01 +00:00
class my_build_py(build_py):
def run(self):
link_or_copy('test','start-coin-daemons.py','stop-coin-daemons.py')
build_py.run(self)
2016-08-22 14:20:46 +03:00
module1 = Extension(
name = 'mmgen.secp256k1',
sources = ['extmod/secp256k1mod.c'],
2019-11-14 17:19:32 +00:00
libraries = ['secp256k1'] + ([],['gmp'])[have_msys2],
library_dirs = ['/usr/local/lib',r'C:\msys64\mingw64\lib',r'C:\msys64\usr\lib'],
include_dirs = ['/usr/local/include',r'C:\msys64\mingw64\include',r'C:\msys64\usr\include'],
2016-08-22 14:20:46 +03:00
)
2021-04-16 11:06:10 +00:00
os.umask(0o0022)
from mmgen.globalvars import g
setup(
name = 'mmgen',
2016-08-22 14:20:46 +03:00
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',
2017-01-08 08:51:50 +03:00
keywords = g.keywords,
2020-06-27 10:22:01 +00:00
cmdclass = {
'build_ext': my_build_ext,
'build_py': my_build_py,
'install_data': my_install_data,
},
2019-11-14 17:19:32 +00:00
ext_modules = [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 = [
2013-12-17 12:20:28 +04:00
'mmgen.__init__',
'mmgen.addr',
'mmgen.altcoin',
'mmgen.baseconv',
'mmgen.base_obj',
'mmgen.bech32',
'mmgen.bip39',
'mmgen.cfg',
2016-12-08 18:02:28 +03:00
'mmgen.color',
'mmgen.common',
2014-08-07 22:35:02 +04:00
'mmgen.crypto',
'mmgen.daemon',
2019-07-03 18:16:09 +00:00
'mmgen.devtools',
'mmgen.ed25519',
'mmgen.ed25519ll_djbec',
ERC20 token support (create/deploy, TX create/sign/send) This feature is EXPERIMENTAL. Until v0.9.9 is released, mainnet use is strictly at your own risk! To test on dev chain, run 'test/test.py -e ethdev' To test on Kovan, add '--testnet=1' option to all commands below Transaction example: Generate some ETH addresses with your default wallet: $ mmgen-addrgen --coin=eth 1-5 Create an EOS token tracking wallet and import the addresses into it: $ mmgen-addrimport --coin=eth --token=86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0 ABCDABCD-ETH[1-5].addrs Send 10+ EOS from an exchange or another wallet to address ABCDABCD:E:1 Create a TX sending 10 EOS to address aabbccdd..., with change to ABCDABCD:E:2: $ mmgen-txcreate --coin=eth --token=eos aabbccddaabbccddaabbccddaabbccddaabbccdd,10 ABCDABCD:E:2 On your offline machine, sign the TX: $ mmgen-txsign --coin=eth --token=eos ABC123-EOS[10,50000].rawtx On your online machine, send the TX: $ mmgen-txsend --coin=eth --token=eos ABC123-EOS[10,50000].sigtx View your EOS tracking wallet: $ mmgen-tool --coin=eth --token=eos twview Token creation/deployment example: Install the Solidity compiler ('solc') on your system. Create a token 'MFT' with default parameters, owned by ddeeff... (ABCDABCD:E:1): $ scripts/create-token.py --symbol=MFT --name='My First Token' ddeeffddeeffddeeffddeeffddeeffddeeffddee Deploy the token on the ETH blockchain: $ mmgen-txdo --coin=eth --tx-gas=200000 --contract-data=SafeMath.bin $ mmgen-txdo --coin=eth --tx-gas=250000 --contract-data=Owned.bin $ mmgen-txdo --coin=eth --tx-gas=1100000 --contract-data=Token.bin ... Token address: abcd1234abcd1234abcd1234abcd1234abcd1234 Create an MFT token tracking wallet and import your ETH addresses into it: $ mmgen-addrimport --coin=eth --token=abcd1234abcd1234abcd1234abcd1234abcd1234 ABCDABCD-ETH[1-5].addrs View your MFT tracking wallet: $ mmgen-tool --coin=eth --token=mft twview
2018-07-25 12:57:04 +00:00
'mmgen.exception',
'mmgen.filename',
2016-12-08 18:02:28 +03:00
'mmgen.globalvars',
'mmgen.help',
'mmgen.keccak',
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
'mmgen.led',
'mmgen.license',
'mmgen.mn_electrum',
'mmgen.mn_entry',
'mmgen.mn_monero',
'mmgen.mn_tirosh',
'mmgen.obj',
'mmgen.opts',
'mmgen.protocol',
'mmgen.regtest',
'mmgen.rpc',
'mmgen.seed',
'mmgen.sha2',
2014-04-09 22:45:23 +04:00
'mmgen.term',
'mmgen.tool',
'mmgen.tw',
2016-12-08 18:02:28 +03:00
'mmgen.tx',
2020-05-18 13:25:00 +00:00
'mmgen.txfile',
'mmgen.txsign',
2014-04-03 16:40:22 +04:00
'mmgen.util',
'mmgen.wallet',
'mmgen.xmrwallet',
2013-12-17 12:20:28 +04:00
'mmgen.altcoins.__init__',
'mmgen.altcoins.eth.__init__',
ERC20 token support (create/deploy, TX create/sign/send) This feature is EXPERIMENTAL. Until v0.9.9 is released, mainnet use is strictly at your own risk! To test on dev chain, run 'test/test.py -e ethdev' To test on Kovan, add '--testnet=1' option to all commands below Transaction example: Generate some ETH addresses with your default wallet: $ mmgen-addrgen --coin=eth 1-5 Create an EOS token tracking wallet and import the addresses into it: $ mmgen-addrimport --coin=eth --token=86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0 ABCDABCD-ETH[1-5].addrs Send 10+ EOS from an exchange or another wallet to address ABCDABCD:E:1 Create a TX sending 10 EOS to address aabbccdd..., with change to ABCDABCD:E:2: $ mmgen-txcreate --coin=eth --token=eos aabbccddaabbccddaabbccddaabbccddaabbccdd,10 ABCDABCD:E:2 On your offline machine, sign the TX: $ mmgen-txsign --coin=eth --token=eos ABC123-EOS[10,50000].rawtx On your online machine, send the TX: $ mmgen-txsend --coin=eth --token=eos ABC123-EOS[10,50000].sigtx View your EOS tracking wallet: $ mmgen-tool --coin=eth --token=eos twview Token creation/deployment example: Install the Solidity compiler ('solc') on your system. Create a token 'MFT' with default parameters, owned by ddeeff... (ABCDABCD:E:1): $ scripts/create-token.py --symbol=MFT --name='My First Token' ddeeffddeeffddeeffddeeffddeeffddeeffddee Deploy the token on the ETH blockchain: $ mmgen-txdo --coin=eth --tx-gas=200000 --contract-data=SafeMath.bin $ mmgen-txdo --coin=eth --tx-gas=250000 --contract-data=Owned.bin $ mmgen-txdo --coin=eth --tx-gas=1100000 --contract-data=Token.bin ... Token address: abcd1234abcd1234abcd1234abcd1234abcd1234 Create an MFT token tracking wallet and import your ETH addresses into it: $ mmgen-addrimport --coin=eth --token=abcd1234abcd1234abcd1234abcd1234abcd1234 ABCDABCD-ETH[1-5].addrs View your MFT tracking wallet: $ mmgen-tool --coin=eth --token=mft twview
2018-07-25 12:57:04 +00:00
'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',
2020-09-21 14:40:50 +00:00
'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',
2014-08-07 22:35:02 +04:00
'mmgen.main',
'mmgen.main_addrgen',
'mmgen.main_addrimport',
'mmgen.main_autosign',
'mmgen.main_passgen',
'mmgen.main_regtest',
'mmgen.main_seedjoin',
'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.main_xmrwallet',
2014-08-07 22:35:02 +04:00
'mmgen.share.__init__',
'mmgen.share.Opts',
],
scripts = [
'cmds/mmgen-addrgen',
'cmds/mmgen-addrimport',
2021-06-08 11:46:05 +00:00
'cmds/mmgen-autosign',
'cmds/mmgen-keygen',
'cmds/mmgen-passchg',
2021-06-08 11:46:05 +00:00
'cmds/mmgen-passgen',
'cmds/mmgen-regtest',
'cmds/mmgen-seedjoin',
2021-06-08 11:46:05 +00:00
'cmds/mmgen-seedsplit',
'cmds/mmgen-split',
2021-06-08 11:46:05 +00:00
'cmds/mmgen-subwalletgen',
'cmds/mmgen-tool',
'cmds/mmgen-txbump',
2021-06-08 11:46:05 +00:00
'cmds/mmgen-txcreate',
'cmds/mmgen-txdo',
2021-06-08 11:46:05 +00:00
'cmds/mmgen-txsend',
'cmds/mmgen-txsign',
'cmds/mmgen-walletchk',
'cmds/mmgen-walletconv',
'cmds/mmgen-walletgen',
'cmds/mmgen-xmrwallet',
2013-12-17 12:20:28 +04:00
]
)