Python3 implementation of the Bytom protocol. https://pypi.org/project/pybtm/
修订版 | d94914214b2cfb493e89fdbded050e7965e2b89a (tree) |
---|---|
时间 | 2019-03-28 16:14:36 |
作者 | Chengcheng Zhang <943420582@qq.c...> |
Commiter | Chengcheng Zhang |
fix get_address bug, update readme.md
@@ -16,6 +16,8 @@ pybtm | ||
16 | 16 | - [2.11 Verify signature](#211-verify-signature) |
17 | 17 | - [2.12 Create new key](#212-create-new-key) |
18 | 18 | - [2.13 Create HD path](#213-create-hd-path) |
19 | + - [2.14 Create control program](#214-create-control-program) | |
20 | + - [Create address](#create-address) | |
19 | 21 | |
20 | 22 | Python3 implementation of the Bytom protocol. |
21 | 23 |
@@ -25,6 +27,10 @@ Python3 implementation of the Bytom protocol. | ||
25 | 27 | $ pip install pybtm |
26 | 28 | ``` |
27 | 29 | |
30 | +Requires: | |
31 | + | |
32 | +- Python>=3.7 | |
33 | + | |
28 | 34 | ## 2 Usage |
29 | 35 | |
30 | 36 | ### 2.1 Create entropy |
@@ -323,3 +329,45 @@ Return: | ||
323 | 329 | >>> receiver.get_path_from_index(account_index_int, address_index_int, change_bool) |
324 | 330 | {'path': ['2c000000', '99000000', '01000000', '01000000', '01000000'], 'path_str': 'm/44/153/1/1/1'} |
325 | 331 | ``` |
332 | + | |
333 | +### 2.14 Create control program | |
334 | + | |
335 | +get_control_program create control program. | |
336 | + | |
337 | +Parameter: | |
338 | + | |
339 | +- account_index_int: account index, e.g. 1, 2, 3... | |
340 | +- address_index_int: address index, e.g. 1, 2, 3... | |
341 | +- change_bool: If receiver is change, change_bool is True, otherwise the change_bool is False. | |
342 | +- xpub_hexstr: 512 bits expanded public key, type is hex string. | |
343 | + | |
344 | +Return: | |
345 | + | |
346 | +- control_program_hexstr: type is hex string. | |
347 | + | |
348 | +```python | |
349 | +>>> from pybtm import receiver | |
350 | +>>> account_index_int = 1 | |
351 | +>>> address_index_int = 1 | |
352 | +>>> change_bool = False | |
353 | +>>> xpub_hexstr = '3c6664244d2d57168d173c4691dbf8741a67d972b2d3e1b0067eb825e2005d20c5eebd1c26ccad4de5142d7c339bf62cc1fb79a8b3e42a708cd521368dbc9286' | |
354 | +>>> receiver.get_control_program(account_index_int, address_index_int, change_bool, xpub_hexstr) | |
355 | +'0014052620b86a6d5e07311d5019dffa3864ccc8a6bd' | |
356 | +``` | |
357 | + | |
358 | +### Create address | |
359 | + | |
360 | +get_address create address from control program. | |
361 | + | |
362 | +Parameter: | |
363 | + | |
364 | +- control_program_hexstr: control program. | |
365 | +- network_str: 3 types of network is available: mainnet, testnet and solonet. | |
366 | + | |
367 | +Return: | |
368 | + | |
369 | +- address: bytom address. | |
370 | + | |
371 | +```python | |
372 | + | |
373 | +``` | |
\ No newline at end of file |
@@ -125,7 +125,7 @@ def get_address(control_program_hexstr, network_str): | ||
125 | 125 | hrp = 'tm' |
126 | 126 | else: |
127 | 127 | hrp = 'sm' |
128 | - address_str = segwit_addr.encode(hrp, 0, bytes.fromhex(public_key_hash_hexstr)) | |
128 | + address_str = encode(hrp, 0, bytes.fromhex(public_key_hash_hexstr)) | |
129 | 129 | return address_str |
130 | 130 | |
131 | 131 |