You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

74 lines
2.8 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. ---
  2. layout: simple
  3. ---
  4. ## A toy chain
  5. ### The chain should have these properties:
  6. - Running on at least 2 pre-defined [nodes][7] (IP addresses given in a [config file][8] / no additional discovery necessary)-
  7. - [PoW][9], with every node a miner-
  8. - The [difficulty][10] is fixed (i.e., block time is not), each [block rewards][12] 100 coins-
  9. - [ECDSA][13] cryptography; addresses may be pure public keys-
  10. - Protect against [double][14] spending
  11. - [Transactions][11] can have additional data payload, signed by the sender (and there needs to be a way to [set it][5])
  12. - Blocks can have additional data payload (and there needs to be a way to set it)
  13. - Implement a simple REST-like [web service][1] [API](/api/) which implements the following services and returns JSON data:
  14. * Query the [block count][2].
  15. * Query a [single block][3] and return all its transaction data.
  16. * Query a [single transaction][4] and return all its data.
  17. * Create a [transaction][5] from JSON [data][11] and accept it for [mining][6].
  18. ### Example of curl commands
  19. ```sh
  20. # getting block count
  21. curl http://127.0.0.1:8089/api/0.0/getheight
  22. # getting 4th block
  23. curl http://127.0.0.1:8089/api/0.0/getblock?n=4
  24. # getting transaction Ztxrms5c5oKqb9Zof3xeC5Q2ZQjSaWv7FU4rAxe2s3sP
  25. curl http://127.0.0.1:8089/api/0.0/gettx?txaddr=Ztxrms5c5oKqb9Zof3xeC5Q2ZQjSaWv7FU4rAxe2s3sP
  26. # posting a transaction
  27. cat txpool/tx.yml | sed -e "s/$/%0a/g" | curl -s -X POST http://127.0.0.1:8089/api/0.0/settx -d @-
  28. # processing the txpool (mining)
  29. curl http://127.0.0.1:8089/api/0.0/minepool
  30. ```
  31. ### Security Warning
  32. Blockchains are transparent and public so we encrypt private keys and other sensitive data,
  33. however as it is just a toy, we expose **all the files** for educational purpose.
  34. >> ** PLEASE DO NOT USE IN A PRODUCTION ENVIRONMENT **
  35. note:
  36. sensitive data are encrypted w/ git-crypt;
  37. please send us your public key if you need access
  38. or ask for a shared DH secret
  39. decrypt can be done with the command :
  40. ```sh
  41. export GPG_ASKPASS=ssh-askpass
  42. git-crypt unlock
  43. #gpg --decrypt local.key.asc | git-crypt unlock -
  44. ```
  45. [1]: webservice.html
  46. [2]: http://127.0.0.1:8089/api/0.0/getheight
  47. [3]: http://127.0.0.1:8089/api/0.0/getblock
  48. [4]: http://127.0.0.1:8089/api/0.0/gettx?encode=json&addr=txcoin
  49. [5]: http://127.0.0.1:8089/api/settx.html
  50. [6]: http://127.0.0.1:8089/api/0.0/minepool
  51. [7]: http://127.0.0.1:8089/docs/nodes.html
  52. [7a]: http://127.0.0.1:8089/api/0.0/getnodes
  53. [8]: http://127.0.0.1:8089/api/0.0/config
  54. [9]: http://127.0.0.1:8089/docs/pow.html
  55. [10]: http://127.0.0.1:8089/docs/difficulties.html
  56. [11]: http://127.0.0.1:8089/api/transaction.html
  57. [12]: http://127.0.0.1:8089/docs/bkreward.html
  58. [13]: http://127.0.0.1:8089/admin/keygen.html
  59. [14]: http://127.0.0.1:8089/docs/UTXO.html