Skip to content

Commit 625f0e9

Browse files
committed
feat(hive): add HiveGetPublicKeys, HiveSignAccountCreate, HiveSignAccountUpdate
- messages_hive_pb2.py: regenerated from updated proto; now includes all 10 message types (HiveGetPublicKey/Keys, HivePublicKey/Keys, HiveSignTx/ed, HiveSignAccountCreate/ed, HiveSignAccountUpdate/ed). Added role field to HiveGetPublicKey. - mapping.py: register wire IDs 1604-1609 for the six new message types. - hive.py: add get_public_keys(), sign_account_create(), sign_account_update() helpers. get_public_key() gains optional role parameter. - client.py: add hive_get_public_keys(), hive_sign_account_create(), hive_sign_account_update() mixin methods with @expect decorators.
1 parent 0c254fc commit 625f0e9

4 files changed

Lines changed: 122 additions & 16 deletions

File tree

keepkeylib/client.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,9 +1855,16 @@ def zcash_sign_pczt(self, address_n, actions, account=None,
18551855

18561856
# ── Hive ────────────────────────────────────────────────────
18571857
@expect(hive_proto.HivePublicKey)
1858-
def hive_get_public_key(self, address_n, show_display=False):
1858+
def hive_get_public_key(self, address_n, show_display=False, role=None):
1859+
kwargs = dict(address_n=address_n, show_display=show_display)
1860+
if role is not None:
1861+
kwargs['role'] = role
1862+
return self.call(hive_proto.HiveGetPublicKey(**kwargs))
1863+
1864+
@expect(hive_proto.HivePublicKeys)
1865+
def hive_get_public_keys(self, account_index=0, show_display=False):
18591866
return self.call(
1860-
hive_proto.HiveGetPublicKey(address_n=address_n, show_display=show_display)
1867+
hive_proto.HiveGetPublicKeys(account_index=account_index, show_display=show_display)
18611868
)
18621869

18631870
@expect(hive_proto.HiveSignedTx)
@@ -1877,6 +1884,43 @@ def hive_sign_tx(self, address_n, chain_id, ref_block_num, ref_block_prefix,
18771884
'memo': memo,
18781885
}))
18791886

1887+
@expect(hive_proto.HiveSignedAccountCreate)
1888+
def hive_sign_account_create(self, address_n, chain_id, ref_block_num, ref_block_prefix,
1889+
expiration, creator, new_account_name, fee_amount=3000,
1890+
owner_key='', active_key='', posting_key='', memo_key=''):
1891+
return self.call(hive_proto.HiveSignAccountCreate(
1892+
address_n=address_n,
1893+
chain_id=chain_id,
1894+
ref_block_num=ref_block_num,
1895+
ref_block_prefix=ref_block_prefix,
1896+
expiration=expiration,
1897+
creator=creator,
1898+
new_account_name=new_account_name,
1899+
fee_amount=fee_amount,
1900+
owner_key=owner_key,
1901+
active_key=active_key,
1902+
posting_key=posting_key,
1903+
memo_key=memo_key,
1904+
))
1905+
1906+
@expect(hive_proto.HiveSignedAccountUpdate)
1907+
def hive_sign_account_update(self, address_n, chain_id, ref_block_num, ref_block_prefix,
1908+
expiration, account,
1909+
new_owner_key='', new_active_key='',
1910+
new_posting_key='', new_memo_key=''):
1911+
return self.call(hive_proto.HiveSignAccountUpdate(
1912+
address_n=address_n,
1913+
chain_id=chain_id,
1914+
ref_block_num=ref_block_num,
1915+
ref_block_prefix=ref_block_prefix,
1916+
expiration=expiration,
1917+
account=account,
1918+
new_owner_key=new_owner_key,
1919+
new_active_key=new_active_key,
1920+
new_posting_key=new_posting_key,
1921+
new_memo_key=new_memo_key,
1922+
))
1923+
18801924
class KeepKeyClient(ProtocolMixin, TextUIMixin, BaseClient):
18811925
pass
18821926

keepkeylib/hive.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
from . import messages_hive_pb2 as proto
22

33

4-
def get_public_key(client, address_n, show_display=False):
4+
def get_public_key(client, address_n, show_display=False, role=None):
5+
kwargs = dict(address_n=address_n, show_display=show_display)
6+
if role is not None:
7+
kwargs['role'] = role
8+
return client.call(proto.HiveGetPublicKey(**kwargs))
9+
10+
11+
def get_public_keys(client, account_index=0, show_display=False):
512
return client.call(
6-
proto.HiveGetPublicKey(address_n=address_n, show_display=show_display)
13+
proto.HiveGetPublicKeys(account_index=account_index, show_display=show_display)
714
)
815

916

@@ -23,3 +30,40 @@ def sign_tx(client, address_n, chain_id, ref_block_num, ref_block_prefix,
2330
'asset_symbol': asset_symbol,
2431
'memo': memo,
2532
}))
33+
34+
35+
def sign_account_create(client, address_n, chain_id, ref_block_num, ref_block_prefix,
36+
expiration, creator, new_account_name, fee_amount=3000,
37+
owner_key='', active_key='', posting_key='', memo_key=''):
38+
return client.call(proto.HiveSignAccountCreate(
39+
address_n=address_n,
40+
chain_id=chain_id,
41+
ref_block_num=ref_block_num,
42+
ref_block_prefix=ref_block_prefix,
43+
expiration=expiration,
44+
creator=creator,
45+
new_account_name=new_account_name,
46+
fee_amount=fee_amount,
47+
owner_key=owner_key,
48+
active_key=active_key,
49+
posting_key=posting_key,
50+
memo_key=memo_key,
51+
))
52+
53+
54+
def sign_account_update(client, address_n, chain_id, ref_block_num, ref_block_prefix,
55+
expiration, account,
56+
new_owner_key='', new_active_key='',
57+
new_posting_key='', new_memo_key=''):
58+
return client.call(proto.HiveSignAccountUpdate(
59+
address_n=address_n,
60+
chain_id=chain_id,
61+
ref_block_num=ref_block_num,
62+
ref_block_prefix=ref_block_prefix,
63+
expiration=expiration,
64+
account=account,
65+
new_owner_key=new_owner_key,
66+
new_active_key=new_active_key,
67+
new_posting_key=new_posting_key,
68+
new_memo_key=new_memo_key,
69+
))

keepkeylib/mapping.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,16 @@ def check_missing():
100100

101101
# Manually register Hive messages (not in the old messages_pb2.py enum)
102102
_hive_wire_ids = {
103-
1600: ('HiveGetPublicKey', hive_proto),
104-
1601: ('HivePublicKey', hive_proto),
105-
1602: ('HiveSignTx', hive_proto),
106-
1603: ('HiveSignedTx', hive_proto),
103+
1600: ('HiveGetPublicKey', hive_proto),
104+
1601: ('HivePublicKey', hive_proto),
105+
1602: ('HiveSignTx', hive_proto),
106+
1603: ('HiveSignedTx', hive_proto),
107+
1604: ('HiveGetPublicKeys', hive_proto),
108+
1605: ('HivePublicKeys', hive_proto),
109+
1606: ('HiveSignAccountCreate', hive_proto),
110+
1607: ('HiveSignedAccountCreate', hive_proto),
111+
1608: ('HiveSignAccountUpdate', hive_proto),
112+
1609: ('HiveSignedAccountUpdate', hive_proto),
107113
}
108114
for wire_id, (msg_name, mod) in _hive_wire_ids.items():
109115
msg_class = getattr(mod, msg_name, None)

keepkeylib/messages_hive_pb2.py

Lines changed: 20 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)