Skip to content

Commit 2419ac0

Browse files
sekulicdaltafan
andauthored
Indexer (#524)
* Draft APIs for v0.6 * Add endpoint to get chain of txs for a vtxo * Fixes after review * New iteration * Fixes * Fix virtual tx apis * Add endpoint to explorer to subscribe for addresses * init * wip explorer * explorer get tx history * pr review * pr review * indexer.proto * tmp * fix lint * fix * fix * init * sdk indexer impl * fix * pr review * Add indexer to grpc-gateway * Fix queries * Fix app layer * Fix interface layer * Update protos * Update sdk * Fix * Add api to vtxo repo to get all vtxos with pubkey & Fixes * Add info to chained tx & Fix rest endpoint conflict * Fixes * Updates and fixes to indexer svc * Update client sdk * Doxkerize sqlc command * Fix test * Fix return txid in history endpoint * Fix returning redeem txs with matching txid in sqlite db * Fix spendable vtxos endpoint --------- Co-authored-by: altafan <[email protected]>
1 parent 3904bdf commit 2419ac0

File tree

80 files changed

+16445
-80
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+16445
-80
lines changed

api-spec/openapi/swagger/ark/v1/indexer.swagger.json

Lines changed: 796 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "ark/v1/new_types.proto",
5+
"version": "version not set"
6+
},
7+
"consumes": [
8+
"application/json"
9+
],
10+
"produces": [
11+
"application/json"
12+
],
13+
"paths": {},
14+
"definitions": {
15+
"protobufAny": {
16+
"type": "object",
17+
"properties": {
18+
"@type": {
19+
"type": "string"
20+
}
21+
},
22+
"additionalProperties": {}
23+
},
24+
"rpcStatus": {
25+
"type": "object",
26+
"properties": {
27+
"code": {
28+
"type": "integer",
29+
"format": "int32"
30+
},
31+
"message": {
32+
"type": "string"
33+
},
34+
"details": {
35+
"type": "array",
36+
"items": {
37+
"type": "object",
38+
"$ref": "#/definitions/protobufAny"
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}

api-spec/protobuf/ark/v1/admin.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ service AdminService {
2323
post: "/v1/admin/rounds"
2424
body: "*"
2525
};
26-
}
26+
}
2727
rpc CreateNote(CreateNoteRequest) returns (CreateNoteResponse) {
2828
option (google.api.http) = {
2929
post: "/v1/admin/note"
@@ -98,11 +98,11 @@ message CreateNoteResponse {
9898

9999
message GetMarketHourConfigRequest {}
100100
message GetMarketHourConfigResponse {
101-
MarketHourConfig config = 1;
101+
MarketHourConfig config = 1;
102102
}
103103

104104
message UpdateMarketHourConfigRequest {
105-
MarketHourConfig config = 1;
105+
MarketHourConfig config = 1;
106106
}
107107
message UpdateMarketHourConfigResponse {}
108108

@@ -131,4 +131,4 @@ message WithdrawRequest {
131131

132132
message WithdrawResponse {
133133
string txid = 1;
134-
}
134+
}
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
syntax = "proto3";
2+
3+
package ark.v1;
4+
5+
import "google/api/annotations.proto";
6+
7+
service IndexerService {
8+
rpc GetCommitmentTx(GetCommitmentTxRequest) returns (GetCommitmentTxResponse) {
9+
option (google.api.http) = {
10+
get: "/v1/commitmentTx/{txid}"
11+
};
12+
};
13+
rpc GetVtxoTree(GetVtxoTreeRequest) returns (GetVtxoTreeResponse) {
14+
option (google.api.http) = {
15+
get: "/v1/batch/{batch_outpoint.txid}/{batch_outpoint.vout}/tree"
16+
};
17+
};
18+
rpc GetForfeitTxs(GetForfeitTxsRequest) returns (GetForfeitTxsResponse) {
19+
option (google.api.http) = {
20+
get: "/v1/batch/{batch_outpoint.txid}/{batch_outpoint.vout}/forfeitTxs"
21+
};
22+
};
23+
rpc GetConnectors(GetConnectorsRequest) returns (GetConnectorsResponse) {
24+
option (google.api.http) = {
25+
get: "/v1/batch/{batch_outpoint.txid}/{batch_outpoint.vout}/connectors"
26+
};
27+
};
28+
rpc GetSpendableVtxos(GetSpendableVtxosRequest) returns (GetSpendableVtxosResponse) {
29+
option (google.api.http) = {
30+
get: "/v1/spendableVtxos/{address}"
31+
};
32+
};
33+
rpc GetTransactionHistory(GetTransactionHistoryRequest) returns (GetTransactionHistoryResponse) {
34+
option (google.api.http) = {
35+
get: "/v1/history/{address}"
36+
};
37+
};
38+
rpc GetVtxoChain(GetVtxoChainRequest) returns (GetVtxoChainResponse) {
39+
option (google.api.http) = {
40+
get: "/v1/vtxo/{outpoint.txid}/{outpoint.vout}/chain"
41+
};
42+
}
43+
rpc GetVirtualTxs(GetVirtualTxsRequest) returns (GetVirtualTxsResponse) {
44+
option (google.api.http) = {
45+
get: "/v1/virtualTx/{txids}"
46+
};
47+
}
48+
rpc GetSweptCommitmentTx(GetSweptCommitmentTxRequest) returns (GetSweptCommitmentTxResponse) {
49+
option (google.api.http) = {
50+
get: "/v1/commitmentTx/{txid}/swept"
51+
};
52+
}
53+
}
54+
55+
message GetCommitmentTxRequest {
56+
string txid = 1;
57+
}
58+
message GetCommitmentTxResponse {
59+
int64 started_at = 1;
60+
int64 ended_at = 2;
61+
map<uint32, IndexerBatch> batches = 3;
62+
}
63+
64+
message GetVtxoTreeRequest {
65+
IndexerOutpoint batch_outpoint = 1;
66+
IndexerPageRequest page = 2;
67+
}
68+
message GetVtxoTreeResponse {
69+
repeated IndexerNode vtxo_tree = 1;
70+
IndexerPageResponse page = 2;
71+
}
72+
73+
message GetForfeitTxsRequest {
74+
IndexerOutpoint batch_outpoint = 1;
75+
IndexerPageRequest page = 2;
76+
}
77+
message GetForfeitTxsResponse {
78+
repeated string txs = 1;
79+
IndexerPageResponse page = 2;
80+
}
81+
82+
message GetConnectorsRequest {
83+
IndexerOutpoint batch_outpoint = 1;
84+
IndexerPageRequest page = 2;
85+
}
86+
message GetConnectorsResponse {
87+
repeated IndexerNode connectors = 1;
88+
IndexerPageResponse page = 2;
89+
}
90+
91+
message GetSpendableVtxosRequest {
92+
string address = 1;
93+
IndexerPageRequest page = 2;
94+
}
95+
message GetSpendableVtxosResponse {
96+
repeated IndexerVtxo vtxos = 1;
97+
IndexerPageResponse page = 2;
98+
}
99+
100+
message GetTransactionHistoryRequest {
101+
string address = 1;
102+
int64 start_time = 2;
103+
int64 end_time = 3;
104+
IndexerPageRequest page = 4;
105+
}
106+
message GetTransactionHistoryResponse {
107+
repeated IndexerTxHistoryRecord history = 1;
108+
IndexerPageResponse page = 2;
109+
}
110+
111+
message GetVtxoChainRequest {
112+
IndexerOutpoint outpoint = 1;
113+
IndexerPageRequest page = 2;
114+
}
115+
message GetVtxoChainResponse {
116+
map<string, IndexerTransactions> graph = 1;
117+
IndexerPageResponse page = 2;
118+
}
119+
120+
message GetVirtualTxsRequest {
121+
repeated string txids = 1;
122+
IndexerPageRequest page = 2;
123+
}
124+
message GetVirtualTxsResponse {
125+
repeated string txs = 1;
126+
IndexerPageResponse page = 2;
127+
}
128+
129+
message GetSweptCommitmentTxRequest {
130+
string txid = 1;
131+
}
132+
message GetSweptCommitmentTxResponse {
133+
repeated string swept_by = 1;
134+
}
135+
136+
message SubscribeForAddressesRequest {
137+
repeated string addresses = 1;
138+
}
139+
message SubscribeForAddressesResponse {
140+
string address = 1;
141+
repeated IndexerVtxo new_vtxos = 2;
142+
repeated IndexerVtxo spent_vtxos = 3;
143+
}
144+
145+
message IndexerTransactions {
146+
repeated IndexerChain txs = 1;
147+
int64 expires_at = 2;
148+
}
149+
150+
message IndexerBatch {
151+
uint64 total_batch_amount = 1;
152+
uint64 total_forfeit_amount = 2;
153+
int32 total_input_vtxos = 3;
154+
int32 total_output_vtxos = 4;
155+
int64 expires_at = 5;
156+
bool swept = 6;
157+
}
158+
159+
message IndexerOutpoint {
160+
string txid = 1;
161+
uint32 vout = 2;
162+
}
163+
164+
message IndexerNode {
165+
string txid = 1;
166+
string parent_txid = 3;
167+
int32 level = 4;
168+
int32 level_index = 5;
169+
}
170+
171+
message IndexerVtxo {
172+
IndexerOutpoint outpoint = 1;
173+
int64 created_at = 2;
174+
int64 expires_at = 3;
175+
uint64 amount = 4;
176+
string script = 5;
177+
bool is_leaf = 6;
178+
bool is_swept = 7;
179+
bool is_spent = 8;
180+
string spent_by = 9;
181+
}
182+
183+
message IndexerChain {
184+
string txid = 1;
185+
IndexerChainedTxType type = 2;
186+
}
187+
188+
message IndexerTxHistoryRecord {
189+
oneof key {
190+
string commitment_txid = 1;
191+
string virtual_txid = 2;
192+
}
193+
IndexerTxType type = 3;
194+
uint64 amount = 4;
195+
int64 created_at = 5;
196+
int64 confirmed_at = 6;
197+
bool is_settled = 7;
198+
}
199+
200+
enum IndexerTxType {
201+
INDEXER_TX_TYPE_UNSPECIFIED = 0;
202+
INDEXER_TX_TYPE_RECEIVED = 1;
203+
INDEXER_TX_TYPE_SENT = 2;
204+
INDEXER_TX_TYPE_SWEEP = 3;
205+
}
206+
207+
enum IndexerChainedTxType {
208+
INDEXER_CHAINED_TX_TYPE_UNSPECIFIED = 0;
209+
INDEXER_CHAINED_TX_TYPE_VIRTUAL = 1;
210+
INDEXER_CHAINED_TX_TYPE_COMMITMENT = 2;
211+
}
212+
213+
message IndexerPageRequest {
214+
int32 size = 1;
215+
int32 index = 2;
216+
}
217+
218+
message IndexerPageResponse {
219+
int32 current = 1;
220+
int32 next = 2;
221+
int32 total = 3;
222+
}

api-spec/protobuf/ark/v1/service.proto

100755100644
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ message Musig2 {
138138

139139
message RegisterOutputsForNextRoundRequest {
140140
string request_id = 1;
141-
// List of receivers for to convert to leaves in the next VTXO tree.
141+
// List of receivers for to convert to leaves in the next VTXO tree.
142142
repeated Output outputs = 2;
143143
optional Musig2 musig2 = 3;
144144
}
@@ -159,7 +159,7 @@ message SubmitTreeSignaturesRequest {
159159
message SubmitTreeSignaturesResponse {}
160160

161161
message SubmitSignedForfeitTxsRequest {
162-
// Forfeit txs signed by the user.
162+
// Forfeit txs signed by the user.
163163
repeated string signed_forfeit_txs = 1;
164164
// The user has to sign also the round tx if he registerd a boarding UTXO.
165165
optional string signed_round_tx = 2;
@@ -173,7 +173,7 @@ message GetEventStreamResponse {
173173
RoundFinalizedEvent round_finalized = 2;
174174
RoundFailed round_failed = 3;
175175
RoundSigningEvent round_signing = 4;
176-
RoundSigningNoncesGeneratedEvent round_signing_nonces_generated = 5;
176+
RoundSigningNoncesGeneratedEvent round_signing_nonces_generated = 5;
177177
}
178178
}
179179

api-spec/protobuf/ark/v1/wallet.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ service WalletInitializerService {
3131
rpc GetStatus(GetStatusRequest) returns (GetStatusResponse) {
3232
option (google.api.http) = {
3333
get: "/v1/admin/wallet/status"
34-
};
34+
};
3535
}
3636
}
3737

0 commit comments

Comments
 (0)