mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
Removed 'version' from HDNodeType & fixed unit tests
This commit is contained in:
parent
60e23c38d3
commit
e19c8881c0
@ -6,23 +6,23 @@ class TestMsgGetpublic_key(common.TrezorTest):
|
||||
|
||||
def test_btc(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Bitcoin', []) ), 'xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Bitcoin', [1]) ), 'xpub68zNxjsTrV8y9AadThLW7dTAqEpZ7xBLFSyJ3X9pjTv6Njg6kxgjXJkzxq8u3ttnjBw1jupQHMP3gpGZzZqd1eh5S4GjkaMhPR18vMyUi8N')
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Bitcoin', [0, -1]) ), 'xpub6A3FoZqYXj1AbW4thRwBh26YwZWbmoyjTaZwwxJjY1oKUpefLepL3RFS9DHKQrjAfxDrzDepYMDZPqXN6upQm3bHQ9xaXD5a3mqni3goF4v')
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Bitcoin', [-9, 0]) ), 'xpub6A2h5mzLDfYginoD7q7wCWbq18wTbN9gducRr2w5NRTwdLeoT3cJSwefFqW7uXTpVFGtpUyDMBNYs3DNvvXx6NPjF9YEbUQrtxFSWnPtVrv')
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Bitcoin', [0, 9999999]) ), 'xpub6A3FoZqQEK6iwLZ4HFkqSo5fb35BH4bpjC4SPZ63prfLdGYPwYxEuC6o91bUvFFdMzKWe5rs3axHRUjxJaSvBnKKFtnfLwDACRxPxabsv2r')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([]), 0x0488B21E), 'xpub661MyMwAqRbcF1zGijBb2K6x9YiJPh58xpcCeLvTxMX6spkY3PcpJ4ABcCyWfskq5DDxM3e6Ez5ePCqG5bnPUXR4wL8TZWyoDaUdiWW7bKy')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([1]), 0x0488B21E), 'xpub68zNxjsTrV8y9AadThLW7dTAqEpZ7xBLFSyJ3X9pjTv6Njg6kxgjXJkzxq8u3ttnjBw1jupQHMP3gpGZzZqd1eh5S4GjkaMhPR18vMyUi8N')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]), 0x0488B21E), 'xpub6A3FoZqYXj1AbW4thRwBh26YwZWbmoyjTaZwwxJjY1oKUpefLepL3RFS9DHKQrjAfxDrzDepYMDZPqXN6upQm3bHQ9xaXD5a3mqni3goF4v')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]), 0x0488B21E), 'xpub6A2h5mzLDfYginoD7q7wCWbq18wTbN9gducRr2w5NRTwdLeoT3cJSwefFqW7uXTpVFGtpUyDMBNYs3DNvvXx6NPjF9YEbUQrtxFSWnPtVrv')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]), 0x0488B21E), 'xpub6A3FoZqQEK6iwLZ4HFkqSo5fb35BH4bpjC4SPZ63prfLdGYPwYxEuC6o91bUvFFdMzKWe5rs3axHRUjxJaSvBnKKFtnfLwDACRxPxabsv2r')
|
||||
|
||||
def test_ltc(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Litecoin', []) ), 'Ltub2SSUS19CirucVPGDKDBatBDBEM2s9UbH66pBURfaKrMocCPLhQ7Z7hecy5VYLHA5fRdXwB2e61j2VJCNzVsqKTCVEU1vECjqi5EyczFX9xp')
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Litecoin', [1]) ), 'Ltub2VRVRP5VjvSyPXra4BLVyVZPv397sjhUNjBGsbtw6xko77JuQyBULxFSKheviJJ3KQLbL3Cx8P2RnudguTw4raUVjCACRG7jsumUptYx55C')
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Litecoin', [0, -1]) ), 'Ltub2WUNGD3aRAKAqsLqHuwBYtCn2MqAXbVsarmvn33quWe2DCHTzfK4s4jsW5oM5G8RGAdSaM3NPNrwVvtV1ourbyNhhHr3BtqcYGc8caf5GoT')
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Litecoin', [-9, 0]) ), 'Ltub2WToYRCN76rgyA59iK7w4Ni45wG2M9fpmBpQg7gBjvJeMiHc7473Gb96ci29Zvs55TgUQcMmCD1vy8aVqpdPwJB9YHRhGAAuPT1nRLLXmFu')
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Litecoin', [0, 9999999]) ), 'Ltub2WUNGD3S7kQjBhpzsjkqJfBtfqPk2r7xrUGRDdqACMW3MeBCbZSyiqbEVt7WaeesxCj6EDFQtcbfXa75DUYN2i6jZ2g81cyCgvijs9J2u2n')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([]), 0x019dA462), 'Ltub2SSUS19CirucVPGDKDBatBDBEM2s9UbH66pBURfaKrMocCPLhQ7Z7hecy5VYLHA5fRdXwB2e61j2VJCNzVsqKTCVEU1vECjqi5EyczFX9xp')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([1]), 0x019dA462), 'Ltub2VRVRP5VjvSyPXra4BLVyVZPv397sjhUNjBGsbtw6xko77JuQyBULxFSKheviJJ3KQLbL3Cx8P2RnudguTw4raUVjCACRG7jsumUptYx55C')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([0, -1]), 0x019dA462), 'Ltub2WUNGD3aRAKAqsLqHuwBYtCn2MqAXbVsarmvn33quWe2DCHTzfK4s4jsW5oM5G8RGAdSaM3NPNrwVvtV1ourbyNhhHr3BtqcYGc8caf5GoT')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([-9, 0]), 0x019dA462), 'Ltub2WToYRCN76rgyA59iK7w4Ni45wG2M9fpmBpQg7gBjvJeMiHc7473Gb96ci29Zvs55TgUQcMmCD1vy8aVqpdPwJB9YHRhGAAuPT1nRLLXmFu')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([0, 9999999]), 0x019dA462), 'Ltub2WUNGD3S7kQjBhpzsjkqJfBtfqPk2r7xrUGRDdqACMW3MeBCbZSyiqbEVt7WaeesxCj6EDFQtcbfXa75DUYN2i6jZ2g81cyCgvijs9J2u2n')
|
||||
|
||||
def test_tbtc(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
self.assertEqual(bip32.serialize( self.client.get_public_node('Testnet', [111, 42]) ), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz')
|
||||
self.assertEqual(bip32.serialize(self.client.get_public_node([111, 42]), 0x043587CF), 'tpubDAgixSyai5PWbc8N1mBkHDR5nLgAnHFtY7r4y5EzxqAxrt9YUDpZL3kaRoHVvCfrcwNo31c2isBP2uTHcZxEosuKbyJhCAbrvGoPuLUZ7Mz')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -91,9 +91,9 @@ def get_subnode(node, i):
|
||||
|
||||
return node_out
|
||||
|
||||
def serialize(node):
|
||||
def serialize(node, version=0x0488B21E):
|
||||
s = ''
|
||||
s += struct.pack('>I', node.version)
|
||||
s += struct.pack('>I', version)
|
||||
s += struct.pack('>B', node.depth)
|
||||
s += struct.pack('>I', node.fingerprint)
|
||||
s += struct.pack('>I', node.child_num)
|
||||
|
@ -323,9 +323,9 @@ class ProtocolMixin(object):
|
||||
|
||||
@field('node')
|
||||
@expect(proto.PublicKey)
|
||||
def get_public_node(self, coin_name, n):
|
||||
def get_public_node(self, n):
|
||||
n = self._convert_prime(n)
|
||||
return self.call(proto.GetPublicKey(address_n=n, coin_name=coin_name))
|
||||
return self.call(proto.GetPublicKey(address_n=n))
|
||||
|
||||
@field('address')
|
||||
@expect(proto.Address)
|
||||
@ -538,7 +538,6 @@ class ProtocolMixin(object):
|
||||
# privkey 00e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35
|
||||
# checksum e77e9d71
|
||||
|
||||
node.version = int(data[0:8], 16)
|
||||
node.depth = int(data[8:10], 16)
|
||||
node.fingerprint = int(data[10:18], 16)
|
||||
node.child_num = int(data[18:26], 16)
|
||||
|
Loading…
Reference in New Issue
Block a user