v1.49.3: auditoría en frío, parche 2a — OFAC, polvo, herramientas y errores en llano
- OFAC como CERTEZA en flujo y simulador; exchange con su consecuencia. - Polvo propio no heredado; polvo con forma de rastreo PROBABLE. - Formato de dirección con tipoDireccion (mayúsculas, bitcoin:, tb1p, 2…, suma). - Tx en crudo reconoce PSBT/txid/dirección; firma BIP-322 reconocida. - Tarifa bajo la mínima; errores de red en llano (errorDeNodo); copiar que falla. - Comprobar transacción, plural, SIN CONFIRMAR, pie del Markdown en signet, EUR editable, fuera «clustering». - test40 nuevo; test35 y test18 ampliados. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L5npnUYgSPkAaHkdaeUqBr
This commit is contained in:
+1
-1
@@ -39,7 +39,7 @@ console.log("=== Procedencia en los avisos ===\n");
|
||||
const m = det(de("mining"), "entity_mining");
|
||||
ok("pool: fuente y fecha", /coinbase/.test(m) && /31\/05\/2026/.test(m));
|
||||
const c = det(de("exchange"), "entity_exchange");
|
||||
ok("exchange por agrupación: fuente y fecha", /clustering/.test(c) && /03\/06\/2026/.test(c));
|
||||
ok("exchange por agrupación: fuente y fecha", /agrupación de direcciones \(bitcoin-data\)/.test(c) && /03\/06\/2026/.test(c));
|
||||
const r = det(deSrc("richlist"), "entity_exchange");
|
||||
ok("exchange por etiqueta: «de terceros», no «publicada por el exchange»", /etiquetas públicas de terceros/.test(r) && /No las ha confirmado el exchange/.test(r) && !/direcciones públicas conocidas/.test(r), r.slice(0, 200));
|
||||
}
|
||||
|
||||
+5
-1
@@ -22,7 +22,7 @@ const cut = (desde, hasta) => {
|
||||
return lines.slice(s, e).join("\n");
|
||||
};
|
||||
const F = new Function(`const C = { green:"g", amber:"a", red:"r", t2:"t", blue:"b", purple:"p" };
|
||||
const ENTITY_INDEX = new Map([["bc1qexchangeprueba000000000000000000000", { name:"ExchangePrueba", cat:"exchange", src:"richlist" }]]); const OFAC_SET = new Set();
|
||||
const ENTITY_INDEX = new Map([["bc1qexchangeprueba000000000000000000000", { name:"ExchangePrueba", cat:"exchange", src:"richlist" }], ["bc1qofacprueba0000000000000000000000000", { name:"SancionadaPrueba", cat:"ofac" }]]); const OFAC_SET = new Set();
|
||||
${cut("// ── FORMATO: lógica pura", "// ── fin formato")}
|
||||
${cut("// ── FLUJO: lógica pura", "// ── fin flujo")}
|
||||
${cut("function detectWallets", "function analyzeAddress")}
|
||||
@@ -116,6 +116,10 @@ ok("entidad: sin coincidencia en el análisis no se marca aunque se pase entidad
|
||||
const E = conFee({ txid: "2".repeat(64), vin: [vin(5000000, W(1))], vout: [vout(1234567, "bc1qexchangeprueba000000000000000000000"), vout(3755555, TR(4), "v1_p2tr")] });
|
||||
const gE = geo(E, { ancho: 800, entidadDe: a => F.ENTITY_INDEX.get(a) || null });
|
||||
ok("entidad: con coincidencia, «entidad: ExchangePrueba» en su salida", gE.salidas[0].marcas.some(m => m.texto === "entidad: ExchangePrueba") && !marcas(gE.salidas[1]).includes("entidad"));
|
||||
ok("entidad de terceros: POSIBLE", gE.salidas[0].marcas.find(m => m.id === "entidad").certeza === "POSIBLE");
|
||||
const O = conFee({ txid: "3".repeat(64), vin: [vin(5000000, W(1))], vout: [vout(1234567, "bc1qofacprueba0000000000000000000000000"), vout(3755555, TR(4), "v1_p2tr")] });
|
||||
const mO = geo(O, { ancho: 800, entidadDe: a => F.ENTITY_INDEX.get(a) || null }).salidas[0].marcas.find(m => m.id === "entidad");
|
||||
ok("v1.49.3: lista OFAC en el flujo, CERTEZA como su señal (no «nadie la ha confirmado»)", mO && mO.certeza === "CERTEZA" && /lista OFAC/.test(mO.texto) && !/nadie la ha confirmado/.test(mO.detalle), JSON.stringify(mO));
|
||||
|
||||
console.log("Wallet cargada, simulación y Boltzmann");
|
||||
const mia = a => a === W(9) ? "cambio" : a === W(1) ? "recepción" : null;
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
// v1.49.3 — parche 2a, tercera parte: OFAC con su certeza en el simulador,
|
||||
// polvo con forma de rastreo, polvo propio que no es «heredado» y errores de
|
||||
// red dichos en llano.
|
||||
//
|
||||
// Uso: node tests/test40.js
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const lines = require("./fuente.js")().split("\n");
|
||||
const cut = (desde, hasta) => {
|
||||
const s = lines.findIndex(l => l.includes(desde));
|
||||
const e = lines.findIndex((l, i) => i > s && l.includes(hasta));
|
||||
if (s === -1 || e === -1) { console.error(`No se localiza «${desde}» en el código de la app`); process.exit(1); }
|
||||
return lines.slice(s, e).join("\n");
|
||||
};
|
||||
const E = new Function(`const C = { green:"g", amber:"a", red:"r", t2:"t", blue:"b", purple:"p" };
|
||||
const ENTITY_INDEX = new Map(); const OFAC_SET = new Set();
|
||||
${cut("// ── FORMATO: lógica pura", "// ── fin formato")}
|
||||
${cut("function detectWallets", "function analyzeAddress")}
|
||||
${cut("function analyzeAddress", "// ── SIMULADOR DE GASTO")}
|
||||
${cut("// ── SIMULADOR DE GASTO", "// ── fin simulador")}
|
||||
${cut("function errorDeNodo", "// ── fin errorDeNodo")}
|
||||
return { analyzeTx, hechosDeGasto, errorDeNodo };`)();
|
||||
const T = JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", "contraste-25oct.json"), "utf8")).txs;
|
||||
|
||||
let pass = 0, fail = 0;
|
||||
const ok = (n, c, x) => { console.log(` ${c ? "✓" : "✗"} ${n}`); if (!c && x !== undefined) console.log(" " + x); c ? pass++ : fail++; };
|
||||
const ch = (a, id) => a.checks.find(c => c.id === id);
|
||||
const WP = "v0_p2wpkh";
|
||||
const IN = (v, a) => ({ txid: "aa".repeat(32), vout: 0, sequence: 0xfffffffd, prevout: { value: v, scriptpubkey_type: WP, scriptpubkey_address: a, scriptpubkey: "0014" + "ab".repeat(20) } });
|
||||
const OUT = (v, a) => ({ value: v, scriptpubkey_type: WP, scriptpubkey_address: a, scriptpubkey: "0014" + "cd".repeat(20) });
|
||||
const TX = (vin, vout) => ({ txid: "ee".repeat(32), version: 2, locktime: 0, weight: 800, fee: vin.reduce((s, v) => s + v.prevout.value, 0) - vout.reduce((s, o) => s + o.value, 0), status: { confirmed: true, block_height: 900000 }, vin, vout });
|
||||
|
||||
console.log("=== Polvo ===\n");
|
||||
{
|
||||
const d = ch(E.analyzeTx(T.dust), "dust");
|
||||
ok("655c533b…: 555 sat y el resto de vuelta a quien paga → forma de rastreo, PROBABLE", d && d.certainty === "PROBABLE" && /forma de polvo para rastrear/.test(d.label), d && `${d.certainty} · ${d.label}`);
|
||||
const muchas = ch(E.analyzeTx(TX([IN(100000, "bc1qA")], [OUT(600, "bc1qB"), OUT(600, "bc1qC"), OUT(600, "bc1qD"), OUT(96000, "bc1qE")])), "dust");
|
||||
ok("tres salidas diminutas iguales: también PROBABLE", muchas && muchas.certainty === "PROBABLE");
|
||||
const suelta = ch(E.analyzeTx(TX([IN(100000, "bc1qA")], [OUT(700, "bc1qB"), OUT(97000, "bc1qC")])), "dust");
|
||||
ok("una salida pequeña y el resto a otra dirección: sigue POSIBLE", suelta && suelta.certainty === "POSIBLE");
|
||||
const tx = TX([IN(100000, "bc1qMIA")], [OUT(700, "bc1qB"), OUT(97000, "bc1qMIA2")]);
|
||||
const envio = E.analyzeTx(tx, { misDirecciones: new Set(["bc1qMIA", "bc1qMIA2"]) });
|
||||
ok("si lo mandas tú, el polvo no es «heredado» ni suma a lo que decidieron otros", !ch(envio, "dust").heredado && envio.exposicion.puntos === 0, JSON.stringify(envio.exposicion));
|
||||
const recibo = E.analyzeTx(tx, { misDirecciones: new Set(["bc1qB"]) });
|
||||
ok("si lo recibes, sí", ch(recibo, "dust").heredado === true && recibo.exposicion.puntos > 0);
|
||||
}
|
||||
|
||||
console.log("\n=== Simulador: OFAC ===\n");
|
||||
{
|
||||
const h = E.hechosDeGasto({ monedas: [], destino: "bc1qX", clusters: [], walletAddrs: null, labels: new Map(), entidad: { name: "Sancionada", cat: "ofac" } });
|
||||
const o = h.find(x => x.id === "destino_entidad");
|
||||
ok("destino en la lista OFAC: CERTEZA y «copia local de la lista», no «etiqueta de terceros»", o && o.certeza === "CERTEZA" && /copia local de la lista de sanciones OFAC/.test(o.texto) && !/etiqueta de terceros/.test(o.texto), o && o.texto);
|
||||
const x = E.hechosDeGasto({ monedas: [], destino: "bc1qX", clusters: [], walletAddrs: null, labels: new Map(), entidad: { name: "ExPrueba", cat: "exchange", src: "richlist" } }).find(x => x.id === "destino_entidad");
|
||||
ok("exchange: etiqueta de terceros y qué supone si pide identificación", x && x.certeza === "PROBABLE" && /etiqueta de terceros/.test(x.texto) && /pide identificación/.test(x.texto), x && x.texto);
|
||||
}
|
||||
|
||||
console.log("\n=== Errores de red en llano ===\n");
|
||||
{
|
||||
const e502 = E.errorDeNodo(new Error("HTTP 502"), "txoko-metrics");
|
||||
ok("502: dice qué pasa y qué comando mirar", /servicio que hay detrás no/.test(e502) && /systemctl status txoko-metrics/.test(e502), e502);
|
||||
const ff = E.errorDeNodo(new TypeError("Failed to fetch"));
|
||||
ok("Failed to fetch: no se llega al nodo (apagado, Tailscale, certificado)", /No se llega al nodo/.test(ff) && /Tailscale/.test(ff), ff);
|
||||
const ab = new Error("x"); ab.name = "AbortError";
|
||||
ok("timeout: sin respuesta a tiempo", /Sin respuesta a tiempo/.test(E.errorDeNodo(ab, "mempool")));
|
||||
ok("ninguno sale en inglés", ![e502, ff].some(t => /Failed to fetch|HTTP \d/.test(t)));
|
||||
}
|
||||
|
||||
console.log(`\n${pass} correctas, ${fail} fallidas`);
|
||||
process.exit(fail ? 1 : 0);
|
||||
Reference in New Issue
Block a user