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