forked from keepkey/python-keepkey
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelloworld.py
executable file
·34 lines (25 loc) · 943 Bytes
/
helloworld.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
from __future__ import print_function
from keepkeylib.client import KeepKeyClient
from keepkeylib.transport_webusb import WebUsbTransport
def main():
# List all connected KeepKeys on USB
devices = WebUsbTransport.enumerate()
# Check whether we found any
if len(devices) == 0:
print('No KeepKey found')
return
# Use first connected device
transport = WebUsbTransport(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)
bip32_path = client.expand_path("44'/0'/0'/0/0")
address = client.get_address('Bitcoin', bip32_path)
print('Bitcoin address:', address)
client.close()
if __name__ == '__main__':
main()