Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //A theoretical implementation of the bitcoin wire protocol in protocol buffers
- //This file simply shows that the bitcoin protocol could quite easily be ported into
- //protocol buffers, allowing for several languages to access it. This only deals
- //with the serialization info, actual wrapping in packets, etc. still need to be
- //performed. Most notably, the message header would need to be wrapped around
- //any message used here.
- enum Services {
- NODE_NETWORK = 1;
- }
- message Address {
- required Services node_services = 1;
- //Don't require reserved bytes, thanks to protobuf
- required fixed32 ip_address = 2;
- required int32 port = 3;
- }
- message Version {
- required uint32 version = 1;
- //Local Services already in the Address
- required fixed64 timestamp = 2;
- required Address from_address = 3;
- required Address to_address = 4;
- required fixed64 nonce = 5; //What is this for? Is it necessary?
- required string sub_version = 6;
- required uint32 starting_height = 7;
- }
- message Addr {
- repeated Address adresses = 1 ;
- }
- enum InventoryType {
- ERROR = 0;
- MSG_TX = 1;
- MSG_BLOCK = 2;
- }
- message Inv {
- required InventoryType type = 1;
- required fixed32 hash = 2;
- }
- //this is the inv message, for when a node wants to share with another node
- message InvList {
- repeated Inv inventory = 1;
- }
- message GetData {
- repeated Inv inventory = 1;
- }
- message GetBlocks {
- required fixed32 hash_start = 1;
- required fixed32 hash_stop = 2;
- }
- message TxIn {
- required fixed32 prev_hash = 1;
- required uint32 index = 2;
- required bytes script = 3;
- //Don't include sequence info, not currently used
- }
- message TxOut {
- required uint32 value = 1;
- required bytes script = 2;
- }
- message Tx {
- required uint32 version = 1;
- repeated TxIn inputs = 2;
- repeated TxOut outputs = 3;
- //Lock Time not included, not currently used
- }
- message Block {
- required uint32 version = 1;
- required fixed32 prev_block_hash = 2;
- required fixed32 merkle_root = 3;
- required fixed32 time = 4; //Does this make sense? We use 64 bit timestamps in version
- required fixed32 difficulty_target = 5;
- required fixed32 nonce = 6;
- }
- //GetAddr, CheckOrder, SubmitOrder, Reply, Ping, VerAck have no data, not implementing
- message Alert {
- required string alert_message = 1;
- required string signature = 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement