V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
cr4fun
V2EX  ›  Python

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

  •  
  •   cr4fun · 2018-08-17 18:55:29 +08:00 · 1583 次点击
    这是一个创建于 2290 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用法:

    先下载整个项目,解压缩后安装必要的 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

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2725 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 10:21 · PVG 18:21 · LAX 02:21 · JFK 05:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.