feat: check tipo script legacy (P2PKH/P2SH), peso -15

This commit is contained in:
Aitor
2026-06-04 10:47:31 +02:00
parent 46636bdba9
commit 2874f7c933
+22 -2
View File
@@ -1024,7 +1024,7 @@
input_reuse: 25, input_type_mixing: 14, output_type_mismatch: 8, input_reuse: 25, input_type_mixing: 14, output_type_mismatch: 8,
round_numbers: 10, rbf: 5, peeling: 8, round_numbers: 10, rbf: 5, peeling: 8,
unnecessary_input: 12, dust: 8, change_detection: 10, unnecessary_input: 12, dust: 8, change_detection: 10,
wallet_fingerprint: 6, batch_payment: 45, entity_ofac: 20, op_return: 30, wallet_fingerprint: 6, batch_payment: 45, entity_ofac: 20, op_return: 30, legacy_type: 15,
}; };
let deductions = 0; let deductions = 0;
@@ -1501,7 +1501,27 @@
penalty: 0, informational: true, penalty: 0, informational: true,
}); });
// ── 16. Detección de entidades conocidas ────────────────────────── // ── 16. Tipo legacy (P2PKH / P2SH) ───────────────────────────────
// Inputs en formato legacy (P2PKH = 1..., P2SH = 3...) revelan UTXOs antiguos
// o wallets que no han migrado a SegWit/Taproot. Mayor huella on-chain y
// menor anonimato en el conjunto de usuarios modernos.
const legacyTypes = ["p2pkh", "p2sh"];
const allInputScriptTypes = [...new Set(tx.vin.map(v=>v.prevout?.scriptpubkey_type).filter(Boolean))];
const hasLegacyInputs = allInputScriptTypes.some(t => legacyTypes.includes(t));
const legacyInputTypes = allInputScriptTypes.filter(t => legacyTypes.includes(t));
checks.push({
id:"legacy_type", label:"Tipo de script legacy (P2PKH/P2SH)", certainty:"CERTEZA",
pass: !hasLegacyInputs,
actionability: "wallet",
detail: hasLegacyInputs
? `Los inputs usan tipo legacy (${legacyInputTypes.join(", ")}). Las direcciones legacy (1... para P2PKH, 3... para P2SH) tienen mayor huella on-chain que SegWit (bc1q...) o Taproot (bc1p...) y forman un conjunto de usuarios cada vez más pequeño, lo que reduce el anonimato por conjunto.`
: "Los inputs usan SegWit o Taproot — no se detecta tipo legacy.",
didactic: "P2PKH y P2SH son los formatos originales de Bitcoin. La mayoría de wallets modernos usan SegWit (bc1q) o Taproot (bc1p), que son más eficientes y tienen menor huella. Usar legacy no es un error activo, pero sí una característica del UTXO observable por cualquiera.",
penalty: hasLegacyInputs ? weights.legacy_type : 0,
});
if (hasLegacyInputs) deductions += weights.legacy_type;
// ── 17. Detección de entidades conocidas ──────────────────────────
// Cruza direcciones de inputs y outputs contra el ENTITY_INDEX embebido. // Cruza direcciones de inputs y outputs contra el ENTITY_INDEX embebido.
const allTxAddrs = [ const allTxAddrs = [
...tx.vin.map(v => ({ addr: v.prevout?.scriptpubkey_address, side: "input" })), ...tx.vin.map(v => ({ addr: v.prevout?.scriptpubkey_address, side: "input" })),