v1.37.0: modo signet para pruebas y talleres

- Selector de red en Ajustes (mainnet con tu nodo / signet), cada red con
  su propia dirección; en signet, por defecto, mempool.space/signet.
- Banda fija «SIGNET · sin valor», sin precios y sin panel de sistema.
- La web de los enlaces ↗ sigue a la red activa.
- tests/test26.js. README: la excepción, dicha claramente.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5npnUYgSPkAaHkdaeUqBr
This commit is contained in:
2026-10-22 23:12:36 +02:00
co-authored by Claude Sonnet 5.5
parent 6973838a59
commit 14ac26825b
10 changed files with 151 additions and 33 deletions
+25 -9
View File
@@ -128,12 +128,22 @@
// adivinar si va http o https, ni si es el 4080 o el 4081.
const origen = (typeof location!=="undefined" && /^https?:$/.test(location.protocol)) ? location.origin : null;
const paginaHttps = typeof location!=="undefined" && location.protocol==="https:";
const [url,setUrl]=useState(config.url||origen||"");
const [red,setRed]=useState(config.red==="signet"?"signet":"mainnet");
const [urlMain,setUrlMain]=useState(config.url||origen||"");
const [urlSig,setUrlSig]=useState(config.urlSignet||"");
const [webMain,setWebMain]=useState(config.web||"");
const [webSig,setWebSig]=useState(config.webSignet||"");
const signet = red==="signet";
// El resto del formulario trabaja con la red elegida.
const url = signet ? (urlSig.trim()||SIGNET_PUBLICA) : urlMain;
const setUrl = signet ? setUrlSig : setUrlMain;
const web = signet ? webSig : webMain;
const setWeb = signet ? setWebSig : setWebMain;
const choqueProtocolo = paginaHttps && /^http:\/\//i.test(url.trim());
const [name,setName]=useState(config.name||"");
const [web,setWeb]=useState(config.web||"");
const webOk = !web.trim() || /^https?:\/\/[^\s]{1,200}$/.test(web.trim());
const webPropuesta = derivarWebMempool(url) || "";
const urlOk = signet ? (!urlSig.trim() || /^https?:\/\/[^\s]{1,200}$/.test(urlSig.trim())) : !!urlMain.trim();
const [remember,setRemember]=useState(()=>ALMACEN.get("config", null)!=null);
const [testing,setTesting]=useState(false);
const [testResult,setTestResult]=useState(null);
@@ -144,8 +154,11 @@
setTesting(false);
};
const handleSave=()=>{
const cfg={url:url.replace(/\/$/,""),name:name||"Mi nodo"};
if(web.trim()) cfg.web=web.trim().replace(/\/$/,"");
const cfg={url:urlMain.trim().replace(/\/$/,""),name:name||"Mi nodo"};
if(webMain.trim()) cfg.web=webMain.trim().replace(/\/$/,"");
if(signet) cfg.red="signet";
if(urlSig.trim()) cfg.urlSignet=urlSig.trim().replace(/\/$/,"");
if(webSig.trim()) cfg.webSignet=webSig.trim().replace(/\/$/,"");
if(remember){ ALMACEN.set("config", cfg); }
else { ALMACEN.del("config"); }
onSave(cfg);
@@ -157,18 +170,21 @@
<span style={{fontFamily:C.mono,color:C.green,fontSize:"0.82rem",fontWeight:700}}>AJUSTES</span>
<button onClick={onClose} style={{background:"none",border:"none",color:C.t2,cursor:"pointer",fontSize:"1rem",fontFamily:C.mono}}>✕</button>
</div>
<div style={{fontSize:"0.62rem",color:C.t2,fontFamily:C.mono,textTransform:"uppercase",marginBottom:6}}>Red</div>
<Segmentos color={signet?C.purple:C.green} valor={red} onCambio={setRed} opciones={[{id:"mainnet",label:"Mainnet · tu nodo"},{id:"signet",label:"Signet · pruebas"}]}/>
{signet&&<div style={{fontSize:"0.65rem",color:C.t2,marginBottom:14,lineHeight:1.6}}>Signet es la red de pruebas: las monedas no valen nada. Por defecto se consulta <span style={{fontFamily:C.mono,color:C.t1}}>{SIGNET_PUBLICA}</span> (un tercero: ve lo que miras, pero no hay dinero real). Si algún día montas tu propia Mempool de signet, pon su dirección abajo. La dirección de mainnet se conserva.</div>}
<div style={{fontSize:"0.62rem",color:C.t2,fontFamily:C.mono,textTransform:"uppercase",marginBottom:6}}>Nombre del nodo</div>
<input value={name} onChange={e=>setName(e.target.value)} placeholder="Mi nodo"
style={{width:"100%",background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"10px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.8rem",outline:"none",boxSizing:"border-box",marginBottom:14}}/>
<div style={{fontSize:"0.62rem",color:C.t2,fontFamily:C.mono,textTransform:"uppercase",marginBottom:6}}>URL de tu Mempool</div>
<input value={url} onChange={e=>setUrl(e.target.value)} placeholder={paginaHttps?"https://100.x.x.x:4081":"http://100.x.x.x:4080"}
<div style={{fontSize:"0.62rem",color:C.t2,fontFamily:C.mono,textTransform:"uppercase",marginBottom:6}}>{signet?"URL de la Mempool de signet":"URL de tu Mempool"}</div>
<input value={signet?urlSig:urlMain} onChange={e=>setUrl(e.target.value)} placeholder={signet?SIGNET_PUBLICA:(paginaHttps?"https://100.x.x.x:4081":"http://100.x.x.x:4080")}
style={{width:"100%",background:C.bg,border:`1px solid ${C.borderBright}`,borderRadius:6,padding:"10px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.8rem",outline:"none",boxSizing:"border-box",marginBottom:8}}/>
{choqueProtocolo&&<div style={{fontSize:"0.66rem",color:C.red,marginBottom:8,lineHeight:1.55}}>Esta página está abierta con <strong>https</strong>: el navegador bloqueará una dirección <strong>http</strong> sin avisar. Usa la versión https (normalmente el puerto 4081).</div>}
<div style={{fontSize:"0.65rem",color:C.t2,marginBottom:12,lineHeight:1.6}}>
{!signet&&<div style={{fontSize:"0.65rem",color:C.t2,marginBottom:12,lineHeight:1.6}}>
{origen
? <>Si has abierto el dashboard desde tu nodo, es la misma dirección que la de esta página: <span style={{fontFamily:C.mono,color:C.t1}}>{origen}</span>{url.trim().replace(/\/$/,"")!==origen&&<button onClick={()=>setUrl(origen)} style={{marginLeft:8,padding:"2px 8px",background:"none",border:`1px solid ${C.border}`,borderRadius:4,color:C.blue,fontFamily:C.mono,fontSize:"0.62rem",cursor:"pointer"}}>usar esta</button>}</>
: <>IP Tailscale del nodo con el puerto de Mempool. Con https: <span style={{fontFamily:C.mono}}>https://100.x.x.x:4081</span> · con http: <span style={{fontFamily:C.mono}}>http://100.x.x.x:4080</span></>}
</div>
</div>}
<div style={{fontSize:"0.62rem",color:C.t2,fontFamily:C.mono,textTransform:"uppercase",marginBottom:6}}>Web de Mempool (para los enlaces ↗) · opcional</div>
<input value={web} onChange={e=>setWeb(e.target.value)} placeholder={webPropuesta||"https://100.x.x.x:4081"}
style={{width:"100%",background:C.bg,border:`1px solid ${webOk?C.borderBright:C.red}`,borderRadius:6,padding:"10px 12px",color:C.t1,fontFamily:C.mono,fontSize:"0.8rem",outline:"none",boxSizing:"border-box",marginBottom:8}}/>
@@ -204,7 +220,7 @@
{testResult&&<div style={{padding:"8px 12px",borderRadius:6,fontFamily:C.mono,fontSize:"0.72rem",marginBottom:14,background:testResult.ok?C.greenMuted:C.redMuted,color:testResult.ok?C.green:C.red}}>{testResult.msg}</div>}
<div style={{display:"flex",gap:8}}>
<button onClick={testConn} disabled={!url||testing} style={{flex:1,padding:10,background:C.blueMuted,border:`1px solid ${C.blue}40`,borderRadius:6,color:C.blue,fontFamily:C.mono,fontSize:"0.75rem",cursor:"pointer",fontWeight:700}}>{testing?"PROBANDO···":"PROBAR"}</button>
<button onClick={handleSave} disabled={!url||!webOk} style={{flex:1,padding:10,background:C.greenMuted,border:`1px solid ${C.green}40`,borderRadius:6,color:C.green,fontFamily:C.mono,fontSize:"0.75rem",cursor:"pointer",fontWeight:700}}>GUARDAR</button>
<button onClick={handleSave} disabled={!urlOk||!webOk||(!signet&&!urlMain.trim())} style={{flex:1,padding:10,background:C.greenMuted,border:`1px solid ${C.green}40`,borderRadius:6,color:C.green,fontFamily:C.mono,fontSize:"0.75rem",cursor:"pointer",fontWeight:700}}>GUARDAR</button>
<button onClick={onClose} style={{padding:"10px 14px",background:"none",border:`1px solid ${C.border}`,borderRadius:6,color:C.t2,fontFamily:C.mono,fontSize:"0.75rem",cursor:"pointer"}}>✕</button>
</div>
<DatosGuardados onReinicio={()=>{ try { window.__txokoReiniciar && window.__txokoReiniciar(); } catch {} }}/>