v1.34.0: leer QR con la cámara
Botón ⌗ QR junto a cada campo (direcciones, URI de pago, txid, xpub, PSBT, tx en crudo). Enseña lo leído y pide confirmar. Rechaza semillas y claves privadas sin mostrarlas. Foto de respaldo sin cámara en directo. Librería qr 0.7.2 (Paul Miller) en vendor/qr/, con su huella en SETUP. Pruebas en tests/test22.js. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L5npnUYgSPkAaHkdaeUqBr
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
// ── QR: lógica pura (probada en tests/test22.js) ───────────────────────
|
||||
// Qué es lo que se ha leído en un QR y si encaja en el campo donde se
|
||||
// quiere usar. Nada de esto toca la red ni guarda nada: solo mira texto.
|
||||
//
|
||||
// Lo primero es SIEMPRE descartar secretos. Es fácil escanear sin querer
|
||||
// la tarjeta SeedQR del SeedSigner o una clave privada: Txoko no los
|
||||
// necesita nunca, así que ni se muestran ni se guardan.
|
||||
const QR_SEMILLA_PALABRAS = new Set([12, 15, 18, 21, 24]);
|
||||
function pareceSecretoQR(texto) {
|
||||
const s = String(texto ?? "");
|
||||
const t = s.trim();
|
||||
// SeedQR (estándar): 4 dígitos por palabra → 48 (12 palabras) a 96 (24).
|
||||
if (/^\d+$/.test(t) && t.length >= 48 && t.length <= 96 && t.length % 4 === 0) return true;
|
||||
// Semilla en palabras (BIP-39 completa o con las 4 primeras letras).
|
||||
const palabras = t.toLowerCase().split(/\s+/);
|
||||
if (QR_SEMILLA_PALABRAS.has(palabras.length) && palabras.every(p => /^[a-z]{3,8}$/.test(p))) return true;
|
||||
// CompactSeedQR: 16 o 32 bytes en binario (llegan como caracteres de control).
|
||||
if ((s.length === 16 || s.length === 32) && /[\u0000-\u0008\u000e-\u001f\u007f-ÿ]/.test(s)) return true;
|
||||
// Clave privada extendida (xprv, yprv, zprv, tprv…) o clave privada WIF.
|
||||
if (/[xyztuvXYZUV]prv[1-9A-HJ-NP-Za-km-z]{100,}/.test(t)) return true;
|
||||
if (/^[5KLc9][1-9A-HJ-NP-Za-km-z]{50,51}$/.test(t)) return true;
|
||||
return false;
|
||||
}
|
||||
// Las direcciones bech32 suelen ir en mayúsculas dentro del QR (ocupan
|
||||
// menos); en minúsculas son la misma dirección.
|
||||
const normalizarDireccionQR = d => /^(bc1|tb1|bcrt1)/i.test(d) ? d.toLowerCase() : d;
|
||||
const esDireccionQR = d => /^(bc1|tb1|bcrt1)[02-9ac-hj-np-z]{8,87}$/.test(d) || /^[13mn2][1-9A-HJ-NP-Za-km-z]{25,34}$/.test(d);
|
||||
const QR_XPUB = "[xyzXYZtuvUV]pub[1-9A-HJ-NP-Za-km-z]{100,112}";
|
||||
function clasificarQR(texto) {
|
||||
const crudo = String(texto ?? "");
|
||||
if (pareceSecretoQR(crudo)) return { tipo: "secreto" };
|
||||
const t = crudo.trim();
|
||||
if (!t) return { tipo: "vacio" };
|
||||
// URI de pago (BIP-21): bitcoin:<dirección>?amount=…&label=…
|
||||
const uri = t.match(/^bitcoin:([^?]+)(?:\?(.*))?$/i);
|
||||
if (uri) {
|
||||
const dir = normalizarDireccionQR(uri[1]);
|
||||
if (!esDireccionQR(dir)) return { tipo: "desconocido" };
|
||||
let importe = null, etiqueta = null;
|
||||
try { const p = new URLSearchParams(uri[2] || ""); importe = p.get("amount"); etiqueta = p.get("label"); } catch {}
|
||||
return { tipo: "direccion", valor: dir, importe, etiqueta };
|
||||
}
|
||||
if (/^lightning:|^ln(bc|tb|bcrt)\d*[a-z]?1/i.test(t)) return { tipo: "lightning" };
|
||||
// QR animados (varias partes): UR (Sparrow, SeedSigner), BBQr (Coldcard,
|
||||
// Sparrow…) y el antiguo de Specter. Se reconocen; leerlos es la fase 2.
|
||||
if (/^ur:/i.test(t)) { const m = t.match(/^ur:([a-z0-9-]+)\//i); return { tipo: "ur", urTipo: m ? m[1].toLowerCase() : null }; }
|
||||
if (/^B\$[2HZ][A-Z][0-9A-Z]{4}/.test(t)) return { tipo: "bbqr", archivo: t[3] };
|
||||
if (/^p\d+of\d+\s/i.test(t)) return { tipo: "specter" };
|
||||
if (/^cHNidP8/.test(t) || /^70736274ff/i.test(t)) return { tipo: "psbt", valor: t };
|
||||
// xpub suelta o como la muestra SeedSigner: [huella/ruta]zpub…
|
||||
const xp = t.match(new RegExp(`^(?:\\[([0-9a-fA-F]{8})((?:/\\d+[h']?)*)\\])?(${QR_XPUB})$`));
|
||||
if (xp) return { tipo: "xpub", valor: xp[3], huella: xp[1] ? xp[1].toLowerCase() : null, ruta: xp[2] ? "m" + xp[2] : null };
|
||||
// Descriptor con una xpub dentro: wpkh([…]xpub…/0/*)
|
||||
const desc = t.match(new RegExp(`^(?:wpkh|sh|pkh|tr|wsh)\\(.*?(${QR_XPUB})`));
|
||||
if (desc) return { tipo: "xpub", valor: desc[1], huella: null, ruta: null, descriptor: true };
|
||||
if (/^[0-9a-fA-F]{64}$/.test(t)) return { tipo: "txid", valor: t.toLowerCase() };
|
||||
if (/^0[1-3]000000[0-9a-fA-F]{100,}$/.test(t) && t.length % 2 === 0) return { tipo: "tx", valor: t.toLowerCase() };
|
||||
const dir = normalizarDireccionQR(t);
|
||||
if (esDireccionQR(dir)) return { tipo: "direccion", valor: dir };
|
||||
return { tipo: "desconocido" };
|
||||
}
|
||||
// Qué acepta cada campo de la app.
|
||||
const QR_CAMPOS = {
|
||||
txid: ["txid"],
|
||||
direccion: ["direccion"],
|
||||
busqueda: ["txid", "direccion"],
|
||||
xpub: ["xpub"],
|
||||
psbt: ["psbt"],
|
||||
tx: ["tx"],
|
||||
};
|
||||
const QR_NOMBRE = {
|
||||
direccion: "una dirección", txid: "un identificador de transacción (txid)", xpub: "una clave pública extendida (xpub)",
|
||||
psbt: "una PSBT", tx: "una transacción en crudo", lightning: "una factura de Lightning",
|
||||
ur: "un QR animado (UR)", bbqr: "un QR animado (BBQr)", specter: "un QR animado (Specter)",
|
||||
vacio: "un QR vacío", desconocido: "algo que Txoko no reconoce",
|
||||
};
|
||||
function encajaQR(r, campo) {
|
||||
const acepta = QR_CAMPOS[campo] || [];
|
||||
if (!r || r.tipo === "secreto") return { ok: false, mensaje: "" };
|
||||
if (acepta.includes(r.tipo)) return { ok: true, mensaje: "" };
|
||||
const espera = acepta.map(a => QR_NOMBRE[a]).join(" o ");
|
||||
if (["ur", "bbqr", "specter"].includes(r.tipo))
|
||||
return { ok: false, mensaje: `Es ${QR_NOMBRE[r.tipo]}, de los que pasan varias imágenes seguidas. Txoko todavía no lee QR animados. Mientras tanto, guarda la PSBT como archivo y ábrela con «…o abrir archivo .psbt».` };
|
||||
return { ok: false, mensaje: `Has leído ${QR_NOMBRE[r.tipo] || QR_NOMBRE.desconocido}, pero aquí va ${espera}.` };
|
||||
}
|
||||
// Bytes del QR → texto. Si son 16 o 32 bytes que no son texto, es una
|
||||
// CompactSeedQR: se devuelve algo que pareceSecretoQR reconoce, sin
|
||||
// convertir la semilla en texto legible.
|
||||
function textoDeBytesQR(bytes) {
|
||||
const imprimible = Array.from(bytes).every(b => b >= 0x20 && b <= 0x7e || b === 0x0a || b === 0x0d || b === 0x09);
|
||||
if ((bytes.length === 16 || bytes.length === 32) && !imprimible) return "\u0001".repeat(bytes.length);
|
||||
try { return new TextDecoder("utf-8", { fatal: true }).decode(bytes); }
|
||||
catch { return Array.from(bytes, b => String.fromCharCode(b)).join(""); }
|
||||
}
|
||||
// ── fin QR ──────────────────────────────────────────────────────────────
|
||||
@@ -0,0 +1,187 @@
|
||||
// ── Leer QR con la cámara (v1.34) ─────────────────────────────────────
|
||||
// La librería (qr de Paul Miller) vive en vendor/qr/ y solo se carga al
|
||||
// abrir el lector. Todo ocurre en el navegador: la imagen de la cámara no
|
||||
// sale del aparato y leer un QR no hace ninguna consulta de red.
|
||||
let promesaLectorQR = null;
|
||||
// import() dinámico escondido en una función para que Babel no lo toque.
|
||||
const importarModulo = new Function("u", "return import(u)");
|
||||
function cargarLectorQR() {
|
||||
if (!promesaLectorQR) {
|
||||
promesaLectorQR = importarModulo(new URL("vendor/qr/decode.js", location.href).href)
|
||||
.then(m => m.decodeQR || m.default)
|
||||
.catch(e => { promesaLectorQR = null; throw e; });
|
||||
}
|
||||
return promesaLectorQR;
|
||||
}
|
||||
function resumenQR(r) {
|
||||
if (!r) return "";
|
||||
if (r.tipo === "xpub") return `${r.valor.slice(0, 12)}…${r.valor.slice(-8)}${r.huella ? ` · huella ${r.huella}` : ""}${r.ruta ? ` · ${r.ruta}` : ""}`;
|
||||
if (r.tipo === "psbt") return `PSBT de ${r.valor.length.toLocaleString("es-ES")} caracteres`;
|
||||
if (r.tipo === "tx") return `transacción de ${(r.valor.length / 2).toLocaleString("es-ES")} bytes`;
|
||||
return r.valor;
|
||||
}
|
||||
|
||||
function BotonQR({ campo, onLeido, color }) {
|
||||
const [abierto, setAbierto] = useState(false);
|
||||
const col = color || C.purple;
|
||||
return (
|
||||
<>
|
||||
<button type="button" onClick={() => setAbierto(true)} title="Leer un QR con la cámara" aria-label="Leer un QR con la cámara"
|
||||
style={{ padding: "0 12px", minWidth: 42, background: C.bg, border: `1px solid ${col}40`, borderRadius: 6, color: col, fontSize: "1rem", cursor: "pointer", flexShrink: 0 }}>
|
||||
⌗<span style={{ fontFamily: C.mono, fontSize: "0.6rem", marginLeft: 4 }}>QR</span>
|
||||
</button>
|
||||
{abierto && <LectorQR campo={campo} onCerrar={() => setAbierto(false)} onUsar={v => { setAbierto(false); onLeido(v); }} />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function LectorQR({ campo, onCerrar, onUsar }) {
|
||||
const videoRef = useRef(null), streamRef = useRef(null), vivoRef = useRef(true), fotoRef = useRef(null);
|
||||
const [fase, setFase] = useState("cargando"); // cargando · camara · sin-camara · leido · otro · secreto · sin-lector
|
||||
const [aviso, setAviso] = useState("");
|
||||
const [leido, setLeido] = useState(null);
|
||||
|
||||
const pararCamara = () => {
|
||||
if (streamRef.current) { streamRef.current.getTracks().forEach(t => t.stop()); streamRef.current = null; }
|
||||
if (videoRef.current) videoRef.current.srcObject = null;
|
||||
};
|
||||
const procesar = texto => {
|
||||
pararCamara();
|
||||
setAviso("");
|
||||
const r = clasificarQR(texto);
|
||||
if (r.tipo === "secreto") { setLeido(null); setFase("secreto"); return; }
|
||||
const e = encajaQR(r, campo);
|
||||
setLeido(r);
|
||||
if (e.ok) { setFase("leido"); setAviso(""); }
|
||||
else { setFase("otro"); setAviso(e.mensaje); }
|
||||
};
|
||||
const leerImagen = (decode, fuente, w, h, opts) => {
|
||||
const lienzo = document.createElement("canvas");
|
||||
lienzo.width = w; lienzo.height = h;
|
||||
const ctx = lienzo.getContext("2d", { willReadFrequently: true });
|
||||
ctx.drawImage(fuente, 0, 0, w, h);
|
||||
const img = ctx.getImageData(0, 0, w, h);
|
||||
try { return decode({ width: w, height: h, data: img.data }, { textDecoder: textoDeBytesQR, ...opts }); }
|
||||
catch { return null; }
|
||||
};
|
||||
|
||||
const arrancar = async () => {
|
||||
setAviso(""); setLeido(null); setFase("cargando");
|
||||
let decode;
|
||||
try { decode = await cargarLectorQR(); }
|
||||
catch { if (vivoRef.current) setFase("sin-lector"); return; }
|
||||
if (!vivoRef.current) return;
|
||||
if (!window.isSecureContext || !navigator.mediaDevices?.getUserMedia) {
|
||||
setAviso("La cámara en directo solo funciona si abres Txoko por https. Puedes hacer una foto del QR.");
|
||||
setFase("sin-camara"); return;
|
||||
}
|
||||
try {
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: { ideal: "environment" } }, audio: false });
|
||||
if (!vivoRef.current) { stream.getTracks().forEach(t => t.stop()); return; }
|
||||
streamRef.current = stream;
|
||||
setFase("camara");
|
||||
const v = videoRef.current;
|
||||
v.srcObject = stream;
|
||||
v.setAttribute("playsinline", ""); v.muted = true;
|
||||
await v.play().catch(() => {});
|
||||
let ultimo = 0;
|
||||
const bucle = ahora => {
|
||||
if (!vivoRef.current || !streamRef.current) return;
|
||||
if (ahora - ultimo > 120 && v.videoWidth) {
|
||||
ultimo = ahora;
|
||||
const esc = Math.min(1, 720 / Math.max(v.videoWidth, v.videoHeight));
|
||||
const t = leerImagen(decode, v, Math.round(v.videoWidth * esc), Math.round(v.videoHeight * esc));
|
||||
if (t != null) { procesar(t); return; }
|
||||
}
|
||||
requestAnimationFrame(bucle);
|
||||
};
|
||||
requestAnimationFrame(bucle);
|
||||
} catch (e) {
|
||||
const n = e && e.name;
|
||||
setAviso(n === "NotAllowedError" ? "No hay permiso para usar la cámara (o el navegador no lo da con este certificado). Puedes hacer una foto del QR."
|
||||
: n === "NotFoundError" || n === "OverconstrainedError" ? "No encuentro ninguna cámara en este aparato. Puedes elegir una imagen con el QR."
|
||||
: "No se ha podido abrir la cámara. Puedes hacer una foto del QR.");
|
||||
setFase("sin-camara");
|
||||
}
|
||||
};
|
||||
|
||||
const leerFoto = async archivo => {
|
||||
if (!archivo) return;
|
||||
setAviso("Buscando el QR en la imagen…");
|
||||
try {
|
||||
const decode = await cargarLectorQR();
|
||||
const bmp = await createImageBitmap(archivo);
|
||||
const esc = Math.min(1, 1600 / Math.max(bmp.width, bmp.height));
|
||||
const t = leerImagen(decode, bmp, Math.round(bmp.width * esc), Math.round(bmp.height * esc), { effort: Infinity, timeLimit: 3000 });
|
||||
if (bmp.close) bmp.close();
|
||||
if (t != null) procesar(t);
|
||||
else setAviso("No encuentro ningún QR en esa imagen. Prueba con otra más cerca y con luz.");
|
||||
} catch {
|
||||
setAviso("No he podido leer esa imagen.");
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
vivoRef.current = true;
|
||||
arrancar();
|
||||
const tecla = e => { if (e.key === "Escape") onCerrar(); };
|
||||
window.addEventListener("keydown", tecla);
|
||||
return () => { vivoRef.current = false; pararCamara(); window.removeEventListener("keydown", tecla); };
|
||||
}, []);
|
||||
|
||||
const boton = (txt, onClick, col, fuerte) => (
|
||||
<button type="button" onClick={onClick} style={{ padding: "9px 14px", background: fuerte ? `${col}22` : "none", border: `1px solid ${col}${fuerte ? "" : "60"}`, borderRadius: 6, color: col, fontFamily: C.mono, fontSize: "0.72rem", cursor: "pointer", fontWeight: fuerte ? 700 : 400 }}>{txt}</button>
|
||||
);
|
||||
return (
|
||||
<div role="dialog" aria-modal="true" aria-label="Leer un QR"
|
||||
style={{ position: "fixed", inset: 0, zIndex: 1000, background: "rgba(0,0,0,0.78)", display: "flex", alignItems: "center", justifyContent: "center", padding: 16 }}
|
||||
onClick={e => { if (e.target === e.currentTarget) onCerrar(); }}>
|
||||
<div style={{ width: "100%", maxWidth: 440, background: C.bgCard, border: `1px solid ${C.borderBright}`, borderRadius: 10, padding: 16, display: "flex", flexDirection: "column", gap: 12 }}>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
||||
<div style={{ fontFamily: C.mono, fontSize: "0.7rem", color: C.t1, fontWeight: 700, letterSpacing: "0.08em" }}>LEER UN QR</div>
|
||||
<button type="button" onClick={onCerrar} aria-label="Cerrar el lector" style={{ background: "none", border: "none", color: C.t2, fontSize: "1.1rem", cursor: "pointer" }}>×</button>
|
||||
</div>
|
||||
|
||||
{(fase === "camara" || fase === "cargando") && (
|
||||
<div style={{ position: "relative", width: "100%", aspectRatio: "1 / 1", background: "#000", borderRadius: 8, overflow: "hidden" }}>
|
||||
<video ref={videoRef} playsInline muted style={{ width: "100%", height: "100%", objectFit: "cover", display: fase === "camara" ? "block" : "none" }} />
|
||||
<div style={{ position: "absolute", inset: "14%", border: `2px solid ${C.green}aa`, borderRadius: 10, pointerEvents: "none" }} />
|
||||
{fase === "cargando" && <div style={{ position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", color: C.t2, fontFamily: C.mono, fontSize: "0.7rem" }}>abriendo la cámara…</div>}
|
||||
</div>
|
||||
)}
|
||||
{fase === "camara" && <div style={{ fontSize: "0.66rem", color: C.t2, lineHeight: 1.5 }}>Apunta al QR. La imagen no sale de este aparato.</div>}
|
||||
|
||||
{fase === "sin-lector" && (
|
||||
<div style={{ fontSize: "0.7rem", color: C.amber, lineHeight: 1.6 }}>
|
||||
Falta el lector de QR en el nodo: la carpeta <span style={{ fontFamily: C.mono }}>vendor/qr/</span>. Se instala con el paso 2 de SETUP.md.
|
||||
</div>
|
||||
)}
|
||||
|
||||
{fase === "secreto" && (
|
||||
<div style={{ padding: "12px 14px", background: C.redMuted, border: `1px solid ${C.red}60`, borderRadius: 8, fontSize: "0.72rem", color: C.t1, lineHeight: 1.6 }}>
|
||||
<strong style={{ color: C.red }}>Esto parece una semilla o una clave privada.</strong> Txoko no la necesita nunca, así que no la muestra ni la guarda: ya la ha olvidado. Guarda esa tarjeta y asegúrate de que no la ha visto nadie.
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(fase === "leido" || fase === "otro") && leido && (
|
||||
<div style={{ padding: "10px 12px", background: C.bg, border: `1px solid ${fase === "leido" ? C.green : C.amber}60`, borderRadius: 8 }}>
|
||||
<div style={{ fontSize: "0.6rem", color: C.t2, fontFamily: C.mono, marginBottom: 4 }}>HE LEÍDO {(QR_NOMBRE[leido.tipo] || "").toUpperCase()}</div>
|
||||
{leido.valor && <div style={{ fontFamily: C.mono, fontSize: "0.72rem", color: C.t1, wordBreak: "break-all" }}>{resumenQR(leido)}</div>}
|
||||
{leido.importe && <div style={{ fontSize: "0.64rem", color: C.t2, marginTop: 4 }}>El QR pedía un pago de {leido.importe} BTC{leido.etiqueta ? ` («${leido.etiqueta}»)` : ""}. Txoko solo usa la dirección.</div>}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{aviso && <div style={{ fontSize: "0.68rem", color: fase === "otro" ? C.amber : C.t2, lineHeight: 1.6 }}>{aviso}</div>}
|
||||
|
||||
<div style={{ display: "flex", gap: 8, flexWrap: "wrap" }}>
|
||||
{fase === "leido" && boton("Usar esto", () => onUsar(leido.valor), C.green, true)}
|
||||
{(fase === "leido" || fase === "otro" || fase === "secreto") && boton("Leer otro", arrancar, C.purple)}
|
||||
{fase !== "sin-lector" && boton("Hacer una foto o elegir imagen", () => fotoRef.current && fotoRef.current.click(), C.blue)}
|
||||
{boton("Cerrar", onCerrar, C.t2)}
|
||||
<input ref={fotoRef} type="file" accept="image/*" capture="environment" style={{ display: "none" }}
|
||||
onChange={e => { pararCamara(); setFase("sin-camara"); leerFoto(e.target.files[0]); e.target.value = ""; }} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -66,6 +66,7 @@
|
||||
style={{flex:1,background:C.bgCard,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"11px 14px",color:C.t1,fontFamily:C.mono,fontSize:"0.78rem",outline:"none"}}
|
||||
onFocus={e=>e.target.style.borderColor=C.purple} onBlur={e=>e.target.style.borderColor=C.borderBright}
|
||||
/>
|
||||
<BotonQR campo="busqueda" onLeido={v=>setQuery(v)}/>
|
||||
<button onClick={()=>search()} style={{padding:"11px 20px",background:C.purpleMuted,border:`1px solid ${C.purple}40`,borderRadius:6,color:C.purple,fontFamily:C.mono,fontSize:"0.75rem",cursor:"pointer",fontWeight:700}}>
|
||||
{loading?"···":"BUSCAR"}
|
||||
</button>
|
||||
@@ -130,6 +131,7 @@
|
||||
style={{flex:1,background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"9px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.75rem",outline:"none"}}
|
||||
onFocus={e=>e.target.style.borderColor=C.green} onBlur={e=>e.target.style.borderColor=C.borderBright}
|
||||
/>
|
||||
<BotonQR campo="txid" color={C.green} onLeido={v=>setTxid(v)}/>
|
||||
<button onClick={verify} style={{padding:"9px 16px",background:C.greenMuted,border:`1px solid ${C.green}40`,borderRadius:6,color:C.green,fontFamily:C.mono,fontSize:"0.72rem",cursor:"pointer",fontWeight:700}}>
|
||||
{loading?"···":"VERIFICAR"}
|
||||
</button>
|
||||
@@ -356,6 +358,7 @@
|
||||
style={{flex:1,background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"9px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.75rem",outline:"none"}}
|
||||
onFocus={e=>e.target.style.borderColor=C.purple} onBlur={e=>e.target.style.borderColor=C.borderBright}
|
||||
/>
|
||||
<BotonQR campo="direccion" onLeido={v=>setAddr(v)}/>
|
||||
<button onClick={fetchUtxos} style={{padding:"9px 16px",background:C.purpleMuted,border:`1px solid ${C.purple}40`,borderRadius:6,color:C.purple,fontFamily:C.mono,fontSize:"0.72rem",cursor:"pointer",fontWeight:700}}>
|
||||
{loading?"···":"MAPEAR"}
|
||||
</button>
|
||||
|
||||
@@ -328,6 +328,7 @@
|
||||
placeholder="xpub... o zpub..."
|
||||
style={{flex:1,background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"8px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.7rem",outline:"none"}}
|
||||
/>
|
||||
<BotonQR campo="xpub" color={C.green} onLeido={v=>setXpubInput(v)}/>
|
||||
<select value={xpubCount} onChange={e=>setXpubCount(Number(e.target.value))}
|
||||
title="Direcciones a derivar por rama"
|
||||
style={{background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"8px 8px",color:C.t1,fontFamily:C.mono,fontSize:"0.7rem",outline:"none",cursor:"pointer"}}>
|
||||
@@ -626,6 +627,7 @@
|
||||
style={{flex:1,background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"11px 14px",color:C.t1,fontFamily:C.mono,fontSize:"0.78rem",outline:"none"}}
|
||||
onFocus={e=>e.target.style.borderColor=C.purple} onBlur={e=>e.target.style.borderColor=C.borderBright}
|
||||
/>
|
||||
<BotonQR campo="txid" onLeido={v=>setQuery(v)}/>
|
||||
<button onClick={()=>analyze()} style={{padding:"11px 20px",background:C.purpleMuted,border:`1px solid ${C.purple}40`,borderRadius:6,color:C.purple,fontFamily:C.mono,fontSize:"0.75rem",cursor:"pointer",fontWeight:700}}>
|
||||
{loading?"···":"ANALIZAR"}
|
||||
</button>
|
||||
|
||||
@@ -163,6 +163,7 @@
|
||||
<div style={{display:"flex",gap:8,flexWrap:"wrap",opacity:demo?0.45:1}}>
|
||||
<input value={txidInput} onChange={e=>setTxidInput(e.target.value)} placeholder={demo?"(no se usa en el ejemplo)":"txid del robo (64 caracteres hex)"} disabled={demo}
|
||||
style={{flex:"3 1 220px",minWidth:0,background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"10px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.72rem",outline:"none"}}/>
|
||||
{!demo&&<BotonQR campo="txid" color={C.red} onLeido={v=>setTxidInput(v)}/>}
|
||||
<input value={voutInput} onChange={e=>setVoutInput(e.target.value)} type="number" min="0" disabled={demo} placeholder="vout (0 = salida 1)" title="Número de la salida robada dentro de esa transacción (la primera es 0)"
|
||||
style={{flex:"1 1 70px",minWidth:0,background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"10px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.72rem",outline:"none"}}/>
|
||||
<select value={maxHops} onChange={e=>setMaxHops(Number(e.target.value))} disabled={demo} title="Tope de saltos: una red de seguridad para proteger el nodo"
|
||||
|
||||
@@ -136,6 +136,7 @@
|
||||
style={{flex:1,background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"9px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.75rem",outline:"none"}}
|
||||
onFocus={e=>e.target.style.borderColor=C.blue} onBlur={e=>e.target.style.borderColor=C.borderBright}
|
||||
/>
|
||||
<BotonQR campo="direccion" color={C.blue} onLeido={v=>setAddr(v)}/>
|
||||
<button onClick={validate} style={{padding:"9px 16px",background:C.blueMuted,border:`1px solid ${C.blue}40`,borderRadius:6,color:C.blue,fontFamily:C.mono,fontSize:"0.72rem",cursor:"pointer",fontWeight:700}}>COMPROBAR</button>
|
||||
</div>
|
||||
{result&&(
|
||||
@@ -204,6 +205,7 @@
|
||||
style={{flex:1,background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"9px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.75rem",outline:"none"}}
|
||||
onFocus={e=>e.target.style.borderColor=C.blue} onBlur={e=>e.target.style.borderColor=C.borderBright}
|
||||
/>
|
||||
<BotonQR campo="txid" color={C.blue} onLeido={v=>setTxid(v)}/>
|
||||
<button onClick={decode} style={{padding:"9px 16px",background:C.blueMuted,border:`1px solid ${C.blue}40`,borderRadius:6,color:C.blue,fontFamily:C.mono,fontSize:"0.72rem",cursor:"pointer",fontWeight:700}}>{loading?"···":"DETECTAR"}</button>
|
||||
</div>
|
||||
{err&&<div style={{padding:"8px 12px",background:C.redMuted,border:`1px solid ${C.red}30`,borderRadius:6,color:C.red,fontFamily:C.mono,fontSize:"0.72rem"}}>{err}</div>}
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
/>
|
||||
<div style={{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap",marginBottom:10}}>
|
||||
<button onClick={decode} style={{padding:"9px 16px",background:C.blueMuted,border:`1px solid ${C.blue}40`,borderRadius:6,color:C.blue,fontFamily:C.mono,fontSize:"0.72rem",cursor:"pointer",fontWeight:700}}>ANALIZAR</button>
|
||||
<BotonQR campo="psbt" color={C.blue} onLeido={v=>cambiarTexto(v)}/>
|
||||
<label style={{padding:"9px 16px",background:"none",border:`1px solid ${C.border}`,borderRadius:6,color:C.t2,fontFamily:C.mono,fontSize:"0.7rem",cursor:"pointer"}}>
|
||||
…o abrir archivo .psbt
|
||||
<input type="file" accept=".psbt,.txn,application/octet-stream" style={{display:"none"}} onChange={e=>{ setInput(""); cargarArchivo(e.target.files[0]); e.target.value=""; }}/>
|
||||
@@ -157,7 +158,10 @@
|
||||
style={{width:"100%",background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"10px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.72rem",outline:"none",resize:"vertical",boxSizing:"border-box",marginBottom:8}}
|
||||
onFocus={e=>e.target.style.borderColor=C.blue} onBlur={e=>e.target.style.borderColor=C.borderBright}
|
||||
/>
|
||||
<button onClick={decode} style={{padding:"9px 16px",background:C.blueMuted,border:`1px solid ${C.blue}40`,borderRadius:6,color:C.blue,fontFamily:C.mono,fontSize:"0.72rem",cursor:"pointer",fontWeight:700,marginBottom:10}}>COMPROBAR</button>
|
||||
<div style={{display:"flex",gap:8,alignItems:"stretch",marginBottom:10}}>
|
||||
<button onClick={decode} style={{padding:"9px 16px",background:C.blueMuted,border:`1px solid ${C.blue}40`,borderRadius:6,color:C.blue,fontFamily:C.mono,fontSize:"0.72rem",cursor:"pointer",fontWeight:700}}>COMPROBAR</button>
|
||||
<BotonQR campo="tx" color={C.blue} onLeido={v=>{ setInput(v); setResult(null); setErr(null); }}/>
|
||||
</div>
|
||||
{err&&<div style={{padding:"8px 12px",background:C.redMuted,border:`1px solid ${C.red}30`,borderRadius:6,color:C.red,fontFamily:C.mono,fontSize:"0.72rem"}}>{err}</div>}
|
||||
{result&&(
|
||||
<div style={{padding:"12px 14px",background:C.bg,borderRadius:6,border:`1px solid ${C.green}40`}}>
|
||||
|
||||
+1
-1
@@ -84,7 +84,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.33.0</span>
|
||||
<span style={{fontFamily:C.mono,fontSize:"0.62rem",color:C.t2,letterSpacing:"0.05em"}}>· tu nodo, tus reglas · v1.34.0</span>
|
||||
</footer>
|
||||
{showConfig&&<ConfigModal config={config} themeId={themeId} onTheme={switchTheme} onSave={cfg=>{setConfig(cfg);setShowConfig(false);}} onClose={()=>setShowConfig(false)}/>}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user