示例#1
0
def Create_wallet_file():
    # create the clinet object
    devices = Wait_for_devices()
    transport = Choose_device(devices)
    client = TrezorClient(transport)
    
    
    # Label your wallet, something like 'lumen'.
    print('Please provide label for new drive: ')
    label = input()
    
    print('Computer asked TREZOR for new strong password.\n')
    print('Please confirm action on your device.\n')
    trezor_entropy = client.get_entropy(32)
    urandom_entropy = os.urandom(32)
    passw = hashlib.sha256(trezor_entropy + urandom_entropy).digest()
    
    if len(passw) != 32:
        raise Exception("32 bytes password expected")
        
    bip32_path = [10, 0]
    passw_encrypted = client.encrypt_keyvalue(bip32_path, label, passw, False, True)

    wallet_info = {'label': label,
            'bip32_path': bip32_path,
            'password_encrypted_hex': binascii.hexlify(passw_encrypted).decode(),
            'Address':Keypair.from_raw_seed(passw).address().decode()}
    
    #Store the wallet Information
    with open('Stellar_wallet.json', 'w') as fp:
        json.dump(wallet_info, fp)
        
    print('Please disconnect your Trezor hardware wallet.')
示例#2
0
def Trezor_Access():
    '''Asking access to the Trezor wallet and generate the stellar keypair.'''
    
    devices = Wait_for_devices()
    transport = Choose_device(devices)
    client = TrezorClient(transport)
    
    data = Get_data()
    
    print('Please confirm action on your device.\n')
    passw = client.decrypt_keyvalue(data['bip32_path'],
                                    data['label'],
                                    binascii.unhexlify(data['password_encrypted_hex'].encode()),
                                    False, True)
    
    kp = Keypair.from_raw_seed(passw)
    return kp
示例#3
0
 def get_kp(self):
     return Keypair.from_raw_seed(sha256(self.seed).digest())
def account_keypair(seed, account_number):
    """Return the account keypair for a 64-byte binary seed and account_number."""
    from stellar_base.keypair import Keypair
    acc_seed = derive_along_path(ACCOUNT_PATH_FORMAT % account_number, seed)
    return Keypair.from_raw_seed(acc_seed)