# README
[![Build Status](https://app.travis-ci.com/tompin/multicrypto.svg?branch=master)](https://app.travis-ci.com/github/tompin/multicrypto)
[![Coverage Status](https://coveralls.io/repos/github/tompin/multicrypto/badge.svg?branch=master)](https://coveralls.io/github/tompin/multicrypto?branch=master)
[![Latest Version](https://img.shields.io/pypi/v/multicrypto.svg)](https://pypi.python.org/pypi/multicrypto/)
[![Python Version](https://img.shields.io/pypi/pyversions/multicrypto.svg)](https://www.python.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
Highly experimental, pure python tool for cryptocurrencies.
Please notice that coins could change their protocols so make sure the coin parameters are not outdated.
## INSTALLATION
### Additional packages needed on Ubuntu
```bash
sudo apt-get install build-essential python3-setuptools python3-wheel python3-dev python3-pip
```
If you don't have Python 3, install it by following instructions from python.org.
Supported Python versions are 3.8, 3.9, 3.10, 3.11, 3.12. Then run (using pip for python 3) :
```bash
pip install multicrypto
```
The package contains below commands:
1. `sweepaddress` - combines many inputs into one
2. `sendcrypto` - creates raw transaction and send it to insight explorer api
3. `checkaddress` - checks address balance using insight explorer api
4. `transaddress` - translates address to different coin format (resulting address will have the same private key)
5. `transprivkey` - translates WIF private key to different coin format
6. `genaddress` - generates vanity address for given coin
7. `signmessage`- signs message using ECDSA
8. `verifymessage` - verify ECDSA signed message
## USAGE
Before running any commands it is advised to disable shell history. For example on linux it should
be enough to run:
```bash
unset HISTFILE
```
### Run
1. Combining many small inputs to larger ones.
```bash
sweepaddress --coin_symbol=<COIN SYMBOL> --address=<ADDRESS> --private_key=<PRIVATE KEY> --minimum_input_threshold=<INT> --maximum_input_threshold=<INT>
```
After mining some currency for longer period we could end up with address having a lot of small inputs.
In such case it is very likely it will be not possible to send the funds in one transaction and it could
be difficult to cope with. Let say for Zen Cash we have private key of the address which inputs
we want to combine, but we want only combine inputs which are smaller than 0.1 ZEN:
```bash
sweepaddress -c ZEN -p KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp --maximum_input_threshold==10000000
```
This will create appropriate number of transactions (by default one transaction for each 200 inputs, you can
override this value by setting parameter --batch_size, but setting it too high will result in too big transaction error),
transaction fee will be set to default 0.00001 ZEN (you can override it using --fee parameter) and the
funds will be sent back to original address (you can override the output address using --address parameter).
2. Sending funds:
```bash
sendcrypto --coin_symbol=<COIN_SYMBOL> --satoshis=<INT> --address=<ADDRESS> --private_key=<PRIVATE KEY> --minimum_input_threshold=<INT> --maximum_input_threshold=<INT>
```
Sending (P2PKH) 0.25 BTC to address 1BTC1NNjeiAmFqe2n1QJjkEa4aMyAhkpKG with default fee 10000 satoshis
and only using inputs containing not more than 100000 satoshis:
```bash
sendcrypto -c BTC -s 25000000 -x 100000 -a 1BTC1NNjeiAmFqe2n1QJjkEa4aMyAhkpKG -p KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp
```
Sending (P2PSH) 0.0019 BTC on testnet to address 2NDN55zZ6BtStckQWnhGJejBdM5EaGcNn7h with fee 5000 satoshis
(notice that both input address 2NAMu8JCTLXtTv2LRQktByt1EoKaJaVmDAj and unlocking script 5106519351935387
must be provided):
```bash
sendcrypto -a 2NDN55zZ6BtStckQWnhGJejBdM5EaGcNn7h -c TBTC -i 2NAMu8JCTLXtTv2LRQktByt1EoKaJaVmDAj -u 5106519351935387 -s 190000 -f 5000
```
3. Listing address inputs with total amount:
```bash
checkaddress --coin_symbol=<COIN SYMBOL> --address=<ADDRESS> --minimum_input_threshold=<INT> --maximum_input_threshold=<INT>
```
For example:
```bash
checkaddress -c BTC -a 14YK4mzJGo5NKkNnmVJeuEAQftLt795Gec
```
4. Translating address between coins:
```bash
transaddress --address=<ADDRESS> --input_symbol=<COIN SYMBOL> --output_symbol=<COIN SYMBOL>
```
For example to translate Bitcoin address 1BTC1NNjeiAmFqe2n1QJjkEa4aMyAhkpKG to Zcash address we enter:
```bash
transaddress -a 1BTC1NNjeiAmFqe2n1QJjkEa4aMyAhkpKG -i BTC -o ZEC
```
5. Translating private key in wif format between coins
```bash
transprivkey --private_key=<PRIVATE_KEY> --output_symbol=<COIN SYMBOL>
```
For example to translate Bitcoin private key KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp
to Zcash private key we enter:
```bash
transprivkey -p KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp -o ZEC
```
6. Generating address with given pattern and corresponding private key:
```bash
genaddress --pattern=<PATTERN> --symbol=<COIN SYMBOL> --output_dir=<DIRECTORY TO STORE QR CODES>
```
For example if we want to create address with prefix t1aaaa for Zcash coin and save corresponding
QR codes to /home/john directory we enter:
```bash
genaddress -p t1aaaa -s ZEC -d /home/john
```
To generate Bitcoin segwit address starting with 3BTC we enter:
```bash
genaddress -p 3BTC -s BTC -w
```
7. Signing message proving ownership of an address:
```bash
signmessage --coin_symbol=<COIN SYMBOL> --private_key=<PRIVATE KEY> --message=<MESSAGE TO SIGN>
```
For example proving ownership of BTC address 1HCfFoucNXgYLvpcN2X4TwmUXJjGUMJ2hi:
```bash
signmessage -c BTC -p KzReaUKzSaGarrhFhjNMweTrpUx4gqX1KCMFSWJx9374kYNHpmSu -m "Hello World!"
```
will return: `H7Ul0s8Za640duU2MhsifCX1H3Ma2NKRtLvtLYye6mFpZTW0fgXbM//bXq1yeXLHphXi8BUjtBsBHy0zrZjCYsQ=`
8. Verifying if signed message was created using private key of given address:
```bash
verifymessage --coin_symbol=<COIN SYMBOL> --address=<ADDRESS> --message=<MESSAGE> --signed_message=<SIGNED MESSAGE>
```
For example verifying if `H7Ul0s8Za640duU2MhsifCX1H3Ma2NKRtLvtLYye6mFpZTW0fgXbM//bXq1yeXLHphXi8BUjtBsBHy0zrZjCYsQ=`
is signed `Hello World!` message by owner of BTC address 1HCfFoucNXgYLvpcN2X4TwmUXJjGUMJ2hi we run:
```bash
verifymessage -c BTC -a 1HCfFoucNXgYLvpcN2X4TwmUXJjGUMJ2hi -m "Hello World!" -s H7Ul0s8Za640duU2MhsifCX1H3Ma2NKRtLvtLYye6mFpZTW0fgXbM//bXq1yeXLHphXi8BUjtBsBHy0zrZjCYsQ=
```
### Supported coins
| Coin | Symbol | Address generation | P2PKH transactions | P2SH transactions |
| --- | --- | --- | --- | --- |
| Bitcoin | BTC | Yes | Yes | Yes |
| BitcoinZ | BTCZ | Yes | Yes | Yes |
| Dash | DASH | Yes | Yes | Yes |
| Dogecoin | DOGE | Yes | No | No |
| Litecoin | LTC | Yes | Yes | Yes |
| Safecoin | SAFE | Yes | Yes | Yes |
| TENT | TENT | Yes | Yes | Yes |
| Smartcash | SMART | Yes | No | No |
| Zcash | ZEC | Yes | Yes | Yes |
| Zclassic | ZCL | Yes | Yes | Yes |
| Zeitcoin | ZEIT | Yes | No | No |
| Horizen | ZEN | Yes | Yes | Yes |
| Zero | ZERO | Yes | Yes | Yes |
## Tests
Install pytest, pytest-cov and tox packages:
```bash
pip install -r requirements_dev.txt
```
Run tests and check report htmlcov/index.html:
```bash
python -m pytest --cov=./ --cov-report=html
```
## Adding new coin
1. Add new entry in `settings.py`. Prefix bytes are usually defined in chainparams.cpp or
base58.h files.
Exemplary for Zen we have:
```bash
'ZEN': {
'name': 'zen cash',
'address_prefix_bytes': b'\x20\x89',
'secret_prefix_bytes': b'\x80',
'script_prefix_bytes': b'\x1c\xbd',
'params': {'check_block_at_height': True},
'apis': [
{'url': 'https://explorer.zensystem.io/insight-api-zen'}
]
}
```
2. Update this readme with new supported coin and add appropriate tests
3. Create pull request
Raw data
{
"_id": null,
"home_page": "https://github.com/tompin/multicrypto",
"name": "multicrypto",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "cryptocurrency,address,transaction",
"author": "tompin",
"author_email": "tompin@tuta.io",
"download_url": "https://files.pythonhosted.org/packages/35/50/c1d69f92fe7ccbf7518bd724eba22e81409884f1c63ef732b3606abd2797/multicrypto-0.1.17.tar.gz",
"platform": null,
"description": "# README\n\n[![Build Status](https://app.travis-ci.com/tompin/multicrypto.svg?branch=master)](https://app.travis-ci.com/github/tompin/multicrypto)\n[![Coverage Status](https://coveralls.io/repos/github/tompin/multicrypto/badge.svg?branch=master)](https://coveralls.io/github/tompin/multicrypto?branch=master)\n[![Latest Version](https://img.shields.io/pypi/v/multicrypto.svg)](https://pypi.python.org/pypi/multicrypto/)\n[![Python Version](https://img.shields.io/pypi/pyversions/multicrypto.svg)](https://www.python.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\nHighly experimental, pure python tool for cryptocurrencies.\nPlease notice that coins could change their protocols so make sure the coin parameters are not outdated. \n\n## INSTALLATION\n\n### Additional packages needed on Ubuntu\n```bash\nsudo apt-get install build-essential python3-setuptools python3-wheel python3-dev python3-pip\n```\n\nIf you don't have Python 3, install it by following instructions from python.org. \nSupported Python versions are 3.8, 3.9, 3.10, 3.11, 3.12. Then run (using pip for python 3) :\n```bash\npip install multicrypto\n```\n\nThe package contains below commands:\n 1. `sweepaddress` - combines many inputs into one\n 2. `sendcrypto` - creates raw transaction and send it to insight explorer api\n 3. `checkaddress` - checks address balance using insight explorer api\n 4. `transaddress` - translates address to different coin format (resulting address will have the same private key) \n 5. `transprivkey` - translates WIF private key to different coin format\n 6. `genaddress` - generates vanity address for given coin\n 7. `signmessage`- signs message using ECDSA\n 8. `verifymessage` - verify ECDSA signed message \n\n## USAGE\nBefore running any commands it is advised to disable shell history. For example on linux it should \nbe enough to run:\n```bash\nunset HISTFILE\n```\n### Run\n1. Combining many small inputs to larger ones.\n```bash\nsweepaddress --coin_symbol=<COIN SYMBOL> --address=<ADDRESS> --private_key=<PRIVATE KEY> --minimum_input_threshold=<INT> --maximum_input_threshold=<INT>\n```\nAfter mining some currency for longer period we could end up with address having a lot of small inputs. \nIn such case it is very likely it will be not possible to send the funds in one transaction and it could \nbe difficult to cope with. Let say for Zen Cash we have private key of the address which inputs \nwe want to combine, but we want only combine inputs which are smaller than 0.1 ZEN:\n```bash\nsweepaddress -c ZEN -p KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp --maximum_input_threshold==10000000\n```\nThis will create appropriate number of transactions (by default one transaction for each 200 inputs, you can \noverride this value by setting parameter --batch_size, but setting it too high will result in too big transaction error),\ntransaction fee will be set to default 0.00001 ZEN (you can override it using --fee parameter) and the\nfunds will be sent back to original address (you can override the output address using --address parameter).\n2. Sending funds:\n```bash\nsendcrypto --coin_symbol=<COIN_SYMBOL> --satoshis=<INT> --address=<ADDRESS> --private_key=<PRIVATE KEY> --minimum_input_threshold=<INT> --maximum_input_threshold=<INT>\n```\nSending (P2PKH) 0.25 BTC to address 1BTC1NNjeiAmFqe2n1QJjkEa4aMyAhkpKG with default fee 10000 satoshis\nand only using inputs containing not more than 100000 satoshis:\n```bash\nsendcrypto -c BTC -s 25000000 -x 100000 -a 1BTC1NNjeiAmFqe2n1QJjkEa4aMyAhkpKG -p KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp\n```\nSending (P2PSH) 0.0019 BTC on testnet to address 2NDN55zZ6BtStckQWnhGJejBdM5EaGcNn7h with fee 5000 satoshis\n(notice that both input address 2NAMu8JCTLXtTv2LRQktByt1EoKaJaVmDAj and unlocking script 5106519351935387\nmust be provided):\n```bash\nsendcrypto -a 2NDN55zZ6BtStckQWnhGJejBdM5EaGcNn7h -c TBTC -i 2NAMu8JCTLXtTv2LRQktByt1EoKaJaVmDAj -u 5106519351935387 -s 190000 -f 5000\n```\n3. Listing address inputs with total amount:\n```bash\ncheckaddress --coin_symbol=<COIN SYMBOL> --address=<ADDRESS> --minimum_input_threshold=<INT> --maximum_input_threshold=<INT>\n``` \nFor example:\n```bash\ncheckaddress -c BTC -a 14YK4mzJGo5NKkNnmVJeuEAQftLt795Gec\n```\n4. Translating address between coins:\n```bash\ntransaddress --address=<ADDRESS> --input_symbol=<COIN SYMBOL> --output_symbol=<COIN SYMBOL>\n```\nFor example to translate Bitcoin address 1BTC1NNjeiAmFqe2n1QJjkEa4aMyAhkpKG to Zcash address we enter:\n```bash\ntransaddress -a 1BTC1NNjeiAmFqe2n1QJjkEa4aMyAhkpKG -i BTC -o ZEC\n```\n5. Translating private key in wif format between coins\n```bash\ntransprivkey --private_key=<PRIVATE_KEY> --output_symbol=<COIN SYMBOL>\n```\nFor example to translate Bitcoin private key KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp\nto Zcash private key we enter:\n```bash\ntransprivkey -p KwDiDMtpksBAcfyHsVS5XzmirtyjKWSeaeM9U1QppugixMUeKMqp -o ZEC\n```\n6. Generating address with given pattern and corresponding private key:\n```bash\ngenaddress --pattern=<PATTERN> --symbol=<COIN SYMBOL> --output_dir=<DIRECTORY TO STORE QR CODES>\n```\nFor example if we want to create address with prefix t1aaaa for Zcash coin and save corresponding\nQR codes to /home/john directory we enter:\n```bash\ngenaddress -p t1aaaa -s ZEC -d /home/john\n```\nTo generate Bitcoin segwit address starting with 3BTC we enter:\n```bash\ngenaddress -p 3BTC -s BTC -w\n```\n7. Signing message proving ownership of an address:\n```bash\nsignmessage --coin_symbol=<COIN SYMBOL> --private_key=<PRIVATE KEY> --message=<MESSAGE TO SIGN>\n```\nFor example proving ownership of BTC address 1HCfFoucNXgYLvpcN2X4TwmUXJjGUMJ2hi:\n```bash\nsignmessage -c BTC -p KzReaUKzSaGarrhFhjNMweTrpUx4gqX1KCMFSWJx9374kYNHpmSu -m \"Hello World!\"\n```\nwill return: `H7Ul0s8Za640duU2MhsifCX1H3Ma2NKRtLvtLYye6mFpZTW0fgXbM//bXq1yeXLHphXi8BUjtBsBHy0zrZjCYsQ=`\n\n8. Verifying if signed message was created using private key of given address:\n```bash\nverifymessage --coin_symbol=<COIN SYMBOL> --address=<ADDRESS> --message=<MESSAGE> --signed_message=<SIGNED MESSAGE>\n```\nFor example verifying if `H7Ul0s8Za640duU2MhsifCX1H3Ma2NKRtLvtLYye6mFpZTW0fgXbM//bXq1yeXLHphXi8BUjtBsBHy0zrZjCYsQ=`\nis signed `Hello World!` message by owner of BTC address 1HCfFoucNXgYLvpcN2X4TwmUXJjGUMJ2hi we run:\n```bash\nverifymessage -c BTC -a 1HCfFoucNXgYLvpcN2X4TwmUXJjGUMJ2hi -m \"Hello World!\" -s H7Ul0s8Za640duU2MhsifCX1H3Ma2NKRtLvtLYye6mFpZTW0fgXbM//bXq1yeXLHphXi8BUjtBsBHy0zrZjCYsQ=\n```\n\n### Supported coins\n| Coin | Symbol | Address generation | P2PKH transactions | P2SH transactions |\n| --- | --- | --- | --- | --- |\n| Bitcoin | BTC | Yes | Yes | Yes |\n| BitcoinZ | BTCZ | Yes | Yes | Yes |\n| Dash | DASH | Yes | Yes | Yes |\n| Dogecoin | DOGE | Yes | No | No |\n| Litecoin | LTC | Yes | Yes | Yes |\n| Safecoin | SAFE | Yes | Yes | Yes |\n| TENT | TENT | Yes | Yes | Yes |\n| Smartcash | SMART | Yes | No | No |\n| Zcash | ZEC | Yes | Yes | Yes |\n| Zclassic | ZCL | Yes | Yes | Yes |\n| Zeitcoin | ZEIT | Yes | No | No |\n| Horizen | ZEN | Yes | Yes | Yes |\n| Zero | ZERO | Yes | Yes | Yes |\n\n## Tests\nInstall pytest, pytest-cov and tox packages:\n```bash\npip install -r requirements_dev.txt\n```\nRun tests and check report htmlcov/index.html:\n```bash\npython -m pytest --cov=./ --cov-report=html\n```\n\n## Adding new coin\n1. Add new entry in `settings.py`. Prefix bytes are usually defined in chainparams.cpp or \nbase58.h files. \n\nExemplary for Zen we have:\n```bash\n'ZEN': {\n 'name': 'zen cash',\n 'address_prefix_bytes': b'\\x20\\x89',\n 'secret_prefix_bytes': b'\\x80',\n 'script_prefix_bytes': b'\\x1c\\xbd',\n 'params': {'check_block_at_height': True},\n 'apis': [\n {'url': 'https://explorer.zensystem.io/insight-api-zen'}\n ]\n}\n```\n2. Update this readme with new supported coin and add appropriate tests\n3. Create pull request\n",
"bugtrack_url": null,
"license": "http://opensource.org/licenses/MIT",
"summary": "Tool for translating and creating custom addresses for various cryptocurrencies",
"version": "0.1.17",
"project_urls": {
"Homepage": "https://github.com/tompin/multicrypto"
},
"split_keywords": [
"cryptocurrency",
"address",
"transaction"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3550c1d69f92fe7ccbf7518bd724eba22e81409884f1c63ef732b3606abd2797",
"md5": "ed67307faa92d84fd22ef23a144f5274",
"sha256": "3afdd165ff39e9c5cd9670123f7f77484854c9370c32ec777895fb0fba9741c7"
},
"downloads": -1,
"filename": "multicrypto-0.1.17.tar.gz",
"has_sig": false,
"md5_digest": "ed67307faa92d84fd22ef23a144f5274",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 40144,
"upload_time": "2023-05-03T13:51:42",
"upload_time_iso_8601": "2023-05-03T13:51:42.360986Z",
"url": "https://files.pythonhosted.org/packages/35/50/c1d69f92fe7ccbf7518bd724eba22e81409884f1c63ef732b3606abd2797/multicrypto-0.1.17.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-03 13:51:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tompin",
"github_project": "multicrypto",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"requirements": [],
"tox": true,
"lcname": "multicrypto"
}