From 3098bbfa7d86f41282b18c95f4dc9293184dfa74 Mon Sep 17 00:00:00 2001 From: davide3011 Date: Fri, 23 Jan 2026 09:19:42 +0100 Subject: [PATCH] Aggiunge visualizzazione chiavi compresse/non compresse in report HTML --- databases/view_db.py | 104 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 4 deletions(-) diff --git a/databases/view_db.py b/databases/view_db.py index 97d47f6..3670d5a 100755 --- a/databases/view_db.py +++ b/databases/view_db.py @@ -75,6 +75,20 @@ class P2PKDatabaseViewer: stats['unspent_value_btc'] = unspent_sat / 100000000.0 stats['unspent_value_sat'] = int(unspent_sat) + # Conta chiavi compresse vs non compresse + cursor.execute('SELECT scriptpubkey FROM p2pk_addresses') + all_scripts = cursor.fetchall() + compressed_count = 0 + uncompressed_count = 0 + for (script,) in all_scripts: + if script and script.startswith('41') and len(script) == 134: + uncompressed_count += 1 + elif script and script.startswith('21') and len(script) == 70: + compressed_count += 1 + + stats['compressed_count'] = compressed_count + stats['uncompressed_count'] = uncompressed_count + except Exception as e: print(f"โš ๏ธ Errore nel calcolo statistiche: {e}") import traceback @@ -91,7 +105,9 @@ class P2PKDatabaseViewer: 'unique_txs': 0, 'unspent_count': 0, 'unspent_value_btc': 0.0, - 'unspent_value_sat': 0 + 'unspent_value_sat': 0, + 'compressed_count': 0, + 'uncompressed_count': 0 } conn.close() @@ -140,7 +156,8 @@ class P2PKDatabaseViewer: rows_html = [] for row in p2pk_data: - pubkey = self.extract_pubkey_from_script(row[4]) + scriptpubkey = row[4] + pubkey = self.extract_pubkey_from_script(scriptpubkey) txid_short = row[2][:16] if len(row[2]) > 16 else row[2] timestamp_str = datetime.fromtimestamp(row[6]).strftime('%Y-%m-%d %H:%M') if row[6] else 'N/A' # row[5] รจ giร  in satoshi, lo convertiamo in BTC dividendo per 100000000 @@ -152,8 +169,19 @@ class P2PKDatabaseViewer: utxo_status = '๐ŸŸข NON SPESO' if is_unspent else '๐Ÿ”ด SPESO' utxo_class = 'unspent' if is_unspent else 'spent' + # Determina se la chiave รจ compressa o non compressa + if scriptpubkey and scriptpubkey.startswith('41') and len(scriptpubkey) == 134: + key_type = 'uncompressed' + key_type_badge = '๐Ÿ“œ Non Compressa (65 bytes)' + elif scriptpubkey and scriptpubkey.startswith('21') and len(scriptpubkey) == 70: + key_type = 'compressed' + key_type_badge = '๐Ÿ“ฆ Compressa (33 bytes)' + else: + key_type = 'unknown' + key_type_badge = 'โ“ Sconosciuta' + row_html = f''' - + {row[0]} {row[1]} @@ -163,7 +191,8 @@ class P2PKDatabaseViewer: {row[3]}
- {pubkey} + {key_type_badge} +
{pubkey}
@@ -462,6 +491,33 @@ class P2PKDatabaseViewer: tr.spent {{ opacity: 0.7; }} + + .key-type-badge {{ + padding: 4px 10px; + border-radius: 15px; + font-size: 0.8em; + font-weight: bold; + display: inline-block; + margin-bottom: 5px; + }} + + .key-type-badge.uncompressed {{ + background: #cfe2ff; + color: #084298; + border: 1px solid #9ec5fe; + }} + + .key-type-badge.compressed {{ + background: #d1e7dd; + color: #0a3622; + border: 1px solid #a3cfbb; + }} + + .key-type-badge.unknown {{ + background: #f8d7da; + color: #58151c; + border: 1px solid #f1aeb5; + }} @@ -505,6 +561,14 @@ class P2PKDatabaseViewer:
๐Ÿ’Ž Valore Non Speso
{stats['unspent_value_btc']:.8f} BTC
+
+
๐Ÿ“œ Chiavi Non Compresse
+
{stats['uncompressed_count']:,}
+
+
+
๐Ÿ“ฆ Chiavi Compresse
+
{stats['compressed_count']:,}
+
@@ -518,6 +582,12 @@ class P2PKDatabaseViewer:
+
+ + + +
+ {self._generate_table_html(p2pk_data)} @@ -581,6 +651,32 @@ class P2PKDatabaseViewer: }} }} }} + + function filterByKeyType(keyType) {{ + const table = document.getElementById('dataTable'); + if (!table) return; + + const tr = table.getElementsByTagName('tr'); + + // Aggiorna stato pulsanti del gruppo key-type + event.target.parentElement.querySelectorAll('.filter-btn').forEach(btn => {{ + btn.classList.remove('active'); + }}); + event.target.classList.add('active'); + + // Filtra righe in base al tipo di chiave + for (let i = 1; i < tr.length; i++) {{ + const row = tr[i]; + + if (keyType === 'all-keys') {{ + row.style.display = ''; + }} else if (keyType === 'uncompressed') {{ + row.style.display = row.classList.contains('uncompressed') ? '' : 'none'; + }} else if (keyType === 'compressed') {{ + row.style.display = row.classList.contains('compressed') ? '' : 'none'; + }} + }} + }}