使用签名提交memo上链。

这是个无币区块链的应用,没有UTXO。因此也没有wallet的概念。

客户端可以生成地址,然后使用私钥签名,签名的内容经过服务端检查,可以上链。

生成一个地址 和私钥

  1. python3 client.py -a n

返回的信息类似:

  1. address:Z/qsNWOAAWULpqvtM/OMHmJE+6PG0oPUsOMGk2ySYgrUB5noaZsD6b0NbbPgslr1cdninkqYKcJ+sx74/Mhn2A==
  2. private_key:196f72bf05e307458a0691ca73a2981d859e499ef9fc264183feddde5bd47217

使用签名发消息上链

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

收到信息类似如下:

  1. [
  2. {
  3. "data": "Genesis Block",
  4. "hash": "65661446c4106d81e864fe4dca5fea70364023f881330017489207652d53e3fc",
  5. "index": 0,
  6. "previous_hash": 0,
  7. "timestamp": 1534499678402
  8. },
  9. {
  10. "data": {
  11. "from": "gwCSgiOvn0ndfftgsOIYNjPjEcT24BrMEWH7lZ5qCmFlyaUnR/frznDDFdfNSWJLGta14c+0gDUc7RS4kkf1aQ==",
  12. "memo": "hello",
  13. "to": "gwCSgiOvn0ndfftgsOIYNjPjEcT24BrMEWH7lZ5qCmFlyaUnR/frznDDFdfNSWJLGta14c+0gDUc7RS4kkf1aQ=="
  14. },
  15. "hash": "89f9e9c445690624dceca3ef8f3f43b65f6a6558ffd25c13bc952e9d7624838a",
  16. "index": 1,
  17. "previous_hash": "65661446c4106d81e864fe4dca5fea70364023f881330017489207652d53e3fc",
  18. "timestamp": 1534499684262
  19. },
  20. {
  21. "data": {
  22. "from": "Z/qsNWOAAWULpqvtM/OMHmJE+6PG0oPUsOMGk2ySYgrUB5noaZsD6b0NbbPgslr1cdninkqYKcJ+sx74/Mhn2A==",
  23. "memo": "hello",
  24. "to": "Z/qsNWOAAWULpqvtM/OMHmJE+6PG0oPUsOMGk2ySYgrUB5noaZsD6b0NbbPgslr1cdninkqYKcJ+sx74/Mhn2A=="
  25. },
  26. "hash": "144d2a6f6724b78f5ccd1c81e01fae8c6a7b9ec474a3131f94331203e9daa9a7",
  27. "index": 2,
  28. "previous_hash": "89f9e9c445690624dceca3ef8f3f43b65f6a6558ffd25c13bc952e9d7624838a",
  29. "timestamp": 1534501157600
  30. }
  31. ]