@bsv/sdk 1.6.8 → 1.6.10

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 (92) hide show
  1. package/README.md +9 -4
  2. package/dist/cjs/package.json +7 -5
  3. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +11 -3
  4. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
  5. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js +1 -1
  6. package/dist/cjs/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  7. package/dist/cjs/src/wallet/substrates/utils/toOriginHeader.js +21 -0
  8. package/dist/cjs/src/wallet/substrates/utils/toOriginHeader.js.map +1 -0
  9. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  10. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +9 -1
  11. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
  12. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js +1 -1
  13. package/dist/esm/src/wallet/substrates/WalletWireProcessor.js.map +1 -1
  14. package/dist/esm/src/wallet/substrates/utils/toOriginHeader.js +17 -0
  15. package/dist/esm/src/wallet/substrates/utils/toOriginHeader.js.map +1 -0
  16. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  17. package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
  18. package/dist/types/src/wallet/substrates/utils/toOriginHeader.d.ts +2 -0
  19. package/dist/types/src/wallet/substrates/utils/toOriginHeader.d.ts.map +1 -0
  20. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  21. package/dist/umd/bundle.js +1 -1
  22. package/docs/concepts/beef.md +84 -0
  23. package/docs/concepts/chain-tracking.md +122 -0
  24. package/docs/concepts/decentralized-identity.md +184 -0
  25. package/docs/concepts/fees.md +217 -0
  26. package/docs/concepts/identity-certificates.md +255 -0
  27. package/docs/concepts/index.md +62 -0
  28. package/docs/concepts/key-management.md +176 -0
  29. package/docs/concepts/script-templates.md +163 -0
  30. package/docs/concepts/sdk-philosophy.md +72 -0
  31. package/docs/concepts/signatures.md +179 -0
  32. package/docs/concepts/spv-verification.md +106 -0
  33. package/docs/concepts/transaction-encoding.md +148 -0
  34. package/docs/concepts/transaction-structure.md +63 -0
  35. package/docs/concepts/trust-model.md +123 -0
  36. package/docs/concepts/verification.md +219 -0
  37. package/docs/concepts/wallet-integration.md +95 -0
  38. package/docs/guides/direct-transaction-creation.md +137 -0
  39. package/docs/guides/http-client-configuration.md +414 -0
  40. package/docs/guides/index.md +30 -0
  41. package/docs/guides/transaction-signing-methods.md +268 -0
  42. package/docs/index.md +74 -0
  43. package/docs/reference/arc-config.md +698 -0
  44. package/docs/reference/brc-100.md +33 -0
  45. package/docs/reference/configuration.md +829 -0
  46. package/docs/reference/debugging.md +700 -0
  47. package/docs/reference/errors.md +547 -0
  48. package/docs/reference/index.md +98 -0
  49. package/docs/reference/network-config.md +914 -0
  50. package/docs/reference/op-codes.md +306 -0
  51. package/docs/reference/transaction-signatures.md +94 -0
  52. package/docs/{wallet.md → reference/wallet.md} +9 -0
  53. package/docs/requirements.txt +3 -0
  54. package/docs/tutorials/advanced-transaction.md +575 -0
  55. package/docs/tutorials/aes-encryption.md +947 -0
  56. package/docs/tutorials/authfetch-tutorial.md +957 -0
  57. package/docs/tutorials/ecdh-key-exchange.md +547 -0
  58. package/docs/tutorials/elliptic-curve-fundamentals.md +603 -0
  59. package/docs/tutorials/error-handling.md +1215 -0
  60. package/docs/tutorials/first-transaction-low-level.md +204 -0
  61. package/docs/tutorials/first-transaction.md +278 -0
  62. package/docs/tutorials/hashes-and-hmacs.md +814 -0
  63. package/docs/tutorials/identity-management.md +702 -0
  64. package/docs/tutorials/index.md +182 -0
  65. package/docs/tutorials/key-management.md +536 -0
  66. package/docs/tutorials/protowallet-development.md +716 -0
  67. package/docs/tutorials/script-construction.md +690 -0
  68. package/docs/tutorials/spv-merkle-proofs.md +682 -0
  69. package/docs/tutorials/testnet-transactions-low-level.md +352 -0
  70. package/docs/tutorials/transaction-broadcasting.md +535 -0
  71. package/docs/tutorials/transaction-types.md +419 -0
  72. package/docs/tutorials/type-42.md +582 -0
  73. package/docs/tutorials/uhrp-storage.md +579 -0
  74. package/package.json +7 -5
  75. package/src/transaction/__tests/Transaction.test.ts +1 -1
  76. package/src/wallet/substrates/HTTPWalletJSON.ts +11 -1
  77. package/src/wallet/substrates/WalletWireProcessor.ts +1 -1
  78. package/src/wallet/substrates/__tests/toOriginHeader.test.ts +34 -0
  79. package/src/wallet/substrates/utils/toOriginHeader.ts +15 -0
  80. package/docs/README.md +0 -21
  81. /package/docs/{auth.md → reference/auth.md} +0 -0
  82. /package/docs/{compat.md → reference/compat.md} +0 -0
  83. /package/docs/{identity.md → reference/identity.md} +0 -0
  84. /package/docs/{kvstore.md → reference/kvstore.md} +0 -0
  85. /package/docs/{messages.md → reference/messages.md} +0 -0
  86. /package/docs/{overlay-tools.md → reference/overlay-tools.md} +0 -0
  87. /package/docs/{primitives.md → reference/primitives.md} +0 -0
  88. /package/docs/{registry.md → reference/registry.md} +0 -0
  89. /package/docs/{script.md → reference/script.md} +0 -0
  90. /package/docs/{storage.md → reference/storage.md} +0 -0
  91. /package/docs/{totp.md → reference/totp.md} +0 -0
  92. /package/docs/{transaction.md → reference/transaction.md} +0 -0
@@ -0,0 +1,829 @@
1
+ # Configuration Reference
2
+
3
+ Complete reference for SDK configuration options, interfaces, and setup patterns in the BSV TypeScript SDK.
4
+
5
+ ## Core Configuration Interface
6
+
7
+ ```typescript
8
+ interface SDKConfig {
9
+ network: NetworkType
10
+ arc: ARCConfig
11
+ fees: FeeConfig
12
+ security: SecurityConfig
13
+ wallet: WalletConfig
14
+ chainTracker: ChainTrackerConfig
15
+ logging: LoggingConfig
16
+ }
17
+ ```
18
+
19
+ ## Network Configuration
20
+
21
+ ### NetworkType
22
+
23
+ ```typescript
24
+ type NetworkType = 'mainnet' | 'testnet' | 'regtest'
25
+ ```
26
+
27
+ ### Network Parameters
28
+
29
+ ```typescript
30
+ interface NetworkConfig {
31
+ name: NetworkType
32
+ chainParams: {
33
+ genesisHash: string
34
+ port: number
35
+ dnsSeeds: string[]
36
+ addressPrefix: {
37
+ pubKeyHash: number
38
+ scriptHash: number
39
+ privateKey: number
40
+ }
41
+ }
42
+ defaultEndpoints: {
43
+ arc: string[]
44
+ chainTracker: string[]
45
+ broadcast: string[]
46
+ }
47
+ }
48
+ ```
49
+
50
+ ### Predefined Networks
51
+
52
+ #### Mainnet Configuration
53
+ ```typescript
54
+ const MAINNET_CONFIG: NetworkConfig = {
55
+ name: 'mainnet',
56
+ chainParams: {
57
+ genesisHash: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
58
+ port: 8333,
59
+ dnsSeeds: [
60
+ 'seed.bitcoinsv.io',
61
+ 'seed.cascharia.com',
62
+ 'seed.satoshisvision.network'
63
+ ],
64
+ addressPrefix: {
65
+ pubKeyHash: 0x00,
66
+ scriptHash: 0x05,
67
+ privateKey: 0x80
68
+ }
69
+ },
70
+ defaultEndpoints: {
71
+ arc: ['https://arc.taal.com'],
72
+ chainTracker: ['https://api.whatsonchain.com/v1/bsv/main'],
73
+ broadcast: ['https://api.whatsonchain.com/v1/bsv/main/tx/raw']
74
+ }
75
+ }
76
+ ```
77
+
78
+ #### Testnet Configuration
79
+ ```typescript
80
+ const TESTNET_CONFIG: NetworkConfig = {
81
+ name: 'testnet',
82
+ chainParams: {
83
+ genesisHash: '000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943',
84
+ port: 18333,
85
+ dnsSeeds: [
86
+ 'testnet-seed.bitcoinsv.io',
87
+ 'testnet-seed.cascharia.com'
88
+ ],
89
+ addressPrefix: {
90
+ pubKeyHash: 0x6f,
91
+ scriptHash: 0xc4,
92
+ privateKey: 0xef
93
+ }
94
+ },
95
+ defaultEndpoints: {
96
+ arc: ['https://arc-testnet.taal.com'],
97
+ chainTracker: ['https://api.whatsonchain.com/v1/bsv/test'],
98
+ broadcast: ['https://api.whatsonchain.com/v1/bsv/test/tx/raw']
99
+ }
100
+ }
101
+ ```
102
+
103
+ #### Regtest Configuration
104
+ ```typescript
105
+ const REGTEST_CONFIG: NetworkConfig = {
106
+ name: 'regtest',
107
+ chainParams: {
108
+ genesisHash: '0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206',
109
+ port: 18444,
110
+ dnsSeeds: [],
111
+ addressPrefix: {
112
+ pubKeyHash: 0x6f,
113
+ scriptHash: 0xc4,
114
+ privateKey: 0xef
115
+ }
116
+ },
117
+ defaultEndpoints: {
118
+ arc: ['http://localhost:9090'],
119
+ chainTracker: ['http://localhost:3001/v1/bsv/regtest'],
120
+ broadcast: ['http://localhost:3001/v1/bsv/regtest/tx/raw']
121
+ }
122
+ }
123
+ ```
124
+
125
+ ## ARC Configuration
126
+
127
+ ### ARCConfig Interface
128
+
129
+ ```typescript
130
+ interface ARCConfig {
131
+ apiUrl: string
132
+ apiKey?: string
133
+ timeout: number
134
+ retryAttempts: number
135
+ retryDelay: number
136
+ rateLimiting: {
137
+ requestsPerSecond: number
138
+ burstLimit: number
139
+ }
140
+ endpoints: {
141
+ submit: string
142
+ status: string
143
+ policy: string
144
+ }
145
+ }
146
+ ```
147
+
148
+ ### Default ARC Configuration
149
+
150
+ ```typescript
151
+ const DEFAULT_ARC_CONFIG: ARCConfig = {
152
+ apiUrl: 'https://arc.taal.com',
153
+ timeout: 30000, // 30 seconds
154
+ retryAttempts: 3,
155
+ retryDelay: 1000, // 1 second
156
+ rateLimiting: {
157
+ requestsPerSecond: 10,
158
+ burstLimit: 50
159
+ },
160
+ endpoints: {
161
+ submit: '/v1/tx',
162
+ status: '/v1/tx/{txid}',
163
+ policy: '/v1/policy'
164
+ }
165
+ }
166
+ ```
167
+
168
+ ### ARC Authentication
169
+
170
+ ```typescript
171
+ interface ARCAuth {
172
+ type: 'bearer' | 'api-key' | 'none'
173
+ credentials: {
174
+ token?: string
175
+ apiKey?: string
176
+ secret?: string
177
+ }
178
+ }
179
+ ```
180
+
181
+ ## Fee Configuration
182
+
183
+ ### FeeConfig Interface
184
+
185
+ ```typescript
186
+ interface FeeConfig {
187
+ strategy: FeeStrategy
188
+ rates: FeeRates
189
+ limits: FeeLimits
190
+ estimation: FeeEstimationConfig
191
+ }
192
+ ```
193
+
194
+ ### Fee Strategy Types
195
+
196
+ ```typescript
197
+ type FeeStrategy = 'fixed' | 'dynamic' | 'priority' | 'custom'
198
+
199
+ interface FeeRates {
200
+ // Satoshis per byte
201
+ standard: number
202
+ priority: number
203
+ economy: number
204
+ custom?: number
205
+ }
206
+
207
+ interface FeeLimits {
208
+ minFeeRate: number // Minimum satoshis per byte
209
+ maxFeeRate: number // Maximum satoshis per byte
210
+ maxTotalFee: number // Maximum total fee in satoshis
211
+ }
212
+ ```
213
+
214
+ ### Default Fee Configuration
215
+
216
+ ```typescript
217
+ const DEFAULT_FEE_CONFIG: FeeConfig = {
218
+ strategy: 'standard',
219
+ rates: {
220
+ standard: 0.5, // 0.5 sat/byte
221
+ priority: 1.0, // 1.0 sat/byte
222
+ economy: 0.25 // 0.25 sat/byte
223
+ },
224
+ limits: {
225
+ minFeeRate: 0.25,
226
+ maxFeeRate: 10.0,
227
+ maxTotalFee: 100000 // 1000 sat maximum
228
+ },
229
+ estimation: {
230
+ enabled: true,
231
+ source: 'arc',
232
+ fallbackRate: 0.5,
233
+ updateInterval: 300000 // 5 minutes
234
+ }
235
+ }
236
+ ```
237
+
238
+ ### Fee Estimation Configuration
239
+
240
+ ```typescript
241
+ interface FeeEstimationConfig {
242
+ enabled: boolean
243
+ source: 'arc' | 'chainTracker' | 'static'
244
+ fallbackRate: number
245
+ updateInterval: number
246
+ cacheTimeout: number
247
+ }
248
+ ```
249
+
250
+ ## Security Configuration
251
+
252
+ ### SecurityConfig Interface
253
+
254
+ ```typescript
255
+ interface SecurityConfig {
256
+ keyGeneration: KeyGenerationConfig
257
+ encryption: EncryptionConfig
258
+ validation: ValidationConfig
259
+ randomness: RandomnessConfig
260
+ }
261
+ ```
262
+
263
+ ### Key Generation Configuration
264
+
265
+ ```typescript
266
+ interface KeyGenerationConfig {
267
+ source: 'secure-random' | 'deterministic'
268
+ entropy: {
269
+ minBits: number
270
+ sources: EntropySource[]
271
+ }
272
+ derivation: {
273
+ hardened: boolean
274
+ maxDepth: number
275
+ }
276
+ }
277
+
278
+ type EntropySource = 'crypto' | 'mouse' | 'keyboard' | 'timing'
279
+ ```
280
+
281
+ ### Encryption Configuration
282
+
283
+ ```typescript
284
+ interface EncryptionConfig {
285
+ algorithm: 'AES-GCM' | 'AES-CBC'
286
+ keySize: 128 | 256
287
+ ivSize: number
288
+ tagSize: number
289
+ keyDerivation: {
290
+ algorithm: 'PBKDF2' | 'scrypt'
291
+ iterations: number
292
+ saltSize: number
293
+ }
294
+ }
295
+ ```
296
+
297
+ ### Default Security Configuration
298
+
299
+ ```typescript
300
+ const DEFAULT_SECURITY_CONFIG: SecurityConfig = {
301
+ keyGeneration: {
302
+ source: 'secure-random',
303
+ entropy: {
304
+ minBits: 256,
305
+ sources: ['crypto']
306
+ },
307
+ derivation: {
308
+ hardened: true,
309
+ maxDepth: 5
310
+ }
311
+ },
312
+ encryption: {
313
+ algorithm: 'AES-GCM',
314
+ keySize: 256,
315
+ ivSize: 12,
316
+ tagSize: 16,
317
+ keyDerivation: {
318
+ algorithm: 'PBKDF2',
319
+ iterations: 100000,
320
+ saltSize: 32
321
+ }
322
+ },
323
+ validation: {
324
+ strictMode: true,
325
+ checkSignatures: true,
326
+ validateScripts: true,
327
+ enforceMinimumFees: true
328
+ },
329
+ randomness: {
330
+ source: 'crypto.getRandomValues',
331
+ testRandomness: false,
332
+ fallbackToMath: false
333
+ }
334
+ }
335
+ ```
336
+
337
+ ## Wallet Configuration
338
+
339
+ ### WalletConfig Interface
340
+
341
+ ```typescript
342
+ interface WalletConfig {
343
+ substrate: WalletSubstrate
344
+ connection: ConnectionConfig
345
+ authentication: AuthConfig
346
+ permissions: PermissionConfig
347
+ }
348
+ ```
349
+
350
+ ### Wallet Substrate Types
351
+
352
+ ```typescript
353
+ type WalletSubstrate =
354
+ | 'auto'
355
+ | 'Cicada'
356
+ | 'XDM'
357
+ | 'window.CWI'
358
+ | 'json-api'
359
+ | 'react-native'
360
+ | WalletInterface
361
+ ```
362
+
363
+ ### Connection Configuration
364
+
365
+ ```typescript
366
+ interface ConnectionConfig {
367
+ timeout: number
368
+ retryAttempts: number
369
+ retryDelay: number
370
+ keepAlive: boolean
371
+ autoReconnect: boolean
372
+ }
373
+ ```
374
+
375
+ ### Authentication Configuration
376
+
377
+ ```typescript
378
+ interface AuthConfig {
379
+ required: boolean
380
+ timeout: number
381
+ cacheCredentials: boolean
382
+ refreshInterval: number
383
+ originator: string
384
+ }
385
+ ```
386
+
387
+ ### Default Wallet Configuration
388
+
389
+ ```typescript
390
+ const DEFAULT_WALLET_CONFIG: WalletConfig = {
391
+ substrate: 'auto',
392
+ connection: {
393
+ timeout: 10000,
394
+ retryAttempts: 3,
395
+ retryDelay: 1000,
396
+ keepAlive: true,
397
+ autoReconnect: true
398
+ },
399
+ authentication: {
400
+ required: true,
401
+ timeout: 30000,
402
+ cacheCredentials: false,
403
+ refreshInterval: 3600000, // 1 hour
404
+ originator: 'localhost'
405
+ },
406
+ permissions: {
407
+ createActions: true,
408
+ signTransactions: true,
409
+ accessKeys: false,
410
+ manageOutputs: true
411
+ }
412
+ }
413
+ ```
414
+
415
+ ## Chain Tracker Configuration
416
+
417
+ ### ChainTrackerConfig Interface
418
+
419
+ ```typescript
420
+ interface ChainTrackerConfig {
421
+ primary: ChainTrackerEndpoint
422
+ fallbacks: ChainTrackerEndpoint[]
423
+ failover: FailoverConfig
424
+ caching: CacheConfig
425
+ }
426
+ ```
427
+
428
+ ### Chain Tracker Endpoint
429
+
430
+ ```typescript
431
+ interface ChainTrackerEndpoint {
432
+ url: string
433
+ apiKey?: string
434
+ timeout: number
435
+ rateLimiting: RateLimitConfig
436
+ capabilities: TrackerCapability[]
437
+ }
438
+
439
+ type TrackerCapability =
440
+ | 'getHeight'
441
+ | 'getHeader'
442
+ | 'getTransaction'
443
+ | 'getMerkleProof'
444
+ | 'broadcast'
445
+ ```
446
+
447
+ ### Failover Configuration
448
+
449
+ ```typescript
450
+ interface FailoverConfig {
451
+ enabled: boolean
452
+ maxFailures: number
453
+ failureWindow: number
454
+ recoveryTime: number
455
+ healthCheck: {
456
+ enabled: boolean
457
+ interval: number
458
+ timeout: number
459
+ }
460
+ }
461
+ ```
462
+
463
+ ### Default Chain Tracker Configuration
464
+
465
+ ```typescript
466
+ const DEFAULT_CHAINTRACKER_CONFIG: ChainTrackerConfig = {
467
+ primary: {
468
+ url: 'https://api.whatsonchain.com/v1/bsv/main',
469
+ timeout: 10000,
470
+ rateLimiting: {
471
+ requestsPerSecond: 5,
472
+ burstLimit: 20
473
+ },
474
+ capabilities: ['getHeight', 'getHeader', 'getTransaction', 'getMerkleProof']
475
+ },
476
+ fallbacks: [
477
+ {
478
+ url: 'https://api.bitindex.network',
479
+ timeout: 15000,
480
+ rateLimiting: {
481
+ requestsPerSecond: 3,
482
+ burstLimit: 10
483
+ },
484
+ capabilities: ['getHeight', 'getTransaction']
485
+ }
486
+ ],
487
+ failover: {
488
+ enabled: true,
489
+ maxFailures: 3,
490
+ failureWindow: 300000, // 5 minutes
491
+ recoveryTime: 600000, // 10 minutes
492
+ healthCheck: {
493
+ enabled: true,
494
+ interval: 60000, // 1 minute
495
+ timeout: 5000
496
+ }
497
+ },
498
+ caching: {
499
+ enabled: true,
500
+ ttl: 30000, // 30 seconds
501
+ maxSize: 1000,
502
+ strategy: 'lru'
503
+ }
504
+ }
505
+ ```
506
+
507
+ ## Logging Configuration
508
+
509
+ ### LoggingConfig Interface
510
+
511
+ ```typescript
512
+ interface LoggingConfig {
513
+ level: LogLevel
514
+ outputs: LogOutput[]
515
+ format: LogFormat
516
+ filters: LogFilter[]
517
+ performance: PerformanceLoggingConfig
518
+ }
519
+ ```
520
+
521
+ ### Log Levels and Outputs
522
+
523
+ ```typescript
524
+ type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace'
525
+
526
+ interface LogOutput {
527
+ type: 'console' | 'file' | 'remote'
528
+ config: {
529
+ file?: string
530
+ url?: string
531
+ maxSize?: number
532
+ rotation?: boolean
533
+ }
534
+ }
535
+
536
+ interface LogFormat {
537
+ timestamp: boolean
538
+ level: boolean
539
+ component: boolean
540
+ structured: boolean
541
+ colors: boolean
542
+ }
543
+ ```
544
+
545
+ ### Default Logging Configuration
546
+
547
+ ```typescript
548
+ const DEFAULT_LOGGING_CONFIG: LoggingConfig = {
549
+ level: 'info',
550
+ outputs: [
551
+ {
552
+ type: 'console',
553
+ config: {}
554
+ }
555
+ ],
556
+ format: {
557
+ timestamp: true,
558
+ level: true,
559
+ component: true,
560
+ structured: false,
561
+ colors: true
562
+ },
563
+ filters: [],
564
+ performance: {
565
+ enabled: false,
566
+ threshold: 1000,
567
+ includeStackTrace: false
568
+ }
569
+ }
570
+ ```
571
+
572
+ ## Configuration Loading and Management
573
+
574
+ ### Configuration Builder
575
+
576
+ ```typescript
577
+ class SDKConfigBuilder {
578
+ private config: Partial<SDKConfig> = {}
579
+
580
+ network(type: NetworkType): this {
581
+ this.config.network = type
582
+ return this
583
+ }
584
+
585
+ arc(config: Partial<ARCConfig>): this {
586
+ this.config.arc = { ...DEFAULT_ARC_CONFIG, ...config }
587
+ return this
588
+ }
589
+
590
+ fees(config: Partial<FeeConfig>): this {
591
+ this.config.fees = { ...DEFAULT_FEE_CONFIG, ...config }
592
+ return this
593
+ }
594
+
595
+ security(config: Partial<SecurityConfig>): this {
596
+ this.config.security = { ...DEFAULT_SECURITY_CONFIG, ...config }
597
+ return this
598
+ }
599
+
600
+ wallet(config: Partial<WalletConfig>): this {
601
+ this.config.wallet = { ...DEFAULT_WALLET_CONFIG, ...config }
602
+ return this
603
+ }
604
+
605
+ chainTracker(config: Partial<ChainTrackerConfig>): this {
606
+ this.config.chainTracker = { ...DEFAULT_CHAINTRACKER_CONFIG, ...config }
607
+ return this
608
+ }
609
+
610
+ logging(config: Partial<LoggingConfig>): this {
611
+ this.config.logging = { ...DEFAULT_LOGGING_CONFIG, ...config }
612
+ return this
613
+ }
614
+
615
+ build(): SDKConfig {
616
+ return {
617
+ network: this.config.network || 'testnet',
618
+ arc: this.config.arc || DEFAULT_ARC_CONFIG,
619
+ fees: this.config.fees || DEFAULT_FEE_CONFIG,
620
+ security: this.config.security || DEFAULT_SECURITY_CONFIG,
621
+ wallet: this.config.wallet || DEFAULT_WALLET_CONFIG,
622
+ chainTracker: this.config.chainTracker || DEFAULT_CHAINTRACKER_CONFIG,
623
+ logging: this.config.logging || DEFAULT_LOGGING_CONFIG
624
+ }
625
+ }
626
+ }
627
+ ```
628
+
629
+ ### Configuration Usage Examples
630
+
631
+ #### Basic Configuration
632
+
633
+ ```typescript
634
+ import { SDKConfigBuilder } from '@bsv/sdk'
635
+
636
+ const config = new SDKConfigBuilder()
637
+ .network('testnet')
638
+ .fees({ strategy: 'priority' })
639
+ .build()
640
+ ```
641
+
642
+ #### Production Configuration
643
+
644
+ ```typescript
645
+ const productionConfig = new SDKConfigBuilder()
646
+ .network('mainnet')
647
+ .arc({
648
+ apiUrl: 'https://arc.taal.com',
649
+ apiKey: process.env.TAAL_API_KEY,
650
+ timeout: 30000
651
+ })
652
+ .fees({
653
+ strategy: 'dynamic',
654
+ rates: {
655
+ standard: 0.5,
656
+ priority: 1.0,
657
+ economy: 0.25
658
+ }
659
+ })
660
+ .security({
661
+ validation: {
662
+ strictMode: true,
663
+ checkSignatures: true,
664
+ validateScripts: true
665
+ }
666
+ })
667
+ .chainTracker({
668
+ primary: {
669
+ url: 'https://api.whatsonchain.com/v1/bsv/main',
670
+ timeout: 10000
671
+ },
672
+ failover: {
673
+ enabled: true,
674
+ maxFailures: 3
675
+ }
676
+ })
677
+ .logging({
678
+ level: 'warn',
679
+ outputs: [
680
+ { type: 'console', config: {} },
681
+ { type: 'file', config: { file: '/var/log/bsv-sdk.log' } }
682
+ ]
683
+ })
684
+ .build()
685
+ ```
686
+
687
+ #### Development Configuration
688
+
689
+ ```typescript
690
+ const devConfig = new SDKConfigBuilder()
691
+ .network('regtest')
692
+ .arc({
693
+ apiUrl: 'http://localhost:9090',
694
+ timeout: 5000
695
+ })
696
+ .fees({
697
+ strategy: 'fixed',
698
+ rates: { standard: 1.0 }
699
+ })
700
+ .chainTracker({
701
+ primary: {
702
+ url: 'http://localhost:3001/v1/bsv/regtest',
703
+ timeout: 5000
704
+ },
705
+ failover: { enabled: false }
706
+ })
707
+ .logging({
708
+ level: 'debug',
709
+ format: {
710
+ timestamp: true,
711
+ colors: true,
712
+ structured: true
713
+ }
714
+ })
715
+ .build()
716
+ ```
717
+
718
+ ## Environment-Based Configuration
719
+
720
+ ### Configuration from Environment Variables
721
+
722
+ ```typescript
723
+ function loadConfigFromEnv(): SDKConfig {
724
+ return new SDKConfigBuilder()
725
+ .network((process.env.BSV_NETWORK as NetworkType) || 'testnet')
726
+ .arc({
727
+ apiUrl: process.env.ARC_API_URL || 'https://arc-testnet.taal.com',
728
+ apiKey: process.env.ARC_API_KEY,
729
+ timeout: parseInt(process.env.ARC_TIMEOUT || '30000')
730
+ })
731
+ .fees({
732
+ strategy: (process.env.FEE_STRATEGY as FeeStrategy) || 'standard',
733
+ rates: {
734
+ standard: parseFloat(process.env.FEE_RATE_STANDARD || '0.5'),
735
+ priority: parseFloat(process.env.FEE_RATE_PRIORITY || '1.0'),
736
+ economy: parseFloat(process.env.FEE_RATE_ECONOMY || '0.25')
737
+ }
738
+ })
739
+ .wallet({
740
+ substrate: (process.env.WALLET_SUBSTRATE as WalletSubstrate) || 'auto',
741
+ authentication: {
742
+ originator: process.env.WALLET_ORIGINATOR || 'localhost'
743
+ }
744
+ })
745
+ .logging({
746
+ level: (process.env.LOG_LEVEL as LogLevel) || 'info'
747
+ })
748
+ .build()
749
+ }
750
+ ```
751
+
752
+ ### Configuration Validation
753
+
754
+ ```typescript
755
+ function validateConfig(config: SDKConfig): string[] {
756
+ const errors: string[] = []
757
+
758
+ // Validate network
759
+ if (!['mainnet', 'testnet', 'regtest'].includes(config.network)) {
760
+ errors.push('Invalid network type')
761
+ }
762
+
763
+ // Validate ARC configuration
764
+ if (!config.arc.apiUrl) {
765
+ errors.push('ARC API URL is required')
766
+ }
767
+
768
+ if (config.arc.timeout < 1000) {
769
+ errors.push('ARC timeout must be at least 1000ms')
770
+ }
771
+
772
+ // Validate fee configuration
773
+ if (config.fees.rates.standard <= 0) {
774
+ errors.push('Standard fee rate must be positive')
775
+ }
776
+
777
+ if (config.fees.limits.minFeeRate > config.fees.limits.maxFeeRate) {
778
+ errors.push('Minimum fee rate cannot exceed maximum fee rate')
779
+ }
780
+
781
+ // Validate security configuration
782
+ if (config.security.encryption.keySize !== 128 && config.security.encryption.keySize !== 256) {
783
+ errors.push('Encryption key size must be 128 or 256 bits')
784
+ }
785
+
786
+ return errors
787
+ }
788
+ ```
789
+
790
+ ## Configuration Best Practices
791
+
792
+ ### Security Considerations
793
+
794
+ 1. **Never hardcode API keys** - Use environment variables or secure configuration management
795
+ 2. **Use HTTPS endpoints** - Ensure all external API calls use secure connections
796
+ 3. **Validate configuration** - Always validate configuration before using
797
+ 4. **Rotate credentials** - Regularly rotate API keys and authentication tokens
798
+ 5. **Limit permissions** - Use principle of least privilege for wallet permissions
799
+
800
+ ### Performance Optimization
801
+
802
+ 1. **Configure appropriate timeouts** - Balance responsiveness with reliability
803
+ 2. **Use connection pooling** - Reuse connections where possible
804
+ 3. **Enable caching** - Cache frequently accessed data with appropriate TTLs
805
+ 4. **Configure failover** - Use multiple endpoints for high availability
806
+ 5. **Monitor performance** - Enable performance logging in production
807
+
808
+ ### Environment-Specific Settings
809
+
810
+ #### Development
811
+ - Use testnet or regtest networks
812
+ - Enable debug logging
813
+ - Shorter timeouts for faster feedback
814
+ - Disable strict validation for testing
815
+
816
+ #### Staging
817
+ - Mirror production configuration
818
+ - Enable comprehensive logging
819
+ - Use production-like endpoints
820
+ - Enable all validation checks
821
+
822
+ #### Production
823
+ - Use mainnet network
824
+ - Minimal logging (warn/error only)
825
+ - Longer timeouts for reliability
826
+ - Enable all security features
827
+ - Use redundant endpoints
828
+
829
+ This comprehensive configuration reference provides developers with all the tools needed to properly configure the BSV TypeScript SDK for any environment or use case.