@bsv/sdk 1.6.12 → 1.6.14

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 (82) hide show
  1. package/README.md +4 -4
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js +1 -1
  4. package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
  5. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  6. package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js +1 -1
  7. package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
  8. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  9. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  10. package/dist/umd/bundle.js +1 -1
  11. package/docs/MARKDOWN_VALIDATION_GUIDE.md +175 -0
  12. package/docs/concepts/beef.md +8 -0
  13. package/docs/concepts/chain-tracking.md +12 -0
  14. package/docs/concepts/decentralized-identity.md +37 -0
  15. package/docs/concepts/fees.md +32 -0
  16. package/docs/concepts/identity-certificates.md +53 -1
  17. package/docs/concepts/index.md +15 -0
  18. package/docs/concepts/key-management.md +9 -0
  19. package/docs/concepts/script-templates.md +13 -0
  20. package/docs/concepts/sdk-philosophy.md +8 -0
  21. package/docs/concepts/signatures.md +15 -0
  22. package/docs/concepts/spv-verification.md +12 -0
  23. package/docs/concepts/transaction-encoding.md +19 -0
  24. package/docs/concepts/transaction-structure.md +4 -0
  25. package/docs/concepts/trust-model.md +16 -0
  26. package/docs/concepts/verification.md +31 -0
  27. package/docs/concepts/wallet-integration.md +6 -0
  28. package/docs/guides/development-wallet-setup.md +374 -0
  29. package/docs/guides/direct-transaction-creation.md +12 -2
  30. package/docs/guides/http-client-configuration.md +122 -48
  31. package/docs/guides/index.md +117 -9
  32. package/docs/guides/large-transactions.md +448 -0
  33. package/docs/guides/multisig-transactions.md +792 -0
  34. package/docs/guides/security-best-practices.md +494 -0
  35. package/docs/guides/transaction-batching.md +132 -0
  36. package/docs/guides/transaction-signing-methods.md +230 -79
  37. package/docs/index.md +0 -2
  38. package/docs/reference/auth.md +212 -159
  39. package/docs/reference/compat.md +120 -96
  40. package/docs/reference/configuration.md +6 -0
  41. package/docs/reference/debugging.md +5 -0
  42. package/docs/reference/errors.md +50 -0
  43. package/docs/reference/identity.md +21 -12
  44. package/docs/reference/index.md +14 -1
  45. package/docs/reference/kvstore.md +21 -19
  46. package/docs/reference/messages.md +3 -0
  47. package/docs/reference/op-codes.md +20 -1
  48. package/docs/reference/overlay-tools.md +46 -18
  49. package/docs/reference/primitives.md +571 -390
  50. package/docs/reference/registry.md +43 -20
  51. package/docs/reference/script.md +140 -105
  52. package/docs/reference/storage.md +32 -12
  53. package/docs/reference/totp.md +16 -11
  54. package/docs/reference/transaction-signatures.md +2 -1
  55. package/docs/reference/transaction.md +201 -120
  56. package/docs/reference/wallet.md +241 -64
  57. package/docs/tutorials/advanced-transaction.md +1 -4
  58. package/docs/tutorials/aes-encryption.md +3 -1
  59. package/docs/tutorials/authfetch-tutorial.md +29 -0
  60. package/docs/tutorials/ecdh-key-exchange.md +2 -0
  61. package/docs/tutorials/elliptic-curve-fundamentals.md +3 -0
  62. package/docs/tutorials/error-handling.md +1 -0
  63. package/docs/tutorials/first-transaction-low-level.md +1 -0
  64. package/docs/tutorials/first-transaction.md +5 -8
  65. package/docs/tutorials/hashes-and-hmacs.md +5 -31
  66. package/docs/tutorials/identity-management.md +27 -0
  67. package/docs/tutorials/index.md +114 -77
  68. package/docs/tutorials/key-management.md +5 -3
  69. package/docs/tutorials/protowallet-development.md +27 -0
  70. package/docs/tutorials/spv-merkle-proofs.md +9 -6
  71. package/docs/tutorials/testnet-transactions-low-level.md +25 -18
  72. package/docs/tutorials/transaction-broadcasting.md +10 -7
  73. package/docs/tutorials/transaction-types.md +5 -4
  74. package/docs/tutorials/type-42.md +0 -14
  75. package/docs/tutorials/uhrp-storage.md +23 -3
  76. package/package.json +1 -1
  77. package/src/identity/README.md +0 -1
  78. package/src/primitives/__tests/SymmetricKey.test.ts +45 -0
  79. package/src/primitives/__tests/SymmetricKeyCompatibility.test.ts +150 -0
  80. package/src/transaction/__tests/Transaction.test.ts +1 -1
  81. package/src/transaction/broadcasters/DefaultBroadcaster.ts +1 -1
  82. package/src/transaction/broadcasters/__tests/ARC.test.ts +1 -1
@@ -14,6 +14,7 @@ Bitcoin scripts operate in a **stack-based execution environment** with two prim
14
14
  - **Alt Stack**: Provides additional stack flexibility for complex operations
15
15
 
16
16
  Scripts consist of two parts:
17
+
17
18
  1. **Unlocking Script**: Provided by the spender, supplies data to satisfy locking conditions
18
19
  2. **Locking Script**: Defines the conditions that must be met to spend the output
19
20
 
@@ -47,6 +48,7 @@ const script = Script.fromASM('OP_DUP OP_HASH160 ' + publicKeyHash + ' OP_EQUALV
47
48
  ## Opcode Categories
48
49
 
49
50
  ### Push Operations
51
+
50
52
  Push data onto the stack:
51
53
 
52
54
  ```typescript
@@ -63,6 +65,7 @@ OP.OP_PUSHDATA4 // Push up to 4,294,967,295 bytes
63
65
  ```
64
66
 
65
67
  ### Stack Operations
68
+
66
69
  Manipulate stack contents:
67
70
 
68
71
  ```typescript
@@ -75,6 +78,7 @@ OP.OP_TOALTSTACK // Move item to alt stack
75
78
  ```
76
79
 
77
80
  ### Arithmetic Operations
81
+
78
82
  Perform mathematical operations:
79
83
 
80
84
  ```typescript
@@ -88,6 +92,7 @@ OP.OP_MAX // Return maximum of two values
88
92
  ```
89
93
 
90
94
  ### Comparison Operations
95
+
91
96
  Compare values and return boolean results:
92
97
 
93
98
  ```typescript
@@ -100,6 +105,7 @@ OP.OP_WITHIN // Check if value is within range
100
105
  ```
101
106
 
102
107
  ### Cryptographic Operations
108
+
103
109
  Perform cryptographic functions:
104
110
 
105
111
  ```typescript
@@ -112,6 +118,7 @@ OP.OP_CHECKMULTISIG // Verify multiple signatures
112
118
  ```
113
119
 
114
120
  ### Control Flow Operations
121
+
115
122
  Control script execution:
116
123
 
117
124
  ```typescript
@@ -125,6 +132,7 @@ OP.OP_RETURN // Mark output as unspendable
125
132
  ## Common Script Patterns
126
133
 
127
134
  ### Pay-to-Public-Key-Hash (P2PKH)
135
+
128
136
  The most common Bitcoin script pattern:
129
137
 
130
138
  ```typescript
@@ -145,6 +153,7 @@ const p2pkhUnlock = new UnlockingScript([
145
153
  ```
146
154
 
147
155
  ### Data Storage Script
156
+
148
157
  Store arbitrary data on the blockchain:
149
158
 
150
159
  ```typescript
@@ -156,6 +165,7 @@ const dataScript = new LockingScript([
156
165
  ```
157
166
 
158
167
  ### Multi-Signature Script
168
+
159
169
  Require multiple signatures:
160
170
 
161
171
  ```typescript
@@ -170,10 +180,10 @@ const multisigScript = new LockingScript([
170
180
  ])
171
181
  ```
172
182
 
173
-
174
183
  ## Security Considerations
175
184
 
176
185
  ### Disabled Opcodes
186
+
177
187
  Some opcodes are disabled for security reasons:
178
188
 
179
189
  ```typescript
@@ -187,6 +197,7 @@ OP.OP_VERNOTIF // Disabled: inverse conditional verification
187
197
  ## Best Practices
188
198
 
189
199
  ### 1. Use Script Templates
200
+
190
201
  Leverage SDK script templates for common patterns:
191
202
 
192
203
  ```typescript
@@ -198,6 +209,7 @@ const lockingScript = p2pkh.lock(publicKeyHash)
198
209
  ```
199
210
 
200
211
  ### 2. Validate Scripts
212
+
201
213
  Always validate scripts before use:
202
214
 
203
215
  ```typescript
@@ -210,6 +222,7 @@ try {
210
222
  ```
211
223
 
212
224
  ### 3. Handle Execution Errors
225
+
213
226
  Implement proper error handling:
214
227
 
215
228
  ```typescript
@@ -228,6 +241,7 @@ try {
228
241
  ## Common Use Cases
229
242
 
230
243
  ### 1. Payment Scripts
244
+
231
245
  Standard payment to public key hash:
232
246
 
233
247
  ```typescript
@@ -235,6 +249,7 @@ const paymentScript = Script.fromASM(`OP_DUP OP_HASH160 ${pubKeyHash} OP_EQUALVE
235
249
  ```
236
250
 
237
251
  ### 2. Data Storage
252
+
238
253
  Store application data on-chain:
239
254
 
240
255
  ```typescript
@@ -242,6 +257,7 @@ const dataScript = Script.fromASM(`OP_RETURN ${Buffer.from(jsonData).toString('h
242
257
  ```
243
258
 
244
259
  ### 3. Smart Contracts
260
+
245
261
  Create conditional spending logic:
246
262
 
247
263
  ```typescript
@@ -256,6 +272,7 @@ const contractScript = Script.fromASM(`
256
272
  ```
257
273
 
258
274
  ### 4. Puzzle Scripts
275
+
259
276
  Create cryptographic puzzles:
260
277
 
261
278
  ```typescript
@@ -266,6 +283,7 @@ const puzzleScript = Script.fromASM(`OP_HASH256 ${targetHash} OP_EQUAL`)
266
283
  ## Debugging Scripts
267
284
 
268
285
  ### Script Execution Tracing
286
+
269
287
  Monitor script execution step by step:
270
288
 
271
289
  ```typescript
@@ -284,6 +302,7 @@ while (!spend.isFinished()) {
284
302
  ```
285
303
 
286
304
  ### Common Debugging Patterns
305
+
287
306
  Identify and fix common script issues:
288
307
 
289
308
  ```typescript
@@ -58,6 +58,7 @@ outputsToAdmit: number[]
58
58
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
59
59
 
60
60
  ---
61
+
61
62
  ### Interface: LookupQuestion
62
63
 
63
64
  The question asked to the Overlay Services Engine when a consumer of state wishes to look up information.
@@ -89,6 +90,7 @@ service: string
89
90
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
90
91
 
91
92
  ---
93
+
92
94
  ### Interface: LookupResolverConfig
93
95
 
94
96
  Configuration options for the Lookup resolver.
@@ -120,6 +122,7 @@ The facilitator used to make requests to Overlay Services hosts.
120
122
  ```ts
121
123
  facilitator?: OverlayLookupFacilitator
122
124
  ```
125
+
123
126
  See also: [OverlayLookupFacilitator](./overlay-tools.md#interface-overlaylookupfacilitator)
124
127
 
125
128
  #### Property hostOverrides
@@ -133,6 +136,7 @@ hostOverrides?: Record<string, string[]>
133
136
  #### Property networkPreset
134
137
 
135
138
  The network preset to use, unless other options override it.
139
+
136
140
  - mainnet: use mainnet SLAP trackers and HTTPS facilitator
137
141
  - testnet: use testnet SLAP trackers and HTTPS facilitator
138
142
  - local: directly query from localhost:8080 and a facilitator that permits plain HTTP
@@ -152,6 +156,7 @@ slapTrackers?: string[]
152
156
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
153
157
 
154
158
  ---
159
+
155
160
  ### Interface: OverlayBroadcastFacilitator
156
161
 
157
162
  Facilitates transaction broadcasts that return STEAK.
@@ -167,6 +172,7 @@ See also: [STEAK](./overlay-tools.md#type-steak), [TaggedBEEF](./overlay-tools.m
167
172
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
168
173
 
169
174
  ---
175
+
170
176
  ### Interface: OverlayLookupFacilitator
171
177
 
172
178
  Facilitates lookups to URLs that return answers.
@@ -186,11 +192,13 @@ Returns a lookup answer for a lookup question
186
192
  ```ts
187
193
  lookup: (url: string, question: LookupQuestion, timeout?: number) => Promise<LookupAnswer>
188
194
  ```
195
+
189
196
  See also: [LookupAnswer](./overlay-tools.md#type-lookupanswer), [LookupQuestion](./overlay-tools.md#interface-lookupquestion)
190
197
 
191
198
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
192
199
 
193
200
  ---
201
+
194
202
  ### Interface: SHIPBroadcasterConfig
195
203
 
196
204
  Configuration options for the SHIP broadcaster.
@@ -215,11 +223,13 @@ The facilitator used to make requests to Overlay Services hosts.
215
223
  ```ts
216
224
  facilitator?: OverlayBroadcastFacilitator
217
225
  ```
226
+
218
227
  See also: [OverlayBroadcastFacilitator](./overlay-tools.md#interface-overlaybroadcastfacilitator)
219
228
 
220
229
  #### Property networkPreset
221
230
 
222
231
  The network preset to use, unless other options override it.
232
+
223
233
  - mainnet: use mainnet resolver and HTTPS facilitator
224
234
  - testnet: use testnet resolver and HTTPS facilitator
225
235
  - local: directly send to localhost:8080 and a facilitator that permits plain HTTP
@@ -259,11 +269,13 @@ The resolver used to locate suitable hosts with SHIP
259
269
  ```ts
260
270
  resolver?: LookupResolver
261
271
  ```
272
+
262
273
  See also: [LookupResolver](./overlay-tools.md#class-lookupresolver)
263
274
 
264
275
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
265
276
 
266
277
  ---
278
+
267
279
  ### Interface: TaggedBEEF
268
280
 
269
281
  Tagged BEEF
@@ -279,6 +291,7 @@ export interface TaggedBEEF {
279
291
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
280
292
 
281
293
  ---
294
+
282
295
  ## Classes
283
296
 
284
297
  | |
@@ -309,6 +322,7 @@ See also: [OverlayBroadcastFacilitator](./overlay-tools.md#interface-overlaybroa
309
322
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
310
323
 
311
324
  ---
325
+
312
326
  ### Class: HTTPSOverlayLookupFacilitator
313
327
 
314
328
  ```ts
@@ -325,6 +339,7 @@ See also: [LookupAnswer](./overlay-tools.md#type-lookupanswer), [LookupQuestion]
325
339
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
326
340
 
327
341
  ---
342
+
328
343
  ### Class: LookupResolver
329
344
 
330
345
  Represents an SHIP transaction broadcaster.
@@ -345,11 +360,13 @@ Given a LookupQuestion, returns a LookupAnswer. Aggregates across multiple servi
345
360
  ```ts
346
361
  async query(question: LookupQuestion, timeout?: number): Promise<LookupAnswer>
347
362
  ```
363
+
348
364
  See also: [LookupAnswer](./overlay-tools.md#type-lookupanswer), [LookupQuestion](./overlay-tools.md#interface-lookupquestion)
349
365
 
350
366
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
351
367
 
352
368
  ---
369
+
353
370
  ### Class: OverlayAdminTokenTemplate
354
371
 
355
372
  Script template enabling the creation, unlocking, and decoding of SHIP and SLAP advertisements.
@@ -381,12 +398,13 @@ Constructs a new Overlay Admin template instance
381
398
  ```ts
382
399
  constructor(wallet: WalletInterface)
383
400
  ```
401
+
384
402
  See also: [WalletInterface](./wallet.md#interface-walletinterface)
385
403
 
386
404
  Argument Details
387
405
 
388
- + **wallet**
389
- + Wallet to use for locking and unlocking
406
+ - **wallet**
407
+ - Wallet to use for locking and unlocking
390
408
 
391
409
  #### Method decode
392
410
 
@@ -400,6 +418,7 @@ static decode(script: LockingScript): {
400
418
  topicOrService: string;
401
419
  }
402
420
  ```
421
+
403
422
  See also: [LockingScript](./script.md#class-lockingscript)
404
423
 
405
424
  Returns
@@ -408,8 +427,8 @@ Decoded SHIP or SLAP advertisement
408
427
 
409
428
  Argument Details
410
429
 
411
- + **script**
412
- + Locking script comprising a SHIP or SLAP token to decode
430
+ - **script**
431
+ - Locking script comprising a SHIP or SLAP token to decode
413
432
 
414
433
  #### Method lock
415
434
 
@@ -418,6 +437,7 @@ Creates a new advertisement locking script
418
437
  ```ts
419
438
  async lock(protocol: "SHIP" | "SLAP", domain: string, topicOrService: string): Promise<LockingScript>
420
439
  ```
440
+
421
441
  See also: [LockingScript](./script.md#class-lockingscript)
422
442
 
423
443
  Returns
@@ -426,12 +446,12 @@ Locking script comprising the advertisement token
426
446
 
427
447
  Argument Details
428
448
 
429
- + **protocol**
430
- + SHIP or SLAP
431
- + **domain**
432
- + Domain where the topic or service is available
433
- + **topicOrService**
434
- + Topic or service to advertise
449
+ - **protocol**
450
+ - SHIP or SLAP
451
+ - **domain**
452
+ - Domain where the topic or service is available
453
+ - **topicOrService**
454
+ - Topic or service to advertise
435
455
 
436
456
  #### Method unlock
437
457
 
@@ -443,6 +463,7 @@ unlock(protocol: "SHIP" | "SLAP"): {
443
463
  estimateLength: (tx: Transaction, inputIndex: number) => Promise<number>;
444
464
  }
445
465
  ```
466
+
446
467
  See also: [Transaction](./transaction.md#class-transaction), [UnlockingScript](./script.md#class-unlockingscript), [sign](./compat.md#variable-sign)
447
468
 
448
469
  Returns
@@ -451,12 +472,13 @@ Script unlocker capable of unlocking the advertisement token
451
472
 
452
473
  Argument Details
453
474
 
454
- + **protocol**
455
- + SHIP or SLAP, depending on the token to unlock
475
+ - **protocol**
476
+ - SHIP or SLAP, depending on the token to unlock
456
477
 
457
478
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
458
479
 
459
480
  ---
481
+
460
482
  ### Class: TopicBroadcaster
461
483
 
462
484
  Broadcasts transactions to one or more overlay topics.
@@ -477,14 +499,15 @@ Constructs an instance of the SHIP broadcaster.
477
499
  ```ts
478
500
  constructor(topics: string[], config: SHIPBroadcasterConfig = {})
479
501
  ```
502
+
480
503
  See also: [SHIPBroadcasterConfig](./overlay-tools.md#interface-shipbroadcasterconfig)
481
504
 
482
505
  Argument Details
483
506
 
484
- + **topics**
485
- + The list of SHIP topic names where transactions are to be sent.
486
- + **config**
487
- + Configuration options for the SHIP broadcaster.
507
+ - **topics**
508
+ - The list of SHIP topic names where transactions are to be sent.
509
+ - **config**
510
+ - Configuration options for the SHIP broadcaster.
488
511
 
489
512
  #### Method broadcast
490
513
 
@@ -493,6 +516,7 @@ Broadcasts a transaction to Overlay Services via SHIP.
493
516
  ```ts
494
517
  async broadcast(tx: Transaction): Promise<BroadcastResponse | BroadcastFailure>
495
518
  ```
519
+
496
520
  See also: [BroadcastFailure](./transaction.md#interface-broadcastfailure), [BroadcastResponse](./transaction.md#interface-broadcastresponse), [Transaction](./transaction.md#class-transaction)
497
521
 
498
522
  Returns
@@ -501,12 +525,13 @@ A promise that resolves to either a success or failure response.
501
525
 
502
526
  Argument Details
503
527
 
504
- + **tx**
505
- + The transaction to be sent.
528
+ - **tx**
529
+ - The transaction to be sent.
506
530
 
507
531
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
508
532
 
509
533
  ---
534
+
510
535
  ## Functions
511
536
 
512
537
  ## Types
@@ -539,6 +564,7 @@ export type LookupAnswer = {
539
564
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
540
565
 
541
566
  ---
567
+
542
568
  ### Type: STEAK
543
569
 
544
570
  Submitted Transaction Execution AcKnowledgment
@@ -552,6 +578,7 @@ See also: [AdmittanceInstructions](./overlay-tools.md#interface-admittanceinstru
552
578
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
553
579
 
554
580
  ---
581
+
555
582
  ## Enums
556
583
 
557
584
  ## Variables
@@ -576,6 +603,7 @@ DEFAULT_SLAP_TRACKERS: string[] = [
576
603
  Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
577
604
 
578
605
  ---
606
+
579
607
  ### Variable: DEFAULT_TESTNET_SLAP_TRACKERS
580
608
 
581
609
  ```ts