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''' -