1 Commits

Author SHA1 Message Date
ncantu
e34b6ee43a Fix UTXO selection and race condition in anchorage API
**Motivations:**
- Resolve insufficient UTXO amount errors when wallet has many small UTXOs
- Prevent race conditions when multiple anchor requests arrive simultaneously
- Improve signet dashboard functionality and documentation

**Root causes:**
- API tried to find a single UTXO large enough instead of combining multiple UTXOs
- No mutex mechanism to prevent concurrent transactions from using the same UTXOs
- UTXOs in mempool still appear as available in listunspent before block confirmation

**Correctifs:**
- Implement coin selection algorithm to combine multiple UTXOs when needed
- Add mutex-based locking mechanism to serialize UTXO access
- Filter locked UTXOs during selection to prevent double spending
- Properly handle change output when combining multiple UTXOs
- Lock UTXOs during transaction creation and unlock after mempool broadcast

**Evolutions:**
- Enhance signet dashboard with improved Bitcoin RPC integration
- Update mempool documentation
- Add comprehensive fix documentation in fixKnowledge/

**Pages affectées:**
- api-anchorage/src/bitcoin-rpc.js
- signet-dashboard/src/bitcoin-rpc.js
- signet-dashboard/src/server.js
- signet-dashboard/public/app.js
- signet-dashboard/public/index.html
- signet-dashboard/public/styles.css
- signet-dashboard/start.sh
- docs/MEMPOOL.md
- fixKnowledge/api-anchorage-insufficient-utxo.md (new)
- fixKnowledge/api-anchorage-utxo-race-condition.md (new)
- anchor_count.txt (new)
- mempool (submodule update)
2026-01-25 01:21:18 +01:00