@bsv/sdk 1.8.1 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/kvstore/index.js +3 -1
- package/dist/cjs/src/kvstore/index.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/kvstore/index.js +1 -0
- package/dist/esm/src/kvstore/index.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/kvstore/index.d.ts +1 -0
- package/dist/types/src/kvstore/index.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +3 -3
- package/dist/umd/bundle.js.map +1 -1
- package/docs/reference/compat.md +15 -27
- package/docs/reference/identity.md +12 -16
- package/docs/reference/kvstore.md +471 -4
- package/docs/reference/messages.md +0 -8
- package/docs/reference/overlay-tools.md +15 -22
- package/docs/reference/primitives.md +168 -168
- package/docs/reference/registry.md +9 -19
- package/docs/reference/script.md +31 -32
- package/docs/reference/storage.md +10 -14
- package/docs/reference/totp.md +5 -5
- package/docs/reference/transaction.md +67 -70
- package/docs/reference/wallet.md +131 -135
- package/package.json +1 -1
- package/src/kvstore/index.ts +1 -0
|
@@ -4,8 +4,420 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
4
4
|
|
|
5
5
|
## Interfaces
|
|
6
6
|
|
|
7
|
+
| |
|
|
8
|
+
| --- |
|
|
9
|
+
| [KVContext](#interface-kvcontext) |
|
|
10
|
+
| [KVStoreConfig](#interface-kvstoreconfig) |
|
|
11
|
+
| [KVStoreEntry](#interface-kvstoreentry) |
|
|
12
|
+
| [KVStoreGetOptions](#interface-kvstoregetoptions) |
|
|
13
|
+
| [KVStoreLookupResult](#interface-kvstorelookupresult) |
|
|
14
|
+
| [KVStoreQuery](#interface-kvstorequery) |
|
|
15
|
+
| [KVStoreRemoveOptions](#interface-kvstoreremoveoptions) |
|
|
16
|
+
| [KVStoreSetOptions](#interface-kvstoresetoptions) |
|
|
17
|
+
| [KVStoreToken](#interface-kvstoretoken) |
|
|
18
|
+
|
|
19
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
### Interface: KVContext
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
export interface KVContext {
|
|
27
|
+
key: string;
|
|
28
|
+
protocolID: WalletProtocol;
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
### Interface: KVStoreConfig
|
|
36
|
+
|
|
37
|
+
Configuration interface for GlobalKVStore operations.
|
|
38
|
+
Defines all options for connecting to overlay services and managing KVStore behavior.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
export interface KVStoreConfig {
|
|
42
|
+
overlayHost?: string;
|
|
43
|
+
protocolID?: WalletProtocol;
|
|
44
|
+
serviceName?: string;
|
|
45
|
+
tokenAmount?: number;
|
|
46
|
+
topics?: string[];
|
|
47
|
+
originator?: string;
|
|
48
|
+
wallet?: WalletInterface;
|
|
49
|
+
networkPreset?: "mainnet" | "testnet" | "local";
|
|
50
|
+
acceptDelayedBroadcast?: boolean;
|
|
51
|
+
tokenSetDescription?: string;
|
|
52
|
+
tokenUpdateDescription?: string;
|
|
53
|
+
tokenRemovalDescription?: string;
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Property acceptDelayedBroadcast
|
|
58
|
+
|
|
59
|
+
Whether to accept delayed broadcast
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
acceptDelayedBroadcast?: boolean
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
#### Property networkPreset
|
|
66
|
+
|
|
67
|
+
Network preset for overlay services
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
networkPreset?: "mainnet" | "testnet" | "local"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
#### Property originator
|
|
74
|
+
|
|
75
|
+
Originator
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
originator?: string
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Property overlayHost
|
|
82
|
+
|
|
83
|
+
The overlay service host URL
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
overlayHost?: string
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Property protocolID
|
|
90
|
+
|
|
91
|
+
Protocol ID for the KVStore protocol
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
protocolID?: WalletProtocol
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Property serviceName
|
|
98
|
+
|
|
99
|
+
Service name for overlay submission
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
serviceName?: string
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### Property tokenAmount
|
|
106
|
+
|
|
107
|
+
Amount of satoshis for each token
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
tokenAmount?: number
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### Property tokenRemovalDescription
|
|
114
|
+
|
|
115
|
+
Description for token removal
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
tokenRemovalDescription?: string
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Property tokenSetDescription
|
|
122
|
+
|
|
123
|
+
Description for token set
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
tokenSetDescription?: string
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### Property tokenUpdateDescription
|
|
130
|
+
|
|
131
|
+
Description for token update
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
tokenUpdateDescription?: string
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### Property topics
|
|
138
|
+
|
|
139
|
+
Topics for overlay submission
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
topics?: string[]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Property wallet
|
|
146
|
+
|
|
147
|
+
Wallet interface for operations
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
wallet?: WalletInterface
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
### Interface: KVStoreEntry
|
|
157
|
+
|
|
158
|
+
KVStore entry returned from queries
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
export interface KVStoreEntry {
|
|
162
|
+
key: string;
|
|
163
|
+
value: string;
|
|
164
|
+
controller: PubKeyHex;
|
|
165
|
+
protocolID: WalletProtocol;
|
|
166
|
+
token?: KVStoreToken;
|
|
167
|
+
history?: string[];
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
See also: [KVStoreToken](#interface-kvstoretoken)
|
|
172
|
+
|
|
173
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
### Interface: KVStoreGetOptions
|
|
177
|
+
|
|
178
|
+
Options for configuring KVStore get operations (local processing)
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
export interface KVStoreGetOptions {
|
|
182
|
+
history?: boolean;
|
|
183
|
+
includeToken?: boolean;
|
|
184
|
+
serviceName?: string;
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
#### Property history
|
|
189
|
+
|
|
190
|
+
Whether to build and include history for each entry
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
history?: boolean
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### Property includeToken
|
|
197
|
+
|
|
198
|
+
Whether to include token transaction data in results
|
|
199
|
+
|
|
200
|
+
```ts
|
|
201
|
+
includeToken?: boolean
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Property serviceName
|
|
205
|
+
|
|
206
|
+
Service name for overlay retrieval
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
serviceName?: string
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
### Interface: KVStoreLookupResult
|
|
216
|
+
|
|
217
|
+
Result structure for KVStore lookups from overlay services.
|
|
218
|
+
Contains the transaction output information for a found key-value pair.
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
export interface KVStoreLookupResult {
|
|
222
|
+
txid: string;
|
|
223
|
+
outputIndex: number;
|
|
224
|
+
outputScript: string;
|
|
225
|
+
satoshis: number;
|
|
226
|
+
history?: (output: any, currentDepth: number) => Promise<boolean>;
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
### Interface: KVStoreQuery
|
|
234
|
+
|
|
235
|
+
Query parameters for KVStore lookups from overlay services.
|
|
236
|
+
Used when searching for existing key-value pairs in the network.
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
export interface KVStoreQuery {
|
|
240
|
+
key?: string;
|
|
241
|
+
controller?: PubKeyHex;
|
|
242
|
+
protocolID?: WalletProtocol;
|
|
243
|
+
limit?: number;
|
|
244
|
+
skip?: number;
|
|
245
|
+
sortOrder?: "asc" | "desc";
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
### Interface: KVStoreRemoveOptions
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
export interface KVStoreRemoveOptions {
|
|
256
|
+
protocolID?: WalletProtocol;
|
|
257
|
+
tokenRemovalDescription?: string;
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
### Interface: KVStoreSetOptions
|
|
265
|
+
|
|
266
|
+
```ts
|
|
267
|
+
export interface KVStoreSetOptions {
|
|
268
|
+
protocolID?: WalletProtocol;
|
|
269
|
+
tokenSetDescription?: string;
|
|
270
|
+
tokenUpdateDescription?: string;
|
|
271
|
+
tokenAmount?: number;
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
### Interface: KVStoreToken
|
|
279
|
+
|
|
280
|
+
Token structure containing a KVStore token from overlay services.
|
|
281
|
+
Wraps the transaction data and metadata for a key-value pair.
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
export interface KVStoreToken {
|
|
285
|
+
txid: string;
|
|
286
|
+
outputIndex: number;
|
|
287
|
+
satoshis: number;
|
|
288
|
+
beef: Beef;
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
293
|
+
|
|
294
|
+
---
|
|
7
295
|
## Classes
|
|
8
296
|
|
|
297
|
+
| |
|
|
298
|
+
| --- |
|
|
299
|
+
| [GlobalKVStore](#class-globalkvstore) |
|
|
300
|
+
| [LocalKVStore](#class-localkvstore) |
|
|
301
|
+
|
|
302
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
### Class: GlobalKVStore
|
|
307
|
+
|
|
308
|
+
Implements a global key-value storage system which uses an overlay service to track key-value pairs.
|
|
309
|
+
Each key-value pair is represented by a PushDrop token output.
|
|
310
|
+
Allows getting, setting, and removing key-value pairs with optional fetching by protocolID and history tracking.
|
|
311
|
+
|
|
312
|
+
```ts
|
|
313
|
+
export class GlobalKVStore {
|
|
314
|
+
constructor(config: KVStoreConfig = {})
|
|
315
|
+
async get(query: KVStoreQuery, options: KVStoreGetOptions = {}): Promise<KVStoreEntry | KVStoreEntry[] | undefined>
|
|
316
|
+
async set(key: string, value: string, options: KVStoreSetOptions = {}): Promise<OutpointString>
|
|
317
|
+
async remove(key: string, outputs?: CreateActionOutput[], options: KVStoreRemoveOptions = {}): Promise<HexString>
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
See also: [KVStoreConfig](#interface-kvstoreconfig), [KVStoreEntry](#interface-kvstoreentry), [KVStoreGetOptions](#interface-kvstoregetoptions), [KVStoreQuery](#interface-kvstorequery), [KVStoreRemoveOptions](#interface-kvstoreremoveoptions), [KVStoreSetOptions](#interface-kvstoresetoptions)
|
|
322
|
+
|
|
323
|
+
#### Constructor
|
|
324
|
+
|
|
325
|
+
Creates an instance of the GlobalKVStore.
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
constructor(config: KVStoreConfig = {})
|
|
329
|
+
```
|
|
330
|
+
See also: [KVStoreConfig](#interface-kvstoreconfig)
|
|
331
|
+
|
|
332
|
+
Argument Details
|
|
333
|
+
|
|
334
|
+
+ **config**
|
|
335
|
+
+ Configuration options for the KVStore. Defaults to empty object.
|
|
336
|
+
+ **config.wallet**
|
|
337
|
+
+ Wallet to use for operations. Defaults to WalletClient.
|
|
338
|
+
|
|
339
|
+
Throws
|
|
340
|
+
|
|
341
|
+
If the configuration contains invalid parameters.
|
|
342
|
+
|
|
343
|
+
#### Method get
|
|
344
|
+
|
|
345
|
+
Retrieves data from the KVStore.
|
|
346
|
+
Can query by key+controller (single result), protocolID, controller, or key (multiple results).
|
|
347
|
+
|
|
348
|
+
```ts
|
|
349
|
+
async get(query: KVStoreQuery, options: KVStoreGetOptions = {}): Promise<KVStoreEntry | KVStoreEntry[] | undefined>
|
|
350
|
+
```
|
|
351
|
+
See also: [KVStoreEntry](#interface-kvstoreentry), [KVStoreGetOptions](#interface-kvstoregetoptions), [KVStoreQuery](#interface-kvstorequery)
|
|
352
|
+
|
|
353
|
+
Returns
|
|
354
|
+
|
|
355
|
+
Single entry for key+controller queries, array for all other queries
|
|
356
|
+
|
|
357
|
+
Argument Details
|
|
358
|
+
|
|
359
|
+
+ **query**
|
|
360
|
+
+ Query parameters sent to overlay
|
|
361
|
+
+ **options**
|
|
362
|
+
+ Configuration options for the get operation
|
|
363
|
+
|
|
364
|
+
#### Method remove
|
|
365
|
+
|
|
366
|
+
Removes the key-value pair associated with the given key from the overlay service.
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
async remove(key: string, outputs?: CreateActionOutput[], options: KVStoreRemoveOptions = {}): Promise<HexString>
|
|
370
|
+
```
|
|
371
|
+
See also: [KVStoreRemoveOptions](#interface-kvstoreremoveoptions)
|
|
372
|
+
|
|
373
|
+
Returns
|
|
374
|
+
|
|
375
|
+
A promise that resolves to the txid of the removal transaction if successful.
|
|
376
|
+
|
|
377
|
+
Argument Details
|
|
378
|
+
|
|
379
|
+
+ **key**
|
|
380
|
+
+ The key to remove.
|
|
381
|
+
+ **outputs**
|
|
382
|
+
+ Additional outputs to include in the removal transaction.
|
|
383
|
+
+ **options**
|
|
384
|
+
+ Optional parameters for the removal operation.
|
|
385
|
+
|
|
386
|
+
Throws
|
|
387
|
+
|
|
388
|
+
If the key is invalid.
|
|
389
|
+
|
|
390
|
+
If the key does not exist in the store.
|
|
391
|
+
|
|
392
|
+
If the overlay service is unreachable or the transaction fails.
|
|
393
|
+
|
|
394
|
+
If there are existing tokens that cannot be unlocked.
|
|
395
|
+
|
|
396
|
+
#### Method set
|
|
397
|
+
|
|
398
|
+
Sets a key-value pair. The current user (wallet identity) becomes the controller.
|
|
399
|
+
|
|
400
|
+
```ts
|
|
401
|
+
async set(key: string, value: string, options: KVStoreSetOptions = {}): Promise<OutpointString>
|
|
402
|
+
```
|
|
403
|
+
See also: [KVStoreSetOptions](#interface-kvstoresetoptions)
|
|
404
|
+
|
|
405
|
+
Returns
|
|
406
|
+
|
|
407
|
+
The outpoint of the created token
|
|
408
|
+
|
|
409
|
+
Argument Details
|
|
410
|
+
|
|
411
|
+
+ **key**
|
|
412
|
+
+ The key to set (user computes this however they want)
|
|
413
|
+
+ **value**
|
|
414
|
+
+ The value to store
|
|
415
|
+
+ **options**
|
|
416
|
+
+ Configuration options for the set operation
|
|
417
|
+
|
|
418
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
419
|
+
|
|
420
|
+
---
|
|
9
421
|
### Class: LocalKVStore
|
|
10
422
|
|
|
11
423
|
Implements a key-value storage system backed by transaction outputs managed by a wallet.
|
|
@@ -22,8 +434,6 @@ export default class LocalKVStore {
|
|
|
22
434
|
}
|
|
23
435
|
```
|
|
24
436
|
|
|
25
|
-
See also: [OutpointString](./wallet.md#type-outpointstring), [WalletClient](./wallet.md#class-walletclient), [WalletInterface](./wallet.md#interface-walletinterface), [encrypt](./messages.md#variable-encrypt)
|
|
26
|
-
|
|
27
437
|
#### Constructor
|
|
28
438
|
|
|
29
439
|
Creates an instance of the localKVStore.
|
|
@@ -31,7 +441,6 @@ Creates an instance of the localKVStore.
|
|
|
31
441
|
```ts
|
|
32
442
|
constructor(wallet: WalletInterface = new WalletClient(), context = "kvstore default", encrypt = true, originator?: string, acceptDelayedBroadcast = false)
|
|
33
443
|
```
|
|
34
|
-
See also: [WalletClient](./wallet.md#class-walletclient), [WalletInterface](./wallet.md#interface-walletinterface), [encrypt](./messages.md#variable-encrypt)
|
|
35
444
|
|
|
36
445
|
Argument Details
|
|
37
446
|
|
|
@@ -110,7 +519,6 @@ to the same key from missing earlier changes.
|
|
|
110
519
|
```ts
|
|
111
520
|
async set(key: string, value: string): Promise<OutpointString>
|
|
112
521
|
```
|
|
113
|
-
See also: [OutpointString](./wallet.md#type-outpointstring)
|
|
114
522
|
|
|
115
523
|
Returns
|
|
116
524
|
|
|
@@ -134,3 +542,62 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
134
542
|
|
|
135
543
|
## Variables
|
|
136
544
|
|
|
545
|
+
| |
|
|
546
|
+
| --- |
|
|
547
|
+
| [kvProtocol](#variable-kvprotocol) |
|
|
548
|
+
| [kvStoreInterpreter](#variable-kvstoreinterpreter) |
|
|
549
|
+
|
|
550
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
### Variable: kvProtocol
|
|
555
|
+
|
|
556
|
+
```ts
|
|
557
|
+
kvProtocol = {
|
|
558
|
+
protocolID: 0,
|
|
559
|
+
key: 1,
|
|
560
|
+
value: 2,
|
|
561
|
+
controller: 3,
|
|
562
|
+
signature: 4
|
|
563
|
+
}
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
### Variable: kvStoreInterpreter
|
|
570
|
+
|
|
571
|
+
```ts
|
|
572
|
+
kvStoreInterpreter: InterpreterFunction<string, KVContext> = async (transaction: Transaction, outputIndex: number, ctx?: KVContext): Promise<string | undefined> => {
|
|
573
|
+
try {
|
|
574
|
+
const output = transaction.outputs[outputIndex];
|
|
575
|
+
if (output == null || output.lockingScript == null)
|
|
576
|
+
return undefined;
|
|
577
|
+
if (ctx == null || ctx.key == null)
|
|
578
|
+
return undefined;
|
|
579
|
+
const decoded = PushDrop.decode(output.lockingScript);
|
|
580
|
+
if (decoded.fields.length !== Object.keys(kvProtocol).length)
|
|
581
|
+
return undefined;
|
|
582
|
+
const key = Utils.toUTF8(decoded.fields[kvProtocol.key]);
|
|
583
|
+
const protocolID = Utils.toUTF8(decoded.fields[kvProtocol.protocolID]);
|
|
584
|
+
if (key !== ctx.key || protocolID !== JSON.stringify(ctx.protocolID))
|
|
585
|
+
return undefined;
|
|
586
|
+
try {
|
|
587
|
+
return Utils.toUTF8(decoded.fields[kvProtocol.value]);
|
|
588
|
+
}
|
|
589
|
+
catch {
|
|
590
|
+
return undefined;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
catch {
|
|
594
|
+
return undefined;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
See also: [KVContext](#interface-kvcontext), [kvProtocol](#variable-kvprotocol)
|
|
600
|
+
|
|
601
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
602
|
+
|
|
603
|
+
---
|
|
@@ -49,8 +49,6 @@ decrypt = (message: number[], recipient: PrivateKey): number[] => {
|
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
See also: [PrivateKey](./primitives.md#class-privatekey), [PublicKey](./primitives.md#class-publickey), [Reader](./primitives.md#class-reader), [SymmetricKey](./primitives.md#class-symmetrickey), [encode](./primitives.md#variable-encode), [toBase64](./primitives.md#function-tobase64), [toHex](./primitives.md#variable-tohex)
|
|
53
|
-
|
|
54
52
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Variables](#variables)
|
|
55
53
|
|
|
56
54
|
---
|
|
@@ -78,8 +76,6 @@ encrypt = (message: number[], sender: PrivateKey, recipient: PublicKey): number[
|
|
|
78
76
|
}
|
|
79
77
|
```
|
|
80
78
|
|
|
81
|
-
See also: [PrivateKey](./primitives.md#class-privatekey), [PublicKey](./primitives.md#class-publickey), [SymmetricKey](./primitives.md#class-symmetrickey), [encode](./primitives.md#variable-encode), [toArray](./primitives.md#variable-toarray), [toBase64](./primitives.md#function-tobase64)
|
|
82
|
-
|
|
83
79
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Variables](#variables)
|
|
84
80
|
|
|
85
81
|
---
|
|
@@ -111,8 +107,6 @@ sign = (message: number[], signer: PrivateKey, verifier?: PublicKey): number[] =
|
|
|
111
107
|
}
|
|
112
108
|
```
|
|
113
109
|
|
|
114
|
-
See also: [Curve](./primitives.md#class-curve), [PrivateKey](./primitives.md#class-privatekey), [PublicKey](./primitives.md#class-publickey), [encode](./primitives.md#variable-encode), [toArray](./primitives.md#variable-toarray), [toBase64](./primitives.md#function-tobase64)
|
|
115
|
-
|
|
116
110
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Variables](#variables)
|
|
117
111
|
|
|
118
112
|
---
|
|
@@ -151,8 +145,6 @@ verify = (message: number[], sig: number[], recipient?: PrivateKey): boolean =>
|
|
|
151
145
|
}
|
|
152
146
|
```
|
|
153
147
|
|
|
154
|
-
See also: [PrivateKey](./primitives.md#class-privatekey), [PublicKey](./primitives.md#class-publickey), [Reader](./primitives.md#class-reader), [Signature](./primitives.md#class-signature), [encode](./primitives.md#variable-encode), [toBase64](./primitives.md#function-tobase64), [toHex](./primitives.md#variable-tohex)
|
|
155
|
-
|
|
156
148
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Variables](#variables)
|
|
157
149
|
|
|
158
150
|
---
|