• R/O
  • HTTP
  • SSH
  • HTTPS

pybtm: 提交

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


Commit MetaInfo

修订版01b8dee6da84308779106b9816a9d90831db7b9f (tree)
时间2019-04-01 12:58:17
作者Chengcheng Zhang <943420582@qq.c...>
CommiterChengcheng Zhang

Log Message

modify submit_transaction

更改概述

差异

--- a/README.md
+++ b/README.md
@@ -415,8 +415,8 @@ submit_transaction submit transaction.
415415
416416 Parameter:
417417
418-- raw_transaction_str: raw transaction.
419-- network_str: 3 types of network is available: mainnet, testnet and solonet.
418+- raw_transaction_hexstr: raw transaction.
419+- submit_url: you can send raw transaction through submit_url.
420420
421421 Return:
422422
@@ -424,7 +424,17 @@ Return:
424424
425425 ```python
426426 >>> from pybtm import transaction
427->>> transaction.submit_transaction('070100010161015f28b7b53d8dc90006bf97e0a4eaae2a72ec3d869873188698b694beaf20789f21ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8099c4d5990100011600149335b1cbd4a77b78e33315a0ed10a95b12e7ca48630240897e2d9d24a3b5faaed0579dee7597b401491595675f897504f8945b29d836235bd2fca72a3ad0cae814628973ebcd142d9d6cc92d0b2571b69e5370a98a340c208cb7fb3086f58db9a31401b99e8c658be66134fb9034de1d5c462679270b090702013effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80f9f8bc98010116001406ce4b689ba026ffd3a7ca65d1d059546d4b78a000013dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c6868f01011600147929ef91997c827bebf60fa608f876ea27523c4700', 'testnet')
427+>>> raw_transaction_hexstr = '070100010160015e5dfc352f9247985e92b2688a9a0a0e3e45a52f633c7d2c35cf6485fc1f03a89cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8094ebdc030101160014052620b86a6d5e07311d5019dffa3864ccc8a6bd630240988348a301c86563eb16105cc0c7e12e8cd1fbc7e9031933dac05a32d2a696bc77b83f25a99a4a9458d976c5327b8004918545a3fde567f28d805f741db54e0b20e87ca3acdebdcad9a1d0f2caecf8ce0dbfc73d060807a210c6f225488347961402013dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80b6f7f302011600147950bb5fcfb1c3fe14198c14ebd4ad85bb69bbc500013cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8084af5f011600141d8e1c2d71843f41e2131d7fd6df8b47e2cf56b900'
428+>>> submit_url = 'https://blockmeta.com/api/wisdom/broadcast-transaction'
429+>>> transaction.submit_transaction(raw_transaction_hexstr, submit_url)
430+'1'
431+```
432+
433+```python
434+>>> from pybtm import transaction
435+>>> raw_transaction_hexstr = '07010001015f015d2f4a8f10afbc0448779fadd916a3f1b8518ffe0b7d20fdf470d8e9b4993ef2b4ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0d8883200011600144a594e3e4cbbd87629476e7ee24c1637df66c0b76302406fd39079681118840fd6fd66cdff769f2d05d8520312e9dd559dc23c36a3cb3921e47cba233d5d2267eb0f128a908d1bab877e172e880d3f36dc6a5e5826540c202854e5c181f5a862edd190e413d75937549758ef4902e1475aac52623f0a239302013cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc09dd81001160014f63f68597df5c88a92e04229e0fd08a3584ade3b00013cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80e1eb1701160014664f28ec6ab8826a028658dc0d0d1f94c6e20fa300'
436+>>> submit_url = 'https://blockmeta.com/api/v2/broadcast-transaction'
437+>>> transaction.submit_transaction(raw_transaction_hexstr, submit_url)
428438 '1'
429439 ```
430440
--- a/pybtm/__init__.py
+++ b/pybtm/__init__.py
@@ -1,2 +1,2 @@
11 name = "pybtm"
2-version = "0.1.0"
\ No newline at end of file
2+version = "0.1.3"
\ No newline at end of file
--- a/pybtm/transaction.py
+++ b/pybtm/transaction.py
@@ -5,24 +5,22 @@ from .receiver import *
55
66 # submit_transaction broadcast raw transaction
77 # raw_transaction_str is signed transaction,
8-# network_str is mainnet or testnet
98 # test data 1:
10-# raw_transaction_str: 070100010160015e0873eddd68c4ba07c9410984799928288ae771bdccc6d974e72c95727813461fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8094ebdc030101160014052620b86a6d5e07311d5019dffa3864ccc8a6bd630240312a052f36efb9826aa1021ec91bc6f125dd07f9c4bff87014612069527e15246518806b654d57fff8b6fe91866a19d5a2fb63a5894335fce92a7b4a7fcd340720e87ca3acdebdcad9a1d0f2caecf8ce0dbfc73d060807a210c6f225488347961402013dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8082eee0020116001418028ef4f8b8c278907864a1977a5ee6707b2a6b00013cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80b8b872011600142935e4869d0317d9701c80a02ecf888143cb9dd200
11-# network_str: testnet
12-def submit_transaction(raw_transaction_str, network_str):
9+# raw_transaction_hexstr: 070100010160015e5dfc352f9247985e92b2688a9a0a0e3e45a52f633c7d2c35cf6485fc1f03a89cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8094ebdc030101160014052620b86a6d5e07311d5019dffa3864ccc8a6bd630240988348a301c86563eb16105cc0c7e12e8cd1fbc7e9031933dac05a32d2a696bc77b83f25a99a4a9458d976c5327b8004918545a3fde567f28d805f741db54e0b20e87ca3acdebdcad9a1d0f2caecf8ce0dbfc73d060807a210c6f225488347961402013dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80b6f7f302011600147950bb5fcfb1c3fe14198c14ebd4ad85bb69bbc500013cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8084af5f011600141d8e1c2d71843f41e2131d7fd6df8b47e2cf56b900
10+# submit_url: https://blockmeta.com/api/wisdom/broadcast-transaction
11+# test data 2:
12+# raw_transaction_hexstr: 07010001015f015d2f4a8f10afbc0448779fadd916a3f1b8518ffe0b7d20fdf470d8e9b4993ef2b4ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0d8883200011600144a594e3e4cbbd87629476e7ee24c1637df66c0b76302406fd39079681118840fd6fd66cdff769f2d05d8520312e9dd559dc23c36a3cb3921e47cba233d5d2267eb0f128a908d1bab877e172e880d3f36dc6a5e5826540c202854e5c181f5a862edd190e413d75937549758ef4902e1475aac52623f0a239302013cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc09dd81001160014f63f68597df5c88a92e04229e0fd08a3584ade3b00013cffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80e1eb1701160014664f28ec6ab8826a028658dc0d0d1f94c6e20fa300
13+# submit_url: https://blockmeta.com/api/v2/broadcast-transaction
14+def submit_transaction(raw_transaction_hexstr, submit_url):
1315 raw_transaction_dict = {
14- "transaction": raw_transaction_str
16+ "transaction": raw_transaction_hexstr
1517 }
1618 raw_transaction_json = json.dumps(raw_transaction_dict)
1719 headers = {
1820 "content-type": "application/json",
1921 "accept": "application/json"
2022 }
21- if network_str == "mainnet":
22- url = "https://blockmeta.com/api/v2/broadcast-transaction"
23- else:
24- url = "https://blockmeta.com/api/wisdom/broadcast-transaction"
25- response = requests.post(url, headers=headers, data=raw_transaction_json)
23+ response = requests.post(submit_url, headers=headers, data=raw_transaction_json)
2624 return response.text[:-1]
2725
2826
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
55
66 setuptools.setup(
77 name="pybtm",
8- version="0.1.0",
8+ version="0.1.3",
99 author="zcc0721",
1010 author_email="zcc0721@foxmail.com",
1111 description="Python3 implementation of the Bytom protocol.",
Show on old repository browser