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