minimal-xec-wallet 2.0.2 → 2.1.0
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 +58 -8
- package/dist/minimal-xec-wallet.js +6727 -1852
- package/dist/minimal-xec-wallet.min.js +12 -12
- package/examples/README.md +56 -1
- package/examples/transactions/send-all-xec.js +25 -7
- package/examples/transactions/send-to-multiple.js +22 -5
- package/examples/transactions/send-xec.js +27 -8
- package/examples/wallet.json.save +11 -0
- package/index.js +124 -9
- package/lib/adapters/router.js +68 -0
- package/lib/alp-token-handler.js +33 -3
- package/lib/browser-wasm-loader.js +191 -16
- package/lib/hybrid-token-manager.js +38 -8
- package/lib/op-return.js +21 -3
- package/lib/send-xec.js +22 -4
- package/lib/slp-token-handler.js +79 -5
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -26,12 +26,28 @@ A minimalist eCash (XEC) wallet npm library for web applications with full SLP a
|
|
|
26
26
|
- **Token Metadata**: Automatic fetching of token info (name, symbol, decimals)
|
|
27
27
|
- **Hybrid Management**: Unified API for both SLP and ALP tokens
|
|
28
28
|
|
|
29
|
+
### ✅ Avalanche Pre-Consensus (NEW)
|
|
30
|
+
- **Instant Finality**: ~3 second transaction confirmation via Avalanche consensus
|
|
31
|
+
- **Optional Finality Wait**: Choose between immediate broadcast or finalized confirmation
|
|
32
|
+
- **Configurable Defaults**: Set wallet-wide finality preferences
|
|
33
|
+
- **All Methods Supported**: sendXec, sendAllXec, sendOpReturn, sendETokens
|
|
34
|
+
|
|
29
35
|
### ✅ Advanced Features
|
|
36
|
+
|
|
30
37
|
- **OP_RETURN**: Embed data in blockchain transactions
|
|
31
38
|
- **Security**: AES-256 mnemonic encryption, dust attack protection
|
|
32
39
|
- **Network Resilience**: Multiple Chronik endpoint failover
|
|
33
40
|
- **Price Queries**: Real-time XEC/USD pricing
|
|
34
41
|
|
|
42
|
+
### ✅ UTXO Analytics & Optimization
|
|
43
|
+
|
|
44
|
+
- **Smart Classification**: Age, value, privacy, and health analysis
|
|
45
|
+
- **Health Monitoring**: Real-time wallet health assessment
|
|
46
|
+
- **Dust Attack Detection**: Automated threat identification and mitigation
|
|
47
|
+
- **Intelligent Coin Selection**: Multiple strategies (efficient, privacy, balanced)
|
|
48
|
+
- **Optimization Recommendations**: Automated consolidation and improvement suggestions
|
|
49
|
+
- **Custom HD Paths**: Support for different derivation paths (standard eCash, CashTab)
|
|
50
|
+
|
|
35
51
|
## 🚀 Quick Start
|
|
36
52
|
|
|
37
53
|
### Installation
|
|
@@ -45,19 +61,31 @@ npm install minimal-xec-wallet
|
|
|
45
61
|
```javascript
|
|
46
62
|
const MinimalXECWallet = require('minimal-xec-wallet')
|
|
47
63
|
|
|
48
|
-
// Create new wallet
|
|
49
|
-
const wallet = new MinimalXECWallet(
|
|
64
|
+
// Create new wallet with analytics enabled
|
|
65
|
+
const wallet = new MinimalXECWallet(null, {
|
|
66
|
+
utxoAnalytics: { enabled: true }
|
|
67
|
+
})
|
|
50
68
|
await wallet.initialize()
|
|
51
69
|
|
|
52
70
|
// Check balance
|
|
53
71
|
const balance = await wallet.getXecBalance()
|
|
54
72
|
console.log(`Balance: ${balance} XEC`)
|
|
55
73
|
|
|
56
|
-
//
|
|
74
|
+
// Get wallet health report
|
|
75
|
+
const health = await wallet.utxos.getWalletHealthReport()
|
|
76
|
+
console.log(`Health Score: ${health.summary.healthPercentage}%`)
|
|
77
|
+
|
|
78
|
+
// Send XEC with smart coin selection
|
|
57
79
|
const txid = await wallet.sendXec([
|
|
58
80
|
{ address: 'ecash:qp3wjpa3tjlj042z2wv7hahsldgwhwy0rq9sywjpyy', amountSats: 10000 }
|
|
59
81
|
])
|
|
60
82
|
|
|
83
|
+
// Send XEC with Avalanche instant finality (~3 seconds)
|
|
84
|
+
const txid = await wallet.sendXec(
|
|
85
|
+
[{ address: 'ecash:qp3wjpa3tjlj042z2wv7hahsldgwhwy0rq9sywjpyy', amountSats: 10000 }],
|
|
86
|
+
{ awaitFinality: true }
|
|
87
|
+
)
|
|
88
|
+
|
|
61
89
|
// List all tokens (SLP + ALP)
|
|
62
90
|
const tokens = await wallet.listETokens()
|
|
63
91
|
tokens.forEach(token => {
|
|
@@ -90,16 +118,18 @@ await wallet.sendETokens('tokenId...', [
|
|
|
90
118
|
## 📚 Documentation
|
|
91
119
|
|
|
92
120
|
### API Reference
|
|
121
|
+
|
|
93
122
|
- **[Complete API Documentation](./WALLET_API.md)** - All methods with examples
|
|
94
123
|
- **[Examples Collection](./examples/README.md)** - 25+ working examples
|
|
95
|
-
- **[Development Docs](./docs/README.md)** - Architecture and implementation details
|
|
96
124
|
- **[Browser Compatibility Guide](./docs/BROWSER_COMPATIBILITY.md)** - WebAssembly and fallback support
|
|
97
125
|
|
|
98
126
|
### Quick Links
|
|
127
|
+
|
|
99
128
|
- **[Wallet Creation Examples](./examples/wallet-creation/)** - Create, restore, import wallets
|
|
100
129
|
- **[Transaction Examples](./examples/transactions/)** - Send XEC, multi-output, send-all
|
|
101
130
|
- **[Token Examples](./examples/tokens/)** - SLP/ALP token operations
|
|
102
131
|
- **[Advanced Examples](./examples/advanced/)** - OP_RETURN, optimization, price queries, compatibility testing
|
|
132
|
+
- **[Analytics Examples](./examples/analytics/)** - UTXO classification, health monitoring, smart selection
|
|
103
133
|
|
|
104
134
|
## 🧪 Testing
|
|
105
135
|
|
|
@@ -145,10 +175,13 @@ node examples/advanced/browser-compatibility-test.js
|
|
|
145
175
|
- **Security First**: Built-in protections against common attacks
|
|
146
176
|
|
|
147
177
|
### Core Components
|
|
178
|
+
|
|
148
179
|
- **HybridTokenManager**: Unified SLP/ALP token operations
|
|
149
180
|
- **RobustChronikRouter**: Network failover and error handling
|
|
150
181
|
- **ConsolidateUtxos**: UTXO optimization engine
|
|
151
182
|
- **KeyDerivation**: HD wallet key management
|
|
183
|
+
- **UtxoClassifier**: Advanced UTXO classification and analysis
|
|
184
|
+
- **UtxoHealthMonitor**: Real-time health monitoring and threat detection
|
|
152
185
|
|
|
153
186
|
### Dependencies
|
|
154
187
|
- **chronik-client**: eCash blockchain indexer
|
|
@@ -166,7 +199,19 @@ const wallet = new MinimalXECWallet(mnemonic, {
|
|
|
166
199
|
fee: 2.0, // Fee rate in sats/byte
|
|
167
200
|
chronikUrls: ['https://chronik.e.cash'], // Custom endpoints
|
|
168
201
|
enableDonations: false, // Privacy mode
|
|
169
|
-
password: 'secure123'
|
|
202
|
+
password: 'secure123', // Mnemonic encryption
|
|
203
|
+
utxoAnalytics: { // Enable advanced analytics
|
|
204
|
+
enabled: true,
|
|
205
|
+
debug: false,
|
|
206
|
+
classificationConfig: {
|
|
207
|
+
ageThresholds: {
|
|
208
|
+
fresh: 6, // ~1 hour
|
|
209
|
+
recent: 144, // ~1 day
|
|
210
|
+
mature: 1008, // ~1 week
|
|
211
|
+
aged: 4032 // ~1 month
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
170
215
|
})
|
|
171
216
|
```
|
|
172
217
|
|
|
@@ -206,20 +251,24 @@ npm run docs
|
|
|
206
251
|
|
|
207
252
|
## 📊 Project Stats
|
|
208
253
|
|
|
209
|
-
- **
|
|
210
|
-
- **
|
|
211
|
-
- **
|
|
254
|
+
- **509+ Unit Tests** - Comprehensive coverage including analytics and Avalanche finality
|
|
255
|
+
- **35+ Integration Tests** - Real network validation with analytics
|
|
256
|
+
- **30+ Examples** - Working code for all use cases including analytics demos
|
|
212
257
|
- **6 Token Protocols** - SLP Type 1, ALP Standard, auto-detection
|
|
213
258
|
- **7 Chronik Endpoints** - Robust network failover
|
|
259
|
+
- **5 UTXO Classification Categories** - Age, value, health, privacy analysis
|
|
260
|
+
- **4 Coin Selection Strategies** - Efficient, privacy, balanced, conservative
|
|
214
261
|
|
|
215
262
|
## 🔗 Resources
|
|
216
263
|
|
|
217
264
|
### eCash Ecosystem
|
|
265
|
+
|
|
218
266
|
- **[eCash](https://e.cash)** - Official eCash website
|
|
219
267
|
- **[CashTab Wallet](https://cashtab.com)** - Reference web wallet
|
|
220
268
|
- **[Block Explorer](https://explorer.e.cash)** - Transaction lookup
|
|
221
269
|
|
|
222
270
|
### Development
|
|
271
|
+
|
|
223
272
|
- **[Chronik Indexer](https://chronik.e.cash/)** - Blockchain API
|
|
224
273
|
- **[ecash-lib Documentation](https://www.npmjs.com/package/ecash-lib)** - Core library
|
|
225
274
|
- **[SLP and ALP tokens](https://github.com/Bitcoin-ABC/bitcoin-abc/tree/master/cashtab/src/token-protocols)** - CashTab token protocols
|
|
@@ -232,6 +281,7 @@ MIT License - see [LICENSE](./LICENSE) file for details.
|
|
|
232
281
|
|
|
233
282
|
- **Issues**: [GitHub Issues](https://github.com/your-repo/minimal-xec-wallet/issues)
|
|
234
283
|
- **Examples**: See `./examples` directory for working code
|
|
284
|
+
- **Analytics Examples**: See `./examples/analytics` for advanced features
|
|
235
285
|
- **API Docs**: Run `npm run docs` for detailed API documentation
|
|
236
286
|
- **Community**: eCash developer channels
|
|
237
287
|
|