ncantu 970b06ee8f Fix: Automatic UTXO provisioning on each Bitcoin anchor transaction
**Motivations:**
- Fix insufficient UTXO amount error in anchor API
- Ensure continuous availability of usable UTXOs for anchor transactions
- Improve anchor transaction reliability and efficiency

**Root causes:**
- UTXO selection logic was too restrictive, rejecting UTXOs larger than needed
- No automatic provisioning of new usable UTXOs when existing ones were not suitable
- Algorithm prevented efficient use of available UTXOs

**Correctifs:**
- Refactored createAnchorTransaction() to provision 7 UTXOs of 2500 sats on each anchor
- Use single large UTXO to create 1 anchor output + 7 provisioning outputs + change
- Simplified UTXO selection: single large UTXO per transaction instead of multiple small ones
- Added UTXO provisioning logic in signet-dashboard
- Enhanced Bitcoin RPC methods in both api-anchorage and signet-dashboard
- Added documentation in fixKnowledge/api-anchorage-utxo-provisioning.md

**Evolutions:**
- Enhanced signet-dashboard with new pages (hash-list, utxo-list, join-signet, api-docs)
- Improved Bitcoin RPC client with better error handling and UTXO management
- Added cache files for hash and UTXO lists
- Updated api-faucet with improved server configuration
- Enhanced anchor count tracking

**Pages affectées:**
- api-anchorage/src/bitcoin-rpc.js: Complete refactor of createAnchorTransaction()
- api-anchorage/src/routes/anchor.js: Enhanced anchor route
- api-anchorage/src/server.js: Server configuration updates
- signet-dashboard/src/bitcoin-rpc.js: Added comprehensive Bitcoin RPC client
- signet-dashboard/src/server.js: Enhanced server with new routes
- signet-dashboard/public/: Added new HTML pages and updated app.js
- api-faucet/src/server.js: Server improvements
- api-faucet/README.md: Documentation updates
- fixKnowledge/api-anchorage-utxo-provisioning.md: New documentation
- anchor_count.txt, hash_list.txt, utxo_list.txt: Tracking files
2026-01-25 14:25:49 +01:00

198 lines
6.6 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Liste des Hash Ancrés - Bitcoin Ancrage Dashboard</title>
<link rel="stylesheet" href="styles.css">
<style>
.hash-list-container {
max-width: 1400px;
margin: 0 auto;
padding: 20px;
}
.header-section {
margin-bottom: 30px;
}
.header-section h1 {
margin-bottom: 10px;
}
.header-section .back-link {
display: inline-block;
margin-bottom: 20px;
color: #007bff;
text-decoration: none;
}
.header-section .back-link:hover {
text-decoration: underline;
}
.info-section {
background: #f8f9fa;
padding: 15px;
border-radius: 5px;
margin-bottom: 20px;
}
.info-section p {
margin: 5px 0;
}
.table-container {
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
background: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background: #007bff;
color: white;
font-weight: bold;
position: sticky;
top: 0;
}
tr:hover {
background: #f5f5f5;
}
.hash-cell {
font-family: monospace;
font-size: 0.9em;
word-break: break-all;
}
.txid-cell {
font-family: monospace;
font-size: 0.9em;
}
.txid-link {
color: #007bff;
text-decoration: none;
}
.txid-link:hover {
text-decoration: underline;
}
.loading {
text-align: center;
padding: 40px;
font-size: 1.2em;
color: #666;
}
.error {
background: #f8d7da;
color: #721c24;
padding: 15px;
border-radius: 5px;
margin: 20px 0;
}
.refresh-button {
background: #28a745;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 1em;
margin-top: 10px;
}
.refresh-button:hover {
background: #218838;
}
.refresh-button:disabled {
background: #6c757d;
cursor: not-allowed;
}
</style>
</head>
<body>
<div class="container">
<div class="hash-list-container">
<div class="header-section">
<a href="/" class="back-link">← Retour au dashboard</a>
<h1>Liste des Hash Ancrés</h1>
<div class="info-section">
<p><strong>Total de hash ancrés :</strong> <span id="hash-count">-</span></p>
<p><strong>Dernière mise à jour :</strong> <span id="last-update">-</span></p>
<button class="refresh-button" onclick="loadHashList()">Actualiser</button>
<a href="/api/hash/list.txt" download="hash_list.txt" style="margin-left: 10px; color: #007bff; text-decoration: none;">📥 Télécharger le fichier texte</a>
</div>
</div>
<div id="content">
<div class="loading">Chargement des hash...</div>
</div>
</div>
</div>
<script>
const API_BASE_URL = window.location.origin;
// Charger la liste au chargement de la page
document.addEventListener('DOMContentLoaded', () => {
loadHashList();
});
async function loadHashList() {
const contentDiv = document.getElementById('content');
const refreshButton = document.querySelector('.refresh-button');
refreshButton.disabled = true;
contentDiv.innerHTML = '<div class="loading">Chargement des hash...</div>';
try {
const response = await fetch(`${API_BASE_URL}/api/hash/list`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
const hashes = data.hashes || [];
document.getElementById('hash-count').textContent = hashes.length.toLocaleString('fr-FR');
updateLastUpdateTime();
if (hashes.length === 0) {
contentDiv.innerHTML = '<div class="info-section"><p>Aucun hash ancré pour le moment.</p></div>';
} else {
let tableHTML = '<div class="table-container"><table><thead><tr>';
tableHTML += '<th>Hash</th>';
tableHTML += '<th>Transaction ID</th>';
tableHTML += '<th>Hauteur du Bloc</th>';
tableHTML += '<th>Confirmations</th>';
tableHTML += '</tr></thead><tbody>';
hashes.forEach((item) => {
const mempoolUrl = 'https://mempool.4nkweb.com/fr';
const txLink = `${mempoolUrl}/tx/${item.txid}`;
tableHTML += '<tr>';
tableHTML += `<td class="hash-cell">${item.hash}</td>`;
tableHTML += `<td class="txid-cell"><a href="${txLink}" target="_blank" rel="noopener noreferrer" class="txid-link">${item.txid}</a></td>`;
tableHTML += `<td>${item.blockHeight !== null ? item.blockHeight.toLocaleString('fr-FR') : '-'}</td>`;
tableHTML += `<td>${item.confirmations.toLocaleString('fr-FR')}</td>`;
tableHTML += '</tr>';
});
tableHTML += '</tbody></table></div>';
contentDiv.innerHTML = tableHTML;
}
} catch (error) {
console.error('Error loading hash list:', error);
contentDiv.innerHTML = `<div class="error">Erreur lors du chargement de la liste des hash : ${error.message}</div>`;
} finally {
refreshButton.disabled = false;
}
}
function updateLastUpdateTime() {
const now = new Date();
document.getElementById('last-update').textContent = now.toLocaleString('fr-FR');
}
</script>
</body>
</html>