@bsv/overlay 0.1.0-alpha.1

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.
Files changed (119) hide show
  1. package/LICENSE.txt +28 -0
  2. package/README.md +220 -0
  3. package/dist/cjs/mod.js +43 -0
  4. package/dist/cjs/mod.js.map +1 -0
  5. package/dist/cjs/package.json +53 -0
  6. package/dist/cjs/src/AdmittanceInstructions.js +3 -0
  7. package/dist/cjs/src/AdmittanceInstructions.js.map +1 -0
  8. package/dist/cjs/src/Engine.js +361 -0
  9. package/dist/cjs/src/Engine.js.map +1 -0
  10. package/dist/cjs/src/LookupAnswer.js +3 -0
  11. package/dist/cjs/src/LookupAnswer.js.map +1 -0
  12. package/dist/cjs/src/LookupFormula.js +3 -0
  13. package/dist/cjs/src/LookupFormula.js.map +1 -0
  14. package/dist/cjs/src/LookupQuestion.js +3 -0
  15. package/dist/cjs/src/LookupQuestion.js.map +1 -0
  16. package/dist/cjs/src/LookupService.js +3 -0
  17. package/dist/cjs/src/LookupService.js.map +1 -0
  18. package/dist/cjs/src/Output.js +3 -0
  19. package/dist/cjs/src/Output.js.map +1 -0
  20. package/dist/cjs/src/STEAK.js +3 -0
  21. package/dist/cjs/src/STEAK.js.map +1 -0
  22. package/dist/cjs/src/TaggedBEEF.js +3 -0
  23. package/dist/cjs/src/TaggedBEEF.js.map +1 -0
  24. package/dist/cjs/src/TopicManager.js +3 -0
  25. package/dist/cjs/src/TopicManager.js.map +1 -0
  26. package/dist/cjs/src/storage/Storage.js +3 -0
  27. package/dist/cjs/src/storage/Storage.js.map +1 -0
  28. package/dist/cjs/src/storage/knex/KnexStorage.js +76 -0
  29. package/dist/cjs/src/storage/knex/KnexStorage.js.map +1 -0
  30. package/dist/cjs/src/storage/knex/all-migrations.js +11 -0
  31. package/dist/cjs/src/storage/knex/all-migrations.js.map +1 -0
  32. package/dist/cjs/src/storage/knex/migrations/2024-05-18-001-initial.js +33 -0
  33. package/dist/cjs/src/storage/knex/migrations/2024-05-18-001-initial.js.map +1 -0
  34. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
  35. package/dist/esm/mod.js +17 -0
  36. package/dist/esm/mod.js.map +1 -0
  37. package/dist/esm/src/AdmittanceInstructions.js +2 -0
  38. package/dist/esm/src/AdmittanceInstructions.js.map +1 -0
  39. package/dist/esm/src/Engine.js +357 -0
  40. package/dist/esm/src/Engine.js.map +1 -0
  41. package/dist/esm/src/LookupAnswer.js +2 -0
  42. package/dist/esm/src/LookupAnswer.js.map +1 -0
  43. package/dist/esm/src/LookupFormula.js +2 -0
  44. package/dist/esm/src/LookupFormula.js.map +1 -0
  45. package/dist/esm/src/LookupQuestion.js +2 -0
  46. package/dist/esm/src/LookupQuestion.js.map +1 -0
  47. package/dist/esm/src/LookupService.js +2 -0
  48. package/dist/esm/src/LookupService.js.map +1 -0
  49. package/dist/esm/src/Output.js +2 -0
  50. package/dist/esm/src/Output.js.map +1 -0
  51. package/dist/esm/src/STEAK.js +2 -0
  52. package/dist/esm/src/STEAK.js.map +1 -0
  53. package/dist/esm/src/TaggedBEEF.js +2 -0
  54. package/dist/esm/src/TaggedBEEF.js.map +1 -0
  55. package/dist/esm/src/TopicManager.js +2 -0
  56. package/dist/esm/src/TopicManager.js.map +1 -0
  57. package/dist/esm/src/storage/Storage.js +2 -0
  58. package/dist/esm/src/storage/Storage.js.map +1 -0
  59. package/dist/esm/src/storage/knex/KnexStorage.js +74 -0
  60. package/dist/esm/src/storage/knex/KnexStorage.js.map +1 -0
  61. package/dist/esm/src/storage/knex/all-migrations.js +9 -0
  62. package/dist/esm/src/storage/knex/all-migrations.js.map +1 -0
  63. package/dist/esm/src/storage/knex/migrations/2024-05-18-001-initial.js +28 -0
  64. package/dist/esm/src/storage/knex/migrations/2024-05-18-001-initial.js.map +1 -0
  65. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  66. package/dist/types/mod.d.ts +14 -0
  67. package/dist/types/mod.d.ts.map +1 -0
  68. package/dist/types/src/AdmittanceInstructions.d.ts +14 -0
  69. package/dist/types/src/AdmittanceInstructions.d.ts.map +1 -0
  70. package/dist/types/src/Engine.d.ts +92 -0
  71. package/dist/types/src/Engine.d.ts.map +1 -0
  72. package/dist/types/src/LookupAnswer.d.ts +15 -0
  73. package/dist/types/src/LookupAnswer.d.ts.map +1 -0
  74. package/dist/types/src/LookupFormula.d.ts +25 -0
  75. package/dist/types/src/LookupFormula.d.ts.map +1 -0
  76. package/dist/types/src/LookupQuestion.d.ts +15 -0
  77. package/dist/types/src/LookupQuestion.d.ts.map +1 -0
  78. package/dist/types/src/LookupService.d.ts +52 -0
  79. package/dist/types/src/LookupService.d.ts.map +1 -0
  80. package/dist/types/src/Output.d.ts +30 -0
  81. package/dist/types/src/Output.d.ts.map +1 -0
  82. package/dist/types/src/STEAK.d.ts +10 -0
  83. package/dist/types/src/STEAK.d.ts.map +1 -0
  84. package/dist/types/src/TaggedBEEF.d.ts +11 -0
  85. package/dist/types/src/TaggedBEEF.d.ts.map +1 -0
  86. package/dist/types/src/TopicManager.d.ts +27 -0
  87. package/dist/types/src/TopicManager.d.ts.map +1 -0
  88. package/dist/types/src/storage/Storage.d.ts +66 -0
  89. package/dist/types/src/storage/Storage.d.ts.map +1 -0
  90. package/dist/types/src/storage/knex/KnexStorage.d.ts +24 -0
  91. package/dist/types/src/storage/knex/KnexStorage.d.ts.map +1 -0
  92. package/dist/types/src/storage/knex/all-migrations.d.ts +10 -0
  93. package/dist/types/src/storage/knex/all-migrations.d.ts.map +1 -0
  94. package/dist/types/src/storage/knex/migrations/2024-05-18-001-initial.d.ts +4 -0
  95. package/dist/types/src/storage/knex/migrations/2024-05-18-001-initial.d.ts.map +1 -0
  96. package/dist/types/tsconfig.types.tsbuildinfo +1 -0
  97. package/docs/API.md +621 -0
  98. package/docs/README.md +8 -0
  99. package/docs/concepts/README.md +4 -0
  100. package/docs/examples/README.md +5 -0
  101. package/docs/examples/gs-wip.md +105 -0
  102. package/docs/internal/README.md +4 -0
  103. package/mod.ts +18 -0
  104. package/package.json +78 -0
  105. package/src/AdmittanceInstructions.ts +14 -0
  106. package/src/Engine.ts +419 -0
  107. package/src/LookupAnswer.ts +14 -0
  108. package/src/LookupFormula.ts +26 -0
  109. package/src/LookupQuestion.ts +15 -0
  110. package/src/LookupService.ts +52 -0
  111. package/src/Output.ts +29 -0
  112. package/src/STEAK.ts +10 -0
  113. package/src/TaggedBEEF.ts +10 -0
  114. package/src/TopicManager.ts +23 -0
  115. package/src/__tests/Engine.test.ts +792 -0
  116. package/src/storage/Storage.ts +72 -0
  117. package/src/storage/knex/KnexStorage.ts +90 -0
  118. package/src/storage/knex/all-migrations.ts +14 -0
  119. package/src/storage/knex/migrations/2024-05-18-001-initial.ts +30 -0
@@ -0,0 +1,361 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const sdk_1 = require("@bsv/sdk");
4
+ /**
5
+ * Am engine for running BSV Overlay Services (topic managers and lookup services).
6
+ */
7
+ class Engine {
8
+ /**
9
+ * Creates a new Overlay Services Engine
10
+ * @param {[key: string]: TopicManager} managers - manages topic admittance
11
+ * @param {[key: string]: LookupService} lookupServices - manages UTXO lookups
12
+ * @param {Storage} storage - for interacting with internally-managed persistent data
13
+ * @param {ChainTracker} chainTracker - Verifies SPV data associated with transactions
14
+ * @param {ProofNotifier[]} [proofNotifiers] - proof notifier services coming soon!
15
+ */
16
+ constructor(managers, lookupServices, storage, chainTracker
17
+ // public proofNotifiers: ProofNotifier[]
18
+ ) {
19
+ this.managers = managers;
20
+ this.lookupServices = lookupServices;
21
+ this.storage = storage;
22
+ this.chainTracker = chainTracker;
23
+ }
24
+ /**
25
+ * Submits a transaction for processing by Overlay Services.
26
+ * @param taggedBEEF — The transaction to process
27
+ * @returns The submitted transaction execution acknowledgement
28
+ */
29
+ async submit(taggedBEEF) {
30
+ var _a, _b;
31
+ for (const t of taggedBEEF.topics) {
32
+ if (!this.managers[t])
33
+ throw new Error(`This server does not support this topic: ${t}`);
34
+ }
35
+ // Validate the transaction SPV information
36
+ const tx = sdk_1.Transaction.fromBEEF(taggedBEEF.beef);
37
+ const txid = tx.id('hex');
38
+ const txValid = await tx.verify(this.chainTracker);
39
+ if (!txValid)
40
+ throw new Error('Unable to verify SPV information.');
41
+ // Find UTXOs belonging to a particular topic
42
+ const steak = {};
43
+ for (const topic of taggedBEEF.topics) {
44
+ // Ensure transaction is not already applied to the topic
45
+ const dupeCheck = await this.storage.doesAppliedTransactionExist({
46
+ txid,
47
+ topic
48
+ });
49
+ if (dupeCheck) {
50
+ // The transaction was already processed.
51
+ // Currently, NO OUTPUTS ARE ADMITTED FOR DUPLICATE TRANSACTIONS.
52
+ // An alternative decision, one that was decided against, would be to act as if the operation was successful: looking up and returning the list of admitted outputs from when the transaction was originally processed.
53
+ // This was decided against, because we don't want to encourage unnecessary flooding of duplicative transactions to overlay services.
54
+ steak[topic] = {
55
+ outputsToAdmit: [],
56
+ coinsToRetain: []
57
+ };
58
+ continue;
59
+ }
60
+ // Check if any input of this transaction is a previous UTXO, adding previous UTXOs to the list
61
+ const previousCoins = [];
62
+ for (const [i, input] of tx.inputs.entries()) {
63
+ const previousTXID = input.sourceTXID || ((_a = input.sourceTransaction) === null || _a === void 0 ? void 0 : _a.id('hex'));
64
+ // Check if a previous UTXO exists in the storage medium
65
+ const output = await this.storage.findOutput(previousTXID, input.sourceOutputIndex, topic);
66
+ if (output) {
67
+ previousCoins.push(i);
68
+ // This output is now spent.
69
+ await this.storage.markUTXOAsSpent(output.txid, output.outputIndex, topic);
70
+ // Notify the lookup services about the spending of this output
71
+ for (const l of Object.values(this.lookupServices)) {
72
+ try {
73
+ if (l.outputSpent) {
74
+ await l.outputSpent(output.txid, output.outputIndex, topic);
75
+ }
76
+ }
77
+ catch (_) { }
78
+ }
79
+ }
80
+ }
81
+ // Use the manager to determine which outputs are admissable
82
+ let admissableOutputs;
83
+ try {
84
+ admissableOutputs = await this.managers[topic].identifyAdmissibleOutputs(taggedBEEF.beef, previousCoins);
85
+ }
86
+ catch (_) {
87
+ // If the topic manager throws an error, other topics may still succeed, so we continue to the next one.
88
+ // No outputs were admitted to this topic in this case. Note, however, that the transaction is still valid according to Bitcoin, so it may have spent some previous overlay members. This is unavoidable and good.
89
+ steak[topic] = {
90
+ outputsToAdmit: [],
91
+ coinsToRetain: []
92
+ };
93
+ continue;
94
+ }
95
+ // Keep track of which outputs to admit, mark as stale, or retain
96
+ let outputsToAdmit = admissableOutputs.outputsToAdmit;
97
+ let staleCoins = [];
98
+ let outputsConsumed = [];
99
+ // Find which outputs should not be retained and mark them as stale
100
+ // For each of the previous UTXOs, if the the UTXO was not included in the list of UTXOs identified for retention, then it will be marked as stale.
101
+ for (const inputIndex of previousCoins) {
102
+ const previousTXID = tx.inputs[inputIndex].sourceTXID || ((_b = tx.inputs[inputIndex].sourceTransaction) === null || _b === void 0 ? void 0 : _b.id('hex'));
103
+ const previousOutputIndex = tx.inputs[inputIndex].sourceOutputIndex;
104
+ if (!admissableOutputs.coinsToRetain.includes(inputIndex)) {
105
+ staleCoins.push({
106
+ txid: previousTXID,
107
+ outputIndex: previousOutputIndex
108
+ });
109
+ }
110
+ else {
111
+ outputsConsumed.push({
112
+ txid: previousTXID,
113
+ outputIndex: previousOutputIndex
114
+ });
115
+ }
116
+ }
117
+ // Remove stale outputs recursively
118
+ for (const coin of staleCoins) {
119
+ const output = await this.storage.findOutput(coin.txid, coin.outputIndex, topic);
120
+ if (output) {
121
+ await this.deleteUTXODeep(output);
122
+ }
123
+ }
124
+ // Handle admittance and notification of incoming UTXOs
125
+ const newUTXOs = [];
126
+ for (const outputIndex of outputsToAdmit) {
127
+ // Store the output
128
+ await this.storage.insertOutput({
129
+ txid,
130
+ outputIndex,
131
+ outputScript: tx.outputs[outputIndex].lockingScript.toBinary(),
132
+ satoshis: tx.outputs[outputIndex].satoshis,
133
+ topic,
134
+ spent: false,
135
+ beef: taggedBEEF.beef,
136
+ consumedBy: [],
137
+ outputsConsumed
138
+ });
139
+ newUTXOs.push({
140
+ txid,
141
+ outputIndex
142
+ });
143
+ // Notify all the lookup services about the new UTXO
144
+ for (const l of Object.values(this.lookupServices)) {
145
+ try {
146
+ if (l.outputAdded) {
147
+ await l.outputAdded(txid, outputIndex, tx.outputs[outputIndex].lockingScript, topic);
148
+ }
149
+ }
150
+ catch (_) { }
151
+ }
152
+ }
153
+ // Update each output consumed to know who consumed it
154
+ for (const output of outputsConsumed) {
155
+ const outputToUpdate = await this.storage.findOutput(output.txid, output.outputIndex, topic);
156
+ if (outputToUpdate) {
157
+ const newConsumedBy = [...new Set([...newUTXOs, ...outputToUpdate.consumedBy])];
158
+ // Note: only update if newConsumedBy !== new Set(JSON.parse(outputToUpdate.consumedBy)) ?
159
+ await this.storage.updateConsumedBy(output.txid, output.outputIndex, topic, newConsumedBy);
160
+ }
161
+ }
162
+ // Insert the applied transaction to prevent duplicate processing
163
+ await this.storage.insertAppliedTransaction({
164
+ txid,
165
+ topic
166
+ });
167
+ // Keep track of what outputs were admitted for what topic
168
+ steak[topic] = admissableOutputs;
169
+ }
170
+ return steak;
171
+ // TODO subscribe to get notified by proof notifiers when proof is found for TX if not already present, so the tree can be chopped down
172
+ // TODO propagate transaction to other nodes according to synchronization agreements
173
+ }
174
+ /**
175
+ * Submit a lookup question to the Overlay Services Engine, and receive bakc a Lookup Answer
176
+ * @param LookupQuestion — The question to ask the Overlay Services Engine
177
+ * @returns The answer to the question
178
+ */
179
+ async lookup(lookupQuestion) {
180
+ // Validate a lookup service for the provider is found
181
+ const lookupService = this.lookupServices[lookupQuestion.service];
182
+ if (!lookupService)
183
+ throw new Error(`Lookup service not found for provider: ${lookupQuestion.service}`);
184
+ let lookupResult = await lookupService.lookup(lookupQuestion);
185
+ // Handle custom lookup service answers
186
+ if (lookupResult.type === 'freeform' || lookupResult.type === 'output-list') {
187
+ return lookupResult;
188
+ }
189
+ lookupResult = lookupResult;
190
+ const hydratedOutputs = [];
191
+ for (const { txid, outputIndex, history } of lookupResult) {
192
+ // Make sure this is an unspent output (UTXO)
193
+ const UTXO = await this.storage.findOutput(txid, outputIndex, undefined, false);
194
+ if (!UTXO)
195
+ continue;
196
+ // Get the history for this utxo and construct a BRC-8 Envelope
197
+ const output = await this.getUTXOHistory(UTXO, history, 0);
198
+ if (output) {
199
+ hydratedOutputs.push({
200
+ beef: output.beef,
201
+ outputIndex: output.outputIndex
202
+ });
203
+ }
204
+ }
205
+ return {
206
+ type: 'output-list',
207
+ outputs: hydratedOutputs
208
+ };
209
+ }
210
+ /**
211
+ * Traverse and return the history of a UTXO
212
+ * @param historySelector
213
+ * @param currentDepth
214
+ * @param output
215
+ * @param txid
216
+ * @param outputIndex
217
+ * @param id
218
+ * @returns {Promise<EnvelopeEvidenceApi>}
219
+ */
220
+ async getUTXOHistory(output, historySelector, currentDepth = 0) {
221
+ // If we have an output but no history selector, jsut return the output.
222
+ if (typeof historySelector === 'undefined') {
223
+ return output;
224
+ }
225
+ // Determine if history traversal should continue for the current node
226
+ let shouldTraverseHistory;
227
+ if (typeof historySelector !== 'number') {
228
+ shouldTraverseHistory = await historySelector(output.beef, output.outputIndex, currentDepth);
229
+ }
230
+ else {
231
+ shouldTraverseHistory = currentDepth <= historySelector;
232
+ }
233
+ if (shouldTraverseHistory === false) {
234
+ return undefined;
235
+ }
236
+ else if (output && output.outputsConsumed.length === 0) {
237
+ return output;
238
+ }
239
+ try {
240
+ // Query the storage engine for UTXOs consumed by this UTXO
241
+ // Only retrieve unique values in case outputs are doubly referenced
242
+ const outputsConsumed = output.outputsConsumed;
243
+ // Find the child outputs for each utxo consumed by the current output
244
+ const childHistories = await (await Promise.all(outputsConsumed.map(async (outputIdentifier) => {
245
+ const output = await this.storage.findOutput(outputIdentifier.txid, outputIdentifier.outputIndex);
246
+ // Make sure an output was found
247
+ if (!output) {
248
+ return undefined;
249
+ }
250
+ // Find previousUTXO history
251
+ return this.getUTXOHistory(output, historySelector, currentDepth + 1);
252
+ }))).filter(x => x !== undefined);
253
+ const tx = sdk_1.Transaction.fromBEEF(output.beef);
254
+ for (const input of childHistories) {
255
+ if (!input)
256
+ continue;
257
+ const inputIndex = tx.inputs.findIndex((input) => {
258
+ var _a;
259
+ const sourceTXID = input.sourceTXID || ((_a = input.sourceTransaction) === null || _a === void 0 ? void 0 : _a.id('hex'));
260
+ return sourceTXID === output.txid && input.sourceOutputIndex === output.outputIndex;
261
+ });
262
+ tx.inputs[inputIndex].sourceTransaction = sdk_1.Transaction.fromBEEF(input.beef);
263
+ }
264
+ const beef = tx.toBEEF();
265
+ return {
266
+ ...output,
267
+ beef
268
+ };
269
+ }
270
+ catch (e) {
271
+ // Handle any errors that occurred
272
+ // Note: Test this!
273
+ console.error(`Error retrieving UTXO history: ${e}`);
274
+ // return []
275
+ throw new Error(`Error retrieving UTXO history: ${e}`);
276
+ }
277
+ }
278
+ /**
279
+ * Delete a UTXO and all stale consumed inputs
280
+ * @param output
281
+ * @param id
282
+ * @param txid
283
+ * @param outputIndex
284
+ * @returns {Promise<void>}
285
+ */
286
+ async deleteUTXODeep(output) {
287
+ var _a;
288
+ try {
289
+ // Delete the current output IFF there are no references to it
290
+ if (output.consumedBy.length === 0) {
291
+ await this.storage.deleteOutput(output.txid, output.outputIndex, output.topic);
292
+ // Notify the lookup services of the UTXO being deleted
293
+ for (const l of Object.values(this.lookupServices)) {
294
+ try {
295
+ await ((_a = l.outputDeleted) === null || _a === void 0 ? void 0 : _a.call(l, output.txid, output.outputIndex, output.topic));
296
+ }
297
+ catch (_) { }
298
+ }
299
+ }
300
+ // If there are no more consumed utxos, return
301
+ if (output.outputsConsumed.length === 0) {
302
+ return;
303
+ }
304
+ // Delete any stale outputs that were consumed as inputs
305
+ output.outputsConsumed.map(async (outputIdentifier) => {
306
+ const staleOutput = await this.storage.findOutput(outputIdentifier.txid, outputIdentifier.outputIndex, output.topic);
307
+ // Make sure an output was found
308
+ if (!staleOutput) {
309
+ return undefined;
310
+ }
311
+ // Parse out the existing data, then concat the new outputs with no duplicates
312
+ if (staleOutput.consumedBy.length !== 0) {
313
+ staleOutput.consumedBy = staleOutput.consumedBy.filter(x => x.txid !== output.txid && x.outputIndex !== output.outputIndex);
314
+ // Update with the new consumedBy data
315
+ await this.storage.updateConsumedBy(outputIdentifier.txid, outputIdentifier.outputIndex, output.topic, staleOutput.consumedBy);
316
+ }
317
+ // Find previousUTXO history
318
+ return await this.deleteUTXODeep(staleOutput);
319
+ });
320
+ }
321
+ catch (error) {
322
+ throw new Error(`Failed to delete all stale outputs: ${error}`);
323
+ }
324
+ }
325
+ /**
326
+ * Find a list of supported topic managers
327
+ * @public
328
+ * @returns {Promise<string[]>} - array of supported topic managers
329
+ */
330
+ async listTopicManagers() {
331
+ return Object.keys(this.managers);
332
+ }
333
+ /**
334
+ * Find a list of supported lookup services
335
+ * @public
336
+ * @returns {Promise<string[]>} - array of supported lookup services
337
+ */
338
+ async listLookupServiceProviders() {
339
+ return Object.keys(this.lookupServices);
340
+ }
341
+ /**
342
+ * Run a query to get the documentation for a particular topic manager
343
+ * @public
344
+ * @returns {Promise<string>} - the documentation for the topic manager
345
+ */
346
+ async getDocumentationForTopicManger(manager) {
347
+ var _a, _b;
348
+ return ((_b = (_a = this.managers[manager]).getDocumentation) === null || _b === void 0 ? void 0 : _b.call(_a)) || 'No documentation found!';
349
+ }
350
+ /**
351
+ * Run a query to get the documentation for a particular lookup service
352
+ * @public
353
+ * @returns {Promise<string>} - the documentation for the lookup service
354
+ */
355
+ async getDocumentationForLookupServiceProvider(provider) {
356
+ var _a, _b;
357
+ return ((_b = (_a = this.lookupServices[provider]).getDocumentation) === null || _b === void 0 ? void 0 : _b.call(_a)) || 'No documentation found!';
358
+ }
359
+ }
360
+ exports.default = Engine;
361
+ //# sourceMappingURL=Engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Engine.js","sourceRoot":"","sources":["../../../src/Engine.ts"],"names":[],"mappings":";;AAUA,kCAAoD;AAEpD;;GAEG;AACH,MAAqB,MAAM;IACvB;;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AED;;;;OAIG;IACH,KAAK,CAAC,wCAAwC,CAAC,QAAa;;QACxD,OAAO,CAAA,MAAA,MAAA,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAC,gBAAgB,kDAAI,KAAI,yBAAyB,CAAA;IAC1F,CAAC;CACJ;AAnZD,yBAmZC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LookupAnswer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LookupAnswer.js","sourceRoot":"","sources":["../../../src/LookupAnswer.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LookupFormula.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LookupFormula.js","sourceRoot":"","sources":["../../../src/LookupFormula.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LookupQuestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LookupQuestion.js","sourceRoot":"","sources":["../../../src/LookupQuestion.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=LookupService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LookupService.js","sourceRoot":"","sources":["../../../src/LookupService.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Output.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Output.js","sourceRoot":"","sources":["../../../src/Output.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=STEAK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"STEAK.js","sourceRoot":"","sources":["../../../src/STEAK.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TaggedBEEF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaggedBEEF.js","sourceRoot":"","sources":["../../../src/TaggedBEEF.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TopicManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TopicManager.js","sourceRoot":"","sources":["../../../src/TopicManager.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Storage.js","sourceRoot":"","sources":["../../../../src/storage/Storage.ts"],"names":[],"mappings":""}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class KnexStorage {
4
+ constructor(knex) {
5
+ this.knex = knex;
6
+ }
7
+ async findOutput(txid, outputIndex, topic, spent) {
8
+ const search = {
9
+ txid,
10
+ outputIndex
11
+ };
12
+ if (topic !== undefined)
13
+ search.topic = topic;
14
+ if (spent !== undefined)
15
+ search.spent = spent;
16
+ const [output] = await this.knex('outputs').where(search).select('txid', 'outputIndex', 'outputScript', 'topic', 'satoshis', 'beef', 'outputsConsumed', 'spent', 'consumedBy');
17
+ if (!output) {
18
+ return null;
19
+ }
20
+ return {
21
+ ...output,
22
+ outputScript: [...output.outputScript],
23
+ beef: [...output.beef],
24
+ spent: Boolean(output.spent),
25
+ outputsConsumed: JSON.parse(output.outputsConsumed),
26
+ consumedBy: JSON.parse(output.consumedBy)
27
+ };
28
+ }
29
+ async deleteOutput(txid, outputIndex, topic) {
30
+ await this.knex('outputs').where({
31
+ txid, outputIndex, topic
32
+ }).del();
33
+ }
34
+ async insertOutput(output) {
35
+ await this.knex('outputs').insert({
36
+ txid: output.txid,
37
+ outputIndex: Number(output.outputIndex),
38
+ outputScript: Buffer.from(output.outputScript),
39
+ topic: output.topic,
40
+ satoshis: Number(output.satoshis),
41
+ beef: [...output.beef],
42
+ outputsConsumed: JSON.stringify(output.outputsConsumed),
43
+ consumedBy: JSON.stringify(output.consumedBy),
44
+ spent: output.spent
45
+ });
46
+ }
47
+ async markUTXOAsSpent(txid, outputIndex, topic) {
48
+ await this.knex('outputs').where({
49
+ txid,
50
+ outputIndex,
51
+ topic
52
+ }).update('spent', true);
53
+ }
54
+ async updateConsumedBy(txid, outputIndex, topic, consumedBy) {
55
+ await this.knex('outputs').where({
56
+ txid,
57
+ outputIndex,
58
+ topic
59
+ }).update('consumedBy', consumedBy);
60
+ }
61
+ async insertAppliedTransaction(tx) {
62
+ await this.knex('applied_transactions').insert({
63
+ txid: tx.txid,
64
+ topic: tx.topic
65
+ });
66
+ }
67
+ async doesAppliedTransactionExist(tx) {
68
+ const appliedTransactions = await this.knex('applied_transactions').where({
69
+ txid: tx.txid,
70
+ topic: tx.topic
71
+ }).select('txid', 'topic');
72
+ return appliedTransactions.length > 0;
73
+ }
74
+ }
75
+ exports.default = KnexStorage;
76
+ //# sourceMappingURL=KnexStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnexStorage.js","sourceRoot":"","sources":["../../../../../src/storage/knex/KnexStorage.ts"],"names":[],"mappings":";;AAIA,MAAqB,WAAW;IAG5B,YAAY,IAAU;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAY,EAAE,WAAmB,EAAE,KAAc,EAAE,KAAe;QAC/E,MAAM,MAAM,GAKR;YACA,IAAI;YACJ,WAAW;SACd,CAAA;QACD,IAAI,KAAK,KAAK,S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KAAK,EAAE,EAAE,CAAC,KAAK;SAClB,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAC1B,OAAO,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAA;IACzC,CAAC;CACJ;AArFD,8BAqFC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const _2024_05_18_001_initial_js_1 = require("./migrations/2024-05-18-001-initial.js");
4
+ /**
5
+ * An array of all migrations, in order.
6
+ */
7
+ const allMigrations = [
8
+ { up: _2024_05_18_001_initial_js_1.up, down: _2024_05_18_001_initial_js_1.down }
9
+ ];
10
+ exports.default = allMigrations;
11
+ //# sourceMappingURL=all-migrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"all-migrations.js","sourceRoot":"","sources":["../../../../../src/storage/knex/all-migrations.ts"],"names":[],"mappings":";;AACA,uFAAqF;AAErF;;GAEG;AACH,MAAM,aAAa,GAGb;IACE,EAAE,EAAE,EAAE,+BAAK,EAAE,IAAI,EAAE,iCAAO,EAAE;CAC/B,CAAA;AAEL,kBAAe,aAAa,CAAA"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.down = exports.up = void 0;
4
+ async function up(knex) {
5
+ await knex.schema.createTable('outputs', table => {
6
+ table.increments();
7
+ table.string('txid', 64);
8
+ table.integer('outputIndex', 10);
9
+ table.binary('outputScript');
10
+ table.string('topic');
11
+ table.integer('satoshis', 15);
12
+ table.binary('beef');
13
+ // Represents the outputs that were provided as inputs
14
+ // to the transaction that created this output.
15
+ // This indicates the correct history of this output.
16
+ table.text('outputsConsumed', 'longtext').defaultTo('[]');
17
+ // Tracks any outputs the current output is used as an input in it's creation
18
+ table.text('consumedBy', 'longtext').defaultTo('[]');
19
+ table.boolean('spent').defaultTo(false);
20
+ });
21
+ await knex.schema.createTable('applied_transactions', table => {
22
+ table.increments();
23
+ table.string('txid', 64);
24
+ table.string('topic');
25
+ });
26
+ }
27
+ exports.up = up;
28
+ async function down(knex) {
29
+ await knex.schema.dropTable('applied_transactions');
30
+ await knex.schema.dropTable('outputs');
31
+ }
32
+ exports.down = down;
33
+ //# sourceMappingURL=2024-05-18-001-initial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"2024-05-18-001-initial.js","sourceRoot":"","sources":["../../../../../../src/storage/knex/migrations/2024-05-18-001-initial.ts"],"names":[],"mappings":";;;AAEO,KAAK,UAAU,EAAE,CAAC,IAAU;IACjC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;QAC/C,KAAK,CAAC,UAAU,EAAE,CAAA;QAClB,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACxB,KAAK,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAA;QAChC,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;QAC5B,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACrB,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAA;QAC7B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QACpB,sDAAsD;QACtD,+CAA+C;QAC/C,qDAAqD;QACrD,KAAK,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACzD,6EAA6E;QAC7E,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACpD,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;IACF,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,sBAAsB,EAAE,KAAK,CAAC,EAAE;QAC5D,KAAK,CAAC,UAAU,EA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