@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
@@ -0,0 +1,416 @@
1
+ import Transaction from '../transaction/Transaction.js';
2
+ import * as Utils from '../primitives/utils.js';
3
+ import { TopicBroadcaster, LookupResolver } from '../overlay-tools/index.js';
4
+ import { PushDrop } from '../script/index.js';
5
+ import WalletClient from '../wallet/WalletClient.js';
6
+ import { Beef } from '../transaction/Beef.js';
7
+ import { Historian } from '../overlay-tools/Historian.js';
8
+ import { kvStoreInterpreter } from './kvStoreInterpreter.js';
9
+ import { ProtoWallet } from '../wallet/ProtoWallet.js';
10
+ import { kvProtocol } from './types.js';
11
+ /**
12
+ * Default configuration values for GlobalKVStore operations.
13
+ * Provides sensible defaults for overlay connection and protocol settings.
14
+ */
15
+ const DEFAULT_CONFIG = {
16
+ protocolID: [1, 'kvstore'],
17
+ serviceName: 'ls_kvstore',
18
+ tokenAmount: 1,
19
+ topics: ['tm_kvstore'],
20
+ networkPreset: 'mainnet',
21
+ acceptDelayedBroadcast: false,
22
+ tokenSetDescription: '',
23
+ tokenUpdateDescription: '',
24
+ tokenRemovalDescription: '' // Will be set dynamically
25
+ };
26
+ /**
27
+ * Implements a global key-value storage system which uses an overlay service to track key-value pairs.
28
+ * Each key-value pair is represented by a PushDrop token output.
29
+ * Allows getting, setting, and removing key-value pairs with optional fetching by protocolID and history tracking.
30
+ */
31
+ export class GlobalKVStore {
32
+ /**
33
+ * The wallet interface used to create transactions and perform cryptographic operations.
34
+ * @readonly
35
+ */
36
+ wallet;
37
+ /**
38
+ * Configuration for the KVStore instance containing all runtime options.
39
+ * @private
40
+ * @readonly
41
+ */
42
+ config;
43
+ /**
44
+ * Historian instance used to extract history from transaction outputs.
45
+ * @private
46
+ */
47
+ historian;
48
+ /**
49
+ * Lookup resolver used to query the overlay for transaction outputs.
50
+ * @private
51
+ */
52
+ lookupResolver;
53
+ /**
54
+ * Topic broadcaster used to broadcast transactions to the overlay.
55
+ * @private
56
+ */
57
+ topicBroadcaster;
58
+ /**
59
+ * A map to store locks for each key to ensure atomic updates.
60
+ * @private
61
+ */
62
+ keyLocks = new Map();
63
+ /**
64
+ * Cached user identity key
65
+ * @private
66
+ */
67
+ cachedIdentityKey = null;
68
+ /**
69
+ * Creates an instance of the GlobalKVStore.
70
+ *
71
+ * @param {KVStoreConfig} [config={}] - Configuration options for the KVStore. Defaults to empty object.
72
+ * @param {WalletInterface} [config.wallet] - Wallet to use for operations. Defaults to WalletClient.
73
+ * @throws {Error} If the configuration contains invalid parameters.
74
+ */
75
+ constructor(config = {}) {
76
+ // Merge with defaults to create a fully resolved config
77
+ this.config = { ...DEFAULT_CONFIG, ...config };
78
+ this.wallet = config.wallet ?? new WalletClient();
79
+ this.historian = new Historian(kvStoreInterpreter);
80
+ this.lookupResolver = new LookupResolver({
81
+ networkPreset: this.config.networkPreset
82
+ });
83
+ this.topicBroadcaster = new TopicBroadcaster(this.config.topics, {
84
+ networkPreset: this.config.networkPreset
85
+ });
86
+ }
87
+ /**
88
+ * Retrieves data from the KVStore.
89
+ * Can query by key+controller (single result), protocolID, controller, or key (multiple results).
90
+ *
91
+ * @param {KVStoreQuery} query - Query parameters sent to overlay
92
+ * @param {KVStoreGetOptions} [options={}] - Configuration options for the get operation
93
+ * @returns {Promise<KVStoreEntry | KVStoreEntry[] | undefined>} Single entry for key+controller queries, array for all other queries
94
+ */
95
+ async get(query, options = {}) {
96
+ if (Object.keys(query).length === 0) {
97
+ throw new Error('Must specify either key, controller, or protocolID');
98
+ }
99
+ if (query.key != null && query.controller != null) {
100
+ // Specific key+controller query - return single entry
101
+ const entries = await this.queryOverlay(query, options);
102
+ return entries.length > 0 ? entries[0] : undefined;
103
+ }
104
+ return await this.queryOverlay(query, options);
105
+ }
106
+ /**
107
+ * Sets a key-value pair. The current user (wallet identity) becomes the controller.
108
+ *
109
+ * @param {string} key - The key to set (user computes this however they want)
110
+ * @param {string} value - The value to store
111
+ * @param {KVStoreSetOptions} [options={}] - Configuration options for the set operation
112
+ * @returns {Promise<OutpointString>} The outpoint of the created token
113
+ */
114
+ async set(key, value, options = {}) {
115
+ if (typeof key !== 'string' || key.length === 0) {
116
+ throw new Error('Key must be a non-empty string.');
117
+ }
118
+ if (typeof value !== 'string') {
119
+ throw new Error('Value must be a string.');
120
+ }
121
+ const controller = await this.getIdentityKey();
122
+ const lockQueue = await this.queueOperationOnKey(key);
123
+ const protocolID = options.protocolID ?? this.config.protocolID;
124
+ const tokenSetDescription = (options.tokenSetDescription != null && options.tokenSetDescription !== '') ? options.tokenSetDescription : `Create KVStore value for ${key}`;
125
+ const tokenUpdateDescription = (options.tokenUpdateDescription != null && options.tokenUpdateDescription !== '') ? options.tokenUpdateDescription : `Update KVStore value for ${key}`;
126
+ const tokenAmount = options.tokenAmount ?? this.config.tokenAmount;
127
+ try {
128
+ // Check for existing token to spend
129
+ const existingEntries = await this.queryOverlay({ key, controller }, { includeToken: true });
130
+ const existingToken = existingEntries.length > 0 ? existingEntries[0].token : undefined;
131
+ // Create PushDrop locking script
132
+ const pushdrop = new PushDrop(this.wallet, this.config.originator);
133
+ const lockingScript = await pushdrop.lock([
134
+ Utils.toArray(JSON.stringify(protocolID), 'utf8'),
135
+ Utils.toArray(key, 'utf8'),
136
+ Utils.toArray(value, 'utf8'),
137
+ Utils.toArray(controller, 'hex')
138
+ ], protocolID ?? this.config.protocolID, Utils.toUTF8(Utils.toArray(key, 'utf8')), 'anyone', true);
139
+ let inputs = [];
140
+ let inputBEEF;
141
+ if (existingToken != null) {
142
+ inputs = [{
143
+ outpoint: `${existingToken.txid}.${existingToken.outputIndex}`,
144
+ unlockingScriptLength: 74,
145
+ inputDescription: 'Previous KVStore token'
146
+ }];
147
+ inputBEEF = existingToken.beef;
148
+ }
149
+ if (inputs.length > 0) {
150
+ // Update existing token
151
+ const { signableTransaction } = await this.wallet.createAction({
152
+ description: tokenUpdateDescription,
153
+ inputBEEF: inputBEEF?.toBinary(),
154
+ inputs,
155
+ outputs: [{
156
+ satoshis: tokenAmount ?? this.config.tokenAmount,
157
+ lockingScript: lockingScript.toHex(),
158
+ outputDescription: 'KVStore token'
159
+ }],
160
+ options: {
161
+ acceptDelayedBroadcast: this.config.acceptDelayedBroadcast,
162
+ randomizeOutputs: false
163
+ }
164
+ }, this.config.originator);
165
+ if (signableTransaction == null) {
166
+ throw new Error('Unable to create update transaction');
167
+ }
168
+ const tx = Transaction.fromAtomicBEEF(signableTransaction.tx);
169
+ const unlocker = pushdrop.unlock(this.config.protocolID, key, 'anyone');
170
+ const unlockingScript = await unlocker.sign(tx, 0);
171
+ const { tx: finalTx } = await this.wallet.signAction({
172
+ reference: signableTransaction.reference,
173
+ spends: { 0: { unlockingScript: unlockingScript.toHex() } }
174
+ }, this.config.originator);
175
+ if (finalTx == null) {
176
+ throw new Error('Unable to finalize update transaction');
177
+ }
178
+ const transaction = Transaction.fromAtomicBEEF(finalTx);
179
+ await this.submitToOverlay(transaction);
180
+ return `${transaction.id('hex')}.0`;
181
+ }
182
+ else {
183
+ // Create new token
184
+ const { tx } = await this.wallet.createAction({
185
+ description: tokenSetDescription,
186
+ outputs: [{
187
+ satoshis: tokenAmount ?? this.config.tokenAmount,
188
+ lockingScript: lockingScript.toHex(),
189
+ outputDescription: 'KVStore token'
190
+ }],
191
+ options: {
192
+ acceptDelayedBroadcast: this.config.acceptDelayedBroadcast,
193
+ randomizeOutputs: false
194
+ }
195
+ }, this.config.originator);
196
+ if (tx == null) {
197
+ throw new Error('Failed to create transaction');
198
+ }
199
+ const transaction = Transaction.fromAtomicBEEF(tx);
200
+ await this.submitToOverlay(transaction);
201
+ return `${transaction.id('hex')}.0`;
202
+ }
203
+ }
204
+ finally {
205
+ if (lockQueue.length > 0) {
206
+ this.finishOperationOnKey(key, lockQueue);
207
+ }
208
+ }
209
+ }
210
+ /**
211
+ * Removes the key-value pair associated with the given key from the overlay service.
212
+ *
213
+ * @param {string} key - The key to remove.
214
+ * @param {CreateActionOutput[] | undefined} [outputs=undefined] - Additional outputs to include in the removal transaction.
215
+ * @param {KVStoreRemoveOptions} [options=undefined] - Optional parameters for the removal operation.
216
+ * @returns {Promise<HexString>} A promise that resolves to the txid of the removal transaction if successful.
217
+ * @throws {Error} If the key is invalid.
218
+ * @throws {Error} If the key does not exist in the store.
219
+ * @throws {Error} If the overlay service is unreachable or the transaction fails.
220
+ * @throws {Error} If there are existing tokens that cannot be unlocked.
221
+ */
222
+ async remove(key, outputs, options = {}) {
223
+ if (typeof key !== 'string' || key.length === 0) {
224
+ throw new Error('Key must be a non-empty string.');
225
+ }
226
+ const controller = await this.getIdentityKey();
227
+ const lockQueue = await this.queueOperationOnKey(key);
228
+ const protocolID = options.protocolID ?? this.config.protocolID;
229
+ const tokenRemovalDescription = (options.tokenRemovalDescription != null && options.tokenRemovalDescription !== '') ? options.tokenRemovalDescription : `Remove KVStore value for ${key}`;
230
+ try {
231
+ const existingEntries = await this.queryOverlay({ key, controller }, { includeToken: true });
232
+ if (existingEntries.length === 0 || existingEntries[0].token == null) {
233
+ throw new Error('The item did not exist, no item was deleted.');
234
+ }
235
+ const existingToken = existingEntries[0].token;
236
+ const inputs = [{
237
+ outpoint: `${existingToken.txid}.${existingToken.outputIndex}`,
238
+ unlockingScriptLength: 74,
239
+ inputDescription: 'KVStore token to remove'
240
+ }];
241
+ const pushdrop = new PushDrop(this.wallet, this.config.originator);
242
+ const { signableTransaction } = await this.wallet.createAction({
243
+ description: tokenRemovalDescription,
244
+ inputBEEF: existingToken.beef.toBinary(),
245
+ inputs,
246
+ outputs,
247
+ options: {
248
+ acceptDelayedBroadcast: this.config.acceptDelayedBroadcast
249
+ }
250
+ }, this.config.originator);
251
+ if (signableTransaction == null) {
252
+ throw new Error('Unable to create removal transaction');
253
+ }
254
+ const tx = Transaction.fromAtomicBEEF(signableTransaction.tx);
255
+ const unlocker = pushdrop.unlock(protocolID ?? this.config.protocolID, key, 'anyone');
256
+ const unlockingScript = await unlocker.sign(tx, 0);
257
+ const { tx: finalTx } = await this.wallet.signAction({
258
+ reference: signableTransaction.reference,
259
+ spends: { 0: { unlockingScript: unlockingScript.toHex() } }
260
+ }, this.config.originator);
261
+ if (finalTx == null) {
262
+ throw new Error('Unable to finalize removal transaction');
263
+ }
264
+ const transaction = Transaction.fromAtomicBEEF(finalTx);
265
+ await this.submitToOverlay(transaction);
266
+ return transaction.id('hex');
267
+ }
268
+ finally {
269
+ if (lockQueue.length > 0) {
270
+ this.finishOperationOnKey(key, lockQueue);
271
+ }
272
+ }
273
+ }
274
+ /**
275
+ * Queues an operation on a specific key to ensure atomic updates.
276
+ * Prevents concurrent operations on the same key from interfering with each other.
277
+ *
278
+ * @param {string} key - The key to queue an operation for.
279
+ * @returns {Promise<Array<(value: void | PromiseLike<void>) => void>>} The lock queue for cleanup.
280
+ * @private
281
+ */
282
+ async queueOperationOnKey(key) {
283
+ // Check if a lock exists for this key and wait for it to resolve
284
+ let lockQueue = this.keyLocks.get(key);
285
+ if (lockQueue == null) {
286
+ lockQueue = [];
287
+ this.keyLocks.set(key, lockQueue);
288
+ }
289
+ let resolveNewLock = () => { };
290
+ const newLock = new Promise((resolve) => {
291
+ resolveNewLock = resolve;
292
+ if (lockQueue != null) {
293
+ lockQueue.push(resolve);
294
+ }
295
+ });
296
+ // If we are the only request, resolve the lock immediately, queue remains at 1 item until request ends.
297
+ if (lockQueue.length === 1) {
298
+ resolveNewLock();
299
+ }
300
+ await newLock;
301
+ return lockQueue;
302
+ }
303
+ /**
304
+ * Finishes an operation on a key and resolves the next waiting operation.
305
+ *
306
+ * @param {string} key - The key to finish the operation for.
307
+ * @param {Array<(value: void | PromiseLike<void>) => void>} lockQueue - The lock queue from queueOperationOnKey.
308
+ * @private
309
+ */
310
+ finishOperationOnKey(key, lockQueue) {
311
+ lockQueue.shift(); // Remove the current lock from the queue
312
+ if (lockQueue.length > 0) {
313
+ // If there are more locks waiting, resolve the next one
314
+ lockQueue[0]();
315
+ }
316
+ else {
317
+ // Clean up empty queue to prevent memory leak
318
+ this.keyLocks.delete(key);
319
+ }
320
+ }
321
+ /**
322
+ * Helper function to fetch and cache user identity key
323
+ *
324
+ * @returns {Promise<PubKeyHex>} The identity key of the current user
325
+ * @private
326
+ */
327
+ async getIdentityKey() {
328
+ if (this.cachedIdentityKey == null) {
329
+ this.cachedIdentityKey = (await this.wallet.getPublicKey({ identityKey: true }, this.config.originator)).publicKey;
330
+ }
331
+ return this.cachedIdentityKey;
332
+ }
333
+ /**
334
+ * Queries the overlay service for KV entries.
335
+ *
336
+ * @param {KVStoreQuery} query - Query parameters sent to overlay
337
+ * @param {KVStoreGetOptions} options - Configuration options for the query
338
+ * @returns {Promise<KVStoreEntry[]>} Array of matching KV entries
339
+ * @private
340
+ */
341
+ async queryOverlay(query, options = {}) {
342
+ const answer = await this.lookupResolver.query({
343
+ service: options.serviceName ?? this.config.serviceName,
344
+ query
345
+ });
346
+ if (answer.type !== 'output-list' || answer.outputs.length === 0) {
347
+ return [];
348
+ }
349
+ const entries = [];
350
+ for (const result of answer.outputs) {
351
+ try {
352
+ const tx = Transaction.fromBEEF(result.beef);
353
+ const output = tx.outputs[result.outputIndex];
354
+ const decoded = PushDrop.decode(output.lockingScript);
355
+ if (decoded.fields.length !== 5) {
356
+ continue;
357
+ }
358
+ // Verify signature
359
+ const anyoneWallet = new ProtoWallet('anyone');
360
+ const signature = decoded.fields.pop();
361
+ try {
362
+ await anyoneWallet.verifySignature({
363
+ data: decoded.fields.reduce((a, e) => [...a, ...e], []),
364
+ signature,
365
+ counterparty: Utils.toHex(decoded.fields[kvProtocol.controller]),
366
+ protocolID: JSON.parse(Utils.toUTF8(decoded.fields[kvProtocol.protocolID])),
367
+ keyID: Utils.toUTF8(decoded.fields[kvProtocol.key])
368
+ });
369
+ }
370
+ catch (error) {
371
+ // Skip all outputs that fail signature verification
372
+ continue;
373
+ }
374
+ const entry = {
375
+ key: Utils.toUTF8(decoded.fields[kvProtocol.key]),
376
+ value: Utils.toUTF8(decoded.fields[kvProtocol.value]),
377
+ controller: Utils.toHex(decoded.fields[kvProtocol.controller]),
378
+ protocolID: JSON.parse(Utils.toUTF8(decoded.fields[kvProtocol.protocolID]))
379
+ };
380
+ if (options.includeToken === true) {
381
+ entry.token = {
382
+ txid: tx.id('hex'),
383
+ outputIndex: result.outputIndex,
384
+ beef: Beef.fromBinary(result.beef),
385
+ satoshis: output.satoshis ?? 1
386
+ };
387
+ }
388
+ if (options.history === true) {
389
+ entry.history = await this.historian.buildHistory(tx, {
390
+ key: entry.key,
391
+ protocolID: entry.protocolID
392
+ });
393
+ }
394
+ entries.push(entry);
395
+ }
396
+ catch (error) {
397
+ continue;
398
+ }
399
+ }
400
+ return entries;
401
+ }
402
+ /**
403
+ * Submits a transaction to an overlay service using TopicBroadcaster.
404
+ * Broadcasts the transaction to the configured topics for network propagation.
405
+ *
406
+ * @param {Transaction} transaction - The transaction to broadcast.
407
+ * @returns {Promise<BroadcastResponse | BroadcastFailure>} The broadcast result.
408
+ * @throws {Error} If the broadcast fails or the network is unreachable.
409
+ * @private
410
+ */
411
+ async submitToOverlay(transaction) {
412
+ return await this.topicBroadcaster.broadcast(transaction);
413
+ }
414
+ }
415
+ export default GlobalKVStore;
416
+ //# sourceMappingURL=GlobalKVStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalKVStore.js","sourceRoot":"","sources":["../../../../src/kvstore/GlobalKVStore.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,+BAA+B,CAAA;AACvD,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAG5E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EA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S,CAAC,WAAW,CAAC,CAAA;IAC3D,CAAC;CACF;AAED,eAAe,aAAa,CAAA"}
@@ -149,8 +149,8 @@ export default class LocalKVStore {
149
149
  }
150
150
  field = decoded.fields[0];
151
151
  }
152
- catch (_) {
153
- 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.`);
152
+ catch (error) {
153
+ 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)}`);
154
154
  }
155
155
  if (!this.encrypt) {
156
156
  r.value = Utils.toUTF8(field);
@@ -260,8 +260,8 @@ export default class LocalKVStore {
260
260
  outpoint = `${txid}.0`;
261
261
  }
262
262
  }
263
- catch (_) {
264
- throw new Error(`There are ${outputs.length} outputs with tag ${key} that cannot be unlocked.`);
263
+ catch (error) {
264
+ throw new Error(`There are ${outputs.length} outputs with tag ${key} that cannot be unlocked. Original error: ${error instanceof Error ? error.message : String(error)}`);
265
265
  }
266
266
  return outpoint;
267
267
  }
@@ -310,8 +310,8 @@ export default class LocalKVStore {
310
310
  }
311
311
  txids.push(txid);
312
312
  }
313
- catch (_) {
314
- throw new Error(`There are ${totalOutputs} outputs with tag ${key} that cannot be unlocked.`);
313
+ catch (error) {
314
+ throw new Error(`There are ${totalOutputs} outputs with tag ${key} that cannot be unlocked. Original error: ${error instanceof Error ? error.message : String(error)}`);
315
315
  }
316
316
  }
317
317
  if (outputs.length === totalOutputs) {
@@ -1 +1 @@
1
- {"version":3,"file":"LocalKVStore.js","sourceRoot":"","sources":["../../../../src/kvstore/LocalKVStore.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,iCAAiC,CAAA;AACtD,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAA;AAE/C,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,WAAW,MAAM,+BAA+B,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AmB,CAAC,EAAE,CAAC,CAAA;wBACnF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,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"}
@@ -0,0 +1,47 @@
1
+ import { PushDrop } from '../script/index.js';
2
+ import * as Utils from '../primitives/utils.js';
3
+ import { kvProtocol } from './types.js';
4
+ /**
5
+ * KVStore interpreter used by Historian.
6
+ *
7
+ * Validates the KVStore PushDrop tokens: [protocolID, key, value, controller, signature].
8
+ * Filters outputs by the provided key in the interpreter context.
9
+ * Produces the plaintext value for matching outputs; returns undefined otherwise.
10
+ *
11
+ * @param transaction - The transaction to inspect.
12
+ * @param outputIndex - The index of the output within transaction.outputs.
13
+ * @param ctx - { key: string, protocolID: WalletProtocol } — per-call context specifying which key to match.
14
+ *
15
+ * @returns string | undefined — the decoded KV value if the output is a valid KVStore token for the
16
+ * given key; otherwise undefined.
17
+ */
18
+ export const kvStoreInterpreter = async (transaction, outputIndex, ctx) => {
19
+ try {
20
+ const output = transaction.outputs[outputIndex];
21
+ if (output == null || output.lockingScript == null)
22
+ return undefined;
23
+ if (ctx == null || ctx.key == null)
24
+ return undefined;
25
+ // Decode the KVStore token
26
+ const decoded = PushDrop.decode(output.lockingScript);
27
+ // Validate KVStore token format (must have 5 fields: [protocolID, key, value, controller, signature])
28
+ if (decoded.fields.length !== Object.keys(kvProtocol).length)
29
+ return undefined;
30
+ // Only return values for the given key and protocolID
31
+ const key = Utils.toUTF8(decoded.fields[kvProtocol.key]);
32
+ const protocolID = Utils.toUTF8(decoded.fields[kvProtocol.protocolID]);
33
+ if (key !== ctx.key || protocolID !== JSON.stringify(ctx.protocolID))
34
+ return undefined;
35
+ try {
36
+ return Utils.toUTF8(decoded.fields[kvProtocol.value]);
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ }
42
+ catch {
43
+ // Skip non-KVStore outputs or malformed tokens
44
+ return undefined;
45
+ }
46
+ };
47
+ //# sourceMappingURL=kvStoreInterpreter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kvStoreInterpreter.js","sourceRoot":"","sources":["../../../../src/kvstore/kvStoreInterpreter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAE7C,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAMvC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,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,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QAErD,sGAAsG;QACtG,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM;YAAE,OAAO,SAAS,CAAA;QAE9E,sDAAsD;QACtD,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;QACxD,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,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,UAAU,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"}
@@ -0,0 +1,8 @@
1
+ export const kvProtocol = {
2
+ protocolID: 0,
3
+ key: 1,
4
+ value: 2,
5
+ controller: 3,
6
+ signature: 4
7
+ };
8
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/kvstore/types.ts"],"names":[],"mappings":"AA2GA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU,EAAE,CAAC;IACb,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,CAAC;CACb,CAAA"}