def test_btc(self): self.setup_mnemonic_nopin_nopassphrase() self.assertEqual(bip32.serialize(self.client.get_public_node([]).node, 0x0488B21E), 'xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy') self.assertEqual(bip32.serialize(self.client.get_public_node([1]).node, 0x0488B21E), 'xpub68zNxjsTrV8y9AadThLW7dTAqEpZ7xBLFSyJ3X9pjTv6Njg6kxgjXJkzxq8u3ttnjBw1jupQHMP3gpGZzZqd1eh5S4GjkaMhPR18vMyUi8N') self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]).node, 0x0488B21E), 'xpub6A3FoZqYXj1AbW4thRwBh26YwZWbmoyjTaZwwxJjY1oKUpefLepL3RFS9DHKQrjAfxDrzDepYMDZPqXN6upQm3bHQ9xaXD5a3mqni3goF4v') self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]).node, 0x0488B21E), 'xpub6A2h5mzLDfYginoD7q7wCWbq18wTbN9gducRr2w5NRTwdLeoT3cJSwefFqW7uXTpVFGtpUyDMBNYs3DNvvXx6NPjF9YEbUQrtxFSWnPtVrv') self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]).node, 0x0488B21E), 'xpub6A3FoZqQEK6iwLZ4HFkqSo5fb35BH4bpjC4SPZ63prfLdGYPwYxEuC6o91bUvFFdMzKWe5rs3axHRUjxJaSvBnKKFtnfLwDACRxPxabsv2r')
def test_ltc(self): self.setup_mnemonic_nopin_nopassphrase() self.assertEqual(bip32.serialize(self.client.get_public_node([]).node, 0x019dA462), 'Ltub2SSUS19CirucVPGDKDBatBDBEM2s9UbH66pBURfaKrMocCPLhQ7Z7hecy5VYLHA5fRdXwB2e61j2VJCNzVsqKTCVEU1vECjqi5EyczFX9xp') self.assertEqual(bip32.serialize(self.client.get_public_node([1]).node, 0x019dA462), 'Ltub2VRVRP5VjvSyPXra4BLVyVZPv397sjhUNjBGsbtw6xko77JuQyBULxFSKheviJJ3KQLbL3Cx8P2RnudguTw4raUVjCACRG7jsumUptYx55C') self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]).node, 0x019dA462), 'Ltub2WUNGD3aRAKAqsLqHuwBYtCn2MqAXbVsarmvn33quWe2DCHTzfK4s4jsW5oM5G8RGAdSaM3NPNrwVvtV1ourbyNhhHr3BtqcYGc8caf5GoT') self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]).node, 0x019dA462), 'Ltub2WToYRCN76rgyA59iK7w4Ni45wG2M9fpmBpQg7gBjvJeMiHc7473Gb96ci29Zvs55TgUQcMmCD1vy8aVqpdPwJB9YHRhGAAuPT1nRLLXmFu') self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]).node, 0x019dA462), 'Ltub2WUNGD3S7kQjBhpzsjkqJfBtfqPk2r7xrUGRDdqACMW3MeBCbZSyiqbEVt7WaeesxCj6EDFQtcbfXa75DUYN2i6jZ2g81cyCgvijs9J2u2n')
def main(): # List all connected KeepKeys on USB devices = HidTransport.enumerate() # Check whether we found any if len(devices) == 0: print('No KeepKey found') return # Use first connected device transport = HidTransport(devices[0]) # Creates object for manipulating KeepKey client = KeepKeyClient(transport) # Print out KeepKey's features and settings print(client.features) # Get the first address of first BIP44 account # (should be the same address as shown in KeepKey wallet Chrome extension) mpath = "44'/0'/0'/0" bip32_path = client.expand_path(mpath) print bip32.serialize(client.get_public_node(bip32_path).node, 0x043587CF) for i in range(11): child_path = '%s%s' % ("44'/0'/0'/0/", str(i)) address = client.get_address('tDash', client.expand_path(child_path)) print 'tDASH address:', child_path, address client.close()
def test_tbtc(self): self.setup_mnemonic_nopin_nopassphrase() self.assertEqual( bip32.serialize( self.client.get_public_node([111, 42]).node, 0x043587CF), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz' )
def test_tbtc(self): self.setup_mnemonic_nopin_nopassphrase() self.assertEqual(bip32.serialize(self.client.get_public_node([111, 42]).node, 0x043587CF), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz')
def check_hw_wallet(): printdbg('checking hw wallet') #client = None client = None signing = False if TYPE_HW_WALLET.lower().startswith("keepkey"): from keepkeylib.client import KeepKeyClient from keepkeylib.transport_hid import HidTransport import keepkeylib.ckd_public as bip32 try: devices = HidTransport.enumerate() except Exception as e: err_msg = str(e.args) print_err_exit(get_caller_name(), get_function_name(), err_msg) if len(devices) == 0: print('===> No HW Wallet found') signing = False else: try: print('===> keepkey HW Wallet found') transport = HidTransport(devices[0]) client = KeepKeyClient(transport) signing = True except Exception as e: err_msg = str(e.args) print_err_exit(get_caller_name(), get_function_name(), err_msg) elif TYPE_HW_WALLET.lower().startswith("trezor"): from trezorlib.client import TrezorClient from trezorlib.transport_hid import HidTransport import trezorlib.ckd_public as bip32 try: devices = HidTransport.enumerate() except Exception as e: err_msg = str(e.args) print_err_exit(get_caller_name(), get_function_name(), err_msg) if len(devices) == 0: print('===> No HW Wallet found') signing = False else: try: print('===> trezor HW Wallet found') transport = HidTransport(devices[0]) client = TrezorClient(transport) signing = True except Exception as e: err_msg = str(e.args) print_err_exit(get_caller_name(), get_function_name(), err_msg) elif TYPE_HW_WALLET.lower().startswith("ledgernanos"): #from btchip.btchip import * #from btchip.btchipUtils import * try: devices = getDongle(False) except Exception as e: err_msg = str(e.args) print_err_exit(get_caller_name(), get_function_name(), err_msg) if not devices: print('===> No HW Wallet found') signing = False else: try: print('===> Ledger nano s HW Wallet found') client = btchip(devices) signing = True except Exception as e: err_msg = str(e.args) print_err_exit(get_caller_name(), get_function_name(), err_msg) if client is not None: if TYPE_HW_WALLET.lower().startswith("ledgernanos"): pass else: try: wallet_supported_coins = list_coins(client) except Exception as e: err_msg = str(e.args) print_err_exit(get_caller_name(), get_function_name(), err_msg) if coin_name not in wallet_supported_coins: err_msg = 'only following coins supported by wallet\n\t' + \ str(wallet_supported_coins) print_err_exit(get_caller_name(), get_function_name(), err_msg) else: err_msg = "Can't run florijncoinmnb without hw wallet" print_err_exit(get_caller_name(), get_function_name(), err_msg) if TYPE_HW_WALLET.lower().startswith("ledgernanos"): mpath = get_mpath() return client, signing, mpath else: try: mpath = get_mpath() bip32_path = client.expand_path(mpath) xpub = bip32.serialize( client.get_public_node(bip32_path).node, (0x0488B21E if MAINNET else 0x043587CF)) except AssertionError as e: err_msg = str(e.args) print_err_exit(get_caller_name(), get_function_name(), err_msg) except Exception as e: err_msg = str(e.args) print_err_exit(get_caller_name(), get_function_name(), err_msg) except KeyboardInterrupt: print_err_exit(get_caller_name(), get_function_name(), "KeyboardInterrupt") printdbg('check_hw_wallet : signing : %s' % signing) printdbg('check_hw_wallet : xpub[:7] : %s' % xpub[:7]) printdbg('check_hw_wallet : xpub[-7:] : %s' % xpub[-7:]) printdbg('check_hw_wallet : mpath : %s' % mpath) return client, signing, bip32, mpath, xpub