Exemplo n.º 1
0
    def test_register_btc_wallet(self):
        result = create_hd_wallet(
            "blockcypher-testsuite-btc",
            "xpub661MyMwAqRbcGHGJXmM5jX85xJtNmjLgyzs7LpCwBnpfK8SF7TktReXmEt2NzuDhi4NCRanpCRynoewDE6Psuptz7gDW1Uxbfsf56GEfmgo",
            coin_symbol='btc',
            api_key=BC_API_KEY)
        wallets = list_wallet_names(api_key=BC_API_KEY)['wallet_names']
        self.assertIn('blockcypher-testsuite-btc', wallets)
        derivation_response = derive_hd_address(
            api_key=BC_API_KEY,
            wallet_name="blockcypher-testsuite-btc",
            num_addresses=1,
            subchain_index=0,
            coin_symbol="btc",
        )
        list_addresses = [
            "14a2zs9YhAxEo3xworxiJML47STab1LZMe",
            "18ZNuW7HEdMrM7ASfDESN7r5mTBHPPEjyo"
        ]
        self.assertIn(
            derivation_response['chains'][0]['chain_addresses'][0]['address'],
            list_addresses)

        delete_wallet('blockcypher-testsuite-btc',
                      coin_symbol='btc',
                      api_key=BC_API_KEY,
                      is_hd_wallet=True)
Exemplo n.º 2
0
    def create_address(self):
        chain = blockcypher.derive_hd_address(
            api_key=self.api,
            wallet_name=self.wallet_name,
            coin_symbol=coin_symbol_from_mkey(self.xpubkey))
        address = chain["chains"][0]["chain_addresses"][0]["address"]

        return address
Exemplo n.º 3
0
def register_unused_addresses(wallet_obj, subchain_index, num_addrs=1):
    '''
    Hit /derive to register new unused_addresses on a subchain_index and verify them client-side

    Returns a list of dicts of the following form:
        [
            {'address': '1abc123...', 'path': 'm/0/9', 'public': '0123456...'},
            ...,
        ]
    '''

    verbose_print('register_unused_addresses called on subchain %s for %s addrs' % (
        subchain_index,
        num_addrs,
        ))

    assert type(subchain_index) is int, subchain_index
    assert type(num_addrs) is int, num_addrs
    assert num_addrs > 0

    mpub = wallet_obj.serialize_b58(private=False)
    coin_symbol = coin_symbol_from_mkey(mpub)
    wallet_name = get_blockcypher_walletname_from_mpub(
            mpub=mpub,
            subchain_indices=[0, 1],
            )
    network = guess_network_from_mkey(mpub)

    # register new address(es)
    derivation_response = derive_hd_address(
            api_key=BLOCKCYPHER_API_KEY,
            wallet_name=wallet_name,
            num_addresses=num_addrs,
            subchain_index=subchain_index,
            coin_symbol=coin_symbol,
            )

    verbose_print('derivation_response:')
    verbose_print(derivation_response)

    address_paths = derivation_response['chains'][0]['chain_addresses']

    # verify new addresses client-side
    full_address_paths = verify_and_fill_address_paths_from_bip32key(
            address_paths=address_paths,
            master_key=mpub,
            network=network,
            )

    return full_address_paths
Exemplo n.º 4
0
 def deriveAddress(self):
     address = derive_hd_address(api_key=blockcypher_key, wallet_name='testnet', coin_symbol='btc')
     return address['chains'][0]['chain_addresses'][0]['address']