@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
package/dist/cjs/package.json
CHANGED
|
Binary file
|
package/docs/index.md
CHANGED
|
@@ -2,71 +2,76 @@
|
|
|
2
2
|
|
|
3
3
|
## SDK Overview
|
|
4
4
|
|
|
5
|
-
The BSV TypeScript SDK is designed to provide an updated and unified layer for developing scalable applications on the BSV Blockchain. It addresses the limitations of previous tools by offering a
|
|
5
|
+
The BSV TypeScript SDK is designed to provide an updated and unified layer for developing scalable applications on the BSV Blockchain. It addresses the limitations of previous tools by offering a Direct Instant Payments (DIP) approach, ensuring privacy and scalability.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
To install the SDK, run:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```bash
|
|
12
|
+
npm install @bsv/sdk
|
|
13
|
+
```
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
You can then import modules from the SDK as follows:
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- [View all tutorials →](./tutorials/index.md)
|
|
17
|
+
```ts
|
|
18
|
+
import { WalletClient, PrivateKey, Transaction } from "@bsv/sdk";
|
|
19
|
+
```
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
Or using require syntax:
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
```js
|
|
24
|
+
const { WalletClient, PrivateKey, Transaction } = require("@bsv/sdk");
|
|
25
|
+
```
|
|
23
26
|
|
|
24
|
-
- [Creating Multi-signature Transactions](./guides/multisig-transactions.md)
|
|
25
|
-
- [Implementing Transaction Batching](./guides/transaction-batching.md)
|
|
26
|
-
- [Configuring Custom ARC Endpoints](./guides/custom-arc-endpoints.md)
|
|
27
|
-
- [View all guides →](./guides/index.md)
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
## BRC-100 Application to Wallet Interface
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
This interface is what most application developers will use to interact with the BSV blockchain.
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
- [Primitives](./reference/primitives.md)
|
|
35
|
-
- [Script](./reference/script.md)
|
|
36
|
-
- [Transaction](./reference/transaction.md)
|
|
37
|
-
- [View all references →](./reference/index.md)
|
|
32
|
+
🚀 **[WalletClient Quickstart](https://fast.brc.dev/)**
|
|
38
33
|
|
|
39
|
-
|
|
34
|
+
- Run SDK code examples without any setup
|
|
35
|
+
- Experiment with transactions, keys, and scripts in real-time
|
|
36
|
+
- Learn by doing with immediate feedback
|
|
37
|
+
- Test concepts from our tutorials interactively
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
[](https://fast.brc.dev/)
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
- [Transaction Structure](./concepts/transaction-structure.md)
|
|
45
|
-
- [SPV Verification](./concepts/spv-verification.md)
|
|
46
|
-
- [BEEF Format](./concepts/beef.md)
|
|
47
|
-
- [View all concepts →](./concepts/index.md)
|
|
41
|
+
Perfect for getting started quickly or experimenting with new ideas.
|
|
48
42
|
|
|
49
|
-
|
|
43
|
+
Another way to familiarize yourself with the Application to Wallet Interface is to checkout this Swagger UI.
|
|
50
44
|
|
|
51
|
-
|
|
45
|
+
[](./swagger/index.html)
|
|
52
46
|
|
|
53
|
-
|
|
47
|
+
Finally, you can deep dive into the details of the interface and types in the reference material below.
|
|
54
48
|
|
|
55
|
-
|
|
49
|
+
## Reference Material
|
|
56
50
|
|
|
57
|
-
|
|
51
|
+
- [Wallet](./reference/wallet.md)
|
|
52
|
+
- [Primitives](./reference/primitives.md)
|
|
53
|
+
- [Script](./reference/script.md)
|
|
54
|
+
- [Transaction](./reference/transaction.md)
|
|
55
|
+
- [Mutual Authenitcation](./reference/auth.md)
|
|
56
|
+
- [Identity](./reference/identity.md)
|
|
57
|
+
- [Overlay Tools](./reference/overlay-tools.md)
|
|
58
|
+
- [Registry](./reference/registry.md)
|
|
59
|
+
- [Storage](./reference/storage.md)
|
|
60
|
+
- [KV Store](./reference/kvstore.md)
|
|
61
|
+
- [Messages](./reference/messages.md)
|
|
62
|
+
- [TOTP](./reference/totp.md)
|
|
63
|
+
- [Compatibility](./reference/compat.md)
|
|
58
64
|
|
|
59
|
-
- Run SDK code examples without any setup
|
|
60
|
-
- Experiment with transactions, keys, and scripts in real-time
|
|
61
|
-
- Learn by doing with immediate feedback
|
|
62
|
-
- Test concepts from our tutorials interactively
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
## Coming Soon™
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
- [Manual Transaction Creation](#manual-transaction-creation)
|
|
69
|
+
- [Broadcasting Transactions](#broadcasting-transactions)
|
|
70
|
+
- [Deriving Keys](#deriving-keys)
|
|
71
|
+
- [Overlays](#overlays)
|
|
72
|
+
- [MessageBox](#message-box)
|
|
67
73
|
|
|
68
|
-
To install the SDK, run:
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
## Performance Reports
|
|
76
|
+
|
|
77
|
+
- [Benchmarks](./performance.md)
|
package/docs/swagger.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
# Markdown Validation Guide for Teranode Documentation
|
|
2
|
-
|
|
3
|
-
This guide provides comprehensive solutions to prevent and catch markdown formatting issues that cause problems in Material MkDocs rendering.
|
|
4
|
-
|
|
5
|
-
## 🛠️ Available Validation Tools
|
|
6
|
-
|
|
7
|
-
### 1. Pre-commit Hooks (Automatic)
|
|
8
|
-
|
|
9
|
-
**Setup**: Already configured in `.pre-commit-config.yaml`
|
|
10
|
-
|
|
11
|
-
- **markdownlint**: Catches formatting issues before commits
|
|
12
|
-
- **Configuration**: `.markdownlint.yml` with rules tailored for Material MkDocs
|
|
13
|
-
|
|
14
|
-
**Usage**:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
# Install pre-commit hooks
|
|
18
|
-
pre-commit install
|
|
19
|
-
|
|
20
|
-
# Run manually on all files
|
|
21
|
-
pre-commit run markdownlint --all-files
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### 2. Custom Validation Script
|
|
25
|
-
|
|
26
|
-
**Location**: `scripts/validate-markdown.py`
|
|
27
|
-
|
|
28
|
-
**Features**:
|
|
29
|
-
|
|
30
|
-
- Detects missing blank lines before lists
|
|
31
|
-
- Finds inconsistent nested bullet indentation
|
|
32
|
-
- Identifies configuration parameters missing Type/Default/Impact details
|
|
33
|
-
- Can automatically fix issues with `--fix` flag
|
|
34
|
-
|
|
35
|
-
**Usage**:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
# Validate all documentation
|
|
39
|
-
python3 scripts/validate-markdown.py docs/
|
|
40
|
-
|
|
41
|
-
# Validate and auto-fix issues
|
|
42
|
-
python3 scripts/validate-markdown.py docs/ --fix
|
|
43
|
-
|
|
44
|
-
# Validate single file
|
|
45
|
-
python3 scripts/validate-markdown.py docs/topics/services/alert.md
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### 3. VS Code Extensions (Real-time)
|
|
49
|
-
|
|
50
|
-
**Recommended Extensions**:
|
|
51
|
-
|
|
52
|
-
- **markdownlint**: Real-time linting in editor
|
|
53
|
-
- **Markdown All in One**: Preview and formatting
|
|
54
|
-
- **Material Theme**: Better syntax highlighting
|
|
55
|
-
|
|
56
|
-
**Setup**:
|
|
57
|
-
|
|
58
|
-
1. Install extensions
|
|
59
|
-
2. Add to VS Code settings.json:
|
|
60
|
-
|
|
61
|
-
```json
|
|
62
|
-
{
|
|
63
|
-
"markdownlint.config": {
|
|
64
|
-
"MD007": { "indent": 4 },
|
|
65
|
-
"MD032": true,
|
|
66
|
-
"MD013": false
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## 🎯 Common Issues & Prevention
|
|
72
|
-
|
|
73
|
-
### Issue 1: Missing Blank Lines Before Lists
|
|
74
|
-
|
|
75
|
-
**Problem**: Lists render inline instead of as proper lists
|
|
76
|
-
**Solution**: Always add blank line before lists
|
|
77
|
-
|
|
78
|
-
```markdown
|
|
79
|
-
❌ Wrong:
|
|
80
|
-
Configuration options:
|
|
81
|
-
|
|
82
|
-
- Option 1
|
|
83
|
-
- Option 2
|
|
84
|
-
|
|
85
|
-
✅ Correct:
|
|
86
|
-
Configuration options:
|
|
87
|
-
|
|
88
|
-
- Option 1
|
|
89
|
-
- Option 2
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Issue 2: Inconsistent Nested Indentation
|
|
93
|
-
|
|
94
|
-
**Problem**: Nested items don't render as nested
|
|
95
|
-
**Solution**: Use exactly 4 spaces for nested items
|
|
96
|
-
|
|
97
|
-
```markdown
|
|
98
|
-
❌ Wrong:
|
|
99
|
-
|
|
100
|
-
- Main item
|
|
101
|
-
- Nested item (2 spaces)
|
|
102
|
-
|
|
103
|
-
✅ Correct:
|
|
104
|
-
|
|
105
|
-
- Main item
|
|
106
|
-
- Nested item (4 spaces)
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Issue 3: Configuration Parameter Formatting
|
|
110
|
-
|
|
111
|
-
**Problem**: Inconsistent parameter documentation
|
|
112
|
-
**Solution**: Use standard format for all parameters
|
|
113
|
-
|
|
114
|
-
```markdown
|
|
115
|
-
✅ Standard Format:
|
|
116
|
-
1. **`parameter_name`**: Brief description.
|
|
117
|
-
- Type: string
|
|
118
|
-
- Default: "value"
|
|
119
|
-
- Impact: Detailed explanation of what this controls.
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## 🚀 Workflow Integration
|
|
123
|
-
|
|
124
|
-
### Daily Development
|
|
125
|
-
|
|
126
|
-
1. **VS Code Extensions**: Real-time feedback while editing
|
|
127
|
-
2. **Pre-commit Hooks**: Automatic validation before commits
|
|
128
|
-
3. **Custom Script**: Bulk validation and fixes
|
|
129
|
-
|
|
130
|
-
### CI/CD Pipeline
|
|
131
|
-
|
|
132
|
-
1. **GitHub Actions**: Validate all PRs
|
|
133
|
-
2. **Deployment**: Only deploy if validation passes
|
|
134
|
-
|
|
135
|
-
### Periodic Maintenance
|
|
136
|
-
|
|
137
|
-
```bash
|
|
138
|
-
# Weekly validation run
|
|
139
|
-
python3 scripts/validate-markdown.py docs/ --fix
|
|
140
|
-
git add -A
|
|
141
|
-
git commit -m "docs: fix markdown formatting issues"
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## 📋 Validation Checklist
|
|
145
|
-
|
|
146
|
-
Before committing documentation changes:
|
|
147
|
-
|
|
148
|
-
- [ ] Run custom validation script
|
|
149
|
-
- [ ] Check pre-commit hooks pass
|
|
150
|
-
- [ ] Preview in Material MkDocs locally
|
|
151
|
-
- [ ] Verify nested lists render correctly
|
|
152
|
-
- [ ] Confirm configuration parameters follow standard format
|
|
153
|
-
|
|
154
|
-
## 🔧 Quick Fixes
|
|
155
|
-
|
|
156
|
-
**Fix all formatting issues in docs**:
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
python3 scripts/validate-markdown.py docs/ --fix
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
**Run markdownlint**:
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
markdownlint docs/ --config .markdownlint.yml --fix
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
**Preview locally**:
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
mkdocs serve
|
|
172
|
-
# Open http://localhost:8000
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
This multi-layered approach ensures high-quality, consistently formatted documentation that renders perfectly in Material MkDocs.
|
package/docs/concepts/beef.md
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# BEEF Format
|
|
2
|
-
|
|
3
|
-
Bitcoin Extras Extension Format (BEEF) - an efficient way to package Bitcoin transactions with their verification data.
|
|
4
|
-
|
|
5
|
-
## What is BEEF?
|
|
6
|
-
|
|
7
|
-
BEEF is a standardized format that combines:
|
|
8
|
-
|
|
9
|
-
- **Transaction Data**: The actual Bitcoin transaction
|
|
10
|
-
- **Merkle Proofs**: SPV verification data
|
|
11
|
-
- **Block Headers**: Chain validation information
|
|
12
|
-
- **Metadata**: Additional context and references
|
|
13
|
-
|
|
14
|
-
## BEEF in the SDK
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
import { Transaction } from '@bsv/sdk'
|
|
18
|
-
|
|
19
|
-
// Create transaction with BEEF data
|
|
20
|
-
const tx = Transaction.fromHexBEEF(beefHex)
|
|
21
|
-
|
|
22
|
-
// Serialize transaction to BEEF
|
|
23
|
-
const beefData = transaction.toBEEF()
|
|
24
|
-
|
|
25
|
-
// Verify transaction using included proofs
|
|
26
|
-
const isValid = await tx.verify(chainTracker)
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Key Benefits
|
|
30
|
-
|
|
31
|
-
### Efficiency
|
|
32
|
-
|
|
33
|
-
- **Compact**: Includes only necessary verification data
|
|
34
|
-
- **Self-Contained**: No external lookups required
|
|
35
|
-
- **Batch Processing**: Multiple transactions in one package
|
|
36
|
-
|
|
37
|
-
### SPV Integration
|
|
38
|
-
|
|
39
|
-
- **Merkle Proofs**: Verify transaction inclusion
|
|
40
|
-
- **Block Headers**: Validate proof of work
|
|
41
|
-
- **Chain Context**: Understand transaction position
|
|
42
|
-
|
|
43
|
-
### Interoperability
|
|
44
|
-
|
|
45
|
-
- **Standardized**: Consistent format across applications
|
|
46
|
-
- **Portable**: Easy to transmit and store
|
|
47
|
-
- **Compatible**: Works with SPV clients
|
|
48
|
-
|
|
49
|
-
## Use Cases
|
|
50
|
-
|
|
51
|
-
### Transaction Broadcasting
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
// Broadcast transaction with proof
|
|
55
|
-
const beefTx = Transaction.fromHexBEEF(beefData)
|
|
56
|
-
await beefTx.broadcast(arcConfig)
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Data Exchange
|
|
60
|
-
|
|
61
|
-
- Share transactions between applications
|
|
62
|
-
- Provide verification data to SPV clients
|
|
63
|
-
- Archive transactions with proofs
|
|
64
|
-
|
|
65
|
-
### Wallet Integration
|
|
66
|
-
|
|
67
|
-
- Import transactions with full context
|
|
68
|
-
- Verify historical transactions
|
|
69
|
-
- Synchronize between devices
|
|
70
|
-
|
|
71
|
-
## BEEF Structure
|
|
72
|
-
|
|
73
|
-
The format includes:
|
|
74
|
-
|
|
75
|
-
1. **Version**: BEEF format version
|
|
76
|
-
2. **Transactions**: One or more Bitcoin transactions
|
|
77
|
-
3. **Proofs**: Merkle proofs for each transaction
|
|
78
|
-
4. **Headers**: Relevant block headers
|
|
79
|
-
5. **Metadata**: Additional application data
|
|
80
|
-
|
|
81
|
-
## Best Practices
|
|
82
|
-
|
|
83
|
-
- Use BEEF for transactions that need verification
|
|
84
|
-
- Include minimal necessary proof data
|
|
85
|
-
- Validate BEEF structure before processing
|
|
86
|
-
- Cache parsed BEEF data for performance
|
|
87
|
-
|
|
88
|
-
## Next Steps
|
|
89
|
-
|
|
90
|
-
- Learn about [SPV Verification](./spv-verification.md) concepts
|
|
91
|
-
- Understand [Transaction Encoding](./transaction-encoding.md) formats
|
|
92
|
-
- Explore [Chain Tracking](./chain-tracking.md) integration
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
# Chain Tracking
|
|
2
|
-
|
|
3
|
-
How the BSV TypeScript SDK interacts with the Bitcoin network to retrieve transaction and blockchain data.
|
|
4
|
-
|
|
5
|
-
## Chain Tracker Concept
|
|
6
|
-
|
|
7
|
-
A chain tracker provides access to Bitcoin blockchain data without running a full node:
|
|
8
|
-
|
|
9
|
-
```typescript
|
|
10
|
-
import { WhatsOnChain } from '@bsv/sdk'
|
|
11
|
-
|
|
12
|
-
// Create a chain tracker
|
|
13
|
-
const chainTracker = new WhatsOnChain('mainnet')
|
|
14
|
-
|
|
15
|
-
// Get transaction data
|
|
16
|
-
const txData = await chainTracker.getTransaction('txid')
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Key Functions
|
|
20
|
-
|
|
21
|
-
### Transaction Lookup
|
|
22
|
-
|
|
23
|
-
- Retrieve transaction details by ID
|
|
24
|
-
- Get transaction status and confirmations
|
|
25
|
-
- Access transaction inputs and outputs
|
|
26
|
-
|
|
27
|
-
### UTXO Queries
|
|
28
|
-
|
|
29
|
-
- Find unspent transaction outputs
|
|
30
|
-
- Check UTXO availability and value
|
|
31
|
-
- Retrieve UTXO locking scripts
|
|
32
|
-
|
|
33
|
-
### Block Information
|
|
34
|
-
|
|
35
|
-
- Get block headers and merkle proofs
|
|
36
|
-
- Verify transaction inclusion in blocks
|
|
37
|
-
- Access block timestamps and difficulty
|
|
38
|
-
|
|
39
|
-
### Network Status
|
|
40
|
-
|
|
41
|
-
- Check network connectivity
|
|
42
|
-
- Monitor chain tip and height
|
|
43
|
-
- Get fee rate recommendations
|
|
44
|
-
|
|
45
|
-
## SPV Integration
|
|
46
|
-
|
|
47
|
-
Chain trackers enable SPV (Simplified Payment Verification):
|
|
48
|
-
|
|
49
|
-
- **Merkle Proofs**: Verify transaction inclusion without full blocks
|
|
50
|
-
- **Header Chain**: Maintain block headers for proof verification
|
|
51
|
-
- **Lightweight**: Minimal data requirements compared to full nodes
|
|
52
|
-
|
|
53
|
-
## Multiple Providers
|
|
54
|
-
|
|
55
|
-
The SDK supports multiple chain tracking services:
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
// Primary and fallback providers
|
|
59
|
-
const config = {
|
|
60
|
-
chainTracker: {
|
|
61
|
-
provider: 'WhatsOnChain',
|
|
62
|
-
network: 'mainnet',
|
|
63
|
-
fallbacks: ['GorillaPool', 'TAAL']
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Benefits
|
|
69
|
-
|
|
70
|
-
### Scalability
|
|
71
|
-
|
|
72
|
-
- No need to store the entire blockchain
|
|
73
|
-
- Fast startup and synchronization
|
|
74
|
-
- Minimal storage requirements
|
|
75
|
-
|
|
76
|
-
### Reliability
|
|
77
|
-
|
|
78
|
-
- Multiple provider support
|
|
79
|
-
- Automatic failover capabilities
|
|
80
|
-
- Redundant data sources
|
|
81
|
-
|
|
82
|
-
### Performance
|
|
83
|
-
|
|
84
|
-
- Targeted data queries
|
|
85
|
-
- Caching of frequently accessed data
|
|
86
|
-
- Optimized for application needs
|
|
87
|
-
|
|
88
|
-
## Common Patterns
|
|
89
|
-
|
|
90
|
-
### Transaction Verification
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
// Verify a transaction exists
|
|
94
|
-
const exists = await chainTracker.getTransaction(txid)
|
|
95
|
-
if (exists) {
|
|
96
|
-
// Transaction is confirmed on-chain
|
|
97
|
-
}
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### UTXO Validation
|
|
101
|
-
|
|
102
|
-
```typescript
|
|
103
|
-
// Check if UTXO is still unspent
|
|
104
|
-
const utxo = await chainTracker.getUTXO(txid, outputIndex)
|
|
105
|
-
if (utxo) {
|
|
106
|
-
// UTXO is available for spending
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Error Handling
|
|
111
|
-
|
|
112
|
-
Chain tracker operations can fail due to:
|
|
113
|
-
|
|
114
|
-
- Network connectivity issues
|
|
115
|
-
- Service provider downtime
|
|
116
|
-
- Invalid transaction IDs
|
|
117
|
-
- Rate limiting
|
|
118
|
-
|
|
119
|
-
The SDK provides automatic retry and failover mechanisms.
|
|
120
|
-
|
|
121
|
-
## Configuration
|
|
122
|
-
|
|
123
|
-
Chain trackers can be configured for:
|
|
124
|
-
|
|
125
|
-
- **Network**: Mainnet, testnet, or regtest
|
|
126
|
-
- **Endpoints**: Custom service URLs
|
|
127
|
-
- **Timeouts**: Request timeout settings
|
|
128
|
-
- **Retry Logic**: Failure handling behavior
|
|
129
|
-
|
|
130
|
-
## Next Steps
|
|
131
|
-
|
|
132
|
-
- Understand [SPV Verification](./spv-verification.md) concepts
|
|
133
|
-
- Learn about [BEEF Format](./beef.md) for efficient data exchange
|
|
134
|
-
- Explore [Trust Model](./trust-model.md) considerations
|