@bsv/overlay 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/mod.js.map +1 -1
- package/dist/cjs/package.json +2 -2
- package/dist/cjs/src/Engine.js +80 -117
- package/dist/cjs/src/Engine.js.map +1 -1
- package/dist/cjs/src/SHIPAdvertisement.js +3 -0
- package/dist/cjs/src/SHIPAdvertisement.js.map +1 -0
- package/dist/cjs/src/SLAPAdvertisement.js +3 -0
- package/dist/cjs/src/SLAPAdvertisement.js.map +1 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/mod.js.map +1 -1
- package/dist/esm/src/Engine.js +83 -114
- package/dist/esm/src/Engine.js.map +1 -1
- package/dist/esm/src/SHIPAdvertisement.js +2 -0
- package/dist/esm/src/SHIPAdvertisement.js.map +1 -0
- package/dist/esm/src/SLAPAdvertisement.js +2 -0
- package/dist/esm/src/SLAPAdvertisement.js.map +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/mod.d.ts +2 -6
- package/dist/types/mod.d.ts.map +1 -1
- package/dist/types/src/Advertiser.d.ts +1 -2
- package/dist/types/src/Advertiser.d.ts.map +1 -1
- package/dist/types/src/Engine.d.ts +27 -15
- package/dist/types/src/Engine.d.ts.map +1 -1
- package/dist/types/src/LookupService.d.ts +1 -3
- package/dist/types/src/LookupService.d.ts.map +1 -1
- package/dist/types/src/SHIPAdvertisement.d.ts +9 -0
- package/dist/types/src/SHIPAdvertisement.d.ts.map +1 -0
- package/dist/types/src/SLAPAdvertisement.d.ts +9 -0
- package/dist/types/src/SLAPAdvertisement.d.ts.map +1 -0
- package/dist/types/src/TopicManager.d.ts +1 -1
- package/dist/types/src/TopicManager.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/docs/API.md +736 -212
- package/mod.ts +2 -6
- package/package.json +2 -2
- package/src/Advertiser.ts +1 -2
- package/src/Engine.ts +123 -127
- package/src/LookupService.ts +1 -3
- package/src/TopicManager.ts +1 -1
- package/src/__tests/Engine.test.ts +1 -5
- package/src/AdmittanceInstructions.ts +0 -14
- package/src/LookupAnswer.ts +0 -14
- package/src/LookupQuestion.ts +0 -15
- package/src/STEAK.ts +0 -10
- package/src/TaggedBEEF.ts +0 -10
package/docs/API.md
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
# API
|
|
2
2
|
|
|
3
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
3
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
4
4
|
|
|
5
5
|
## Interfaces
|
|
6
6
|
|
|
7
7
|
| |
|
|
8
8
|
| --- |
|
|
9
|
+
| [Advertisement](#interface-advertisement) |
|
|
10
|
+
| [AdvertisementData](#interface-advertisementdata) |
|
|
11
|
+
| [Advertiser](#interface-advertiser) |
|
|
12
|
+
| [AppliedTransaction](#interface-appliedtransaction) |
|
|
13
|
+
| [GraphNode](#interface-graphnode) |
|
|
9
14
|
| [LookupService](#interface-lookupservice) |
|
|
10
15
|
| [Storage](#interface-storage) |
|
|
11
16
|
| [TopicManager](#interface-topicmanager) |
|
|
12
17
|
|
|
13
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
18
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
14
19
|
|
|
15
20
|
---
|
|
16
21
|
|
|
@@ -19,10 +24,14 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#typ
|
|
|
19
24
|
Defines a Topic Manager interface that can be implemented for specific use-cases
|
|
20
25
|
|
|
21
26
|
```ts
|
|
22
|
-
export
|
|
23
|
-
identifyAdmissibleOutputs(beef: number[], previousCoins: number[])
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
export interface TopicManager {
|
|
28
|
+
identifyAdmissibleOutputs: (beef: number[], previousCoins: number[]) => Promise<AdmittanceInstructions>;
|
|
29
|
+
identifyNeededInputs?: (beef: number[]) => Promise<Array<{
|
|
30
|
+
txid: string;
|
|
31
|
+
outputIndex: number;
|
|
32
|
+
}>>;
|
|
33
|
+
getDocumentation: () => Promise<string>;
|
|
34
|
+
getMetaData: () => Promise<{
|
|
26
35
|
name: string;
|
|
27
36
|
shortDescription: string;
|
|
28
37
|
iconURL?: string;
|
|
@@ -36,20 +45,20 @@ export default interface TopicManager {
|
|
|
36
45
|
|
|
37
46
|
<summary>Interface TopicManager Details</summary>
|
|
38
47
|
|
|
39
|
-
####
|
|
48
|
+
#### Property getDocumentation
|
|
40
49
|
|
|
41
50
|
Returns a Markdown-formatted documentation string for the topic manager.
|
|
42
51
|
|
|
43
52
|
```ts
|
|
44
|
-
getDocumentation()
|
|
53
|
+
getDocumentation: () => Promise<string>
|
|
45
54
|
```
|
|
46
55
|
|
|
47
|
-
####
|
|
56
|
+
#### Property getMetaData
|
|
48
57
|
|
|
49
58
|
Returns a metadata object that can be used to identify the topic manager.
|
|
50
59
|
|
|
51
60
|
```ts
|
|
52
|
-
getMetaData()
|
|
61
|
+
getMetaData: () => Promise<{
|
|
53
62
|
name: string;
|
|
54
63
|
shortDescription: string;
|
|
55
64
|
iconURL?: string;
|
|
@@ -58,19 +67,30 @@ getMetaData(): Promise<{
|
|
|
58
67
|
}>
|
|
59
68
|
```
|
|
60
69
|
|
|
61
|
-
####
|
|
70
|
+
#### Property identifyAdmissibleOutputs
|
|
62
71
|
|
|
63
72
|
Returns instructions that denote which outputs from the provided transaction to admit into the topic, and which previous coins should be retained.
|
|
64
|
-
Accepts the transaction in BEEF format and an array of those input
|
|
73
|
+
Accepts the transaction in BEEF format and an array of those input indices which spend previously-admitted outputs from the same topic.
|
|
65
74
|
The transaction's BEEF structure will always contain the transactions associated with previous coins for reference (if any), regardless of whether the current transaction was directly proven.
|
|
66
75
|
|
|
67
76
|
```ts
|
|
68
|
-
identifyAdmissibleOutputs(beef: number[], previousCoins: number[])
|
|
77
|
+
identifyAdmissibleOutputs: (beef: number[], previousCoins: number[]) => Promise<AdmittanceInstructions>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Property identifyNeededInputs
|
|
81
|
+
|
|
82
|
+
Identifies and returns the inputs needed to anchor any topical outputs from this transaction to their associated previous history.
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
identifyNeededInputs?: (beef: number[]) => Promise<Array<{
|
|
86
|
+
txid: string;
|
|
87
|
+
outputIndex: number;
|
|
88
|
+
}>>
|
|
69
89
|
```
|
|
70
90
|
|
|
71
91
|
</details>
|
|
72
92
|
|
|
73
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
93
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
74
94
|
|
|
75
95
|
---
|
|
76
96
|
### Interface: LookupService
|
|
@@ -78,13 +98,13 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#typ
|
|
|
78
98
|
Defines a Lookup Service interface to be implemented for specific use-cases
|
|
79
99
|
|
|
80
100
|
```ts
|
|
81
|
-
export
|
|
82
|
-
outputAdded
|
|
83
|
-
outputSpent
|
|
84
|
-
outputDeleted
|
|
85
|
-
lookup(question: LookupQuestion)
|
|
86
|
-
getDocumentation()
|
|
87
|
-
getMetaData()
|
|
101
|
+
export interface LookupService {
|
|
102
|
+
outputAdded?: (txid: string, outputIndex: number, outputScript: Script, topic: string) => Promise<void>;
|
|
103
|
+
outputSpent?: (txid: string, outputIndex: number, topic: string) => Promise<void>;
|
|
104
|
+
outputDeleted?: (txid: string, outputIndex: number, topic: string) => Promise<void>;
|
|
105
|
+
lookup: (question: LookupQuestion) => Promise<LookupAnswer | LookupFormula>;
|
|
106
|
+
getDocumentation: () => Promise<string>;
|
|
107
|
+
getMetaData: () => Promise<{
|
|
88
108
|
name: string;
|
|
89
109
|
shortDescription: string;
|
|
90
110
|
iconURL?: string;
|
|
@@ -98,20 +118,20 @@ export default interface LookupService {
|
|
|
98
118
|
|
|
99
119
|
<summary>Interface LookupService Details</summary>
|
|
100
120
|
|
|
101
|
-
####
|
|
121
|
+
#### Property getDocumentation
|
|
102
122
|
|
|
103
123
|
Returns a Markdown-formatted documentation string for the lookup service.
|
|
104
124
|
|
|
105
125
|
```ts
|
|
106
|
-
getDocumentation()
|
|
126
|
+
getDocumentation: () => Promise<string>
|
|
107
127
|
```
|
|
108
128
|
|
|
109
|
-
####
|
|
129
|
+
#### Property getMetaData
|
|
110
130
|
|
|
111
131
|
Returns a metadata object that can be used to identify the lookup service.
|
|
112
132
|
|
|
113
133
|
```ts
|
|
114
|
-
getMetaData()
|
|
134
|
+
getMetaData: () => Promise<{
|
|
115
135
|
name: string;
|
|
116
136
|
shortDescription: string;
|
|
117
137
|
iconURL?: string;
|
|
@@ -120,50 +140,77 @@ getMetaData(): Promise<{
|
|
|
120
140
|
}>
|
|
121
141
|
```
|
|
122
142
|
|
|
123
|
-
####
|
|
143
|
+
#### Property lookup
|
|
124
144
|
|
|
125
145
|
Queries the lookup service for information
|
|
126
146
|
|
|
127
147
|
```ts
|
|
128
|
-
lookup(question: LookupQuestion)
|
|
148
|
+
lookup: (question: LookupQuestion) => Promise<LookupAnswer | LookupFormula>
|
|
129
149
|
```
|
|
130
150
|
|
|
131
|
-
|
|
151
|
+
#### Property outputAdded
|
|
152
|
+
|
|
153
|
+
Process the event when a new UTXO is let into a topic
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
outputAdded?: (txid: string, outputIndex: number, outputScript: Script, topic: string) => Promise<void>
|
|
157
|
+
```
|
|
132
158
|
|
|
133
|
-
|
|
159
|
+
#### Property outputDeleted
|
|
134
160
|
|
|
135
|
-
|
|
161
|
+
Processes the deletion event for a UTXO.
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
outputDeleted?: (txid: string, outputIndex: number, topic: string) => Promise<void>
|
|
165
|
+
```
|
|
136
166
|
|
|
137
|
-
|
|
138
|
-
+ — The question to be answered by the lookup service
|
|
167
|
+
#### Property outputSpent
|
|
139
168
|
|
|
140
|
-
|
|
169
|
+
Processes the spend event for a UTXO.
|
|
141
170
|
|
|
142
|
-
|
|
171
|
+
```ts
|
|
172
|
+
outputSpent?: (txid: string, outputIndex: number, topic: string) => Promise<void>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
</details>
|
|
176
|
+
|
|
177
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
### Interface: AppliedTransaction
|
|
181
|
+
|
|
182
|
+
Represents a transaction that has been applied to a topic.
|
|
143
183
|
|
|
144
184
|
```ts
|
|
145
|
-
|
|
185
|
+
export interface AppliedTransaction {
|
|
186
|
+
txid: string;
|
|
187
|
+
topic: string;
|
|
188
|
+
}
|
|
146
189
|
```
|
|
147
190
|
|
|
148
|
-
|
|
191
|
+
<details>
|
|
192
|
+
|
|
193
|
+
<summary>Interface AppliedTransaction Details</summary>
|
|
194
|
+
|
|
195
|
+
#### Property topic
|
|
149
196
|
|
|
150
|
-
|
|
197
|
+
Output index of the applied transaction
|
|
151
198
|
|
|
152
199
|
```ts
|
|
153
|
-
|
|
200
|
+
topic: string
|
|
154
201
|
```
|
|
155
202
|
|
|
156
|
-
####
|
|
203
|
+
#### Property txid
|
|
157
204
|
|
|
158
|
-
|
|
205
|
+
TXID of the applied transaction
|
|
159
206
|
|
|
160
207
|
```ts
|
|
161
|
-
|
|
208
|
+
txid: string
|
|
162
209
|
```
|
|
163
210
|
|
|
164
211
|
</details>
|
|
165
212
|
|
|
166
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
213
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
167
214
|
|
|
168
215
|
---
|
|
169
216
|
### Interface: Storage
|
|
@@ -171,17 +218,21 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#typ
|
|
|
171
218
|
Defines the Storage Engine interface used internally by the Overlay Services Engine.
|
|
172
219
|
|
|
173
220
|
```ts
|
|
174
|
-
export
|
|
175
|
-
insertOutput(utxo: Output)
|
|
176
|
-
findOutput(txid: string, outputIndex: number, topic?: string, spent?: boolean)
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
221
|
+
export interface Storage {
|
|
222
|
+
insertOutput: (utxo: Output) => Promise<void>;
|
|
223
|
+
findOutput: (txid: string, outputIndex: number, topic?: string, spent?: boolean, includeBEEF?: boolean) => Promise<Output | null>;
|
|
224
|
+
findOutputsForTransaction: (txid: string, includeBEEF?: boolean) => Promise<Output[]>;
|
|
225
|
+
findUTXOsForTopic: (topic: string, since?: number, includeBEEF?: boolean) => Promise<Output[]>;
|
|
226
|
+
deleteOutput: (txid: string, outputIndex: number, topic: string) => Promise<void>;
|
|
227
|
+
markUTXOAsSpent: (txid: string, outputIndex: number, topic: string) => Promise<void>;
|
|
228
|
+
updateConsumedBy: (txid: string, outputIndex: number, topic: string, consumedBy: Array<{
|
|
180
229
|
txid: string;
|
|
181
230
|
outputIndex: number;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
231
|
+
}>) => Promise<void>;
|
|
232
|
+
updateTransactionBEEF: (txid: string, beef: number[]) => Promise<void>;
|
|
233
|
+
updateOutputBlockHeight?: (txid: string, outputIndex: number, topic: string, blockHeight: number) => Promise<void>;
|
|
234
|
+
insertAppliedTransaction: (tx: AppliedTransaction) => Promise<void>;
|
|
235
|
+
doesAppliedTransactionExist: (tx: AppliedTransaction) => Promise<boolean>;
|
|
185
236
|
}
|
|
186
237
|
```
|
|
187
238
|
|
|
@@ -189,127 +240,208 @@ export default interface Storage {
|
|
|
189
240
|
|
|
190
241
|
<summary>Interface Storage Details</summary>
|
|
191
242
|
|
|
192
|
-
####
|
|
243
|
+
#### Property deleteOutput
|
|
193
244
|
|
|
194
245
|
Deletes an output from storage
|
|
195
246
|
|
|
196
247
|
```ts
|
|
197
|
-
deleteOutput(txid: string, outputIndex: number, topic: string)
|
|
248
|
+
deleteOutput: (txid: string, outputIndex: number, topic: string) => Promise<void>
|
|
198
249
|
```
|
|
199
250
|
|
|
200
|
-
|
|
251
|
+
#### Property doesAppliedTransactionExist
|
|
201
252
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
+ — The topic where the output should be deleted
|
|
253
|
+
Checks if a duplicate transaction exists
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
doesAppliedTransactionExist: (tx: AppliedTransaction) => Promise<boolean>
|
|
257
|
+
```
|
|
208
258
|
|
|
209
|
-
####
|
|
259
|
+
#### Property findOutput
|
|
210
260
|
|
|
211
|
-
|
|
261
|
+
Finds an output from storage
|
|
212
262
|
|
|
213
263
|
```ts
|
|
214
|
-
|
|
264
|
+
findOutput: (txid: string, outputIndex: number, topic?: string, spent?: boolean, includeBEEF?: boolean) => Promise<Output | null>
|
|
215
265
|
```
|
|
216
266
|
|
|
217
|
-
|
|
267
|
+
#### Property findOutputsForTransaction
|
|
218
268
|
|
|
219
|
-
|
|
269
|
+
Finds outputs with a matching transaction ID from storage
|
|
220
270
|
|
|
221
|
-
|
|
271
|
+
```ts
|
|
272
|
+
findOutputsForTransaction: (txid: string, includeBEEF?: boolean) => Promise<Output[]>
|
|
273
|
+
```
|
|
222
274
|
|
|
223
|
-
|
|
224
|
-
+ — Transaction to check
|
|
275
|
+
#### Property findUTXOsForTopic
|
|
225
276
|
|
|
226
|
-
|
|
277
|
+
Finds current UTXOs that have been admitted into a given topic
|
|
227
278
|
|
|
228
|
-
|
|
279
|
+
```ts
|
|
280
|
+
findUTXOsForTopic: (topic: string, since?: number, includeBEEF?: boolean) => Promise<Output[]>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
#### Property insertAppliedTransaction
|
|
284
|
+
|
|
285
|
+
Inserts record of the applied transaction
|
|
229
286
|
|
|
230
287
|
```ts
|
|
231
|
-
|
|
288
|
+
insertAppliedTransaction: (tx: AppliedTransaction) => Promise<void>
|
|
232
289
|
```
|
|
233
290
|
|
|
234
|
-
|
|
291
|
+
#### Property insertOutput
|
|
235
292
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
+ — The topic in which the output is stored
|
|
242
|
-
+ **spent**
|
|
243
|
-
+ — Whether the output must be spent to be returned
|
|
293
|
+
Adds a new output to storage
|
|
294
|
+
|
|
295
|
+
```ts
|
|
296
|
+
insertOutput: (utxo: Output) => Promise<void>
|
|
297
|
+
```
|
|
244
298
|
|
|
245
|
-
####
|
|
299
|
+
#### Property markUTXOAsSpent
|
|
246
300
|
|
|
247
|
-
|
|
301
|
+
Updates a UTXO as spent
|
|
248
302
|
|
|
249
303
|
```ts
|
|
250
|
-
|
|
304
|
+
markUTXOAsSpent: (txid: string, outputIndex: number, topic: string) => Promise<void>
|
|
251
305
|
```
|
|
252
306
|
|
|
253
|
-
|
|
307
|
+
#### Property updateConsumedBy
|
|
254
308
|
|
|
255
|
-
|
|
256
|
-
+ — The transaction to insert
|
|
309
|
+
Updates which outputs are consumed by this output
|
|
257
310
|
|
|
258
|
-
|
|
311
|
+
```ts
|
|
312
|
+
updateConsumedBy: (txid: string, outputIndex: number, topic: string, consumedBy: Array<{
|
|
313
|
+
txid: string;
|
|
314
|
+
outputIndex: number;
|
|
315
|
+
}>) => Promise<void>
|
|
316
|
+
```
|
|
259
317
|
|
|
260
|
-
|
|
318
|
+
#### Property updateOutputBlockHeight
|
|
319
|
+
|
|
320
|
+
Updates the block height on an output
|
|
261
321
|
|
|
262
322
|
```ts
|
|
263
|
-
|
|
323
|
+
updateOutputBlockHeight?: (txid: string, outputIndex: number, topic: string, blockHeight: number) => Promise<void>
|
|
264
324
|
```
|
|
265
325
|
|
|
266
|
-
|
|
326
|
+
#### Property updateTransactionBEEF
|
|
327
|
+
|
|
328
|
+
Updates the beef data for a transaction
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
updateTransactionBEEF: (txid: string, beef: number[]) => Promise<void>
|
|
332
|
+
```
|
|
267
333
|
|
|
268
|
-
|
|
269
|
-
+ — The output to add
|
|
334
|
+
</details>
|
|
270
335
|
|
|
271
|
-
|
|
336
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
272
337
|
|
|
273
|
-
|
|
338
|
+
---
|
|
339
|
+
### Interface: Advertisement
|
|
274
340
|
|
|
275
341
|
```ts
|
|
276
|
-
|
|
342
|
+
export interface Advertisement {
|
|
343
|
+
protocol: "SHIP" | "SLAP";
|
|
344
|
+
identityKey: string;
|
|
345
|
+
domain: string;
|
|
346
|
+
topicOrService: string;
|
|
347
|
+
beef?: number[];
|
|
348
|
+
outputIndex?: number;
|
|
349
|
+
}
|
|
277
350
|
```
|
|
278
351
|
|
|
279
|
-
|
|
352
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
280
353
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
+ **outputIndex**
|
|
284
|
-
+ — Index of the output to update
|
|
285
|
-
+ **topic**
|
|
286
|
-
+ — Topic in which the output should be updated
|
|
354
|
+
---
|
|
355
|
+
### Interface: AdvertisementData
|
|
287
356
|
|
|
288
|
-
|
|
357
|
+
```ts
|
|
358
|
+
export interface AdvertisementData {
|
|
359
|
+
protocol: "SHIP" | "SLAP";
|
|
360
|
+
topicOrServiceName: string;
|
|
361
|
+
}
|
|
362
|
+
```
|
|
289
363
|
|
|
290
|
-
|
|
364
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
### Interface: Advertiser
|
|
368
|
+
|
|
369
|
+
Interface for managing SHIP and SLAP advertisements.
|
|
370
|
+
Provides methods for creating, finding, and revoking advertisements.
|
|
291
371
|
|
|
292
372
|
```ts
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
373
|
+
export interface Advertiser {
|
|
374
|
+
createAdvertisements: (adsData: AdvertisementData[]) => Promise<TaggedBEEF>;
|
|
375
|
+
findAllAdvertisements: (protocol: "SHIP" | "SLAP") => Promise<Advertisement[]>;
|
|
376
|
+
revokeAdvertisements: (advertisements: Advertisement[]) => Promise<TaggedBEEF>;
|
|
377
|
+
parseAdvertisement: (outputScript: Script) => Advertisement;
|
|
378
|
+
}
|
|
297
379
|
```
|
|
298
380
|
|
|
299
|
-
|
|
381
|
+
<details>
|
|
300
382
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
383
|
+
<summary>Interface Advertiser Details</summary>
|
|
384
|
+
|
|
385
|
+
#### Property createAdvertisements
|
|
386
|
+
|
|
387
|
+
Creates a new SHIP/SLAP advertisement for a given topic.
|
|
388
|
+
|
|
389
|
+
```ts
|
|
390
|
+
createAdvertisements: (adsData: AdvertisementData[]) => Promise<TaggedBEEF>
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
#### Property findAllAdvertisements
|
|
394
|
+
|
|
395
|
+
Finds all SHIP/SLAP advertisements.
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
findAllAdvertisements: (protocol: "SHIP" | "SLAP") => Promise<Advertisement[]>
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
#### Property parseAdvertisement
|
|
402
|
+
|
|
403
|
+
Parses an output script to extract an advertisement.
|
|
404
|
+
|
|
405
|
+
```ts
|
|
406
|
+
parseAdvertisement: (outputScript: Script) => Advertisement
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
#### Property revokeAdvertisements
|
|
410
|
+
|
|
411
|
+
Revokes an existing advertisement, either SHIP or SLAP.
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
revokeAdvertisements: (advertisements: Advertisement[]) => Promise<TaggedBEEF>
|
|
415
|
+
```
|
|
309
416
|
|
|
310
417
|
</details>
|
|
311
418
|
|
|
312
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
419
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
### Interface: GraphNode
|
|
423
|
+
|
|
424
|
+
Represents a node in the temporary graph.
|
|
425
|
+
|
|
426
|
+
```ts
|
|
427
|
+
export interface GraphNode {
|
|
428
|
+
txid: string;
|
|
429
|
+
graphID: string;
|
|
430
|
+
rawTx: string;
|
|
431
|
+
outputIndex: number;
|
|
432
|
+
spentBy?: string;
|
|
433
|
+
proof?: string;
|
|
434
|
+
txMetadata?: string;
|
|
435
|
+
outputMetadata?: string;
|
|
436
|
+
inputs?: Record<string, {
|
|
437
|
+
hash: string;
|
|
438
|
+
}> | undefined;
|
|
439
|
+
children: GraphNode[];
|
|
440
|
+
parent?: GraphNode;
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
313
445
|
|
|
314
446
|
---
|
|
315
447
|
## Classes
|
|
@@ -318,27 +450,201 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#typ
|
|
|
318
450
|
| --- |
|
|
319
451
|
| [Engine](#class-engine) |
|
|
320
452
|
| [KnexStorage](#class-knexstorage) |
|
|
453
|
+
| [OverlayGASPRemote](#class-overlaygaspremote) |
|
|
454
|
+
| [OverlayGASPStorage](#class-overlaygaspstorage) |
|
|
321
455
|
|
|
322
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
456
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
323
457
|
|
|
324
458
|
---
|
|
325
459
|
|
|
460
|
+
### Class: OverlayGASPRemote
|
|
461
|
+
|
|
462
|
+
```ts
|
|
463
|
+
export class OverlayGASPRemote implements GASPRemote {
|
|
464
|
+
constructor(public endpointURL: string, public topic: string)
|
|
465
|
+
async getInitialResponse(request: GASPInitialRequest): Promise<GASPInitialResponse>
|
|
466
|
+
async requestNode(graphID: string, txid: string, outputIndex: number, metadata: boolean): Promise<GASPNode>
|
|
467
|
+
async getInitialReply(response: GASPInitialResponse): Promise<GASPInitialReply>
|
|
468
|
+
async submitNode(node: GASPNode): Promise<void | GASPNodeResponse>
|
|
469
|
+
}
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
<details>
|
|
473
|
+
|
|
474
|
+
<summary>Class OverlayGASPRemote Details</summary>
|
|
475
|
+
|
|
476
|
+
#### Method getInitialResponse
|
|
477
|
+
|
|
478
|
+
Given an outgoing initial request, sends the request to the foreign instance and obtains their initial response.
|
|
479
|
+
|
|
480
|
+
```ts
|
|
481
|
+
async getInitialResponse(request: GASPInitialRequest): Promise<GASPInitialResponse>
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
#### Method requestNode
|
|
485
|
+
|
|
486
|
+
Given an outgoing txid, outputIndex and optional metadata, request the associated GASP node from the foreign instance.
|
|
487
|
+
|
|
488
|
+
```ts
|
|
489
|
+
async requestNode(graphID: string, txid: string, outputIndex: number, metadata: boolean): Promise<GASPNode>
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
</details>
|
|
493
|
+
|
|
494
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
495
|
+
|
|
496
|
+
---
|
|
497
|
+
### Class: OverlayGASPStorage
|
|
498
|
+
|
|
499
|
+
```ts
|
|
500
|
+
export class OverlayGASPStorage implements GASPStorage {
|
|
501
|
+
readonly temporaryGraphNodeRefs: Record<string, GraphNode> = {};
|
|
502
|
+
constructor(public topic: string, public engine: Engine, public maxNodesInGraph?: number)
|
|
503
|
+
async findKnownUTXOs(since: number): Promise<Array<{
|
|
504
|
+
txid: string;
|
|
505
|
+
outputIndex: number;
|
|
506
|
+
}>>
|
|
507
|
+
async hydrateGASPNode(graphID: string, txid: string, outputIndex: number, metadata: boolean): Promise<GASPNode>
|
|
508
|
+
async findNeededInputs(tx: GASPNode): Promise<GASPNodeResponse | undefined>
|
|
509
|
+
async appendToGraph(tx: GASPNode, spentBy?: string | undefined): Promise<void>
|
|
510
|
+
async validateGraphAnchor(graphID: string): Promise<void>
|
|
511
|
+
async discardGraph(graphID: string): Promise<void>
|
|
512
|
+
async finalizeGraph(graphID: string): Promise<void>
|
|
513
|
+
}
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
<details>
|
|
517
|
+
|
|
518
|
+
<summary>Class OverlayGASPStorage Details</summary>
|
|
519
|
+
|
|
520
|
+
#### Method appendToGraph
|
|
521
|
+
|
|
522
|
+
Appends a new node to a temporary graph.
|
|
523
|
+
|
|
524
|
+
```ts
|
|
525
|
+
async appendToGraph(tx: GASPNode, spentBy?: string | undefined): Promise<void>
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
Argument Details
|
|
529
|
+
|
|
530
|
+
+ **tx**
|
|
531
|
+
+ The node to append to this graph.
|
|
532
|
+
+ **spentBy**
|
|
533
|
+
+ Unless this is the same node identified by the graph ID, denotes the TXID and input index for the node which spent this one, in 36-byte format.
|
|
534
|
+
|
|
535
|
+
Throws
|
|
536
|
+
|
|
537
|
+
If the node cannot be appended to the graph, either because the graph ID is for a graph the recipient does not want or because the graph has grown to be too large before being finalized.
|
|
538
|
+
|
|
539
|
+
#### Method discardGraph
|
|
540
|
+
|
|
541
|
+
Deletes all data associated with a temporary graph that has failed to sync, if the graph exists.
|
|
542
|
+
|
|
543
|
+
```ts
|
|
544
|
+
async discardGraph(graphID: string): Promise<void>
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
Argument Details
|
|
548
|
+
|
|
549
|
+
+ **graphID**
|
|
550
|
+
+ The TXID and output index (in 36-byte format) for the UTXO at the tip of this graph.
|
|
551
|
+
|
|
552
|
+
#### Method finalizeGraph
|
|
553
|
+
|
|
554
|
+
Finalizes a graph, solidifying the new UTXO and its ancestors so that it will appear in the list of known UTXOs.
|
|
555
|
+
|
|
556
|
+
```ts
|
|
557
|
+
async finalizeGraph(graphID: string): Promise<void>
|
|
558
|
+
```
|
|
559
|
+
|
|
560
|
+
Argument Details
|
|
561
|
+
|
|
562
|
+
+ **graphID**
|
|
563
|
+
+ The TXID and output index (in 36-byte format) for the UTXO at the root of this graph.
|
|
564
|
+
|
|
565
|
+
#### Method findNeededInputs
|
|
566
|
+
|
|
567
|
+
For a given node, returns the inputs needed to complete the graph, including whether updated metadata is requested for those inputs.
|
|
568
|
+
|
|
569
|
+
```ts
|
|
570
|
+
async findNeededInputs(tx: GASPNode): Promise<GASPNodeResponse | undefined>
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
Returns
|
|
574
|
+
|
|
575
|
+
A promise for a mapping of requested input transactions and whether metadata should be provided for each.
|
|
576
|
+
|
|
577
|
+
Argument Details
|
|
578
|
+
|
|
579
|
+
+ **tx**
|
|
580
|
+
+ The node for which needed inputs should be found.
|
|
581
|
+
|
|
582
|
+
#### Method hydrateGASPNode
|
|
583
|
+
|
|
584
|
+
For a given txid and output index, returns the associated transaction, a merkle proof if the transaction is in a block, and metadata if if requested. If no metadata is requested, metadata hashes on inputs are not returned.
|
|
585
|
+
|
|
586
|
+
```ts
|
|
587
|
+
async hydrateGASPNode(graphID: string, txid: string, outputIndex: number, metadata: boolean): Promise<GASPNode>
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
#### Method validateGraphAnchor
|
|
591
|
+
|
|
592
|
+
Checks whether the given graph, in its current state, makes reference only to transactions that are proven in the blockchain, or already known by the recipient to be valid.
|
|
593
|
+
Additionally, in a breadth-first manner (ensuring that all inputs for any given node are processed before nodes that spend them), it ensures that the root node remains valid according to the rules of the overlay's topic manager,
|
|
594
|
+
while considering any coins which the Manager had previously indicated were either valid or invalid.
|
|
595
|
+
|
|
596
|
+
```ts
|
|
597
|
+
async validateGraphAnchor(graphID: string): Promise<void>
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
Argument Details
|
|
601
|
+
|
|
602
|
+
+ **graphID**
|
|
603
|
+
+ The TXID and output index (in 36-byte format) for the UTXO at the tip of this graph.
|
|
604
|
+
|
|
605
|
+
Throws
|
|
606
|
+
|
|
607
|
+
If the graph is not well-anchored, according to the rules of Bitcoin or the rules of the Overlay Topic Manager.
|
|
608
|
+
|
|
609
|
+
</details>
|
|
610
|
+
|
|
611
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
612
|
+
|
|
613
|
+
---
|
|
326
614
|
### Class: Engine
|
|
327
615
|
|
|
328
|
-
|
|
616
|
+
An engine for running BSV Overlay Services (topic managers and lookup services).
|
|
329
617
|
|
|
330
618
|
```ts
|
|
331
|
-
export
|
|
619
|
+
export class Engine {
|
|
332
620
|
constructor(public managers: {
|
|
333
621
|
[key: string]: TopicManager;
|
|
334
622
|
}, public lookupServices: {
|
|
335
623
|
[key: string]: LookupService;
|
|
336
|
-
}, public storage: Storage, public chainTracker: ChainTracker)
|
|
337
|
-
async submit(taggedBEEF: TaggedBEEF): Promise<STEAK>
|
|
624
|
+
}, public storage: Storage, public chainTracker: ChainTracker | "scripts only", public hostingURL?: string, public shipTrackers?: string[], public slapTrackers?: string[], public broadcaster?: Broadcaster, public advertiser?: Advertiser, public syncConfiguration?: SyncConfiguration, public logTime = false, public logPrefix = "[OVERLAY_ENGINE] ", public throwOnBroadcastFailure = false, public overlayBroadcastFacilitator: OverlayBroadcastFacilitator = new HTTPSOverlayBroadcastFacilitator(), public logger: typeof console = console)
|
|
625
|
+
async submit(taggedBEEF: TaggedBEEF, onSteakReady?: (steak: STEAK) => void, mode: "historical-tx" | "current-tx" = "current-tx"): Promise<STEAK>
|
|
338
626
|
async lookup(lookupQuestion: LookupQuestion): Promise<LookupAnswer>
|
|
339
|
-
async
|
|
340
|
-
async
|
|
341
|
-
async
|
|
627
|
+
async syncAdvertisements(): Promise<void>
|
|
628
|
+
async startGASPSync(): Promise<void>
|
|
629
|
+
async provideForeignSyncResponse(initialRequest: GASPInitialRequest, topic: string): Promise<GASPInitialResponse>
|
|
630
|
+
async provideForeignGASPNode(graphID: string, txid: string, outputIndex: number): Promise<GASPNode>
|
|
631
|
+
async getUTXOHistory(output: Output, historySelector?: ((beef: number[], outputIndex: number, currentDepth: number) => Promise<boolean>) | number, currentDepth = 0): Promise<Output | undefined>
|
|
632
|
+
async handleNewMerkleProof(txid: string, proof: MerklePath, blockHeight?: number): Promise<void>
|
|
633
|
+
async listTopicManagers(): Promise<Record<string, {
|
|
634
|
+
name: string;
|
|
635
|
+
shortDescription: string;
|
|
636
|
+
iconURL?: string;
|
|
637
|
+
version?: string;
|
|
638
|
+
informationURL?: string;
|
|
639
|
+
}>>
|
|
640
|
+
async listLookupServices(): Promise<Record<string, {
|
|
641
|
+
name: string;
|
|
642
|
+
shortDescription: string;
|
|
643
|
+
iconURL?: string;
|
|
644
|
+
version?: string;
|
|
645
|
+
informationURL?: string;
|
|
646
|
+
}>>
|
|
647
|
+
async getDocumentationForTopicManager(manager: any): Promise<string>
|
|
342
648
|
async getDocumentationForLookupServiceProvider(provider: any): Promise<string>
|
|
343
649
|
}
|
|
344
650
|
```
|
|
@@ -356,7 +662,7 @@ constructor(public managers: {
|
|
|
356
662
|
[key: string]: TopicManager;
|
|
357
663
|
}, public lookupServices: {
|
|
358
664
|
[key: string]: LookupService;
|
|
359
|
-
}, public storage: Storage, public chainTracker: ChainTracker)
|
|
665
|
+
}, public storage: Storage, public chainTracker: ChainTracker | "scripts only", public hostingURL?: string, public shipTrackers?: string[], public slapTrackers?: string[], public broadcaster?: Broadcaster, public advertiser?: Advertiser, public syncConfiguration?: SyncConfiguration, public logTime = false, public logPrefix = "[OVERLAY_ENGINE] ", public throwOnBroadcastFailure = false, public overlayBroadcastFacilitator: OverlayBroadcastFacilitator = new HTTPSOverlayBroadcastFacilitator(), public logger: typeof console = console)
|
|
360
666
|
```
|
|
361
667
|
|
|
362
668
|
Argument Details
|
|
@@ -369,8 +675,28 @@ Argument Details
|
|
|
369
675
|
+ for interacting with internally-managed persistent data
|
|
370
676
|
+ **chainTracker**
|
|
371
677
|
+ Verifies SPV data associated with transactions
|
|
372
|
-
+ **
|
|
373
|
-
+
|
|
678
|
+
+ **hostingURL**
|
|
679
|
+
+ The URL this engine is hosted at. Required if going to support peer-discovery with an advertiser.
|
|
680
|
+
+ **Broadcaster**
|
|
681
|
+
+ broadcaster used for broadcasting the incoming transaction
|
|
682
|
+
+ **Advertiser**
|
|
683
|
+
+ handles SHIP and SLAP advertisements for peer-discovery
|
|
684
|
+
+ **shipTrackers**
|
|
685
|
+
+ SHIP domains we know to bootstrap the system
|
|
686
|
+
+ **slapTrackers**
|
|
687
|
+
+ SLAP domains we know to bootstrap the system
|
|
688
|
+
+ **syncConfiguration**
|
|
689
|
+
+ — Configuration object describing historical synchronization of topics.
|
|
690
|
+
+ **logTime**
|
|
691
|
+
+ Enables / disables the timing logs for various operations in the Overlay submit route.
|
|
692
|
+
+ **logPrefix**
|
|
693
|
+
+ Supports overriding the log prefix with a custom string.
|
|
694
|
+
+ **throwOnBroadcastFailure**
|
|
695
|
+
+ Enables / disables throwing an error when a transaction broadcast failure is detected.
|
|
696
|
+
+ **overlayBroadcastFacilitator**
|
|
697
|
+
+ Facilitator for propagation to other Overlay Services.
|
|
698
|
+
+ **logger**
|
|
699
|
+
+ The place where log entries are written.
|
|
374
700
|
|
|
375
701
|
#### Method getDocumentationForLookupServiceProvider
|
|
376
702
|
|
|
@@ -384,45 +710,101 @@ Returns
|
|
|
384
710
|
|
|
385
711
|
- the documentation for the lookup service
|
|
386
712
|
|
|
387
|
-
#### Method
|
|
713
|
+
#### Method getDocumentationForTopicManager
|
|
388
714
|
|
|
389
715
|
Run a query to get the documentation for a particular topic manager
|
|
390
716
|
|
|
391
717
|
```ts
|
|
392
|
-
async
|
|
718
|
+
async getDocumentationForTopicManager(manager: any): Promise<string>
|
|
393
719
|
```
|
|
394
720
|
|
|
395
721
|
Returns
|
|
396
722
|
|
|
397
723
|
- the documentation for the topic manager
|
|
398
724
|
|
|
399
|
-
#### Method
|
|
725
|
+
#### Method getUTXOHistory
|
|
726
|
+
|
|
727
|
+
Traverse and return the history of a UTXO.
|
|
728
|
+
|
|
729
|
+
This method traverses the history of a given Unspent Transaction Output (UTXO) and returns
|
|
730
|
+
its historical data based on the provided history selector and current depth.
|
|
731
|
+
|
|
732
|
+
```ts
|
|
733
|
+
async getUTXOHistory(output: Output, historySelector?: ((beef: number[], outputIndex: number, currentDepth: number) => Promise<boolean>) | number, currentDepth = 0): Promise<Output | undefined>
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
Returns
|
|
737
|
+
|
|
738
|
+
- A promise that resolves to the output history if found, or undefined if not.
|
|
739
|
+
|
|
740
|
+
Argument Details
|
|
741
|
+
|
|
742
|
+
+ **output**
|
|
743
|
+
+ The UTXO to traverse the history for.
|
|
744
|
+
+ **historySelector**
|
|
745
|
+
+ Optionally directs the history traversal:
|
|
746
|
+
- If a number, denotes how many previous spends (in terms of chain depth) to include.
|
|
747
|
+
- If a function, accepts a BEEF-formatted transaction, an output index, and the current depth as parameters,
|
|
748
|
+
returning a promise that resolves to a boolean indicating whether to include the output in the history.
|
|
749
|
+
+ **currentDepth**
|
|
750
|
+
+ The current depth of the traversal relative to the top-level UTXO.
|
|
751
|
+
|
|
752
|
+
#### Method handleNewMerkleProof
|
|
753
|
+
|
|
754
|
+
Recursively prune UTXOs when an incoming Merkle Proof is received.
|
|
755
|
+
|
|
756
|
+
```ts
|
|
757
|
+
async handleNewMerkleProof(txid: string, proof: MerklePath, blockHeight?: number): Promise<void>
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
Argument Details
|
|
761
|
+
|
|
762
|
+
+ **txid**
|
|
763
|
+
+ Transaction ID of the associated outputs to prune.
|
|
764
|
+
+ **proof**
|
|
765
|
+
+ Merkle proof containing the Merkle path and other relevant data to verify the transaction.
|
|
766
|
+
+ **blockHeight**
|
|
767
|
+
+ The block height associated with the incoming merkle proof.
|
|
768
|
+
|
|
769
|
+
#### Method listLookupServices
|
|
400
770
|
|
|
401
771
|
Find a list of supported lookup services
|
|
402
772
|
|
|
403
773
|
```ts
|
|
404
|
-
async
|
|
774
|
+
async listLookupServices(): Promise<Record<string, {
|
|
775
|
+
name: string;
|
|
776
|
+
shortDescription: string;
|
|
777
|
+
iconURL?: string;
|
|
778
|
+
version?: string;
|
|
779
|
+
informationURL?: string;
|
|
780
|
+
}>>
|
|
405
781
|
```
|
|
406
782
|
|
|
407
783
|
Returns
|
|
408
784
|
|
|
409
|
-
-
|
|
785
|
+
- Supported lookup services and their metadata
|
|
410
786
|
|
|
411
787
|
#### Method listTopicManagers
|
|
412
788
|
|
|
413
789
|
Find a list of supported topic managers
|
|
414
790
|
|
|
415
791
|
```ts
|
|
416
|
-
async listTopicManagers(): Promise<string
|
|
792
|
+
async listTopicManagers(): Promise<Record<string, {
|
|
793
|
+
name: string;
|
|
794
|
+
shortDescription: string;
|
|
795
|
+
iconURL?: string;
|
|
796
|
+
version?: string;
|
|
797
|
+
informationURL?: string;
|
|
798
|
+
}>>
|
|
417
799
|
```
|
|
418
800
|
|
|
419
801
|
Returns
|
|
420
802
|
|
|
421
|
-
-
|
|
803
|
+
- Supported topic managers and their metadata
|
|
422
804
|
|
|
423
805
|
#### Method lookup
|
|
424
806
|
|
|
425
|
-
Submit a lookup question to the Overlay Services Engine, and receive
|
|
807
|
+
Submit a lookup question to the Overlay Services Engine, and receive back a Lookup Answer
|
|
426
808
|
|
|
427
809
|
```ts
|
|
428
810
|
async lookup(lookupQuestion: LookupQuestion): Promise<LookupAnswer>
|
|
@@ -437,12 +819,74 @@ Argument Details
|
|
|
437
819
|
+ **LookupQuestion**
|
|
438
820
|
+ — The question to ask the Overlay Services Engine
|
|
439
821
|
|
|
822
|
+
#### Method provideForeignGASPNode
|
|
823
|
+
|
|
824
|
+
Provides a GASPNode for the given graphID, transaction ID, and output index.
|
|
825
|
+
|
|
826
|
+
```ts
|
|
827
|
+
async provideForeignGASPNode(graphID: string, txid: string, outputIndex: number): Promise<GASPNode>
|
|
828
|
+
```
|
|
829
|
+
|
|
830
|
+
Returns
|
|
831
|
+
|
|
832
|
+
A promise that resolves to a GASPNode containing the raw transaction and other optional data.
|
|
833
|
+
|
|
834
|
+
Argument Details
|
|
835
|
+
|
|
836
|
+
+ **graphID**
|
|
837
|
+
+ The identifier for the graph to which this node belongs (in the format txid.outputIndex).
|
|
838
|
+
+ **txid**
|
|
839
|
+
+ The transaction ID for the requested output from somewhere within the graph's history.
|
|
840
|
+
+ **outputIndex**
|
|
841
|
+
+ The index of the output in the transaction.
|
|
842
|
+
|
|
843
|
+
Throws
|
|
844
|
+
|
|
845
|
+
An error if no output is found for the given transaction ID and output index.
|
|
846
|
+
|
|
847
|
+
#### Method provideForeignSyncResponse
|
|
848
|
+
|
|
849
|
+
Given a GASP request, create an initial response.
|
|
850
|
+
|
|
851
|
+
This method processes an initial synchronization request by finding the relevant UTXOs for the given topic
|
|
852
|
+
since the provided block height in the request. It constructs a response that includes a list of these UTXOs
|
|
853
|
+
and the min block height from the initial request.
|
|
854
|
+
|
|
855
|
+
```ts
|
|
856
|
+
async provideForeignSyncResponse(initialRequest: GASPInitialRequest, topic: string): Promise<GASPInitialResponse>
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
Returns
|
|
860
|
+
|
|
861
|
+
A promise that resolves to a GASPInitialResponse containing the list of UTXOs and the provided min block height.
|
|
862
|
+
|
|
863
|
+
Argument Details
|
|
864
|
+
|
|
865
|
+
+ **initialRequest**
|
|
866
|
+
+ The GASP initial request containing the version and the block height since the last sync.
|
|
867
|
+
+ **topic**
|
|
868
|
+
+ The topic for which UTXOs are being requested.
|
|
869
|
+
|
|
870
|
+
#### Method startGASPSync
|
|
871
|
+
|
|
872
|
+
This method goes through each topic that we support syncing and attempts to sync with each endpoint
|
|
873
|
+
associated with that topic. If the sync configuration is 'SHIP', it will sync to all peers that support
|
|
874
|
+
the topic.
|
|
875
|
+
|
|
876
|
+
```ts
|
|
877
|
+
async startGASPSync(): Promise<void>
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
Throws
|
|
881
|
+
|
|
882
|
+
Error if the overlay service engine is not configured for topical synchronization.
|
|
883
|
+
|
|
440
884
|
#### Method submit
|
|
441
885
|
|
|
442
886
|
Submits a transaction for processing by Overlay Services.
|
|
443
887
|
|
|
444
888
|
```ts
|
|
445
|
-
async submit(taggedBEEF: TaggedBEEF): Promise<STEAK>
|
|
889
|
+
async submit(taggedBEEF: TaggedBEEF, onSteakReady?: (steak: STEAK) => void, mode: "historical-tx" | "current-tx" = "current-tx"): Promise<STEAK>
|
|
446
890
|
```
|
|
447
891
|
|
|
448
892
|
Returns
|
|
@@ -452,31 +896,70 @@ The submitted transaction execution acknowledgement
|
|
|
452
896
|
Argument Details
|
|
453
897
|
|
|
454
898
|
+ **taggedBEEF**
|
|
455
|
-
+
|
|
899
|
+
+ The transaction to process
|
|
900
|
+
+ **onSTEAKReady**
|
|
901
|
+
+ Optional callback function invoked when the STEAK is ready.
|
|
902
|
+
+ **mode**
|
|
903
|
+
+ — Indicates the submission behavior, whether historical or current. Historical transactions are not broadcast or propagated.
|
|
904
|
+
|
|
905
|
+
The optional callback function should be used to get STEAK when ready, and avoid waiting for broadcast and transaction propagation to complete.
|
|
906
|
+
|
|
907
|
+
#### Method syncAdvertisements
|
|
908
|
+
|
|
909
|
+
Ensures alignment between the current SHIP/SLAP advertisements and the
|
|
910
|
+
configured Topic Managers and Lookup Services in the engine.
|
|
911
|
+
|
|
912
|
+
This method performs the following actions:
|
|
913
|
+
1. Retrieves the current configuration of topics and services.
|
|
914
|
+
2. Fetches the existing SHIP advertisements for each configured topic.
|
|
915
|
+
3. Fetches the existing SLAP advertisements for each configured service.
|
|
916
|
+
4. Compares the current configuration with the fetched advertisements to determine which advertisements
|
|
917
|
+
need to be created or revoked.
|
|
918
|
+
5. Creates new SHIP/SLAP advertisements if they do not exist for the configured topics/services.
|
|
919
|
+
6. Revokes existing SHIP/SLAP advertisements if they are no longer required based on the current configuration.
|
|
920
|
+
|
|
921
|
+
The function uses the `Advertiser` methods to create or revoke advertisements and ensures the updates are
|
|
922
|
+
submitted to the SHIP/SLAP overlay networks using the engine's `submit()` method.
|
|
923
|
+
|
|
924
|
+
```ts
|
|
925
|
+
async syncAdvertisements(): Promise<void>
|
|
926
|
+
```
|
|
927
|
+
|
|
928
|
+
Returns
|
|
929
|
+
|
|
930
|
+
A promise that resolves when the synchronization process is complete.
|
|
931
|
+
|
|
932
|
+
Throws
|
|
933
|
+
|
|
934
|
+
Will throw an error if there are issues during the advertisement synchronization process.
|
|
456
935
|
|
|
457
936
|
</details>
|
|
458
937
|
|
|
459
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
938
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
460
939
|
|
|
461
940
|
---
|
|
462
941
|
### Class: KnexStorage
|
|
463
942
|
|
|
464
943
|
```ts
|
|
465
|
-
export
|
|
944
|
+
export class KnexStorage implements Storage {
|
|
466
945
|
knex: Knex;
|
|
467
946
|
constructor(knex: Knex)
|
|
468
|
-
async findOutput(txid: string, outputIndex: number, topic?: string, spent?: boolean): Promise<Output | null>
|
|
947
|
+
async findOutput(txid: string, outputIndex: number, topic?: string, spent?: boolean, includeBEEF: boolean = false): Promise<Output | null>
|
|
948
|
+
async findOutputsForTransaction(txid: string, includeBEEF: boolean = false): Promise<Output[]>
|
|
949
|
+
async findUTXOsForTopic(topic: string, since?: number, includeBEEF: boolean = false): Promise<Output[]>
|
|
469
950
|
async deleteOutput(txid: string, outputIndex: number, topic: string): Promise<void>
|
|
470
|
-
async insertOutput(output: Output)
|
|
951
|
+
async insertOutput(output: Output): Promise<void>
|
|
471
952
|
async markUTXOAsSpent(txid: string, outputIndex: number, topic?: string): Promise<void>
|
|
472
|
-
async updateConsumedBy(txid: string, outputIndex: number, topic: string, consumedBy: {
|
|
953
|
+
async updateConsumedBy(txid: string, outputIndex: number, topic: string, consumedBy: Array<{
|
|
473
954
|
txid: string;
|
|
474
955
|
outputIndex: number;
|
|
475
|
-
}
|
|
956
|
+
}>): Promise<void>
|
|
957
|
+
async updateTransactionBEEF(txid: string, beef: number[]): Promise<void>
|
|
958
|
+
async updateOutputBlockHeight(txid: string, outputIndex: number, topic: string, blockHeight: number): Promise<void>
|
|
476
959
|
async insertAppliedTransaction(tx: {
|
|
477
960
|
txid: string;
|
|
478
961
|
topic: string;
|
|
479
|
-
})
|
|
962
|
+
}): Promise<void>
|
|
480
963
|
async doesAppliedTransactionExist(tx: {
|
|
481
964
|
txid: string;
|
|
482
965
|
topic: string;
|
|
@@ -484,87 +967,123 @@ export default class KnexStorage implements Storage {
|
|
|
484
967
|
}
|
|
485
968
|
```
|
|
486
969
|
|
|
487
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
970
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
488
971
|
|
|
489
972
|
---
|
|
490
|
-
##
|
|
973
|
+
## Functions
|
|
491
974
|
|
|
492
975
|
| |
|
|
493
976
|
| --- |
|
|
494
|
-
| [
|
|
495
|
-
| [
|
|
496
|
-
| [
|
|
497
|
-
| [
|
|
498
|
-
| [
|
|
499
|
-
| [
|
|
500
|
-
| [
|
|
977
|
+
| [down](#function-down) |
|
|
978
|
+
| [down](#function-down) |
|
|
979
|
+
| [down](#function-down) |
|
|
980
|
+
| [down](#function-down) |
|
|
981
|
+
| [up](#function-up) |
|
|
982
|
+
| [up](#function-up) |
|
|
983
|
+
| [up](#function-up) |
|
|
984
|
+
| [up](#function-up) |
|
|
501
985
|
|
|
502
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
986
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
503
987
|
|
|
504
988
|
---
|
|
505
989
|
|
|
506
|
-
###
|
|
990
|
+
### Function: up
|
|
991
|
+
|
|
992
|
+
```ts
|
|
993
|
+
export async function up(knex: Knex): Promise<void>
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
507
997
|
|
|
508
|
-
|
|
998
|
+
---
|
|
999
|
+
### Function: down
|
|
509
1000
|
|
|
510
1001
|
```ts
|
|
511
|
-
export
|
|
512
|
-
outputsToAdmit: number[];
|
|
513
|
-
coinsToRetain: number[];
|
|
514
|
-
}
|
|
1002
|
+
export async function down(knex: Knex): Promise<void>
|
|
515
1003
|
```
|
|
516
1004
|
|
|
517
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
1005
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
518
1006
|
|
|
519
1007
|
---
|
|
520
|
-
###
|
|
1008
|
+
### Function: up
|
|
1009
|
+
|
|
1010
|
+
```ts
|
|
1011
|
+
export async function up(knex: Knex): Promise<void>
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
521
1015
|
|
|
522
|
-
|
|
1016
|
+
---
|
|
1017
|
+
### Function: down
|
|
523
1018
|
|
|
524
1019
|
```ts
|
|
525
|
-
export
|
|
526
|
-
service: string;
|
|
527
|
-
query: unknown;
|
|
528
|
-
}
|
|
1020
|
+
export async function down(knex: Knex): Promise<void>
|
|
529
1021
|
```
|
|
530
1022
|
|
|
531
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
1023
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
532
1024
|
|
|
533
1025
|
---
|
|
534
|
-
###
|
|
1026
|
+
### Function: up
|
|
535
1027
|
|
|
536
|
-
|
|
1028
|
+
```ts
|
|
1029
|
+
export async function up(knex: Knex): Promise<void>
|
|
1030
|
+
```
|
|
1031
|
+
|
|
1032
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
1033
|
+
|
|
1034
|
+
---
|
|
1035
|
+
### Function: down
|
|
537
1036
|
|
|
538
1037
|
```ts
|
|
539
|
-
export
|
|
540
|
-
txid: string;
|
|
541
|
-
outputIndex: number;
|
|
542
|
-
history?: ((beef: number[], outputIndex: number, currentDepth: number) => Promise<boolean>) | number;
|
|
543
|
-
}[]
|
|
1038
|
+
export async function down(knex: Knex): Promise<void>
|
|
544
1039
|
```
|
|
545
1040
|
|
|
546
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
1041
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
547
1042
|
|
|
548
1043
|
---
|
|
549
|
-
###
|
|
1044
|
+
### Function: up
|
|
550
1045
|
|
|
551
|
-
|
|
552
|
-
|
|
1046
|
+
```ts
|
|
1047
|
+
export async function up(knex: Knex): Promise<void>
|
|
1048
|
+
```
|
|
1049
|
+
|
|
1050
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
1051
|
+
|
|
1052
|
+
---
|
|
1053
|
+
### Function: down
|
|
553
1054
|
|
|
554
1055
|
```ts
|
|
555
|
-
export
|
|
556
|
-
type: "output-list";
|
|
557
|
-
outputs: Array<{
|
|
558
|
-
beef: number[];
|
|
559
|
-
outputIndex: number;
|
|
560
|
-
}>;
|
|
561
|
-
} | {
|
|
562
|
-
type: "freeform";
|
|
563
|
-
result: unknown;
|
|
564
|
-
}
|
|
1056
|
+
export async function down(knex: Knex): Promise<void>
|
|
565
1057
|
```
|
|
566
1058
|
|
|
567
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
1059
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
1060
|
+
|
|
1061
|
+
---
|
|
1062
|
+
## Types
|
|
1063
|
+
|
|
1064
|
+
| |
|
|
1065
|
+
| --- |
|
|
1066
|
+
| [LookupFormula](#type-lookupformula) |
|
|
1067
|
+
| [Output](#type-output) |
|
|
1068
|
+
| [SyncConfiguration](#type-syncconfiguration) |
|
|
1069
|
+
|
|
1070
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
1071
|
+
|
|
1072
|
+
---
|
|
1073
|
+
|
|
1074
|
+
### Type: LookupFormula
|
|
1075
|
+
|
|
1076
|
+
The formula that will be used by the Overlay Services Engine to compute the Lookup Answer. Can be returned by Lookup Services in response to a Lookup Question.
|
|
1077
|
+
|
|
1078
|
+
```ts
|
|
1079
|
+
export type LookupFormula = Array<{
|
|
1080
|
+
txid: string;
|
|
1081
|
+
outputIndex: number;
|
|
1082
|
+
history?: ((beef: number[], outputIndex: number, currentDepth: number) => Promise<boolean>) | number;
|
|
1083
|
+
}>
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
568
1087
|
|
|
569
1088
|
---
|
|
570
1089
|
### Type: Output
|
|
@@ -579,43 +1098,48 @@ export type Output = {
|
|
|
579
1098
|
satoshis: number;
|
|
580
1099
|
topic: string;
|
|
581
1100
|
spent: boolean;
|
|
582
|
-
|
|
583
|
-
outputsConsumed: {
|
|
1101
|
+
outputsConsumed: Array<{
|
|
584
1102
|
txid: string;
|
|
585
1103
|
outputIndex: number;
|
|
586
|
-
}
|
|
587
|
-
consumedBy: {
|
|
1104
|
+
}>;
|
|
1105
|
+
consumedBy: Array<{
|
|
588
1106
|
txid: string;
|
|
589
1107
|
outputIndex: number;
|
|
590
|
-
}
|
|
1108
|
+
}>;
|
|
1109
|
+
beef?: number[];
|
|
1110
|
+
blockHeight?: number;
|
|
591
1111
|
}
|
|
592
1112
|
```
|
|
593
1113
|
|
|
594
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
1114
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
595
1115
|
|
|
596
1116
|
---
|
|
597
|
-
### Type:
|
|
1117
|
+
### Type: SyncConfiguration
|
|
598
1118
|
|
|
599
|
-
|
|
1119
|
+
Configuration for synchronizing supported topic managers.
|
|
600
1120
|
|
|
601
|
-
|
|
602
|
-
export type TaggedBEEF = {
|
|
603
|
-
beef: number[];
|
|
604
|
-
topics: string[];
|
|
605
|
-
}
|
|
606
|
-
```
|
|
1121
|
+
This configuration determines which topics should support synchronization and specifies the mode of synchronization.
|
|
607
1122
|
|
|
608
|
-
|
|
1123
|
+
There are two synchronization modes:
|
|
1124
|
+
1. Sync to predefined hardcoded peers for the specified topic, including associated hosting URLs.
|
|
1125
|
+
2. Use SHIP (Service Host Interconnect Protocol) to sync with all known peers that support the specified topic.
|
|
609
1126
|
|
|
610
|
-
|
|
611
|
-
|
|
1127
|
+
Each entry in the configuration object maps a topic to either an array of overlay service peers (hardcoded URLs) or the string 'SHIP' (for dynamic syncing using SHIP).
|
|
1128
|
+
|
|
1129
|
+
Example
|
|
612
1130
|
|
|
613
|
-
|
|
1131
|
+
```ts
|
|
1132
|
+
// Example usage of SyncConfiguration
|
|
1133
|
+
const config: SyncConfiguration = {
|
|
1134
|
+
"topicManager1": ["http://peer1.com", "http://peer2.com"],
|
|
1135
|
+
"topicManager2": "SHIP"
|
|
1136
|
+
}
|
|
1137
|
+
```
|
|
614
1138
|
|
|
615
1139
|
```ts
|
|
616
|
-
export type
|
|
1140
|
+
export type SyncConfiguration = Record<string, string[] | "SHIP" | false>
|
|
617
1141
|
```
|
|
618
1142
|
|
|
619
|
-
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Types](#types)
|
|
1143
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
620
1144
|
|
|
621
1145
|
---
|