forked from keepkey/python-keepkey
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhive.py
More file actions
69 lines (59 loc) · 2.4 KB
/
Copy pathhive.py
File metadata and controls
69 lines (59 loc) · 2.4 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from . import messages_hive_pb2 as proto
def get_public_key(client, address_n, show_display=False, role=None):
kwargs = dict(address_n=address_n, show_display=show_display)
if role is not None:
kwargs['role'] = role
return client.call(proto.HiveGetPublicKey(**kwargs))
def get_public_keys(client, account_index=0, show_display=False):
return client.call(
proto.HiveGetPublicKeys(account_index=account_index, show_display=show_display)
)
def sign_tx(client, address_n, chain_id, ref_block_num, ref_block_prefix,
expiration, sender, recipient, amount, decimals, asset_symbol, memo=''):
# 'from' is a Python keyword so use **-unpacking to set the field
return client.call(proto.HiveSignTx(**{
'address_n': address_n,
'chain_id': chain_id,
'ref_block_num': ref_block_num,
'ref_block_prefix': ref_block_prefix,
'expiration': expiration,
'from': sender,
'to': recipient,
'amount': amount,
'decimals': decimals,
'asset_symbol': asset_symbol,
'memo': memo,
}))
def sign_account_create(client, address_n, chain_id, ref_block_num, ref_block_prefix,
expiration, creator, new_account_name, fee_amount=3000,
owner_key='', active_key='', posting_key='', memo_key=''):
return client.call(proto.HiveSignAccountCreate(
address_n=address_n,
chain_id=chain_id,
ref_block_num=ref_block_num,
ref_block_prefix=ref_block_prefix,
expiration=expiration,
creator=creator,
new_account_name=new_account_name,
fee_amount=fee_amount,
owner_key=owner_key,
active_key=active_key,
posting_key=posting_key,
memo_key=memo_key,
))
def sign_account_update(client, address_n, chain_id, ref_block_num, ref_block_prefix,
expiration, account,
new_owner_key='', new_active_key='',
new_posting_key='', new_memo_key=''):
return client.call(proto.HiveSignAccountUpdate(
address_n=address_n,
chain_id=chain_id,
ref_block_num=ref_block_num,
ref_block_prefix=ref_block_prefix,
expiration=expiration,
account=account,
new_owner_key=new_owner_key,
new_active_key=new_active_key,
new_posting_key=new_posting_key,
new_memo_key=new_memo_key,
))