v1.24.7: informe pericial sin atribuir de más (huella vacía no cuenta; ramas no seguidas «sin determinar»), importe de la salida y seguido, paradas y ramas pendientes, mezcla como HECHO; test12.js con el rastro real Satoshi→Hal

This commit is contained in:
2026-10-13 20:10:56 +00:00
parent 4b58c6cb35
commit 58249da67b
5 changed files with 403 additions and 34 deletions
+213 -33
View File
@@ -5050,12 +5050,15 @@
// "cambio de actor o entrada en infraestructura de un servicio" — nunca
// CERTEZA, porque una misma persona puede cambiar de wallet sin cambiar
// de dueño de los fondos.
// «sin rasgos distintivos» es la AUSENCIA de huella: dos saltos sin huella
// no tienen «la misma huella». Solo se comparan huellas identificadas.
const huellaIdentificada = fp => { const n = fp?.[0]?.name || null; return n && n !== "sin rasgos distintivos" ? n : null; };
function compareFingerprints(prevFp, nextFp) {
const prevTop = prevFp?.[0]?.name || null;
const nextTop = nextFp?.[0]?.name || null;
const prevTop = huellaIdentificada(prevFp);
const nextTop = huellaIdentificada(nextFp);
if (!prevTop || !nextTop) {
return { changed: null, certainty: null,
note: "Huella insuficiente en uno de los dos saltos para comparar." };
note: "Sin huella identificada en uno de los dos saltos (o en ambos): no hay nada que comparar." };
}
if (prevTop === nextTop) {
return { changed: false, certainty: null,
@@ -5579,7 +5582,7 @@
// ── 1. Resumen ──────────────────────────────────────────────────────
const summary = {
originTxid: origin.txid, originVout: origin.vout, originAddress: origin.address,
originTxid: origin.txid, originVout: origin.vout, originAddress: origin.address || origin.addressLabel || "",
amountTraced: origin.amount, amountStolen,
generatedAt: Math.floor(Date.now()/1000),
hops: maxHop, txCount: allNodes.length + 1, addressesTouched: addressesTouched.size,
@@ -5591,15 +5594,18 @@
: null;
// ── 3. Cronología ────────────────────────────────────────────────────
const chronologyRow = (txid, hop, blockTime, blockHeight, amount, analysis, fingerprint, entityMarks) => ({
level: "HECHO", txid, hop, blockTime, blockHeight, amount, refs:[txid],
// amount = importe de la(s) salida(s) seguida(s) que entran en la tx;
// followed = importe seguido: reparto proporcional de lo robado (una
// cuenta, no una atribución). Pueden ser muy distintos.
const chronologyRow = (txid, hop, blockTime, blockHeight, amount, analysis, fingerprint, entityMarks, followed) => ({
level: "HECHO", txid, hop, blockTime, blockHeight, amount, followed: followed ?? null, refs:[txid],
band: { level:"INFERENCIA", certainty: analysis?.band ? (analysis.band==="ALTA"?"CERTEZA":analysis.band==="MEDIA"?"PROBABLE":"POSIBLE") : null, value: analysis?.band || "—" },
fingerprint: { level:"INFERENCIA", certainty: fingerprint?.[0]?.confidence || null, value: fingerprint?.[0]?.name || "sin huella clara" },
entityMarks: entityMarks || [],
});
const chronology = [
chronologyRow(origin.txid, 0, origin.blockTime, origin.blockHeight, origin.amount, origin.analysis, origin.fingerprint, origin.entityMarks),
...allNodes.map(n => chronologyRow(n.txid, n.hop, n.blockTime, n.blockHeight, n.amountTraced, n.analysis, n.fingerprint, n.entityMarks)),
chronologyRow(origin.txid, 0, origin.blockTime, origin.blockHeight, origin.amount, origin.analysis, origin.fingerprint, origin.entityMarks, origin.amount),
...allNodes.map(n => chronologyRow(n.txid, n.hop, n.blockTime, n.blockHeight, n.amountTraced, n.analysis, n.fingerprint, n.entityMarks, n.amountFollowed)),
];
// ── 4. Direcciones atribuidas al actor ──────────────────────────────
@@ -5670,12 +5676,34 @@
certainty: c.certainty, refTxid: c.txid,
});
}
if (fingerprintStableAddrs.has(a) && !destinatariosMap.has(a)) fundamentos.push({ basis:"huella de wallet estable con el salto anterior", certainty:"POSIBLE" });
if (fundamentos.length === 0) continue;
const ruta = graph.rutaSeguida?.get(a);
if (ruta) fundamentos.push({ basis:"recibió lo seguido y lo volvió a mover en el salto siguiente del rastro", certainty:"POSIBLE", refTxid: ruta.txid });
// La huella estable solo acompaña: por sí sola no atribuye nada.
if (fingerprintStableAddrs.has(a) && !destinatariosMap.has(a)) fundamentos.push({ basis:"huella de wallet identificada y estable con el salto anterior (solo acompaña)", certainty:"POSIBLE", apoyo:true });
if (fundamentos.filter(f => !f.apoyo).length === 0) continue;
if (destinatariosMap.has(a) && !clusterOf.has(a)) continue;
attributed.push({ level:"INFERENCIA", address:a, fundamentos, refs:[a] });
}
// Salidas que no se siguieron ni tienen fundamento: «sin determinar».
// Nunca del actor por defecto. Las de la última tx de una rama son
// «rama abierta»: ahí se dejó de seguir.
const desdeTx = new Set((graph.edges || []).map(e => e.fromTxid));
const atribSet = new Set(attributed.map(x => x.address));
const sinDeterminar = [], vistosSD = new Set();
for (const n of allNodes) {
if (n.stopReason === "mixer" || n.stopReason === "fanOut") continue;
for (const a of n.addresses.out) {
if (atribSet.has(a) || destinatariosMap.has(a) || (n.custodyAddrs || []).includes(a) || vistosSD.has(a)) continue;
vistosSD.add(a);
const abierta = !desdeTx.has(n.txid);
sinDeterminar.push({ level:"HECHO", address:a, txid:n.txid, ramaAbierta:abierta,
basis: abierta ? "rama abierta: es donde se dejó de seguir; sin indicios para atribuirla" : "salida no seguida: sin indicios para atribuirla", refs:[n.txid, a] });
}
}
const pendingBranches = graph.pendientes || [];
const paradaRastro = graph.paradas || [];
// ── 5. Fondos localizados sin gastar ────────────────────────────────
// Solo entra aquí lo COMPROBADO sin gastar. Las ramas con consulta
// fallida (queryFailed) se quedan fuera a propósito: afirmar que unos
@@ -5736,6 +5764,37 @@
conclusions.push({ level:"HECHO", text:`El rastro se detiene en ${n.txid} por el tope de transacciones exploradas — una red de seguridad aparte del límite de saltos, para no sobrecargar el nodo si un salto desemboca en una consolidación con muchísimas ramas. No es un punto de parada natural; se puede seguir rastreando manualmente desde aquí si hace falta.`, refs:[n.txid] });
}
}
// Mezcla con dinero de otros (HECHO: importes de la cadena, haya o no
// importe robado declarado) y salidas del rastro que vuelven a juntarse.
for (const n of allNodes) {
const m = n.mezcla;
if (!m) continue;
if (m.reunidas.length) conclusions.push({ level:"HECHO",
text:`En el salto ${n.hop} (tx ${n.txid}) se vuelven a juntar salidas de transacciones anteriores del rastro que no se habían seguido: ${m.reunidas.map(x => `${x.address} (${btcTxt(x.value)}, de la tx ${x.txid.slice(0,16)}…)`).join(", ")}. Por eso lo que entra es más que la salida seguida.`,
refs:[n.txid, ...m.reunidas.map(x => x.txid)] });
if (m.otras.length) {
const suma = m.otras.reduce((t, x) => t + x.value, 0);
conclusions.push({ level:"HECHO",
text:`En el salto ${n.hop} (tx ${n.txid}) el dinero seguido se juntó con ${btcTxt(suma)} de otra${m.otras.length > 1 ? "s" : ""} dirección${m.otras.length > 1 ? "es" : ""} (${[...new Set(m.otras.map(x => x.address))].join(", ")}). Entran ${btcTxt(m.tin)} en total; lo seguido es ${btcTxt(m.seguido)} (reparto proporcional), el ${m.tin ? (Math.round(m.seguido / m.tin * 1000) / 10).toLocaleString("es-ES") : "0"} % de lo que entra. Desde aquí, cada salida lleva dinero mezclado.`,
refs:[n.txid, ...m.otras.map(x => x.address)] });
}
}
for (const pr of paradaRastro) {
if (pr.motivo === "usuario") conclusions.push({ level:"HECHO",
text:`El rastro se detuvo en el salto ${pr.hop} (tx ${pr.txid}) porque se dejó de seguir: lo decidió quien hizo el peritaje. No se llegó a un final natural (depósito en un servicio, mezcla o monedas sin gastar); lo que sigue desde ahí está sin explorar.`, refs:[pr.txid] });
else if (pr.motivo === "sin_gastar") conclusions.push({ level:"HECHO",
text:`La rama del salto ${pr.hop} (tx ${pr.txid}) termina en monedas sin gastar: es un final natural del rastro.`, refs:[pr.txid] });
else if (pr.motivo === "tope") conclusions.push({ level:"HECHO",
text:`La rama del salto ${pr.hop} (tx ${pr.txid}) se detuvo en el tope de saltos configurado, no en un final natural.`, refs:[pr.txid] });
}
if (pendingBranches.length > 0) {
conclusions.push({ level:"HECHO",
text:`Quedan ${pendingBranches.length} rama(s) sin seguir: ${pendingBranches.map(b => `${b.address} (salida ${b.vout+1} de la tx ${b.txid.slice(0,16)}…, ${btcTxt(b.amount)}; de lo seguido, ${btcTxt(b.seguido)} por reparto proporcional; ${b.estado})`).join("; ")}. Lo que pasó con ese dinero no está en este informe.`,
refs: pendingBranches.map(b => b.txid) });
}
if (sinDeterminar.length > 0) {
conclusions.push({ level:"HECHO", text:`${sinDeterminar.length} dirección(es) del rastro quedan sin determinar: salidas no seguidas o donde se dejó de seguir. No se atribuyen al actor.`, refs: sinDeterminar.map(x => x.address) });
}
if (unspentFunds.length > 0) {
conclusions.push({ level:"HECHO", text:`${unspentFunds.length} salida(s) con fondos localizados sin gastar, sumando ${btcTxt(unspentFunds.reduce((s,u)=>s+u.amount,0))}.`, refs: unspentFunds.map(u=>u.txid) });
}
@@ -5776,7 +5835,7 @@
};
const destinatarios = [...destinatariosMap.values()].filter(d => !attributed.some(x => x.address === d.address));
return { summary, declaracion, chronology, attributed, destinatarios, unspentFunds, truncatedBranches, failedBranches, queryErrors, conclusions, recommendations, methodology, verificationAppendix };
return { summary, declaracion, chronology, attributed, destinatarios, sinDeterminar, pendingBranches, paradaRastro, unspentFunds, truncatedBranches, failedBranches, queryErrors, conclusions, recommendations, methodology, verificationAppendix };
}
// Eslabón recursivo: muestra una tx de origen y permite seguir SUS inputs.
@@ -6256,15 +6315,48 @@
return r;
}
// Cronología de movimientos explorados, en orden.
// Importe seguido que entra en cada tx abierta: reparto proporcional de
// lo robado. Cuenta TODAS las entradas que vienen del rastro (la salida
// robada del origen o salidas de txs abiertas), también las que no se
// siguieron una a una pero vuelven a juntarse. Una cuenta, no una
// atribución.
function seguidoPorTx(per) {
const ori = per.origen, memo = new Map(), enCurso = new Set();
const valorRobado = per.txs.get(ori.txid)?.vout?.[ori.vout]?.value || 0;
const parte = (txid, vout) => {
if (txid === ori.txid) return vout === ori.vout ? valorRobado : 0;
if (!per.abiertas.has(txid) || !per.txs.has(txid)) return 0;
return repartoSalida(entra(txid), per.txs.get(txid), vout).sats;
};
const entra = txid => {
if (txid === ori.txid) return valorRobado;
if (memo.has(txid)) return memo.get(txid);
if (enCurso.has(txid)) return 0;
enCurso.add(txid);
const s = (per.txs.get(txid)?.vin || []).reduce((t, v) => t + parte(v.txid, v.vout), 0);
enCurso.delete(txid); memo.set(txid, s);
return s;
};
const r = new Map();
for (const t of per.abiertas) if (per.txs.has(t)) r.set(t, entra(t));
r.parte = parte;
return r;
}
// Cronología de movimientos explorados, en orden. `sats` es el importe
// de la salida que se gasta; `seguido`, la parte de lo robado que va por
// ella (reparto proporcional). `de` son TODAS las entradas de la tx
// (la seguida primero, en `via`).
function cronologiaPeritaje(per) {
const filas = [];
const seg = seguidoPorTx(per);
const dirDe = x => x ? (x.scriptpubkey_address || etiquetaSinDir(x)) : null;
const ori = per.txs.get(per.origen.txid);
if (ori) {
const o = ori.vout[per.origen.vout];
filas.push({ fecha: ori.status?.block_time || null, txid: ori.txid, sats: o?.value || 0,
de: [...new Set((ori.vin || []).map(v => v.prevout ? (v.prevout.scriptpubkey_address || etiquetaSinDir(v.prevout)) : null).filter(Boolean))],
a: o ? [o.scriptpubkey_address || etiquetaSinDir(o)] : [], que: "robo (salida de origen)" });
filas.push({ fecha: ori.status?.block_time || null, txid: ori.txid, sats: o?.value || 0, seguido: o?.value || 0,
de: [...new Set((ori.vin || []).map(v => dirDe(v.prevout)).filter(Boolean))], via: null,
a: o ? [dirDe(o)] : [], que: "robo (salida de origen)" });
}
for (const [k, g] of per.gastos) {
if (g.estado !== "gastada" || !per.abiertas.has(g.spendTxid)) continue;
@@ -6272,23 +6364,24 @@
const o = per.txs.get(txid)?.vout?.[Number(vout)];
const tg = per.txs.get(g.spendTxid);
if (!o || !tg) continue;
filas.push({ fecha: tg.status?.block_time || null, txid: tg.txid, sats: o.value,
de: [o.scriptpubkey_address || etiquetaSinDir(o)],
a: [...new Set((tg.vout || []).map(x => x.scriptpubkey_address || etiquetaSinDir(x)))], que: "movimiento" });
const via = dirDe(o);
filas.push({ fecha: tg.status?.block_time || null, txid: tg.txid, sats: o.value, seguido: seg.parte(txid, Number(vout)),
de: [...new Set([via, ...(tg.vin || []).map(v => dirDe(v.prevout)).filter(Boolean)])], via,
a: [...new Set((tg.vout || []).map(x => dirDe(x)))], que: "movimiento" });
}
return filas.sort((a, b) => (a.fecha || Infinity) - (b.fecha || Infinity));
}
const fechaISO = ts => ts ? new Date(ts * 1000).toISOString().replace("T", " ").slice(0, 16) + " UTC" : "sin confirmar";
function cronologiaCSV(filas) {
const q = s => `"${String(s).replace(/"/g, '""')}"`;
return ["fecha,importe_sats,importe_btc,de,a,txid,tipo",
...filas.map(f => [q(fechaISO(f.fecha)), f.sats, (f.sats / 1e8).toFixed(8), q(f.de.join(" ")), q(f.a.join(" ")), f.txid, q(f.que)].join(","))].join("\n");
return ["fecha,importe_sats,importe_btc,de,a,txid,tipo,seguido_sats,seguido_btc,via",
...filas.map(f => [q(fechaISO(f.fecha)), f.sats, (f.sats / 1e8).toFixed(8), q(f.de.join(" ")), q(f.a.join(" ")), f.txid, q(f.que), f.seguido ?? "", f.seguido != null ? (f.seguido / 1e8).toFixed(8) : "", q(f.via || "")].join(","))].join("\n");
}
function cronologiaMD(filas, ejemplo) {
return [`# Cronología de movimientos — Txoko${ejemplo ? " (EJEMPLO)" : ""}`, "",
"| Fecha | Importe | De | A | Txid |", "| --- | --- | --- | --- | --- |",
...filas.map(f => `| ${fechaISO(f.fecha)} | ${btcTxt(f.sats)} | ${f.de.join(", ") || "—"} | ${f.a.length > 4 ? f.a.slice(0, 4).join(", ") + ` y ${f.a.length - 4} más` : f.a.join(", ") || "—"} | \`${f.txid}\` |`),
"", "_Solo lo explorado en este peritaje. Los importes son los de cada salida gastada._"].join("\n");
"| Fecha | Importe de la salida | Importe seguido (proporcional) | De | A | Txid |", "| --- | --- | --- | --- | --- | --- |",
...filas.map(f => `| ${fechaISO(f.fecha)} | ${btcTxt(f.sats)} | ${f.seguido != null ? btcTxt(f.seguido) : "—"} | ${f.de.join(", ") || "—"} | ${f.a.length > 4 ? f.a.slice(0, 4).join(", ") + ` y ${f.a.length - 4} más` : f.a.join(", ") || "—"} | \`${f.txid}\` |`),
"", "_Solo lo explorado en este peritaje. «Importe de la salida» es el de la salida gastada; «importe seguido» es la parte de lo robado que va por ella según un reparto proporcional por importes (una cuenta, no una atribución). «De» lista todas las entradas de la transacción, la seguida primero._"].join("\n");
}
// Vigilancia de salidas sin gastar: compara la comprobación nueva con la
@@ -6341,6 +6434,7 @@
}
}
const padreDe = txid => edges.find(e => e.toTxid === txid)?.fromTxid;
const seg = seguidoPorTx(per);
const huella = new Map([[ori.txid, detectWallets(ori)]]);
const orden = [...per.abiertas].filter(t => t !== ori.txid && per.txs.has(t) && hops.has(t)).sort((a, b) => hops.get(a) - hops.get(b));
for (const t of orden) {
@@ -6354,13 +6448,21 @@
const custodyAddrs = outAddrs.filter(a => entidadDe(a)?.cat === "exchange");
const custodyStop = custodyAddrs.length ? { addr:custodyAddrs[0], name:entidadDe(custodyAddrs[0]).name, known:true, byVolume:false } : null;
const dil = detectarDilucion(tx, entrante.get(t) || 0, per.robado);
// Entradas: las que vienen del rastro (seguidas o que vuelven a
// juntarse) y las de otros. HECHO, con o sin importe robado.
const entradas = (tx.vin || []).map(v => ({ txid:v.txid, vout:v.vout, value:v.prevout?.value || 0,
address: v.prevout ? (v.prevout.scriptpubkey_address || etiquetaSinDir(v.prevout)) : "—",
delRastro: v.txid === ori.txid ? v.vout === per.origen.vout : per.abiertas.has(v.txid),
seguida: edges.some(e => e.toTxid === t && e.fromTxid === v.txid && e.fromVout === v.vout) }));
const mezcla = { tin: entradas.reduce((a, x) => a + x.value, 0), seguido: seg.get(t) || 0,
otras: entradas.filter(x => !x.delRastro), reunidas: entradas.filter(x => x.delRastro && !x.seguida) };
const parada = paradaSalto(tx, hops.get(t), per.maxSaltos);
const p = padreDe(t);
nodes.set(t, {
txid:t, hop:hops.get(t), blockTime:tx.status?.block_time ?? null,
blockHeight: tx.status?.confirmed ? (tx.status.block_height ?? null) : null, confirmed:!!tx.status?.confirmed,
vinCount:(tx.vin || []).length, voutCount:(tx.vout || []).length, addresses:{ in:inAddrs, out:outAddrs },
amountTraced: entrante.get(t) || 0, analysis, fingerprint,
amountTraced: entrante.get(t) || 0, amountFollowed: seg.get(t) || 0, mezcla, analysis, fingerprint,
fingerprintComparison: p && huella.has(p) ? compareFingerprints(huella.get(p), fingerprint) : null,
entityMarks: marcasDeTx(tx, analysis).marcas, addressProfiles:{},
changeGuess:{ structural, behavioral:null, combined:null },
@@ -6370,23 +6472,62 @@
stopReason: parada?.motivo === "coinjoin" ? "mixer" : parada?.motivo === "abanico" ? "fanOut" : custodyStop ? "exchange" : null,
});
}
const actor = new Set([oo.scriptpubkey_address].filter(Boolean)), mixers = new Set();
// Semilla para CIOH: solo ENTRADAS de las txs abiertas (y la salida
// robada). Las salidas no se agrupan nunca por estar en la misma tx.
// En un salto con dilución, las otras entradas son dinero de otros: al
// actor solo se le atribuye la dirección por la que llegó el rastro.
const actor = new Set([oo.scriptpubkey_address].filter(Boolean)), mixers = new Set();
const llegada = t => edges.filter(e => e.toTxid === t).map(e => per.txs.get(e.fromTxid)?.vout?.[e.fromVout]?.scriptpubkey_address).filter(Boolean);
for (const n of nodes.values()) {
if (n.stopReason === "mixer") { mixers.add(n.txid); continue; }
(n.diluted ? llegada(n.txid) : n.addresses.in).forEach(a => actor.add(a));
n.addresses.out.forEach(a => { if (!n.custodyAddrs.includes(a)) actor.add(a); });
}
// Camino seguido: direcciones que recibieron lo seguido y lo volvieron
// a mover en un salto abierto.
const rutaSeguida = new Map();
for (const e of edges) {
if (mixers.has(e.toTxid)) continue;
const a = per.txs.get(e.fromTxid)?.vout?.[e.fromVout]?.scriptpubkey_address;
if (a && !rutaSeguida.has(a)) rutaSeguida.set(a, { txid:e.toTxid });
}
// Dónde se detuvo cada rama y por qué; ramas que quedan sin seguir.
const desde = new Set(edges.map(e => e.fromTxid));
const salidasDe = t => t === ori.txid ? [per.origen.vout] : (per.txs.get(t)?.vout || []).map((_, i) => i);
const cuenta = (t, i) => { const o = per.txs.get(t)?.vout?.[i]; return o && !esSalidaDeDatos(o) && o.value >= PER_POLVO && entidadDe(o.scriptpubkey_address)?.cat !== "exchange"; };
const paradas = [ori.txid, ...orden].filter(t => !desde.has(t)).map(t => {
const n = nodes.get(t), tx = per.txs.get(t);
let motivo = t === ori.txid ? null : (paradaSalto(tx, hops.get(t), per.maxSaltos)?.motivo || (n?.custodyStop ? "exchange" : null));
if (!motivo) {
const ss = salidasDe(t).filter(i => cuenta(t, i));
motivo = ss.length === 0 ? "sin_salidas" : ss.every(i => per.gastos.get(claveSalida(t, i))?.estado === "sin_gastar") ? "sin_gastar" : "usuario";
}
return { txid:t, hop:hops.get(t) ?? 0, motivo };
});
const gastadaEnAbierta = (t, i) => [...per.abiertas].some(x => (per.txs.get(x)?.vin || []).some(v => v.txid === t && v.vout === i));
const pendientes = [];
for (const t of [ori.txid, ...orden]) {
const n = nodes.get(t);
if (n && (n.stopReason === "mixer" || n.stopReason === "fanOut")) continue;
for (const i of salidasDe(t)) {
if (!cuenta(t, i)) continue;
const g = per.gastos.get(claveSalida(t, i));
if (g && g.estado !== "gastada") continue; // terminal o fallo: va en su sección
if (g && per.abiertas.has(g.spendTxid)) continue;
if (gastadaEnAbierta(t, i)) continue; // vuelve a juntarse en un salto abierto
const o = per.txs.get(t).vout[i];
pendientes.push({ level:"HECHO", txid:t, vout:i, hop:hops.get(t) ?? 0, address:o.scriptpubkey_address || etiquetaSinDir(o), amount:o.value, seguido:seg.parte(t, i),
estado: g ? `gastada en la tx ${g.spendTxid.slice(0,16)}…, sin abrir` : "sin comprobar", spendTxid:g?.spendTxid || null, refs:[t] });
}
}
const diluidas = new Set([...nodes.values()].filter(n => n.diluted).map(n => n.txid));
const { clusters, linkReasons } = unionFindCluster([...per.txs.values()].filter(t => per.abiertas.has(t.txid) && !mixers.has(t.txid) && !diluidas.has(t.txid)), actor);
const oa = analyzeTx(ori);
return {
origin: { txid:ori.txid, vout:per.origen.vout, address:oo.scriptpubkey_address, amount:oo.value,
origin: { txid:ori.txid, vout:per.origen.vout, address:oo.scriptpubkey_address, addressLabel: oo.scriptpubkey_address || etiquetaSinDir(oo), amount:oo.value,
blockTime:ori.status?.block_time ?? null, blockHeight: ori.status?.confirmed ? (ori.status.block_height ?? null) : null,
fingerprint: huella.get(ori.txid), analysis: oa, entityMarks: marcasDeTx(ori, oa).marcas },
amountStolen: per.robado || null, nodes, edges, unspentTerminals, clusters, linkReasons, queryErrors,
rutaSeguida, paradas, pendientes,
peelingChains: detectPeelingChains(nodes, edges), modo:"a_demanda",
};
}
@@ -7194,7 +7335,10 @@
// Lo que se sigue en cada salto del camino, por reparto de importes.
// En el salto 1 se sigue la salida robada entera; después, la parte
// proporcional de lo que entró en cada salto.
const seguidos = []; camino.forEach((h,k)=>{ if(k<=1){ seguidos.push(per.txs.get(camino[0].txid).vout[per.origen.vout]?.value||0); } else { seguidos.push(repartoSalida(seguidos[k-1], per.txs.get(camino[k-1].txid), h.via).sats); } });
// Lo mismo que el informe: reparto proporcional que cuenta también las
// salidas del rastro que vuelven a juntarse.
const segTx = seguidoPorTx(per);
const seguidos = camino.map((h,k)=> k===0 ? (per.txs.get(camino[0].txid).vout[per.origen.vout]?.value||0) : (segTx.get(h.txid) ?? 0));
const marcada = !!mesa[hop.txid];
const marcar = () => setMesa(m=>{ const n={...m}; if(n[hop.txid]) delete n[hop.txid]; else n[hop.txid]={nota:"",fecha:Date.now(),origen:per.origen.txid}; return n; });
const vigiladas = new Set(Object.keys(vigilancia));
@@ -7957,6 +8101,7 @@
const exportData = {
summary: report.summary, declaracion: report.declaracion,
chronology: report.chronology, attributed: report.attributed,
sinDeterminar: report.sinDeterminar, pendingBranches: report.pendingBranches, paradaRastro: report.paradaRastro,
unspentFunds: report.unspentFunds, conclusions: report.conclusions,
failedBranches: report.failedBranches, queryErrors: report.queryErrors,
destinatarios: report.destinatarios, contexto: report.recommendations, methodology: report.methodology,
@@ -7981,7 +8126,7 @@
`- Generado: ${new Date(summary.generatedAt*1000).toLocaleString("es-ES")}`, ``,
decl ? `## Declaración del afectado (DECLARACION)\n\n${decl.text}\n` : null,
`## Cronología`, ``,
...chronology.map(c => `- [HECHO] ${c.txid.slice(0,16)}… · salto ${c.hop} · ${btcTxt(c.amount)} · ${c.blockTime?new Date(c.blockTime*1000).toLocaleDateString("es-ES"):"sin confirmar"} — banda [INFERENCIA${c.band.certainty?"/"+c.band.certainty:""}] ${c.band.value}, huella [INFERENCIA${c.fingerprint.certainty?"/"+c.fingerprint.certainty:""}] ${c.fingerprint.value}`),
...chronology.map(c => `- [HECHO] ${c.txid.slice(0,16)}… · salto ${c.hop} · importe de la salida ${btcTxt(c.amount)} · importe seguido ${c.followed != null ? btcTxt(c.followed) : "—"} (proporcional) · ${c.blockTime?new Date(c.blockTime*1000).toLocaleDateString("es-ES"):"sin confirmar"} — banda [INFERENCIA${c.band.certainty?"/"+c.band.certainty:""}] ${c.band.value}, huella [INFERENCIA${c.fingerprint.certainty?"/"+c.fingerprint.certainty:""}] ${c.fingerprint.value}`),
``,
`## Direcciones atribuidas al actor`, ``,
...(attributed.length===0 ? ["No se atribuyen direcciones adicionales con fundamento suficiente."] :
@@ -7991,6 +8136,14 @@
...((report.destinatarios||[]).length===0 ? ["Ninguno señalado."] :
report.destinatarios.map(d => `- [INFERENCIA/${d.certainty}] ${d.address} — ${d.basis} [tx ${d.txid}]`)),
``,
`## Sin determinar`, ``,
...((report.sinDeterminar||[]).length===0 ? ["Ninguna."] :
report.sinDeterminar.map(d => `- [HECHO] ${d.address} — ${d.basis} [tx ${d.txid}]`)),
``,
`## Ramas sin seguir`, ``,
...((report.pendingBranches||[]).length===0 ? ["Ninguna."] :
report.pendingBranches.map(b => `- [HECHO] ${b.address} — salida ${b.vout+1} (vout ${b.vout}) de la tx ${b.txid}: ${btcTxt(b.amount)}; de lo seguido, ${btcTxt(b.seguido)} (proporcional); ${b.estado}`)),
``,
`## Fondos localizados sin gastar`, ``,
...(unspentFunds.length===0 ? ["Ninguno detectado en las ramas exploradas."] :
unspentFunds.map(u => `- [HECHO] ${u.address} — ${btcTxt(u.amount)} (tx ${u.txid.slice(0,16)}…, salida ${u.vout+1} · vout ${u.vout})`)),
@@ -8005,8 +8158,8 @@
...conclusions.map((c,i) => `${i+1}. [${c.level}${c.certainty?"/"+c.certainty:""}] ${c.text}`),
``,
`## Movimientos explorados (cronología detallada)`, ``,
`| Fecha | Importe | De | A | Txid |`, `| --- | --- | --- | --- | --- |`,
...(report.movimientos||[]).map(f => `| ${fechaISO(f.fecha)} | ${btcTxt(f.sats)} | ${f.de.join(", ")||"—"} | ${f.a.length>4?f.a.slice(0,4).join(", ")+` y ${f.a.length-4} más`:f.a.join(", ")||"—"} | ${f.txid} |`),
`| Fecha | Importe de la salida | Importe seguido (proporcional) | De | A | Txid |`, `| --- | --- | --- | --- | --- | --- |`,
...(report.movimientos||[]).map(f => `| ${fechaISO(f.fecha)} | ${btcTxt(f.sats)} | ${f.seguido!=null?btcTxt(f.seguido):"—"} | ${f.de.join(", ")||"—"} | ${f.a.length>4?f.a.slice(0,4).join(", ")+` y ${f.a.length-4} más`:f.a.join(", ")||"—"} | ${f.txid} |`),
``,
`## Mesa de trabajo`, ``,
...((report.mesa||[]).length===0 ? ["Sin transacciones marcadas."] : report.mesa.map(m => `- ${m.txid}${m.nota?` — ${m.nota}`:""}`)),
@@ -8146,7 +8299,7 @@
<span style={{fontSize:"0.58rem",color:bColor,fontFamily:C.mono,fontWeight:600}}>{c.band.value}</span>
</div>
<div style={{fontSize:"0.56rem",color:C.t2,fontFamily:C.mono,marginTop:3}}>
{btcTxt(c.amount)} · {c.blockTime?fmt.date(c.blockTime):"sin confirmar"} · huella: {c.fingerprint.value}{c.fingerprint.certainty?` (${c.fingerprint.certainty})`:""}
salida {btcTxt(c.amount)}{c.followed!=null?` · seguido ${btcTxt(c.followed)} (proporcional)`:""} · {c.blockTime?fmt.date(c.blockTime):"sin confirmar"} · huella: {c.fingerprint.value}{c.fingerprint.certainty?` (${c.fingerprint.certainty})`:""}
</div>
{c.entityMarks.length>0&&(
<div style={{display:"flex",gap:6,flexWrap:"wrap",marginTop:4}}>
@@ -8204,6 +8357,33 @@
</div>
)}
{/* Sin determinar y ramas sin seguir */}
{((report.sinDeterminar||[]).length>0||(report.pendingBranches||[]).length>0)&&(
<div style={{marginBottom:14}}>
{(report.pendingBranches||[]).length>0&&(<>
<div style={{fontSize:"0.6rem",color:C.t2,fontFamily:C.mono,fontWeight:700,marginBottom:4,letterSpacing:"0.15em"}}>RAMAS SIN SEGUIR — {report.pendingBranches.length}</div>
<div style={{display:"flex",flexDirection:"column",gap:4,marginBottom:10}}>
{report.pendingBranches.map((b,i)=>(
<div key={i} style={{padding:"7px 10px",background:C.bgCard,border:`1px solid ${C.border}`,borderRadius:6,fontSize:"0.58rem",color:C.t2,fontFamily:C.mono,lineHeight:1.5,wordBreak:"break-all"}}>
<span style={{color:C.t1}}>{b.address}</span> · salida {b.vout+1} de {b.txid.slice(0,16)}… · {btcTxt(b.amount)} · de lo seguido {btcTxt(b.seguido)} (proporcional) · {b.estado}
</div>
))}
</div>
</>)}
{(report.sinDeterminar||[]).length>0&&(<>
<div style={{fontSize:"0.6rem",color:C.t2,fontFamily:C.mono,fontWeight:700,marginBottom:4,letterSpacing:"0.15em"}}>SIN DETERMINAR — {report.sinDeterminar.length}</div>
<div style={{fontSize:"0.62rem",color:C.t2,marginBottom:6,lineHeight:1.5}}>Salidas no seguidas o donde se dejó de seguir. No se atribuyen al actor.</div>
<div style={{display:"flex",flexDirection:"column",gap:4}}>
{report.sinDeterminar.map((d,i)=>(
<div key={i} style={{padding:"7px 10px",background:C.bgCard,border:`1px solid ${C.border}`,borderRadius:6,fontSize:"0.58rem",color:C.t2,fontFamily:C.mono,lineHeight:1.5,wordBreak:"break-all"}}>
<span style={{color:C.t1}}>{d.address}</span> — {d.basis} · tx {d.txid.slice(0,16)}…
</div>
))}
</div>
</>)}
</div>
)}
{/* Fondos sin gastar */}
<div style={{marginBottom:14}}>
<div style={{fontSize:"0.6rem",color:C.green,fontFamily:C.mono,fontWeight:700,marginBottom:8,letterSpacing:"0.15em"}}>FONDOS LOCALIZADOS SIN GASTAR — {report.unspentFunds.length}</div>
@@ -9618,7 +9798,7 @@
<footer style={{borderTop:`1px solid ${C.border}`,padding:"10px 18px",display:"flex",alignItems:"center",justifyContent:"center",gap:6}}>
<span style={{fontSize:"0.95rem",color:C.amber}}>₿</span>
<span style={{fontFamily:C.mono,fontSize:"0.62rem",color:C.amber,letterSpacing:"0.12em"}}>txoko</span>
<span style={{fontFamily:C.mono,fontSize:"0.62rem",color:C.t2,letterSpacing:"0.05em"}}>· tu nodo, tus reglas · v1.24.6</span>
<span style={{fontFamily:C.mono,fontSize:"0.62rem",color:C.t2,letterSpacing:"0.05em"}}>· tu nodo, tus reglas · v1.24.7</span>
</footer>
{showConfig&&<ConfigModal config={config} themeId={themeId} onTheme={switchTheme} onSave={cfg=>{setConfig(cfg);setShowConfig(false);}} onClose={()=>setShowConfig(false)}/>}
</div>