forked from typerow/thrylos
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransactions.proto
More file actions
155 lines (126 loc) · 4.36 KB
/
transactions.proto
File metadata and controls
155 lines (126 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
syntax = "proto3";
package thrylos;
option go_package = "github.com/thrylos-labs/thrylos";
message Transaction {
string id = 1; // Removed json_name, as it's redundant in proto3 when matching the field name exactly.
int64 timestamp = 2;
repeated UTXO inputs = 3;
repeated UTXO outputs = 4;
bytes encrypted_inputs = 5;
bytes encrypted_outputs = 6;
bytes signature = 7; // Use bytes for binary data.
repeated string previous_tx_ids = 8; // Consider if large, split loading.
bytes encrypted_aes_key = 9; // Keep as bytes, ensure encryption keys are not logged or misused.
string sender = 10;
int32 gasfee = 11; // Added gas fee field
string status = 12; // New field for transaction status
bytes block_hash = 13; // Changed from string to bytes
bytes sender_public_key = 14; // For ML-DSA44 public key when needed
bytes salt = 15;
}
// UTXO message optimized for size and clarity.
message UTXO {
string transaction_id = 1;
int32 index = 2;
string owner_address = 3;
int64 amount = 4;
bool is_spent = 5;
}
// WebSocket balance update message
message BalanceMessage {
string blockchain_address = 1; // The address receiving the balance update
int64 balance = 2; // Balance in nanoTHRYLOS
double balance_thrylos = 3; // Balance converted to THRYLOS
}
// Update your BalanceResponse to be more consistent
service BlockchainService {
rpc SubmitTransaction(TransactionRequest) returns (TransactionResponse);
rpc GetBlock(GetBlockRequest) returns (BlockResponse);
rpc GetTransaction(GetTransactionRequest) returns (TransactionResponse);
rpc GetLastBlock(EmptyRequest) returns (BlockResponse);
rpc SubmitTransactionBatch(TransactionBatchRequest) returns (TransactionBatchResponse);
rpc GetBalance(GetBalanceRequest) returns (BalanceResponse);
rpc GetStats(GetStatsRequest) returns (StatsResponse);
rpc GetPendingTransactions(GetPendingTransactionsRequest) returns (PendingTransactionsResponse);
rpc GetBlockByHash(GetBlockByHashRequest) returns (BlockResponse);
rpc GetBlockByIndex(GetBlockByIndexRequest) returns (BlockResponse);
rpc SubscribeToBalanceUpdates(BalanceSubscriptionRequest) returns (stream BalanceMessage);
rpc StreamBalance(GetBalanceRequest) returns (stream BalanceResponse);
}
message BalanceSubscriptionRequest {
string blockchain_address = 1;
}
message GetBlockByHashRequest {
bytes hash = 1;
}
message GetBlockByIndexRequest {
int32 index = 1;
}
message TransactionRequest {
Transaction transaction = 1; // Embedding the Transaction message
}
message TransactionResponse {
string status = 1;
}
message GetBlockRequest {
int32 id = 1;
}
message BlockResponse {
Block block = 1;
}
message TransactionBatchRequest {
repeated Transaction transactions = 1; // List of transactions in a batch
}
message TransactionBatchResponse {
string status = 1; // Status of the batch processing
repeated FailedTransaction failed_transactions = 2; // Added to provide detailed error info
}
message FailedTransaction {
string transaction_id = 1; // The ID of the transaction
string error_message = 2; // Error message explaining why the transaction failed
}
message GetTransactionRequest {
string id = 1;
}
message BalanceResponse {
int64 balance = 1; // Balance in nanoTHRYLOS
double balance_thrylos = 2; // Balance in THRYLOS
string blockchain_address = 3; // The address queried
}
message GetBalanceRequest {
string address = 1; // The blockchain address for which the balance is requested
}
message GetStatsRequest {}
message StatsResponse {
string stats = 1;
}
message GetPendingTransactionsRequest {}
message PendingTransactionsResponse {
string transactions = 1;
}
message Input {
string previousTx = 1;
int32 index = 2;
string signature = 3;
string ownerAddress = 4;
}
message Output {
double amount = 1;
string address = 2;
}
message EmptyRequest {}
// New Block message
message Block {
int32 index = 1;
int64 timestamp = 2;
bytes prev_hash = 3;
string validator = 4;
repeated Transaction transactions = 5;
bytes hash = 6;
bytes signature = 7; // If not already present
bytes salt = 8; // Add this for MLDSA signature scheme
// Note: The signature and salt are not included in what gets signed
}
// to generate the file again run:
// export PATH="$PATH:$(go env GOPATH)/bin"
// protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative transactions.proto