Skip to content

Commit 0c254fc

Browse files
committed
feat(hive): add Hive blockchain support
- messages_hive_pb2.py — generated from messages-hive.proto (IDs 1600-1603) - hive.py — get_public_key / sign_tx client helpers - mapping.py — register HiveGetPublicKey, HivePublicKey, HiveSignTx, HiveSignedTx wire IDs - client.py — hive_get_public_key / hive_sign_tx methods on ProtocolMixin
1 parent 297cba3 commit 0c254fc

4 files changed

Lines changed: 96 additions & 1 deletion

File tree

keepkeylib/client.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from . import messages_tron_pb2 as tron_proto
5050
from . import messages_ton_pb2 as ton_proto
5151
from . import messages_zcash_pb2 as zcash_proto
52+
from . import messages_hive_pb2 as hive_proto
5253
from . import types_pb2 as types
5354
from . import eos
5455
from . import nano
@@ -1852,6 +1853,30 @@ def zcash_sign_pczt(self, address_n, actions, account=None,
18521853

18531854
return resp
18541855

1856+
# ── Hive ────────────────────────────────────────────────────
1857+
@expect(hive_proto.HivePublicKey)
1858+
def hive_get_public_key(self, address_n, show_display=False):
1859+
return self.call(
1860+
hive_proto.HiveGetPublicKey(address_n=address_n, show_display=show_display)
1861+
)
1862+
1863+
@expect(hive_proto.HiveSignedTx)
1864+
def hive_sign_tx(self, address_n, chain_id, ref_block_num, ref_block_prefix,
1865+
expiration, sender, recipient, amount, decimals, asset_symbol, memo=''):
1866+
return self.call(hive_proto.HiveSignTx(**{
1867+
'address_n': address_n,
1868+
'chain_id': chain_id,
1869+
'ref_block_num': ref_block_num,
1870+
'ref_block_prefix': ref_block_prefix,
1871+
'expiration': expiration,
1872+
'from': sender,
1873+
'to': recipient,
1874+
'amount': amount,
1875+
'decimals': decimals,
1876+
'asset_symbol': asset_symbol,
1877+
'memo': memo,
1878+
}))
1879+
18551880
class KeepKeyClient(ProtocolMixin, TextUIMixin, BaseClient):
18561881
pass
18571882

keepkeylib/hive.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from . import messages_hive_pb2 as proto
2+
3+
4+
def get_public_key(client, address_n, show_display=False):
5+
return client.call(
6+
proto.HiveGetPublicKey(address_n=address_n, show_display=show_display)
7+
)
8+
9+
10+
def sign_tx(client, address_n, chain_id, ref_block_num, ref_block_prefix,
11+
expiration, sender, recipient, amount, decimals, asset_symbol, memo=''):
12+
# 'from' is a Python keyword so use **-unpacking to set the field
13+
return client.call(proto.HiveSignTx(**{
14+
'address_n': address_n,
15+
'chain_id': chain_id,
16+
'ref_block_num': ref_block_num,
17+
'ref_block_prefix': ref_block_prefix,
18+
'expiration': expiration,
19+
'from': sender,
20+
'to': recipient,
21+
'amount': amount,
22+
'decimals': decimals,
23+
'asset_symbol': asset_symbol,
24+
'memo': memo,
25+
}))

keepkeylib/mapping.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from . import messages_tron_pb2 as tron_proto
1414
from . import messages_ton_pb2 as ton_proto
1515
from . import messages_zcash_pb2 as zcash_proto
16+
from . import messages_hive_pb2 as hive_proto
1617

1718
map_type_to_class = {}
1819
map_class_to_type = {}
@@ -97,4 +98,17 @@ def check_missing():
9798
map_type_to_class[wire_id] = msg_class
9899
map_class_to_type[msg_class] = wire_id
99100

100-
# check_missing() — skip: Zcash types are not in old messages_pb2 enum
101+
# Manually register Hive messages (not in the old messages_pb2.py enum)
102+
_hive_wire_ids = {
103+
1600: ('HiveGetPublicKey', hive_proto),
104+
1601: ('HivePublicKey', hive_proto),
105+
1602: ('HiveSignTx', hive_proto),
106+
1603: ('HiveSignedTx', hive_proto),
107+
}
108+
for wire_id, (msg_name, mod) in _hive_wire_ids.items():
109+
msg_class = getattr(mod, msg_name, None)
110+
if msg_class is not None:
111+
map_type_to_class[wire_id] = msg_class
112+
map_class_to_type[msg_class] = wire_id
113+
114+
# check_missing() — skip: Zcash/Hive types are not in old messages_pb2 enum

keepkeylib/messages_hive_pb2.py

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

0 commit comments

Comments
 (0)