How to use blockcypher - 10 common examples

To help you get started, we’ve selected a few blockcypher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blockcypher / blockcypher-python / test_blockcypher.py View on Github external
def test_invalid_hash(self):
        assert not is_valid_hash(self.invalid_hash), self.invalid_hash
github blockcypher / blockcypher-python / test_blockcypher.py View on Github external
def test_valid_hash(self):
        assert is_valid_hash(self.valid_hash), self.valid_hash
github blockcypher / blockcypher-python / test_blockcypher.py View on Github external
def test_generate_single_addr(self):
        for coin_symbol in ('btc', 'btc-testnet', 'doge', 'dash', 'ltc', 'bcy'):
            response_dict = generate_new_address(
                    coin_symbol=coin_symbol,
                    api_key=BC_API_KEY,
                    )
            assert is_valid_address(response_dict['address']), response_dict
            assert uses_only_hash_chars(response_dict['private']), response_dict
            assert uses_only_hash_chars(response_dict['public']), response_dict
            assert 'wif' in response_dict, response_dict
github blockcypher / blockcypher-python / test_blockcypher.py View on Github external
def test_create_ps2h_unsigned(self):
        # This address I previously sent funds to but threw out the private key
        create_unsigned_tx(
                inputs=[
                    {
                        'pubkeys': [
                            '036f5ca449944655b5c580ff6686bdd19123d1003b41f49f4b603f53e33f70a2d1',
                            '03e93a754aa03dedbe032e5be051bce031db4337c48fbbcf970d1b27bb25a07964',
                            '02582061ab1dba9d6b5b4e6e29f9da2bd590862f1b1e8566f405eb1d92898eafee',
                            ],
                        'script_type': 'multisig-2-of-3'
                        },
                    ],
                outputs=[
                    {
                        'value': -1,
                        'address': 'CFr99841LyMkyX5ZTGepY58rjXJhyNGXHf',
                        },
                    ],
github blockcypher / blockcypher-python / test_blockcypher.py View on Github external
def test_create_basic_unsigned(self):
        # This address I previously sent funds to but threw out the private key
        create_unsigned_tx(
                inputs=[
                    {'address': 'BwvSPyMWVL1gkp5FZdrGXLpHj2ZJyJYLVB'},
                    ],
                outputs=[
                    {
                        'value': -1,
                        # p2sh address for extra measure
                        'address': 'Dbc9fnf1Kqct7zvfNTiwr6HjvDfPYaFSNg',
                        },
                    ],
                change_address=None,
                include_tosigntx=True,
                # will test signature returned locally:
                verify_tosigntx=True,
                coin_symbol='bcy',
                api_key=BC_API_KEY,
github blockcypher / blockcypher-python / test_blockcypher.py View on Github external
def test_create_nulldata_unsigned(self):
        # This address I previously sent funds to but threw out the private key
        create_unsigned_tx(
                inputs=[
                    {'address': 'BwvSPyMWVL1gkp5FZdrGXLpHj2ZJyJYLVB'},
                    ],
                outputs=[
                    # embed some null-data
                    {
                        'value': 0,
                        'script_type': 'null-data',
                        'script': '6a06010203040506',
                        },
                    ],
                change_address='CFr99841LyMkyX5ZTGepY58rjXJhyNGXHf',
                include_tosigntx=True,
                # will test signature returned locally:
                verify_tosigntx=True,
                coin_symbol='bcy',
github blockcypher / blockcypher-python / test_blockcypher.py View on Github external
def test_get_address_details_before(self):
        address_details = get_address_details(
                address='1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1',
                coin_symbol='btc',
                txn_limit=None,
                api_key=BC_API_KEY,
                show_confidence=False,  # don't return confidence info
                # This way the test result never changes:
                before_bh=4,
                )

        # first TX
        assert len(address_details['txrefs']) == 1
        assert address_details['txrefs'][0]['tx_hash'] == '9b0fc92260312ce44e74ef369f5c66bbb85848f2eddd5a7a1cde251e54ccfdd5'
        assert address_details['txrefs'][0]['block_height'] == 2
        assert address_details['txrefs'][0]['confirmed'] is not None
        assert address_details['txrefs'][0]['tx_input_n'] == -1
        assert address_details['txrefs'][0]['tx_output_n'] == 0
github blockcypher / blockcypher-python / test_blockcypher.py View on Github external
def test_fetching_unspents(self):
        # This address I previously sent funds to but threw out the private key
        address_details = get_address_details(
                address='C3B3dU12vpCVh2jfmGFdqLe5KWxtZfXW8j',
                coin_symbol='bcy',
                txn_limit=None,
                api_key=BC_API_KEY,
                unspent_only=True,
                show_confidence=False,  # don't return confidence info
                # This way the test result never changes:
                before_bh=592822,
                include_script=True,
                )
        assert len(address_details['txrefs']) == 1
        assert address_details['txrefs'][0]['tx_hash'] == 'b12c4b0ab466c9bbd05da88b3be1a13229c85a6edd2869e01e6a557c8a5cca2b'
        assert address_details['txrefs'][0]['block_height'] == 592821
        assert address_details['txrefs'][0]['tx_input_n'] == -1
        assert address_details['txrefs'][0]['tx_output_n'] == 0
        assert address_details['txrefs'][0]['value'] == 1000000
github blockcypher / blockcypher-python / test_blockcypher.py View on Github external
def test_get_address_details_after(self):
        address_details = get_address_details(
                address='1HLoD9E4SDFFPDiYfNYnkBLQ85Y51J3Zb1',
                coin_symbol='btc',
                api_key=BC_API_KEY,
                show_confidence=False,  # don't return confidence info
                # Exclude first result
                after_bh=4,
                txn_limit=1,
                )

        assert len(address_details['txrefs']) == 1
        assert address_details['txrefs'][0]['tx_hash'] != '9b0fc92260312ce44e74ef369f5c66bbb85848f2eddd5a7a1cde251e54ccfdd5'
        assert address_details['txrefs'][0]['block_height'] != 2
github blockcypher / bcwallet / bcwallet / bcwallet.py View on Github external
if sys.stdin.isatty():
        wallet = args.wallet
        verbose_print('Wallet imported from args')
    else:
        wallet = sys.stdin.readline().strip()
        sys.stdin = open('/dev/tty')
        verbose_print('Wallet imported from pipe')
    verbose_print('wallet %s' % wallet)

    if args.bc_api_key:
        global BLOCKCYPHER_API_KEY
        BLOCKCYPHER_API_KEY = args.bc_api_key
        verbose_print('API Key: %s' % BLOCKCYPHER_API_KEY)
        # Crude check
        if not uses_only_hash_chars(BLOCKCYPHER_API_KEY):
            puts(colored.red('Invalid API Key: %s\n' % BLOCKCYPHER_API_KEY))
            sys.exit()

    puts("\nWelcome to bcwallet!")

    puts("\nHere's what makes bcwallet unique:")
    with indent(2):
        for bullet_point, description in EXPLAINER_COPY:
            puts('-%s: %s' % (bullet_point, description))
    puts()

    if wallet:
        network = guess_network_from_mkey(wallet)
        if network:
            # check if valid mkey
            try: