Exemplo n.º 1
0
        def test_derive_wallet(self):
            for i, (public_adr, private_key) in enumerate(_EXPECTED):
                account = account_from_seedphrase(_SEEDPHRASE, i)
                private_key = binascii.a2b_hex(private_key[2:])

                self.assertEqual(account.address, public_adr)
                self.assertEqual(account.privateKey, private_key)
Exemplo n.º 2
0
        def on_button2_2(_):
            self.output_account = account_from_seedphrase(
                self.input_seedphrase, index=0)
            self.output_ethadr = web3.Web3.toChecksumAddress(
                self.output_account.address)
            self.output_ethadr_raw = binascii.a2b_hex(self.output_ethadr[2:])

            # https://eth-account.readthedocs.io/en/latest/eth_account.signers.html#eth_account.signers.local.LocalAccount.key
            self.profile.ethkey = bytes(self.output_account.key)
            self.profile.cskey = bytes(self.session._cskey_raw)

            # set user eth key on client session
            self.session.set_ethkey_from_profile(self.profile)

            # save user config
            self.config.profiles[self.profile_name] = self.profile
            self.config.save(self.input_password)

            self.log.info(
                'XBR ETH key at address {ethadr} set from seed phrase (BIP39 account 0): "{seedphrase}"',
                ethadr=self.output_ethadr,
                seedphrase=self.input_seedphrase)

            member_data = yield self.session.get_member(self.output_ethadr_raw)
            pprint(member_data)
            if not member_data:
                self.log.info('ethadr {output_ethadr} is NOT yet a member',
                              output_ethadr=self.output_ethadr)
                self.set_current_page(2)
            else:
                self.log.info(
                    'ok, ethadr {output_ethadr} already is a member: {member_data}',
                    output_ethadr=self.output_ethadr,
                    member_data=member_data)

                self.profile.member_oid = uuid.UUID(
                    bytes=member_data['member_oid'])
                self.profile.member_adr = self.output_ethadr
                self.profile.email = member_data['email']
                self.profile.username = member_data['username']

                # save user config
                self.config.profiles[self.profile_name] = self.profile
                self.config.save(self.input_password)

                self.output_member_data = member_data
                self._label2.set_label(str(self._member_data['oid']))
                self.set_current_page(4)
Exemplo n.º 3
0
import os
import sys
import binascii

import txaio
txaio.use_twisted()

from autobahn.xbr import account_from_seedphrase


seedphrase = os.environ['XBR_HDWALLET_SEED']
account_idx = int(sys.argv[1])
keyfile = os.path.abspath(sys.argv[2])

account = account_from_seedphrase(seedphrase, account_idx)
adr = account.address
pkey_hex = binascii.b2a_hex(account.privateKey).decode()

print('Using account {} with address {} computed from wallet seedphrase "{}.."'.format(account_idx, adr, seedphrase[:12]))

with open(keyfile, 'wb') as f:
    f.write(account.privateKey)

print('Success! Private key written to file "{}".'.format(keyfile))
Exemplo n.º 4
0
import txaio
txaio.use_twisted()

from autobahn import xbr
import argparse

from autobahn.xbr import generate_seedphrase, check_seedphrase, account_from_seedphrase

if 'XBR_HDWALLET_SEED' not in os.environ:
    raise RuntimeError('XBR_HDWALLET_SEED not set!')
_XBR_HDWALLET_SEED = os.environ['XBR_HDWALLET_SEED']

ACCOUNTS = []
for i in range(20):
    account = account_from_seedphrase(_XBR_HDWALLET_SEED, i)
    ACCOUNTS.append(account)


def _print_balances(w3):
    owner_address = w3.eth.accounts[0]

    print('-' * 120)
    print('Current balances of executing (owner) account:\n')
    balance_eth = w3.eth.getBalance(owner_address)
    balance_xbr = xbr.xbrtoken.functions.balanceOf(owner_address).call()
    balance_eth = float(balance_eth / 10**18)
    balance_xbr = float(balance_xbr / 10**18)
    print('    {:>20}: {:>30} ETH {:>30} XBR'.format(owner_address,
                                                     balance_eth, balance_xbr))