终于可以用签名提交备注信息上链了

2018-08-17 18:55:29 +08:00
 cr4fun

用法:

先下载整个项目,解压缩后安装必要的 pip 库

git clone https://github.com/OpensourceBooks/blockchain

cd blockchain

pip3 install -r requirements.txt

演示

cd 7

python3 blockchain.py

创建一个发消息的地址和私钥:

python3 client.py -a n

返回类似如下信息:

address:Z/qsNWOAAWULpqvtM/OMHmJE+6PG0oPUsOMGk2ySYgrUB5noaZsD6b0NbbPgslr1cdninkqYKcJ+sx74/Mhn2A==

private_key:196f72bf05e307458a0691ca73a2981d859e499ef9fc264183feddde5bd47217

使用签名发消息上链

python3 client.py -a s -f Z/qsNWOAAWULpqvtM/OMHmJE+6PG0oPUsOMGk2ySYgrUB5noaZsD6b0NbbPgslr1cdninkqYKcJ+sx74/Mhn2A== -t Z/qsNWOAAWULpqvtM/OMHmJE+6PG0oPUsOMGk2ySYgrUB5noaZsD6b0NbbPgslr1cdninkqYKcJ+sx74/Mhn2A== -m hello -p 196f72bf05e307458a0691ca73a2981d859e499ef9fc264183feddde5bd47217

返回的信息类似如下:

[
  {
    "data": "Genesis Block",
    "hash": "65661446c4106d81e864fe4dca5fea70364023f881330017489207652d53e3fc",
    "index": 0,
    "previous_hash": 0,
    "timestamp": 1534499678402
  },
  {
    "data": {
      "from": "gwCSgiOvn0ndfftgsOIYNjPjEcT24BrMEWH7lZ5qCmFlyaUnR/frznDDFdfNSWJLGta14c+0gDUc7RS4kkf1aQ==",
      "memo": "hello",
      "to": "gwCSgiOvn0ndfftgsOIYNjPjEcT24BrMEWH7lZ5qCmFlyaUnR/frznDDFdfNSWJLGta14c+0gDUc7RS4kkf1aQ=="
    },
    "hash": "89f9e9c445690624dceca3ef8f3f43b65f6a6558ffd25c13bc952e9d7624838a",
    "index": 1,
    "previous_hash": "65661446c4106d81e864fe4dca5fea70364023f881330017489207652d53e3fc",
    "timestamp": 1534499684262
  },
  {
    "data": {
      "from": "Z/qsNWOAAWULpqvtM/OMHmJE+6PG0oPUsOMGk2ySYgrUB5noaZsD6b0NbbPgslr1cdninkqYKcJ+sx74/Mhn2A==",
      "memo": "hello",
      "to": "Z/qsNWOAAWULpqvtM/OMHmJE+6PG0oPUsOMGk2ySYgrUB5noaZsD6b0NbbPgslr1cdninkqYKcJ+sx74/Mhn2A=="
    },
    "hash": "144d2a6f6724b78f5ccd1c81e01fae8c6a7b9ec474a3131f94331203e9daa9a7",
    "index": 2,
    "previous_hash": "89f9e9c445690624dceca3ef8f3f43b65f6a6558ffd25c13bc952e9d7624838a",
    "timestamp": 1534501157600
  }
]

详情: https://github.com/OpensourceBooks/blockchain/blob/master/7/readme.md

项目地址: https://github.com/OpensourceBooks/blockchain

1573 次点击
所在节点    Python
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/480835

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX