• R/O
  • HTTP
  • SSH
  • HTTPS

pybtm: 提交

Python3 implementation of the Bytom protocol. https://pypi.org/project/pybtm/


Commit MetaInfo

修订版d94914214b2cfb493e89fdbded050e7965e2b89a (tree)
时间2019-03-28 16:14:36
作者Chengcheng Zhang <943420582@qq.c...>
CommiterChengcheng Zhang

Log Message

fix get_address bug, update readme.md

更改概述

差异

--- a/README.md
+++ b/README.md
@@ -16,6 +16,8 @@ pybtm
1616 - [2.11 Verify signature](#211-verify-signature)
1717 - [2.12 Create new key](#212-create-new-key)
1818 - [2.13 Create HD path](#213-create-hd-path)
19+ - [2.14 Create control program](#214-create-control-program)
20+ - [Create address](#create-address)
1921
2022 Python3 implementation of the Bytom protocol.
2123
@@ -25,6 +27,10 @@ Python3 implementation of the Bytom protocol.
2527 $ pip install pybtm
2628 ```
2729
30+Requires:
31+
32+- Python>=3.7
33+
2834 ## 2 Usage
2935
3036 ### 2.1 Create entropy
@@ -323,3 +329,45 @@ Return:
323329 >>> receiver.get_path_from_index(account_index_int, address_index_int, change_bool)
324330 {'path': ['2c000000', '99000000', '01000000', '01000000', '01000000'], 'path_str': 'm/44/153/1/1/1'}
325331 ```
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
--- a/pybtm/receiver.py
+++ b/pybtm/receiver.py
@@ -125,7 +125,7 @@ def get_address(control_program_hexstr, network_str):
125125 hrp = 'tm'
126126 else:
127127 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))
129129 return address_str
130130
131131
Show on old repository browser