Advertisement
Guest User

Untitled

a guest
Dec 5th, 2010
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. //A theoretical implementation of the bitcoin wire protocol in protocol buffers
  2.  
  3. //This file simply shows that the bitcoin protocol could quite easily be ported into
  4. //protocol buffers, allowing for several languages to access it. This only deals
  5. //with the serialization info, actual wrapping in packets, etc. still need to be
  6. //performed. Most notably, the message header would need to be wrapped around
  7. //any message used here.
  8.  
  9. enum Services {
  10. NODE_NETWORK = 1;
  11. }
  12.  
  13. message Address {
  14. required Services node_services = 1;
  15. //Don't require reserved bytes, thanks to protobuf
  16. required fixed32 ip_address = 2;
  17. required int32 port = 3;
  18. }
  19.  
  20. message Version {
  21. required uint32 version = 1;
  22. //Local Services already in the Address
  23. required fixed64 timestamp = 2;
  24. required Address from_address = 3;
  25. required Address to_address = 4;
  26. required fixed64 nonce = 5; //What is this for? Is it necessary?
  27. required string sub_version = 6;
  28. required uint32 starting_height = 7;
  29. }
  30.  
  31. message Addr {
  32. repeated Address adresses = 1 ;
  33. }
  34.  
  35. enum InventoryType {
  36. ERROR = 0;
  37. MSG_TX = 1;
  38. MSG_BLOCK = 2;
  39. }
  40.  
  41. message Inv {
  42. required InventoryType type = 1;
  43. required fixed32 hash = 2;
  44. }
  45.  
  46. //this is the inv message, for when a node wants to share with another node
  47. message InvList {
  48. repeated Inv inventory = 1;
  49. }
  50.  
  51. message GetData {
  52. repeated Inv inventory = 1;
  53. }
  54.  
  55. message GetBlocks {
  56. required fixed32 hash_start = 1;
  57. required fixed32 hash_stop = 2;
  58. }
  59.  
  60. message TxIn {
  61. required fixed32 prev_hash = 1;
  62. required uint32 index = 2;
  63. required bytes script = 3;
  64. //Don't include sequence info, not currently used
  65. }
  66.  
  67. message TxOut {
  68. required uint32 value = 1;
  69. required bytes script = 2;
  70. }
  71.  
  72. message Tx {
  73. required uint32 version = 1;
  74. repeated TxIn inputs = 2;
  75. repeated TxOut outputs = 3;
  76. //Lock Time not included, not currently used
  77. }
  78.  
  79. message Block {
  80. required uint32 version = 1;
  81. required fixed32 prev_block_hash = 2;
  82. required fixed32 merkle_root = 3;
  83. required fixed32 time = 4; //Does this make sense? We use 64 bit timestamps in version
  84. required fixed32 difficulty_target = 5;
  85. required fixed32 nonce = 6;
  86. }
  87.  
  88. //GetAddr, CheckOrder, SubmitOrder, Reply, Ping, VerAck have no data, not implementing
  89.  
  90. message Alert {
  91. required string alert_message = 1;
  92. required string signature = 2;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement