@bsv/sdk 1.6.12 → 1.6.15
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/README.md +4 -4
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js +1 -1
- package/dist/cjs/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js +1 -1
- package/dist/esm/src/transaction/broadcasters/DefaultBroadcaster.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/transaction/http/HttpClient.d.ts +2 -0
- package/dist/types/src/transaction/http/HttpClient.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/MARKDOWN_VALIDATION_GUIDE.md +175 -0
- package/docs/concepts/beef.md +8 -0
- package/docs/concepts/chain-tracking.md +12 -0
- package/docs/concepts/decentralized-identity.md +37 -0
- package/docs/concepts/fees.md +32 -0
- package/docs/concepts/identity-certificates.md +53 -1
- package/docs/concepts/index.md +15 -0
- package/docs/concepts/key-management.md +9 -0
- package/docs/concepts/script-templates.md +13 -0
- package/docs/concepts/sdk-philosophy.md +8 -0
- package/docs/concepts/signatures.md +15 -0
- package/docs/concepts/spv-verification.md +12 -0
- package/docs/concepts/transaction-encoding.md +19 -0
- package/docs/concepts/transaction-structure.md +4 -0
- package/docs/concepts/trust-model.md +16 -0
- package/docs/concepts/verification.md +31 -0
- package/docs/concepts/wallet-integration.md +6 -0
- package/docs/guides/development-wallet-setup.md +374 -0
- package/docs/guides/direct-transaction-creation.md +12 -2
- package/docs/guides/http-client-configuration.md +122 -48
- package/docs/guides/index.md +117 -9
- package/docs/guides/large-transactions.md +448 -0
- package/docs/guides/multisig-transactions.md +792 -0
- package/docs/guides/security-best-practices.md +494 -0
- package/docs/guides/transaction-batching.md +132 -0
- package/docs/guides/transaction-signing-methods.md +230 -79
- package/docs/index.md +0 -2
- package/docs/reference/configuration.md +6 -0
- package/docs/reference/debugging.md +5 -0
- package/docs/reference/errors.md +50 -0
- package/docs/reference/index.md +14 -1
- package/docs/reference/op-codes.md +20 -1
- package/docs/reference/transaction-signatures.md +2 -1
- package/docs/reference/transaction.md +9 -0
- package/docs/tutorials/advanced-transaction.md +1 -4
- package/docs/tutorials/aes-encryption.md +3 -1
- package/docs/tutorials/authfetch-tutorial.md +29 -0
- package/docs/tutorials/ecdh-key-exchange.md +2 -0
- package/docs/tutorials/elliptic-curve-fundamentals.md +3 -0
- package/docs/tutorials/error-handling.md +1 -0
- package/docs/tutorials/first-transaction-low-level.md +1 -0
- package/docs/tutorials/first-transaction.md +5 -8
- package/docs/tutorials/hashes-and-hmacs.md +5 -31
- package/docs/tutorials/identity-management.md +27 -0
- package/docs/tutorials/index.md +114 -77
- package/docs/tutorials/key-management.md +5 -3
- package/docs/tutorials/protowallet-development.md +27 -0
- package/docs/tutorials/spv-merkle-proofs.md +9 -6
- package/docs/tutorials/testnet-transactions-low-level.md +25 -18
- package/docs/tutorials/transaction-broadcasting.md +10 -7
- package/docs/tutorials/transaction-types.md +5 -4
- package/docs/tutorials/type-42.md +0 -14
- package/docs/tutorials/uhrp-storage.md +23 -3
- package/package.json +1 -1
- package/src/identity/README.md +0 -1
- package/src/primitives/__tests/SymmetricKey.test.ts +45 -0
- package/src/primitives/__tests/SymmetricKeyCompatibility.test.ts +150 -0
- package/src/transaction/__tests/Transaction.test.ts +1 -1
- package/src/transaction/broadcasters/DefaultBroadcaster.ts +1 -1
- package/src/transaction/broadcasters/__tests/ARC.test.ts +1 -1
- package/src/transaction/http/HttpClient.ts +2 -0
package/docs/reference/errors.md
CHANGED
|
@@ -7,40 +7,48 @@ Complete reference for error codes, messages, and troubleshooting in the BSV Typ
|
|
|
7
7
|
### Transaction Errors
|
|
8
8
|
|
|
9
9
|
#### INSUFFICIENT_FUNDS
|
|
10
|
+
|
|
10
11
|
**Code**: `INSUFFICIENT_FUNDS`
|
|
11
12
|
**Message**: "Insufficient funds to create transaction"
|
|
12
13
|
**Cause**: Wallet doesn't have enough UTXOs to cover transaction outputs and fees
|
|
13
14
|
**Solutions**:
|
|
15
|
+
|
|
14
16
|
- Check wallet balance with `listOutputs()`
|
|
15
17
|
- Reduce transaction amount
|
|
16
18
|
- Wait for pending transactions to confirm
|
|
17
19
|
- Use smaller fee rates
|
|
18
20
|
|
|
19
21
|
#### INVALID_TRANSACTION
|
|
22
|
+
|
|
20
23
|
**Code**: `INVALID_TRANSACTION`
|
|
21
24
|
**Message**: "Transaction validation failed"
|
|
22
25
|
**Cause**: Transaction structure or signatures are invalid
|
|
23
26
|
**Solutions**:
|
|
27
|
+
|
|
24
28
|
- Verify all inputs are properly signed
|
|
25
29
|
- Check script templates are correct
|
|
26
30
|
- Ensure transaction format is valid
|
|
27
31
|
- Validate all output amounts are positive
|
|
28
32
|
|
|
29
33
|
#### TRANSACTION_TOO_LARGE
|
|
34
|
+
|
|
30
35
|
**Code**: `TRANSACTION_TOO_LARGE`
|
|
31
36
|
**Message**: "Transaction exceeds maximum size limit"
|
|
32
37
|
**Cause**: Transaction size exceeds network limits
|
|
33
38
|
**Solutions**:
|
|
39
|
+
|
|
34
40
|
- Reduce number of inputs/outputs
|
|
35
41
|
- Use more efficient script templates
|
|
36
42
|
- Split into multiple transactions
|
|
37
43
|
- Optimize data storage methods
|
|
38
44
|
|
|
39
45
|
#### INVALID_SCRIPT
|
|
46
|
+
|
|
40
47
|
**Code**: `INVALID_SCRIPT`
|
|
41
48
|
**Message**: "Script execution failed"
|
|
42
49
|
**Cause**: Locking or unlocking script contains errors
|
|
43
50
|
**Solutions**:
|
|
51
|
+
|
|
44
52
|
- Validate script syntax with `Script.fromASM()`
|
|
45
53
|
- Check opcode usage and limits
|
|
46
54
|
- Verify script template implementation
|
|
@@ -49,40 +57,48 @@ Complete reference for error codes, messages, and troubleshooting in the BSV Typ
|
|
|
49
57
|
### Wallet Errors
|
|
50
58
|
|
|
51
59
|
#### WALLET_NOT_CONNECTED
|
|
60
|
+
|
|
52
61
|
**Code**: `WALLET_NOT_CONNECTED`
|
|
53
62
|
**Message**: "Wallet connection not established"
|
|
54
63
|
**Cause**: WalletClient not connected to substrate
|
|
55
64
|
**Solutions**:
|
|
65
|
+
|
|
56
66
|
- Call `await wallet.connectToSubstrate()`
|
|
57
67
|
- Check wallet application is running
|
|
58
68
|
- Verify network connectivity
|
|
59
69
|
- Restart wallet application if needed
|
|
60
70
|
|
|
61
71
|
#### AUTHENTICATION_FAILED
|
|
72
|
+
|
|
62
73
|
**Code**: `AUTHENTICATION_FAILED`
|
|
63
74
|
**Message**: "Wallet authentication failed"
|
|
64
75
|
**Cause**: User denied access or authentication expired
|
|
65
76
|
**Solutions**:
|
|
77
|
+
|
|
66
78
|
- Re-authenticate with wallet
|
|
67
79
|
- Check originator domain permissions
|
|
68
80
|
- Verify wallet trust settings
|
|
69
81
|
- Clear cached authentication state
|
|
70
82
|
|
|
71
83
|
#### WALLET_LOCKED
|
|
84
|
+
|
|
72
85
|
**Code**: `WALLET_LOCKED`
|
|
73
86
|
**Message**: "Wallet is locked or requires password"
|
|
74
87
|
**Cause**: Wallet requires user authentication
|
|
75
88
|
**Solutions**:
|
|
89
|
+
|
|
76
90
|
- Unlock wallet application
|
|
77
91
|
- Enter wallet password
|
|
78
92
|
- Check wallet auto-lock settings
|
|
79
93
|
- Verify user session is active
|
|
80
94
|
|
|
81
95
|
#### ACTION_REJECTED
|
|
96
|
+
|
|
82
97
|
**Code**: `ACTION_REJECTED`
|
|
83
98
|
**Message**: "User rejected the transaction"
|
|
84
99
|
**Cause**: User declined transaction in wallet UI
|
|
85
100
|
**Solutions**:
|
|
101
|
+
|
|
86
102
|
- Retry transaction with user consent
|
|
87
103
|
- Adjust transaction parameters
|
|
88
104
|
- Provide clearer transaction description
|
|
@@ -91,40 +107,48 @@ Complete reference for error codes, messages, and troubleshooting in the BSV Typ
|
|
|
91
107
|
### Network Errors
|
|
92
108
|
|
|
93
109
|
#### NETWORK_ERROR
|
|
110
|
+
|
|
94
111
|
**Code**: `NETWORK_ERROR`
|
|
95
112
|
**Message**: "Network request failed"
|
|
96
113
|
**Cause**: Connection issues with blockchain nodes
|
|
97
114
|
**Solutions**:
|
|
115
|
+
|
|
98
116
|
- Check internet connectivity
|
|
99
117
|
- Verify node endpoints are accessible
|
|
100
118
|
- Try alternative chain trackers
|
|
101
119
|
- Implement retry logic with exponential backoff
|
|
102
120
|
|
|
103
121
|
#### NODE_UNAVAILABLE
|
|
122
|
+
|
|
104
123
|
**Code**: `NODE_UNAVAILABLE`
|
|
105
124
|
**Message**: "Blockchain node is unavailable"
|
|
106
125
|
**Cause**: Target node is down or unreachable
|
|
107
126
|
**Solutions**:
|
|
127
|
+
|
|
108
128
|
- Switch to backup node endpoints
|
|
109
129
|
- Check node status and health
|
|
110
130
|
- Use multiple chain tracker instances
|
|
111
131
|
- Implement failover mechanisms
|
|
112
132
|
|
|
113
133
|
#### BROADCAST_FAILED
|
|
134
|
+
|
|
114
135
|
**Code**: `BROADCAST_FAILED`
|
|
115
136
|
**Message**: "Transaction broadcast failed"
|
|
116
137
|
**Cause**: Network rejected transaction or broadcast error
|
|
117
138
|
**Solutions**:
|
|
139
|
+
|
|
118
140
|
- Verify transaction is valid
|
|
119
141
|
- Check network fees are adequate
|
|
120
142
|
- Retry broadcast after delay
|
|
121
143
|
- Use alternative broadcast endpoints
|
|
122
144
|
|
|
123
145
|
#### TIMEOUT_ERROR
|
|
146
|
+
|
|
124
147
|
**Code**: `TIMEOUT_ERROR`
|
|
125
148
|
**Message**: "Request timeout exceeded"
|
|
126
149
|
**Cause**: Network request took too long
|
|
127
150
|
**Solutions**:
|
|
151
|
+
|
|
128
152
|
- Increase timeout values
|
|
129
153
|
- Check network latency
|
|
130
154
|
- Use faster endpoints
|
|
@@ -133,40 +157,48 @@ Complete reference for error codes, messages, and troubleshooting in the BSV Typ
|
|
|
133
157
|
### Cryptographic Errors
|
|
134
158
|
|
|
135
159
|
#### INVALID_PRIVATE_KEY
|
|
160
|
+
|
|
136
161
|
**Code**: `INVALID_PRIVATE_KEY`
|
|
137
162
|
**Message**: "Private key is invalid or out of range"
|
|
138
163
|
**Cause**: Private key doesn't meet secp256k1 requirements
|
|
139
164
|
**Solutions**:
|
|
165
|
+
|
|
140
166
|
- Generate new key with `PrivateKey.fromRandom()`
|
|
141
167
|
- Validate key is within curve order
|
|
142
168
|
- Check key format and encoding
|
|
143
169
|
- Use proper key derivation methods
|
|
144
170
|
|
|
145
171
|
#### INVALID_PUBLIC_KEY
|
|
172
|
+
|
|
146
173
|
**Code**: `INVALID_PUBLIC_KEY`
|
|
147
174
|
**Message**: "Public key is invalid or not on curve"
|
|
148
175
|
**Cause**: Public key point is invalid
|
|
149
176
|
**Solutions**:
|
|
177
|
+
|
|
150
178
|
- Verify key derivation from private key
|
|
151
179
|
- Check point coordinates are valid
|
|
152
180
|
- Validate key format (compressed/uncompressed)
|
|
153
181
|
- Use `PublicKey.fromPrivateKey()` for generation
|
|
154
182
|
|
|
155
183
|
#### SIGNATURE_VERIFICATION_FAILED
|
|
184
|
+
|
|
156
185
|
**Code**: `SIGNATURE_VERIFICATION_FAILED`
|
|
157
186
|
**Message**: "Digital signature verification failed"
|
|
158
187
|
**Cause**: Signature doesn't match message and public key
|
|
159
188
|
**Solutions**:
|
|
189
|
+
|
|
160
190
|
- Verify message hash is correct
|
|
161
191
|
- Check signature format (DER encoding)
|
|
162
192
|
- Ensure correct public key is used
|
|
163
193
|
- Validate signature components (r, s values)
|
|
164
194
|
|
|
165
195
|
#### ENCRYPTION_FAILED
|
|
196
|
+
|
|
166
197
|
**Code**: `ENCRYPTION_FAILED`
|
|
167
198
|
**Message**: "Symmetric encryption operation failed"
|
|
168
199
|
**Cause**: AES encryption/decryption error
|
|
169
200
|
**Solutions**:
|
|
201
|
+
|
|
170
202
|
- Verify encryption key is valid
|
|
171
203
|
- Check data format and encoding
|
|
172
204
|
- Ensure proper IV/nonce usage
|
|
@@ -175,30 +207,36 @@ Complete reference for error codes, messages, and troubleshooting in the BSV Typ
|
|
|
175
207
|
### SPV Verification Errors
|
|
176
208
|
|
|
177
209
|
#### INVALID_MERKLE_PROOF
|
|
210
|
+
|
|
178
211
|
**Code**: `INVALID_MERKLE_PROOF`
|
|
179
212
|
**Message**: "Merkle proof verification failed"
|
|
180
213
|
**Cause**: Merkle path doesn't lead to valid root
|
|
181
214
|
**Solutions**:
|
|
215
|
+
|
|
182
216
|
- Verify merkle path structure
|
|
183
217
|
- Check transaction hash calculation
|
|
184
218
|
- Validate block header merkle root
|
|
185
219
|
- Ensure proof completeness
|
|
186
220
|
|
|
187
221
|
#### BLOCK_HEADER_INVALID
|
|
222
|
+
|
|
188
223
|
**Code**: `BLOCK_HEADER_INVALID`
|
|
189
224
|
**Message**: "Block header validation failed"
|
|
190
225
|
**Cause**: Block header doesn't meet consensus rules
|
|
191
226
|
**Solutions**:
|
|
227
|
+
|
|
192
228
|
- Verify header hash and difficulty
|
|
193
229
|
- Check timestamp validity
|
|
194
230
|
- Validate previous block hash
|
|
195
231
|
- Ensure proper header format
|
|
196
232
|
|
|
197
233
|
#### CHAIN_VALIDATION_FAILED
|
|
234
|
+
|
|
198
235
|
**Code**: `CHAIN_VALIDATION_FAILED`
|
|
199
236
|
**Message**: "Blockchain validation failed"
|
|
200
237
|
**Cause**: Chain doesn't follow consensus rules
|
|
201
238
|
**Solutions**:
|
|
239
|
+
|
|
202
240
|
- Verify chain continuity
|
|
203
241
|
- Check difficulty adjustments
|
|
204
242
|
- Validate block timestamps
|
|
@@ -207,20 +245,24 @@ Complete reference for error codes, messages, and troubleshooting in the BSV Typ
|
|
|
207
245
|
### Configuration Errors
|
|
208
246
|
|
|
209
247
|
#### INVALID_CONFIG
|
|
248
|
+
|
|
210
249
|
**Code**: `INVALID_CONFIG`
|
|
211
250
|
**Message**: "SDK configuration is invalid"
|
|
212
251
|
**Cause**: Configuration parameters are incorrect
|
|
213
252
|
**Solutions**:
|
|
253
|
+
|
|
214
254
|
- Validate configuration schema
|
|
215
255
|
- Check required parameters are present
|
|
216
256
|
- Verify network settings
|
|
217
257
|
- Use default configuration as baseline
|
|
218
258
|
|
|
219
259
|
#### UNSUPPORTED_NETWORK
|
|
260
|
+
|
|
220
261
|
**Code**: `UNSUPPORTED_NETWORK`
|
|
221
262
|
**Message**: "Network type is not supported"
|
|
222
263
|
**Cause**: Invalid network specification
|
|
223
264
|
**Solutions**:
|
|
265
|
+
|
|
224
266
|
- Use supported networks: mainnet, testnet, regtest
|
|
225
267
|
- Check network configuration
|
|
226
268
|
- Verify chain parameters
|
|
@@ -315,9 +357,11 @@ function categorizeError(error: WalletErrorObject): 'user' | 'network' | 'system
|
|
|
315
357
|
### Common Issues and Solutions
|
|
316
358
|
|
|
317
359
|
#### "RPC Error: no header should have returned false"
|
|
360
|
+
|
|
318
361
|
**Symptoms**: Error during `createAction` calls
|
|
319
362
|
**Cause**: Wallet input selection issues
|
|
320
363
|
**Solutions**:
|
|
364
|
+
|
|
321
365
|
1. Restart wallet application
|
|
322
366
|
2. Ensure wallet is fully synced
|
|
323
367
|
3. Use slightly larger amounts (200-500 satoshis)
|
|
@@ -325,27 +369,33 @@ function categorizeError(error: WalletErrorObject): 'user' | 'network' | 'system
|
|
|
325
369
|
5. Check for sufficient confirmed UTXOs
|
|
326
370
|
|
|
327
371
|
#### "Insufficient funds" with Available Balance
|
|
372
|
+
|
|
328
373
|
**Symptoms**: Error despite wallet showing balance
|
|
329
374
|
**Cause**: UTXOs not properly selected by wallet
|
|
330
375
|
**Solutions**:
|
|
376
|
+
|
|
331
377
|
1. Check UTXO status with `listOutputs()`
|
|
332
378
|
2. Verify UTXOs are confirmed
|
|
333
379
|
3. Restart wallet to refresh UTXO cache
|
|
334
380
|
4. Use manual input selection if supported
|
|
335
381
|
|
|
336
382
|
#### Transaction Broadcast Failures
|
|
383
|
+
|
|
337
384
|
**Symptoms**: Valid transactions rejected by network
|
|
338
385
|
**Cause**: Various network or validation issues
|
|
339
386
|
**Solutions**:
|
|
387
|
+
|
|
340
388
|
1. Verify transaction format and signatures
|
|
341
389
|
2. Check fee rates are adequate
|
|
342
390
|
3. Ensure inputs are unspent
|
|
343
391
|
4. Try alternative broadcast endpoints
|
|
344
392
|
|
|
345
393
|
#### Wallet Connection Issues
|
|
394
|
+
|
|
346
395
|
**Symptoms**: Cannot connect to wallet substrate
|
|
347
396
|
**Cause**: Wallet not running or permission issues
|
|
348
397
|
**Solutions**:
|
|
398
|
+
|
|
349
399
|
1. Ensure wallet application is running
|
|
350
400
|
2. Check originator domain permissions
|
|
351
401
|
3. Clear browser cache and cookies
|
package/docs/reference/index.md
CHANGED
|
@@ -5,6 +5,7 @@ Complete technical specifications and API documentation for the BSV TypeScript S
|
|
|
5
5
|
## Standards and Interfaces
|
|
6
6
|
|
|
7
7
|
### [BRC-100 Wallet Interface](./brc-100.md)
|
|
8
|
+
|
|
8
9
|
- Unified wallet-to-application interface standard
|
|
9
10
|
- WalletClient implementation details
|
|
10
11
|
- JSON API specifications
|
|
@@ -12,26 +13,31 @@ Complete technical specifications and API documentation for the BSV TypeScript S
|
|
|
12
13
|
## Core Classes
|
|
13
14
|
|
|
14
15
|
### [Transaction Class](./transaction.md)
|
|
16
|
+
|
|
15
17
|
- Constructor options and methods
|
|
16
18
|
- Input/output management
|
|
17
19
|
- Serialization formats
|
|
18
20
|
|
|
19
21
|
### [PrivateKey/PublicKey Classes](./primitives.md)
|
|
22
|
+
|
|
20
23
|
- Key generation methods
|
|
21
24
|
- Import/export formats
|
|
22
25
|
- Cryptographic operations
|
|
23
26
|
|
|
24
27
|
### [Transaction Signatures Reference](./transaction-signatures.md)
|
|
28
|
+
|
|
25
29
|
- ECDSA signature components
|
|
26
30
|
- DER encoding format
|
|
27
31
|
- Signature hash types (SIGHASH flags)
|
|
28
32
|
|
|
29
33
|
### [Script Classes](./script.md)
|
|
34
|
+
|
|
30
35
|
- Script construction utilities
|
|
31
36
|
- Standard script templates
|
|
32
37
|
- Custom script patterns
|
|
33
38
|
|
|
34
39
|
### [OP Codes Reference](./op-codes.md)
|
|
40
|
+
|
|
35
41
|
- Complete opcode listing and descriptions
|
|
36
42
|
- Opcode categories and usage patterns
|
|
37
43
|
- Script execution examples
|
|
@@ -39,17 +45,20 @@ Complete technical specifications and API documentation for the BSV TypeScript S
|
|
|
39
45
|
## Module Reference
|
|
40
46
|
|
|
41
47
|
### [Primitives Module](./primitives.md)
|
|
48
|
+
|
|
42
49
|
- Cryptographic primitives
|
|
43
50
|
- Hash functions
|
|
44
51
|
- Security implementation notes
|
|
45
52
|
|
|
46
53
|
### [Transaction Module](./transaction.md)
|
|
54
|
+
|
|
47
55
|
- Transaction lifecycle
|
|
48
56
|
- Fee calculation details
|
|
49
57
|
- Broadcasting options
|
|
50
58
|
- SPV verification
|
|
51
59
|
|
|
52
60
|
### [Wallet Module](./wallet.md)
|
|
61
|
+
|
|
53
62
|
- Wallet architecture patterns
|
|
54
63
|
- Integration guidelines
|
|
55
64
|
- BRC-100 compliance notes
|
|
@@ -57,6 +66,7 @@ Complete technical specifications and API documentation for the BSV TypeScript S
|
|
|
57
66
|
## Configuration Reference
|
|
58
67
|
|
|
59
68
|
### [SDK Configuration Options](./configuration.md)
|
|
69
|
+
|
|
60
70
|
```typescript
|
|
61
71
|
interface SDKConfig {
|
|
62
72
|
network: 'mainnet' | 'testnet' | 'regtest'
|
|
@@ -67,12 +77,14 @@ interface SDKConfig {
|
|
|
67
77
|
```
|
|
68
78
|
|
|
69
79
|
### [ARC Configuration](./arc-config.md)
|
|
80
|
+
|
|
70
81
|
- Endpoint configuration
|
|
71
82
|
- Authentication methods
|
|
72
83
|
- Rate limiting options
|
|
73
84
|
- Failover settings
|
|
74
85
|
|
|
75
86
|
### [Network Configuration](./network-config.md)
|
|
87
|
+
|
|
76
88
|
- Mainnet vs testnet settings
|
|
77
89
|
- Custom network parameters
|
|
78
90
|
- Node endpoint configurations
|
|
@@ -80,17 +92,18 @@ interface SDKConfig {
|
|
|
80
92
|
## Error Reference
|
|
81
93
|
|
|
82
94
|
### [Error Codes and Messages](./errors.md)
|
|
95
|
+
|
|
83
96
|
- Transaction validation errors
|
|
84
97
|
- Network connectivity errors
|
|
85
98
|
- Cryptographic operation errors
|
|
86
99
|
- Troubleshooting steps
|
|
87
100
|
|
|
88
101
|
### [Debugging Guide](./debugging.md)
|
|
102
|
+
|
|
89
103
|
- SDK logging configuration
|
|
90
104
|
- Debug mode activation
|
|
91
105
|
- Transaction inspection tools
|
|
92
106
|
|
|
93
|
-
|
|
94
107
|
## Swagger
|
|
95
108
|
|
|
96
109
|
[BRC-100](https://brc.dev/100) defines a Unified, Vendor-Neutral, Unchanging, and Open BSV Blockchain Standard Wallet-to-Application Interface which is implemented in this library within the WalletClient class. The API is laid out here as a swagger openapi document to offer a fast-track to understanding the interface which is implemented across multiple substrates. The JSON api is generally considered a developer friendly introduction to the WalletClient, where an binary equivalent ABI may be preferred for production use cases.
|
|
@@ -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
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# Transaction Signatures Reference
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
** SKELETON PLACEHOLDER - check <https://docs.bsvblockchain.org/guides/sdks/ts/low-level/tx_sig> ***
|
|
3
4
|
*This is a technical reference document for transaction signatures in the BSV TypeScript SDK.*
|
|
4
5
|
|
|
5
6
|
## Introduction
|
|
@@ -259,6 +259,7 @@ export interface HttpClientRequestOptions<Data = any> {
|
|
|
259
259
|
method?: string;
|
|
260
260
|
headers?: Record<string, string>;
|
|
261
261
|
data?: Data;
|
|
262
|
+
signal?: AbortSignal;
|
|
262
263
|
}
|
|
263
264
|
```
|
|
264
265
|
|
|
@@ -286,6 +287,14 @@ A string to set request's method.
|
|
|
286
287
|
method?: string
|
|
287
288
|
```
|
|
288
289
|
|
|
290
|
+
#### Property signal
|
|
291
|
+
|
|
292
|
+
An optional AbortSignal to cancel the request, including by explicit timeout.
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
signal?: AbortSignal
|
|
296
|
+
```
|
|
297
|
+
|
|
289
298
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
290
299
|
|
|
291
300
|
---
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
**Prerequisites**: Completed "Transaction Types and Data" tutorial, Node.js, basic TypeScript knowledge
|
|
3
3
|
|
|
4
4
|
## Learning Goals
|
|
5
|
+
|
|
5
6
|
- Master multi-input/multi-output transaction construction
|
|
6
7
|
- Implement advanced fee calculation and optimization strategies
|
|
7
8
|
- Handle change outputs efficiently
|
|
@@ -449,7 +450,6 @@ async function createTransactionChain() {
|
|
|
449
450
|
createTransactionChain().catch(console.error)
|
|
450
451
|
```
|
|
451
452
|
|
|
452
|
-
|
|
453
453
|
## Performance Optimization Strategies
|
|
454
454
|
|
|
455
455
|
For high-throughput applications, consider these optimization techniques:
|
|
@@ -546,8 +546,6 @@ async function optimizedTransactionPatterns() {
|
|
|
546
546
|
optimizedTransactionPatterns().catch(console.error)
|
|
547
547
|
```
|
|
548
548
|
|
|
549
|
-
|
|
550
|
-
|
|
551
549
|
## Conclusion
|
|
552
550
|
|
|
553
551
|
You've now mastered advanced transaction construction with the BSV TypeScript SDK's `WalletClient`. You can:
|
|
@@ -567,7 +565,6 @@ These techniques enable you to build production-ready applications that efficien
|
|
|
567
565
|
|
|
568
566
|
- Advanced transaction construction requires robust error handling for production applications. For comprehensive coverage of error handling patterns, retry mechanisms, and recovery strategies, see the dedicated [Error Handling Tutorial](./error-handling.md).
|
|
569
567
|
|
|
570
|
-
|
|
571
568
|
## Additional Resources
|
|
572
569
|
|
|
573
570
|
- [Wallet Reference](../reference/wallet.md)
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
Advanced Encryption Standard (AES) is a symmetric encryption algorithm where the same key is used for both encryption and decryption. The BSV TypeScript SDK provides the `SymmetricKey` class that implements AES-GCM (Galois/Counter Mode), which provides both confidentiality and authenticity.
|
|
18
18
|
|
|
19
19
|
AES-GCM offers several advantages:
|
|
20
|
+
|
|
20
21
|
- **Confidentiality**: Data is encrypted and unreadable without the key
|
|
21
22
|
- **Authenticity**: Built-in authentication prevents tampering
|
|
22
23
|
- **Performance**: Fast encryption/decryption operations
|
|
@@ -127,11 +128,13 @@ console.log('SDK decrypted from hex:', sdkDecryptedMessage)
|
|
|
127
128
|
The `enc` parameter in the SDK's `encrypt()` and `decrypt()` methods can be confusing. Here's how it actually works:
|
|
128
129
|
|
|
129
130
|
**In `encrypt(data, enc)`:**
|
|
131
|
+
|
|
130
132
|
- `enc` specifies how to **interpret the input data**
|
|
131
133
|
- `enc: 'hex'` means the input data is a hex string that should be converted to bytes
|
|
132
134
|
- The output format is determined by the `enc` parameter (hex string if `enc: 'hex'`, byte array otherwise)
|
|
133
135
|
|
|
134
136
|
**In `decrypt(data, enc)`:**
|
|
137
|
+
|
|
135
138
|
- `enc` specifies the **output format**
|
|
136
139
|
- `enc: 'hex'` returns the decrypted data as a hex string
|
|
137
140
|
- `enc: 'utf8'` returns the decrypted data as a UTF-8 string
|
|
@@ -153,7 +156,6 @@ const finalMessage = Buffer.from(decryptedHex, 'hex').toString('utf8')
|
|
|
153
156
|
console.log('Final message:', finalMessage) // 'Hello, World!'
|
|
154
157
|
```
|
|
155
158
|
|
|
156
|
-
|
|
157
159
|
## Complete Encryption Example
|
|
158
160
|
|
|
159
161
|
Here's a comprehensive example demonstrating the full encryption workflow:
|