@bsv/sdk 1.7.7 → 1.8.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 (94) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/kvstore/GlobalKVStore.js +420 -0
  3. package/dist/cjs/src/kvstore/GlobalKVStore.js.map +1 -0
  4. package/dist/cjs/src/kvstore/LocalKVStore.js +6 -6
  5. package/dist/cjs/src/kvstore/LocalKVStore.js.map +1 -1
  6. package/dist/cjs/src/kvstore/kvStoreInterpreter.js +74 -0
  7. package/dist/cjs/src/kvstore/kvStoreInterpreter.js.map +1 -0
  8. package/dist/cjs/src/kvstore/types.js +11 -0
  9. package/dist/cjs/src/kvstore/types.js.map +1 -0
  10. package/dist/cjs/src/overlay-tools/Historian.js +153 -0
  11. package/dist/cjs/src/overlay-tools/Historian.js.map +1 -0
  12. package/dist/cjs/src/script/templates/PushDrop.js +2 -2
  13. package/dist/cjs/src/script/templates/PushDrop.js.map +1 -1
  14. package/dist/cjs/src/transaction/Transaction.js +4 -4
  15. package/dist/cjs/src/transaction/Transaction.js.map +1 -1
  16. package/dist/cjs/src/transaction/fee-models/LivePolicy.js +90 -0
  17. package/dist/cjs/src/transaction/fee-models/LivePolicy.js.map +1 -0
  18. package/dist/cjs/src/transaction/fee-models/index.js +3 -1
  19. package/dist/cjs/src/transaction/fee-models/index.js.map +1 -1
  20. package/dist/cjs/src/wallet/WalletClient.js +43 -52
  21. package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
  22. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +19 -0
  23. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  24. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js +18 -1
  25. package/dist/cjs/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  26. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  27. package/dist/esm/src/kvstore/GlobalKVStore.js +416 -0
  28. package/dist/esm/src/kvstore/GlobalKVStore.js.map +1 -0
  29. package/dist/esm/src/kvstore/LocalKVStore.js +6 -6
  30. package/dist/esm/src/kvstore/LocalKVStore.js.map +1 -1
  31. package/dist/esm/src/kvstore/kvStoreInterpreter.js +47 -0
  32. package/dist/esm/src/kvstore/kvStoreInterpreter.js.map +1 -0
  33. package/dist/esm/src/kvstore/types.js +8 -0
  34. package/dist/esm/src/kvstore/types.js.map +1 -0
  35. package/dist/esm/src/overlay-tools/Historian.js +155 -0
  36. package/dist/esm/src/overlay-tools/Historian.js.map +1 -0
  37. package/dist/esm/src/script/templates/PushDrop.js +2 -2
  38. package/dist/esm/src/script/templates/PushDrop.js.map +1 -1
  39. package/dist/esm/src/transaction/Transaction.js +4 -4
  40. package/dist/esm/src/transaction/Transaction.js.map +1 -1
  41. package/dist/esm/src/transaction/fee-models/LivePolicy.js +85 -0
  42. package/dist/esm/src/transaction/fee-models/LivePolicy.js.map +1 -0
  43. package/dist/esm/src/transaction/fee-models/index.js +1 -0
  44. package/dist/esm/src/transaction/fee-models/index.js.map +1 -1
  45. package/dist/esm/src/wallet/WalletClient.js +43 -52
  46. package/dist/esm/src/wallet/WalletClient.js.map +1 -1
  47. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +19 -0
  48. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  49. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js +18 -1
  50. package/dist/esm/src/wallet/substrates/WalletWireTransceiver.js.map +1 -1
  51. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  52. package/dist/types/src/kvstore/GlobalKVStore.d.ts +129 -0
  53. package/dist/types/src/kvstore/GlobalKVStore.d.ts.map +1 -0
  54. package/dist/types/src/kvstore/kvStoreInterpreter.d.ts +22 -0
  55. package/dist/types/src/kvstore/kvStoreInterpreter.d.ts.map +1 -0
  56. package/dist/types/src/kvstore/types.d.ts +106 -0
  57. package/dist/types/src/kvstore/types.d.ts.map +1 -0
  58. package/dist/types/src/overlay-tools/Historian.d.ts +92 -0
  59. package/dist/types/src/overlay-tools/Historian.d.ts.map +1 -0
  60. package/dist/types/src/script/templates/PushDrop.d.ts +6 -5
  61. package/dist/types/src/script/templates/PushDrop.d.ts.map +1 -1
  62. package/dist/types/src/transaction/Transaction.d.ts +2 -2
  63. package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
  64. package/dist/types/src/transaction/fee-models/LivePolicy.d.ts +41 -0
  65. package/dist/types/src/transaction/fee-models/LivePolicy.d.ts.map +1 -0
  66. package/dist/types/src/transaction/fee-models/index.d.ts +1 -0
  67. package/dist/types/src/transaction/fee-models/index.d.ts.map +1 -1
  68. package/dist/types/src/wallet/WalletClient.d.ts +1 -1
  69. package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
  70. package/dist/types/src/wallet/substrates/WalletWireProcessor.d.ts.map +1 -1
  71. package/dist/types/src/wallet/substrates/WalletWireTransceiver.d.ts.map +1 -1
  72. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  73. package/dist/umd/bundle.js +3 -3
  74. package/dist/umd/bundle.js.map +1 -1
  75. package/docs/reference/script.md +7 -19
  76. package/docs/reference/transaction.md +75 -6
  77. package/docs/reference/wallet.md +1 -1
  78. package/package.json +1 -1
  79. package/src/kvstore/GlobalKVStore.ts +478 -0
  80. package/src/kvstore/LocalKVStore.ts +7 -7
  81. package/src/kvstore/__tests/GlobalKVStore.test.ts +965 -0
  82. package/src/kvstore/__tests/LocalKVStore.test.ts +72 -0
  83. package/src/kvstore/kvStoreInterpreter.ts +49 -0
  84. package/src/kvstore/types.ts +114 -0
  85. package/src/overlay-tools/Historian.ts +195 -0
  86. package/src/overlay-tools/__tests/Historian.test.ts +690 -0
  87. package/src/script/templates/PushDrop.ts +6 -5
  88. package/src/transaction/Transaction.ts +4 -4
  89. package/src/transaction/fee-models/LivePolicy.ts +97 -0
  90. package/src/transaction/fee-models/__tests/LivePolicy.test.ts +148 -0
  91. package/src/transaction/fee-models/index.ts +1 -0
  92. package/src/wallet/WalletClient.ts +50 -51
  93. package/src/wallet/substrates/WalletWireProcessor.ts +21 -0
  94. package/src/wallet/substrates/WalletWireTransceiver.ts +22 -10
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/sdk",
3
- "version": "1.7.7",
3
+ "version": "1.8.1",
4
4
  "type": "commonjs",
5
5
  "description": "BSV Blockchain Software Development Kit",
6
6
  "files": [
@@ -0,0 +1,420 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.GlobalKVStore = void 0;
30
+ const Transaction_js_1 = __importDefault(require("../transaction/Transaction.js"));
31
+ const Utils = __importStar(require("../primitives/utils.js"));
32
+ const index_js_1 = require("../overlay-tools/index.js");
33
+ const index_js_2 = require("../script/index.js");
34
+ const WalletClient_js_1 = __importDefault(require("../wallet/WalletClient.js"));
35
+ const Beef_js_1 = require("../transaction/Beef.js");
36
+ const Historian_js_1 = require("../overlay-tools/Historian.js");
37
+ const kvStoreInterpreter_js_1 = require("./kvStoreInterpreter.js");
38
+ const ProtoWallet_js_1 = require("../wallet/ProtoWallet.js");
39
+ const types_js_1 = require("./types.js");
40
+ /**
41
+ * Default configuration values for GlobalKVStore operations.
42
+ * Provides sensible defaults for overlay connection and protocol settings.
43
+ */
44
+ const DEFAULT_CONFIG = {
45
+ protocolID: [1, 'kvstore'],
46
+ serviceName: 'ls_kvstore',
47
+ tokenAmount: 1,
48
+ topics: ['tm_kvstore'],
49
+ networkPreset: 'mainnet',
50
+ acceptDelayedBroadcast: false,
51
+ tokenSetDescription: '',
52
+ tokenUpdateDescription: '',
53
+ tokenRemovalDescription: '' // Will be set dynamically
54
+ };
55
+ /**
56
+ * Implements a global key-value storage system which uses an overlay service to track key-value pairs.
57
+ * Each key-value pair is represented by a PushDrop token output.
58
+ * Allows getting, setting, and removing key-value pairs with optional fetching by protocolID and history tracking.
59
+ */
60
+ class GlobalKVStore {
61
+ /**
62
+ * Creates an instance of the GlobalKVStore.
63
+ *
64
+ * @param {KVStoreConfig} [config={}] - Configuration options for the KVStore. Defaults to empty object.
65
+ * @param {WalletInterface} [config.wallet] - Wallet to use for operations. Defaults to WalletClient.
66
+ * @throws {Error} If the configuration contains invalid parameters.
67
+ */
68
+ constructor(config = {}) {
69
+ /**
70
+ * A map to store locks for each key to ensure atomic updates.
71
+ * @private
72
+ */
73
+ this.keyLocks = new Map();
74
+ /**
75
+ * Cached user identity key
76
+ * @private
77
+ */
78
+ this.cachedIdentityKey = null;
79
+ // Merge with defaults to create a fully resolved config
80
+ this.config = { ...DEFAULT_CONFIG, ...config };
81
+ this.wallet = config.wallet ?? new WalletClient_js_1.default();
82
+ this.historian = new Historian_js_1.Historian(kvStoreInterpreter_js_1.kvStoreInterpreter);
83
+ this.lookupResolver = new index_js_1.LookupResolver({
84
+ networkPreset: this.config.networkPreset
85
+ });
86
+ this.topicBroadcaster = new index_js_1.TopicBroadcaster(this.config.topics, {
87
+ networkPreset: this.config.networkPreset
88
+ });
89
+ }
90
+ /**
91
+ * Retrieves data from the KVStore.
92
+ * Can query by key+controller (single result), protocolID, controller, or key (multiple results).
93
+ *
94
+ * @param {KVStoreQuery} query - Query parameters sent to overlay
95
+ * @param {KVStoreGetOptions} [options={}] - Configuration options for the get operation
96
+ * @returns {Promise<KVStoreEntry | KVStoreEntry[] | undefined>} Single entry for key+controller queries, array for all other queries
97
+ */
98
+ async get(query, options = {}) {
99
+ if (Object.keys(query).length === 0) {
100
+ throw new Error('Must specify either key, controller, or protocolID');
101
+ }
102
+ if (query.key != null && query.controller != null) {
103
+ // Specific key+controller query - return single entry
104
+ const entries = await this.queryOverlay(query, options);
105
+ return entries.length > 0 ? entries[0] : undefined;
106
+ }
107
+ return await this.queryOverlay(query, options);
108
+ }
109
+ /**
110
+ * Sets a key-value pair. The current user (wallet identity) becomes the controller.
111
+ *
112
+ * @param {string} key - The key to set (user computes this however they want)
113
+ * @param {string} value - The value to store
114
+ * @param {KVStoreSetOptions} [options={}] - Configuration options for the set operation
115
+ * @returns {Promise<OutpointString>} The outpoint of the created token
116
+ */
117
+ async set(key, value, options = {}) {
118
+ if (typeof key !== 'string' || key.length === 0) {
119
+ throw new Error('Key must be a non-empty string.');
120
+ }
121
+ if (typeof value !== 'string') {
122
+ throw new Error('Value must be a string.');
123
+ }
124
+ const controller = await this.getIdentityKey();
125
+ const lockQueue = await this.queueOperationOnKey(key);
126
+ const protocolID = options.protocolID ?? this.config.protocolID;
127
+ const tokenSetDescription = (options.tokenSetDescription != null && options.tokenSetDescription !== '') ? options.tokenSetDescription : `Create KVStore value for ${key}`;
128
+ const tokenUpdateDescription = (options.tokenUpdateDescription != null && options.tokenUpdateDescription !== '') ? options.tokenUpdateDescription : `Update KVStore value for ${key}`;
129
+ const tokenAmount = options.tokenAmount ?? this.config.tokenAmount;
130
+ try {
131
+ // Check for existing token to spend
132
+ const existingEntries = await this.queryOverlay({ key, controller }, { includeToken: true });
133
+ const existingToken = existingEntries.length > 0 ? existingEntries[0].token : undefined;
134
+ // Create PushDrop locking script
135
+ const pushdrop = new index_js_2.PushDrop(this.wallet, this.config.originator);
136
+ const lockingScript = await pushdrop.lock([
137
+ Utils.toArray(JSON.stringify(protocolID), 'utf8'),
138
+ Utils.toArray(key, 'utf8'),
139
+ Utils.toArray(value, 'utf8'),
140
+ Utils.toArray(controller, 'hex')
141
+ ], protocolID ?? this.config.protocolID, Utils.toUTF8(Utils.toArray(key, 'utf8')), 'anyone', true);
142
+ let inputs = [];
143
+ let inputBEEF;
144
+ if (existingToken != null) {
145
+ inputs = [{
146
+ outpoint: `${existingToken.txid}.${existingToken.outputIndex}`,
147
+ unlockingScriptLength: 74,
148
+ inputDescription: 'Previous KVStore token'
149
+ }];
150
+ inputBEEF = existingToken.beef;
151
+ }
152
+ if (inputs.length > 0) {
153
+ // Update existing token
154
+ const { signableTransaction } = await this.wallet.createAction({
155
+ description: tokenUpdateDescription,
156
+ inputBEEF: inputBEEF?.toBinary(),
157
+ inputs,
158
+ outputs: [{
159
+ satoshis: tokenAmount ?? this.config.tokenAmount,
160
+ lockingScript: lockingScript.toHex(),
161
+ outputDescription: 'KVStore token'
162
+ }],
163
+ options: {
164
+ acceptDelayedBroadcast: this.config.acceptDelayedBroadcast,
165
+ randomizeOutputs: false
166
+ }
167
+ }, this.config.originator);
168
+ if (signableTransaction == null) {
169
+ throw new Error('Unable to create update transaction');
170
+ }
171
+ const tx = Transaction_js_1.default.fromAtomicBEEF(signableTransaction.tx);
172
+ const unlocker = pushdrop.unlock(this.config.protocolID, key, 'anyone');
173
+ const unlockingScript = await unlocker.sign(tx, 0);
174
+ const { tx: finalTx } = await this.wallet.signAction({
175
+ reference: signableTransaction.reference,
176
+ spends: { 0: { unlockingScript: unlockingScript.toHex() } }
177
+ }, this.config.originator);
178
+ if (finalTx == null) {
179
+ throw new Error('Unable to finalize update transaction');
180
+ }
181
+ const transaction = Transaction_js_1.default.fromAtomicBEEF(finalTx);
182
+ await this.submitToOverlay(transaction);
183
+ return `${transaction.id('hex')}.0`;
184
+ }
185
+ else {
186
+ // Create new token
187
+ const { tx } = await this.wallet.createAction({
188
+ description: tokenSetDescription,
189
+ outputs: [{
190
+ satoshis: tokenAmount ?? this.config.tokenAmount,
191
+ lockingScript: lockingScript.toHex(),
192
+ outputDescription: 'KVStore token'
193
+ }],
194
+ options: {
195
+ acceptDelayedBroadcast: this.config.acceptDelayedBroadcast,
196
+ randomizeOutputs: false
197
+ }
198
+ }, this.config.originator);
199
+ if (tx == null) {
200
+ throw new Error('Failed to create transaction');
201
+ }
202
+ const transaction = Transaction_js_1.default.fromAtomicBEEF(tx);
203
+ await this.submitToOverlay(transaction);
204
+ return `${transaction.id('hex')}.0`;
205
+ }
206
+ }
207
+ finally {
208
+ if (lockQueue.length > 0) {
209
+ this.finishOperationOnKey(key, lockQueue);
210
+ }
211
+ }
212
+ }
213
+ /**
214
+ * Removes the key-value pair associated with the given key from the overlay service.
215
+ *
216
+ * @param {string} key - The key to remove.
217
+ * @param {CreateActionOutput[] | undefined} [outputs=undefined] - Additional outputs to include in the removal transaction.
218
+ * @param {KVStoreRemoveOptions} [options=undefined] - Optional parameters for the removal operation.
219
+ * @returns {Promise<HexString>} A promise that resolves to the txid of the removal transaction if successful.
220
+ * @throws {Error} If the key is invalid.
221
+ * @throws {Error} If the key does not exist in the store.
222
+ * @throws {Error} If the overlay service is unreachable or the transaction fails.
223
+ * @throws {Error} If there are existing tokens that cannot be unlocked.
224
+ */
225
+ async remove(key, outputs, options = {}) {
226
+ if (typeof key !== 'string' || key.length === 0) {
227
+ throw new Error('Key must be a non-empty string.');
228
+ }
229
+ const controller = await this.getIdentityKey();
230
+ const lockQueue = await this.queueOperationOnKey(key);
231
+ const protocolID = options.protocolID ?? this.config.protocolID;
232
+ const tokenRemovalDescription = (options.tokenRemovalDescription != null && options.tokenRemovalDescription !== '') ? options.tokenRemovalDescription : `Remove KVStore value for ${key}`;
233
+ try {
234
+ const existingEntries = await this.queryOverlay({ key, controller }, { includeToken: true });
235
+ if (existingEntries.length === 0 || existingEntries[0].token == null) {
236
+ throw new Error('The item did not exist, no item was deleted.');
237
+ }
238
+ const existingToken = existingEntries[0].token;
239
+ const inputs = [{
240
+ outpoint: `${existingToken.txid}.${existingToken.outputIndex}`,
241
+ unlockingScriptLength: 74,
242
+ inputDescription: 'KVStore token to remove'
243
+ }];
244
+ const pushdrop = new index_js_2.PushDrop(this.wallet, this.config.originator);
245
+ const { signableTransaction } = await this.wallet.createAction({
246
+ description: tokenRemovalDescription,
247
+ inputBEEF: existingToken.beef.toBinary(),
248
+ inputs,
249
+ outputs,
250
+ options: {
251
+ acceptDelayedBroadcast: this.config.acceptDelayedBroadcast
252
+ }
253
+ }, this.config.originator);
254
+ if (signableTransaction == null) {
255
+ throw new Error('Unable to create removal transaction');
256
+ }
257
+ const tx = Transaction_js_1.default.fromAtomicBEEF(signableTransaction.tx);
258
+ const unlocker = pushdrop.unlock(protocolID ?? this.config.protocolID, key, 'anyone');
259
+ const unlockingScript = await unlocker.sign(tx, 0);
260
+ const { tx: finalTx } = await this.wallet.signAction({
261
+ reference: signableTransaction.reference,
262
+ spends: { 0: { unlockingScript: unlockingScript.toHex() } }
263
+ }, this.config.originator);
264
+ if (finalTx == null) {
265
+ throw new Error('Unable to finalize removal transaction');
266
+ }
267
+ const transaction = Transaction_js_1.default.fromAtomicBEEF(finalTx);
268
+ await this.submitToOverlay(transaction);
269
+ return transaction.id('hex');
270
+ }
271
+ finally {
272
+ if (lockQueue.length > 0) {
273
+ this.finishOperationOnKey(key, lockQueue);
274
+ }
275
+ }
276
+ }
277
+ /**
278
+ * Queues an operation on a specific key to ensure atomic updates.
279
+ * Prevents concurrent operations on the same key from interfering with each other.
280
+ *
281
+ * @param {string} key - The key to queue an operation for.
282
+ * @returns {Promise<Array<(value: void | PromiseLike<void>) => void>>} The lock queue for cleanup.
283
+ * @private
284
+ */
285
+ async queueOperationOnKey(key) {
286
+ // Check if a lock exists for this key and wait for it to resolve
287
+ let lockQueue = this.keyLocks.get(key);
288
+ if (lockQueue == null) {
289
+ lockQueue = [];
290
+ this.keyLocks.set(key, lockQueue);
291
+ }
292
+ let resolveNewLock = () => { };
293
+ const newLock = new Promise((resolve) => {
294
+ resolveNewLock = resolve;
295
+ if (lockQueue != null) {
296
+ lockQueue.push(resolve);
297
+ }
298
+ });
299
+ // If we are the only request, resolve the lock immediately, queue remains at 1 item until request ends.
300
+ if (lockQueue.length === 1) {
301
+ resolveNewLock();
302
+ }
303
+ await newLock;
304
+ return lockQueue;
305
+ }
306
+ /**
307
+ * Finishes an operation on a key and resolves the next waiting operation.
308
+ *
309
+ * @param {string} key - The key to finish the operation for.
310
+ * @param {Array<(value: void | PromiseLike<void>) => void>} lockQueue - The lock queue from queueOperationOnKey.
311
+ * @private
312
+ */
313
+ finishOperationOnKey(key, lockQueue) {
314
+ lockQueue.shift(); // Remove the current lock from the queue
315
+ if (lockQueue.length > 0) {
316
+ // If there are more locks waiting, resolve the next one
317
+ lockQueue[0]();
318
+ }
319
+ else {
320
+ // Clean up empty queue to prevent memory leak
321
+ this.keyLocks.delete(key);
322
+ }
323
+ }
324
+ /**
325
+ * Helper function to fetch and cache user identity key
326
+ *
327
+ * @returns {Promise<PubKeyHex>} The identity key of the current user
328
+ * @private
329
+ */
330
+ async getIdentityKey() {
331
+ if (this.cachedIdentityKey == null) {
332
+ this.cachedIdentityKey = (await this.wallet.getPublicKey({ identityKey: true }, this.config.originator)).publicKey;
333
+ }
334
+ return this.cachedIdentityKey;
335
+ }
336
+ /**
337
+ * Queries the overlay service for KV entries.
338
+ *
339
+ * @param {KVStoreQuery} query - Query parameters sent to overlay
340
+ * @param {KVStoreGetOptions} options - Configuration options for the query
341
+ * @returns {Promise<KVStoreEntry[]>} Array of matching KV entries
342
+ * @private
343
+ */
344
+ async queryOverlay(query, options = {}) {
345
+ const answer = await this.lookupResolver.query({
346
+ service: options.serviceName ?? this.config.serviceName,
347
+ query
348
+ });
349
+ if (answer.type !== 'output-list' || answer.outputs.length === 0) {
350
+ return [];
351
+ }
352
+ const entries = [];
353
+ for (const result of answer.outputs) {
354
+ try {
355
+ const tx = Transaction_js_1.default.fromBEEF(result.beef);
356
+ const output = tx.outputs[result.outputIndex];
357
+ const decoded = index_js_2.PushDrop.decode(output.lockingScript);
358
+ if (decoded.fields.length !== 5) {
359
+ continue;
360
+ }
361
+ // Verify signature
362
+ const anyoneWallet = new ProtoWallet_js_1.ProtoWallet('anyone');
363
+ const signature = decoded.fields.pop();
364
+ try {
365
+ await anyoneWallet.verifySignature({
366
+ data: decoded.fields.reduce((a, e) => [...a, ...e], []),
367
+ signature,
368
+ counterparty: Utils.toHex(decoded.fields[types_js_1.kvProtocol.controller]),
369
+ protocolID: JSON.parse(Utils.toUTF8(decoded.fields[types_js_1.kvProtocol.protocolID])),
370
+ keyID: Utils.toUTF8(decoded.fields[types_js_1.kvProtocol.key])
371
+ });
372
+ }
373
+ catch (error) {
374
+ // Skip all outputs that fail signature verification
375
+ continue;
376
+ }
377
+ const entry = {
378
+ key: Utils.toUTF8(decoded.fields[types_js_1.kvProtocol.key]),
379
+ value: Utils.toUTF8(decoded.fields[types_js_1.kvProtocol.value]),
380
+ controller: Utils.toHex(decoded.fields[types_js_1.kvProtocol.controller]),
381
+ protocolID: JSON.parse(Utils.toUTF8(decoded.fields[types_js_1.kvProtocol.protocolID]))
382
+ };
383
+ if (options.includeToken === true) {
384
+ entry.token = {
385
+ txid: tx.id('hex'),
386
+ outputIndex: result.outputIndex,
387
+ beef: Beef_js_1.Beef.fromBinary(result.beef),
388
+ satoshis: output.satoshis ?? 1
389
+ };
390
+ }
391
+ if (options.history === true) {
392
+ entry.history = await this.historian.buildHistory(tx, {
393
+ key: entry.key,
394
+ protocolID: entry.protocolID
395
+ });
396
+ }
397
+ entries.push(entry);
398
+ }
399
+ catch (error) {
400
+ continue;
401
+ }
402
+ }
403
+ return entries;
404
+ }
405
+ /**
406
+ * Submits a transaction to an overlay service using TopicBroadcaster.
407
+ * Broadcasts the transaction to the configured topics for network propagation.
408
+ *
409
+ * @param {Transaction} transaction - The transaction to broadcast.
410
+ * @returns {Promise<BroadcastResponse | BroadcastFailure>} The broadcast result.
411
+ * @throws {Error} If the broadcast fails or the network is unreachable.
412
+ * @private
413
+ */
414
+ async submitToOverlay(transaction) {
415
+ return await this.topicBroadcaster.broadcast(transaction);
416
+ }
417
+ }
418
+ exports.GlobalKVStore = GlobalKVStore;
419
+ exports.default = GlobalKVStore;
420
+ //# sourceMappingURL=GlobalKVStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalKVStore.js","sourceRoot":"","sources":["../../../../src/kvstore/GlobalKVStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mFAAuD;AACvD,8DAA+C;AAC/C,wDAA4E;AAG5E,iDAA6C;AAC7C,gFAAoD;AACpD,oDAA6C;AAC7C,gEAAyD;AACzD,mEAAuE;AACvE,6DAAsD;AACtD,yCAA8I;AAE9I;;;GAGG;AACH,MAAM,cAAc,GAAkB;IACpC,UAAU,EAAE,CAAC,CAAC,EAAE,SAAS,CAAC;IAC1B,WAAW,EAAE,YAAY;IACzB,WAAW,EAAE,CAAC;IACd,MAAM,EAAE,CAAC,YAAY,CAAC;IACtB,aAAa,EAAE,SAAS;IACxB,sBAAsB,EAAE,KAAK;IAC7B,mBAAmB,EAAE,EAAE;IACvB,sBAAsB,EAAE,EAAE;IAC1B,uBAAuB,EAAE,EAAE,CAAC,0BAA0B;CACvD,CAAA;AAED;;;;GAIG;AACH,MAAa,aAAa;IA4CxB;;;;;;OAMG;IACH,YAAa,SAAwB,EAAE;QAnBvC;;;WAGG;QACc,aAAQ,GAAkE,IAAI,GAAG,EAAE,CAAA;QAEpG;;;WAGG;QACK,sBAAiB,GAAqB,IAAI,CAAA;QA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CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,EAAE;wBACpD,GAAG,EAAE,KAAK,CAAC,GAAG;wBACd,UAAU,EAAE,KAAK,CAAC,UAAU;qBAC7B,CAAC,CAAA;iBACH;gBAED,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;aACpB;YAAC,OAAO,KAAK,EAAE;gBACd,SAAQ;aACT;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;;;;;OAQG;IACK,KAAK,CAAC,eAAe,CAAE,WAAwB;QACrD,OAAO,MAAM,IAAI,CAAC,gBAAgB,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IAC3D,CAAC;CACF;AAzbD,sCAybC;AAED,kBAAe,aAAa,CAAA"}
@@ -153,8 +153,8 @@ class LocalKVStore {
153
153
  }
154
154
  field = decoded.fields[0];
155
155
  }
156
- catch (_) {
157
- throw new Error(`Invalid value found. You need to call set to collapse the corrupted state (or relinquish the corrupted ${outputs[0].outpoint} output from the ${this.context} basket) before you can get this value again.`);
156
+ catch (error) {
157
+ throw new Error(`Invalid value found. You need to call set to collapse the corrupted state (or relinquish the corrupted ${outputs[0].outpoint} output from the ${this.context} basket) before you can get this value again. Original error: ${error instanceof Error ? error.message : String(error)}`);
158
158
  }
159
159
  if (!this.encrypt) {
160
160
  r.value = Utils.toUTF8(field);
@@ -264,8 +264,8 @@ class LocalKVStore {
264
264
  outpoint = `${txid}.0`;
265
265
  }
266
266
  }
267
- catch (_) {
268
- throw new Error(`There are ${outputs.length} outputs with tag ${key} that cannot be unlocked.`);
267
+ catch (error) {
268
+ throw new Error(`There are ${outputs.length} outputs with tag ${key} that cannot be unlocked. Original error: ${error instanceof Error ? error.message : String(error)}`);
269
269
  }
270
270
  return outpoint;
271
271
  }
@@ -314,8 +314,8 @@ class LocalKVStore {
314
314
  }
315
315
  txids.push(txid);
316
316
  }
317
- catch (_) {
318
- throw new Error(`There are ${totalOutputs} outputs with tag ${key} that cannot be unlocked.`);
317
+ catch (error) {
318
+ throw new Error(`There are ${totalOutputs} outputs with tag ${key} that cannot be unlocked. Original error: ${error instanceof Error ? error.message : String(error)}`);
319
319
  }
320
320
  }
321
321
  if (outputs.length === totalOutputs) {
@@ -1 +1 @@
1
- {"version":3,"file":"LocalKVStore.js","sourceRoot":"","sources":["../../../../src/kvstore/LocalKVStore.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,kFAAsD;AACtD,8DAA+C;AAE/C,gFAAoD;AACpD,mFAAuD;AACvD,oDAA6C;AAE7C;;;;GAIG;AACH,MAAqB,YAAY;IAmC/B;;;;;;;;OAQG;IACH,YACE,SAA0B,IAAI,yBAAY,EAAE,EAC5C,OAAO,GAAG,iBAAiB,EAC3B,OAAO,GAAG,IAAI,EACd,UAAmB,EACnB,sBAAsB,GAAG,KAAK;QAtBhC,2BAAsB,GAAY,KAAK,CAAA;QAEvC;;;WAGG;QACc,aAAQ,GAAkE,IAAI,GAAG,EAAE,CAAA;QAkBlG,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACrD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;SAC9D;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAA;IACtD,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAE,GAAW;QAC5C,iEAAiE;QACjE,IAAI,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACtC,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,SAAS,GAAG,EAAE,CAAA;YACd,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG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AC,UAAU,CAAC;4BAC5C,SAAS,EAAE,mBAAmB,CAAC,SAAS;4BACxC,MAAM;yBACP,CAAC,CAAA;wBACF,IAAI,IAAI,KAAK,SAAS,EAAE;4BAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;yBAAE;wBAClF,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;qBACjB;oBAAC,OAAO,KAAK,EAAE;wBACd,MAAM,IAAI,KAAK,CAAC,aAAa,YAAY,qBAAqB,GAAG,6CAA6C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;qBACxK;iBACF;gBACD,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,EAAE;oBAAE,MAAK;iBAAE;aAC/C;YACD,OAAO,KAAK,CAAA;SACb;gBAAS;YACR,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;SAC1C;IACH,CAAC;CACF;AAjVD,+BAiVC"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.kvStoreInterpreter = void 0;
27
+ const index_js_1 = require("../script/index.js");
28
+ const Utils = __importStar(require("../primitives/utils.js"));
29
+ const types_js_1 = require("./types.js");
30
+ /**
31
+ * KVStore interpreter used by Historian.
32
+ *
33
+ * Validates the KVStore PushDrop tokens: [protocolID, key, value, controller, signature].
34
+ * Filters outputs by the provided key in the interpreter context.
35
+ * Produces the plaintext value for matching outputs; returns undefined otherwise.
36
+ *
37
+ * @param transaction - The transaction to inspect.
38
+ * @param outputIndex - The index of the output within transaction.outputs.
39
+ * @param ctx - { key: string, protocolID: WalletProtocol } — per-call context specifying which key to match.
40
+ *
41
+ * @returns string | undefined — the decoded KV value if the output is a valid KVStore token for the
42
+ * given key; otherwise undefined.
43
+ */
44
+ const kvStoreInterpreter = async (transaction, outputIndex, ctx) => {
45
+ try {
46
+ const output = transaction.outputs[outputIndex];
47
+ if (output == null || output.lockingScript == null)
48
+ return undefined;
49
+ if (ctx == null || ctx.key == null)
50
+ return undefined;
51
+ // Decode the KVStore token
52
+ const decoded = index_js_1.PushDrop.decode(output.lockingScript);
53
+ // Validate KVStore token format (must have 5 fields: [protocolID, key, value, controller, signature])
54
+ if (decoded.fields.length !== Object.keys(types_js_1.kvProtocol).length)
55
+ return undefined;
56
+ // Only return values for the given key and protocolID
57
+ const key = Utils.toUTF8(decoded.fields[types_js_1.kvProtocol.key]);
58
+ const protocolID = Utils.toUTF8(decoded.fields[types_js_1.kvProtocol.protocolID]);
59
+ if (key !== ctx.key || protocolID !== JSON.stringify(ctx.protocolID))
60
+ return undefined;
61
+ try {
62
+ return Utils.toUTF8(decoded.fields[types_js_1.kvProtocol.value]);
63
+ }
64
+ catch {
65
+ return undefined;
66
+ }
67
+ }
68
+ catch {
69
+ // Skip non-KVStore outputs or malformed tokens
70
+ return undefined;
71
+ }
72
+ };
73
+ exports.kvStoreInterpreter = kvStoreInterpreter;
74
+ //# sourceMappingURL=kvStoreInterpreter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kvStoreInterpreter.js","sourceRoot":"","sources":["../../../../src/kvstore/kvStoreInterpreter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA6C;AAE7C,8DAA+C;AAC/C,yCAAuC;AAMvC;;;;;;;;;;;;;GAaG;AACI,MAAM,kBAAkB,GAA2C,KAAK,EAAE,WAAwB,EAAE,WAAmB,EAAE,GAAe,EAA+B,EAAE;IAC9K,IAAI;QACF,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAC/C,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,aAAa,IAAI,IAAI;YAAE,OAAO,SAAS,CAAA;QACpE,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,GAAG,IAAI,IAAI;YAAE,OAAO,SAAS,CAAA;QAEpD,2BAA2B;QAC3B,MAAM,OAAO,GAAG,mBAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAErD,sGAAsG;QACtG,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,qBAAU,CAAC,CAAC,MAAM;YAAE,OAAO,SAAS,CAAA;QAE9E,sDAAsD;QACtD,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAU,CAAC,GAAG,CAAC,CAAC,CAAA;QACxD,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAU,CAAC,UAAU,CAAC,CAAC,CAAA;QACtE,IAAI,GAAG,KAAK,GAAG,CAAC,GAAG,IAAI,UAAU,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC;YAAE,OAAO,SAAS,CAAA;QACtF,IAAI;YACF,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAU,CAAC,KAAK,CAAC,CAAC,CAAA;SACtD;QAAC,MAAM;YACN,OAAO,SAAS,CAAA;SACjB;KACF;IAAC,MAAM;QACN,+CAA+C;QAC/C,OAAO,SAAS,CAAA;KACjB;AACH,CAAC,CAAA;AAzBY,QAAA,kBAAkB,sBAyB9B"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kvProtocol = void 0;
4
+ exports.kvProtocol = {
5
+ protocolID: 0,
6
+ key: 1,
7
+ value: 2,
8
+ controller: 3,
9
+ signature: 4
10
+ };
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/kvstore/types.ts"],"names":[],"mappings":";;;AA2Ga,QAAA,UAAU,GAAG;IACxB,UAAU,EAAE,CAAC;IACb,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,CAAC;CACb,CAAA"}