diff --git a/README.md b/README.md index 2124063..812addc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > Private. Self-hosted. No accounts. No backend. No bullshit. -**[Live Demo: xmrpay.link](https://xmrpay.link)** +**[Live: xmrpay.link](https://xmrpay.link)** · **[Tor: mc6wfe...zyd.onion](http://mc6wfeaqc7oijgdcudrr5zsotmwok3jzk3tu2uezzyjisn7nzzjjizyd.onion)** --- diff --git a/app.js b/app.js index aa8b1ae..36a3100 100644 --- a/app.js +++ b/app.js @@ -620,21 +620,28 @@ } // --- Payment Status --- - if (paymentStatus.classList.contains('paid')) { + if (lastPaidData) { y += 4; + var paidDateStr = ''; + if (lastPaidData.verified_at) { + var pd = new Date(lastPaidData.verified_at * 1000); + paidDateStr = pd.toLocaleDateString(I18n.getLang() === 'de' ? 'de-CH' : 'en-US', { + year: 'numeric', month: 'long', day: 'numeric' + }); + } + var paidLine = lastPaidData.amount.toFixed(6) + ' XMR — TX ' + + lastPaidData.tx_hash.substring(0, 8) + '...' + + (paidDateStr ? ' — ' + paidDateStr : ''); + doc.setFillColor(76, 175, 80); doc.roundedRect(margin, y - 4, contentW, 16, 2, 2, 'F'); doc.setFont('helvetica', 'bold'); doc.setFontSize(12); doc.setTextColor(255, 255, 255); - doc.text(I18n.t('status_paid').toUpperCase(), margin + contentW / 2, y + 2, { align: 'center' }); - // Extract details from the paid-detail div - var paidDetail = paymentStatus.querySelector('.paid-detail'); - if (paidDetail) { - doc.setFont('helvetica', 'normal'); - doc.setFontSize(8); - doc.text(paidDetail.textContent, margin + contentW / 2, y + 8, { align: 'center' }); - } + doc.text(I18n.t('status_paid').toUpperCase(), margin + contentW / 2, y + 1, { align: 'center' }); + doc.setFont('helvetica', 'normal'); + doc.setFontSize(7.5); + doc.text(paidLine, margin + contentW / 2, y + 7, { align: 'center' }); y += 22; } diff --git a/app.min.js b/app.min.js index 097e8af..df99520 100644 --- a/app.min.js +++ b/app.min.js @@ -1 +1 @@ -(function(){"use strict";const St="/api/rates.php",It=/^[48][1-9A-HJ-NP-Za-km-z]{94}$/,_t=/^4[1-9A-HJ-NP-Za-km-z]{105}$/;let y=null,lt=0,I=null,z=!1,_=null;const i=e=>document.querySelector(e),u=i("#addr"),C=i("#amount"),L=i("#currency"),q=i("#desc"),T=i("#timerCustom"),D=i("#deadlineBadges");let f=0;const tt=i("#generate"),B=i("#result"),v=i("#qr"),et=i("#uri"),dt=i("#openWallet"),Tt=i("#copyAddr"),w=i("#countdown"),h=i("#fiatHint"),nt=i("#toast"),H=i("#shareLink"),Ft=i("#copyShareLink"),Et=i("#newRequest"),Rt=i("#homeLink"),bt=i("#proofToggle"),M=i("#proofPanel"),F=i("#txHash"),U=i("#txKey"),E=i("#verifyProof"),p=i("#proofResult"),R=i("#paymentStatus"),ut=i("#paymentSummary"),Pt=i("#downloadPdf");let ft=!1,kt=!1,at=null;xt(),Mt()||Bt(),Ut(),I18n.onChange(function(){var e=v.querySelector(".qr-hint");e&&(e.textContent=I18n.t("qr_hint"));var t=v.querySelector(".paid-stamp");if(t&&(t.textContent=I18n.t("status_paid")),at&&it(at),B.classList.contains("visible")){var n=rt(),a=q.value.trim();mt(n,a,f),ht(n,a)}}),u.addEventListener("input",ot),C.addEventListener("input",O),L.addEventListener("change",O),tt.addEventListener("click",pt),Tt.addEventListener("click",()=>gt(u.value.trim())),Ft.addEventListener("click",()=>gt(H.value)),v.addEventListener("click",At),Et.addEventListener("click",vt),Rt.addEventListener("click",function(e){e.preventDefault(),vt()}),D.querySelectorAll(".badge").forEach(function(e){e.addEventListener("click",function(){const t=parseInt(e.getAttribute("data-days"));e.classList.contains("active")?(e.classList.remove("active"),f=0,T.value=""):(D.querySelectorAll(".badge").forEach(function(n){n.classList.remove("active")}),e.classList.add("active"),f=t,T.value="")})}),T.addEventListener("input",function(){D.querySelectorAll(".badge").forEach(function(e){e.classList.remove("active")}),f=parseInt(T.value)||0}),Pt.addEventListener("click",Wt),bt.addEventListener("click",Gt),F.addEventListener("input",Ct),U.addEventListener("input",Ct),E.addEventListener("click",Yt);function vt(){u.value="",C.value="",L.value="EUR",q.value="",f=0,T.value="",D.querySelectorAll(".badge").forEach(function(e){e.classList.remove("active")}),h.textContent="",h.classList.remove("error"),u.classList.remove("valid","invalid"),tt.disabled=!0,B.classList.remove("visible"),I&&clearInterval(I),v.innerHTML="",et.textContent="",H.value="",_=null,M.classList.remove("open"),F.value="",U.value="",E.disabled=!0,p.innerHTML="",p.className="proof-result",R.innerHTML="",R.className="payment-status",ut.innerHTML="",document.title="xmrpay.link \u2014 Monero Invoice Generator",history.replaceState(null,"",location.pathname),window.scrollTo({top:0,behavior:"smooth"}),u.focus()}function N(e){return It.test(e)||_t.test(e)}function ot(){const e=u.value.trim();u.classList.remove("valid","invalid"),e.length!==0&&(N(e)?u.classList.add("valid"):e.length>=10&&u.classList.add("invalid"),Xt())}function Xt(){const e=u.value.trim();tt.disabled=!N(e)}function O(){const e=parseFloat(C.value),t=L.value;if(!e||e<=0){h.textContent="",h.classList.remove("error");return}if(t!=="XMR"&&!y){h.textContent=z?I18n.t("rates_offline"):"",h.classList.toggle("error",z);return}if(h.classList.remove("error"),t==="XMR")if(y){const n=(e*y.eur).toFixed(2);h.textContent="\u2248 "+n+" EUR"}else h.textContent="";else{const n=y[t.toLowerCase()];if(n&&n>0){const a=(e/n).toFixed(8);h.textContent="\u2248 "+a+" XMR"}}}function rt(){const e=parseFloat(C.value),t=L.value;if(!e||e<=0)return null;if(t==="XMR")return e;if(y){const n=y[t.toLowerCase()];if(n&&n>0)return e/n}return null}function qt(e,t,n){let a="monero:"+e;const o=[];return t&&o.push("tx_amount="+t.toFixed(12)),n&&o.push("tx_description="+encodeURIComponent(n)),o.length&&(a+="?"+o.join("&")),a}function Dt(e,t,n,a){const o=new URLSearchParams;return o.set("a",e),t&&o.set("x",t.toFixed(12)),n&&o.set("d",n),a&&o.set("t",a),o.toString()}async function Ht(e){try{const t=await fetch("/api/shorten.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:e})});if(!t.ok)throw new Error("HTTP "+t.status);const n=await t.json();return _||(_=n.code),location.origin+"/s/"+n.code}catch(t){return console.warn("Short URL failed:",t),null}}function pt(){const e=u.value.trim();if(!N(e))return;const t=rt(),n=q.value.trim(),a=f,o=qt(e,t,n);B.classList.add("visible"),et.textContent=o,dt.onclick=function(){window.location.href=o},mt(t,n,a),ht(t,n);const c=Dt(e,t,n,a);H.value=location.origin+"/#"+c,Ht(c).then(function(l){l&&(H.value=l)}),v.innerHTML="",new QRCode(v,{text:o,width:256,height:256,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.M});const d=document.createElement("div");d.className="qr-hint",d.textContent=I18n.t("qr_hint"),v.appendChild(d),Nt(),zt(e),B.scrollIntoView({behavior:"smooth",block:"start"})}function Mt(){const e=location.hash.substring(1);if(!e)return!1;const t=new URLSearchParams(e),n=t.get("a");if(!n||!N(n))return!1;u.value=n,ot();const a=t.get("x");a&&(C.value=parseFloat(a),L.value="XMR");const o=t.get("d");o&&(q.value=o);const c=t.get("t");if(c&&parseInt(c)>0){f=parseInt(c);const l=D.querySelector('.badge[data-days="'+f+'"]');l?l.classList.add("active"):T.value=f}const d=t.get("c");return d&&(_=d,setTimeout(function(){Jt(d)},200)),setTimeout(pt,100),!0}function mt(e,t,n){var a="";if(e){a+='
'+e.toFixed(8)+" XMR
";var o=parseFloat(C.value),c=L.value;c!=="XMR"&&o&&(a+='
\u2248 '+o.toFixed(2)+" "+c+"
")}t&&(a+='
'+t.replace(/"),ut.innerHTML=a}function ht(e,t){var n=[];e&&n.push(e.toFixed(4)+" XMR"),t&&n.push(t),n.length&&(document.title=n.join(" \u2014 ")+" | xmrpay.link")}function Nt(){if(I&&clearInterval(I),w.textContent="",w.className="countdown",!f||f<=0)return;const e=Date.now()+f*864e5;w.classList.add("active");function t(){const n=e-Date.now();if(n<=0){clearInterval(I),w.textContent=I18n.t("countdown_expired"),w.className="countdown expired";return}const a=Math.floor(n/864e5),o=Math.floor(n%864e5/36e5),c=Math.floor(n%36e5/6e4);a>0?w.textContent=I18n.t("countdown_remaining_days").replace("{d}",a).replace("{h}",o):w.textContent=I18n.t("countdown_remaining_hours").replace("{h}",yt(o)).replace("{m}",yt(c))}t(),I=setInterval(t,6e4)}function yt(e){return e<10?"0"+e:""+e}function At(){const e=v.querySelector("canvas");if(!e)return;const t=document.createElement("a");t.download="xmrpay-qr.png",t.href=e.toDataURL("image/png"),t.click()}function gt(e){navigator.clipboard.writeText(e).then(()=>{jt(I18n.t("toast_copied"))})}function jt(e){nt.textContent=e,nt.classList.add("show"),setTimeout(()=>nt.classList.remove("show"),2e3)}function zt(e){try{localStorage.setItem("xmrpay_addr",e)}catch{}}function Bt(){try{const e=localStorage.getItem("xmrpay_addr");e&&(u.value=e,ot())}catch{}}async function xt(){if(!(y&&Date.now()-lt<6e4))try{const e=await fetch(St);if(!e.ok)throw new Error("HTTP "+e.status);y=(await e.json()).monero,lt=Date.now(),z=!1,O()}catch(e){console.warn("Kurse konnten nicht geladen werden:",e),z=!0,O(),setTimeout(xt,1e4)}}function Ut(){"serviceWorker"in navigator&&navigator.serviceWorker.register("sw.js").catch(function(){})}function Ot(){return new Promise(function(e,t){if(window.jspdf){e();return}var n=document.createElement("script");n.src="lib/jspdf.min.js",n.onload=function(){kt=!0,e()},n.onerror=function(){t(new Error("Failed to load jsPDF"))},document.head.appendChild(n)})}async function Wt(){await Ot();var e=window.jspdf.jsPDF,t=new e({orientation:"portrait",unit:"mm",format:"a4"}),n=u.value.trim(),a=rt(),o=q.value.trim(),c=parseFloat(C.value),d=L.value,l=t.internal.pageSize.getWidth(),s=20,g=l-s*2,r=s;t.setFillColor(242,104,33),t.rect(0,0,l,8,"F"),r=22,t.setFont("helvetica","bold"),t.setFontSize(22),t.setTextColor(242,104,33),t.text(I18n.t("pdf_title"),s,r),t.setFont("helvetica","normal"),t.setFontSize(10),t.setTextColor(120,120,120);var st=new Date().toLocaleDateString(I18n.getLang()==="de"?"de-CH":"en-US",{year:"numeric",month:"long",day:"numeric"});t.text(I18n.t("pdf_date")+": "+st,l-s,r,{align:"right"}),r+=6,t.setDrawColor(220,220,220),t.setLineWidth(.3),t.line(s,r,l-s,r);var G=v.querySelector("canvas"),x=50,b=l-s-x,A=r+6;if(G){var K=G.toDataURL("image/png");t.addImage(K,"PNG",b,A,x,x),t.setFontSize(7),t.setTextColor(150,150,150),t.text(I18n.t("pdf_scan_qr"),b+x/2,A+x+4,{align:"center"})}var P=s,Y=b-s-10;r+=14;function k(j,Lt){t.setFont("helvetica","normal"),t.setFontSize(9),t.setTextColor(150,150,150),t.text(j,P,r),r+=5,t.setFont("helvetica","bold"),t.setFontSize(11),t.setTextColor(40,40,40);var wt=t.splitTextToSize(Lt,Y);t.text(wt,P,r),r+=wt.length*5+4}if(a){var m=a.toFixed(8)+" XMR";d!=="XMR"&&c&&(m+=" (~ "+c.toFixed(2)+" "+d+")"),k(I18n.t("pdf_amount"),m)}if(o&&k(I18n.t("pdf_desc"),o),f>0){var S=new Date(Date.now()+f*864e5),J=S.toLocaleDateString(I18n.getLang()==="de"?"de-CH":"en-US",{year:"numeric",month:"long",day:"numeric"});k(I18n.t("pdf_deadline"),J+" ("+I18n.t("pdf_deadline_days").replace("{d}",f)+")")}r=Math.max(r,A+x+12),t.setFont("helvetica","normal"),t.setFontSize(9),t.setTextColor(150,150,150),t.text(I18n.t("pdf_address"),s,r),r+=5,t.setFillColor(245,245,245),t.roundedRect(s,r-3.5,g,10,2,2,"F"),t.setFont("courier","normal"),t.setFontSize(8),t.setTextColor(60,60,60),t.text(n,s+3,r+2.5),r+=14;var V=et.textContent;if(V){t.setFillColor(245,245,245),t.roundedRect(s,r-3.5,g,10,2,2,"F"),t.setFont("courier","normal"),t.setFontSize(6.5),t.setTextColor(100,100,100);var $=t.splitTextToSize(V,g-6);t.text($,s+3,r+2),r+=$.length*3+10}if(R.classList.contains("paid")){r+=4,t.setFillColor(76,175,80),t.roundedRect(s,r-4,g,16,2,2,"F"),t.setFont("helvetica","bold"),t.setFontSize(12),t.setTextColor(255,255,255),t.text(I18n.t("status_paid").toUpperCase(),s+g/2,r+2,{align:"center"});var Q=R.querySelector(".paid-detail");Q&&(t.setFont("helvetica","normal"),t.setFontSize(8),t.text(Q.textContent,s+g/2,r+8,{align:"center"})),r+=22}t.setDrawColor(220,220,220),t.setLineWidth(.3);var X=t.internal.pageSize.getHeight()-15;t.line(s,X,l-s,X),t.setFont("helvetica","normal"),t.setFontSize(7),t.setTextColor(180,180,180),t.text(I18n.t("pdf_footer"),l/2,X+5,{align:"center"});var Z=H.value;Z&&t.text(Z,l/2,X+9,{align:"center"});var ct="xmrpay-"+(o?o.replace(/[^a-zA-Z0-9]/g,"-").substring(0,30):"invoice")+".pdf";t.save(ct)}function Gt(){if(M.classList.contains("open")){M.classList.remove("open");return}if(!ft&&!window.XmrCrypto){Kt().then(function(){ft=!0,M.classList.add("open"),F.focus()});return}M.classList.add("open"),F.focus()}function Kt(){return new Promise(function(e,t){if(window.XmrCrypto){e();return}const n=document.createElement("script");n.src="lib/xmr-crypto.bundle.js",n.onload=e,n.onerror=function(){t(new Error("Failed to load crypto module"))},document.head.appendChild(n)})}function W(e){return/^[0-9a-fA-F]{64}$/.test(e)}function Ct(){const e=F.value.trim(),t=U.value.trim();E.disabled=!(W(e)&&W(t))}async function Yt(){const e=F.value.trim(),t=U.value.trim(),n=u.value.trim();if(!(!W(e)||!W(t)||!N(n))){E.disabled=!0,p.className="proof-result active",p.textContent=I18n.t("proof_verifying");try{var a=await fetch("/api/node.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"gettransactions",params:{txs_hashes:[e],decode_as_json:!0}})}),o=await a.json(),c=o.txs||[];if(c.length===0){p.className="proof-result active error",p.textContent=I18n.t("proof_tx_not_found"),E.disabled=!1;return}for(var d=c[0],l=JSON.parse(d.as_json),s=XmrCrypto.getKeysFromAddress(n),g=s.publicViewKey,r=s.publicSpendKey,st=XmrCrypto.bytesToScalar(XmrCrypto.hexToBytes(t)),G=XmrCrypto.Point.fromHex(g),x=G.multiply(st).multiply(8n),b=x.toBytes(),A=XmrCrypto.Point.fromHex(r),K=l.vout||[],P=l.rct_signatures&&l.rct_signatures.ecdhInfo||[],Y=0n,k=!1,m=0;mdocument.querySelector(e),u=i("#addr"),L=i("#amount"),w=i("#currency"),H=i("#desc"),F=i("#timerCustom"),M=i("#deadlineBadges");let f=0;const tt=i("#generate"),U=i("#result"),v=i("#qr"),et=i("#uri"),dt=i("#openWallet"),Tt=i("#copyAddr"),S=i("#countdown"),h=i("#fiatHint"),nt=i("#toast"),q=i("#shareLink"),Ft=i("#copyShareLink"),Et=i("#newRequest"),Rt=i("#homeLink"),bt=i("#proofToggle"),N=i("#proofPanel"),E=i("#txHash"),O=i("#txKey"),R=i("#verifyProof"),m=i("#proofResult"),W=i("#paymentStatus"),ut=i("#paymentSummary"),Pt=i("#downloadPdf");let ft=!1,kt=!1,g=null;xt(),qt()||Bt(),Ut(),I18n.onChange(function(){var e=v.querySelector(".qr-hint");e&&(e.textContent=I18n.t("qr_hint"));var t=v.querySelector(".paid-stamp");if(t&&(t.textContent=I18n.t("status_paid")),g&&rt(g),U.classList.contains("visible")){var n=ot(),a=H.value.trim();pt(n,a,f),ht(n,a)}}),u.addEventListener("input",at),L.addEventListener("input",G),w.addEventListener("change",G),tt.addEventListener("click",mt),Tt.addEventListener("click",()=>gt(u.value.trim())),Ft.addEventListener("click",()=>gt(q.value)),v.addEventListener("click",At),Et.addEventListener("click",vt),Rt.addEventListener("click",function(e){e.preventDefault(),vt()}),M.querySelectorAll(".badge").forEach(function(e){e.addEventListener("click",function(){const t=parseInt(e.getAttribute("data-days"));e.classList.contains("active")?(e.classList.remove("active"),f=0,F.value=""):(M.querySelectorAll(".badge").forEach(function(n){n.classList.remove("active")}),e.classList.add("active"),f=t,F.value="")})}),F.addEventListener("input",function(){M.querySelectorAll(".badge").forEach(function(e){e.classList.remove("active")}),f=parseInt(F.value)||0}),Pt.addEventListener("click",Wt),bt.addEventListener("click",Gt),E.addEventListener("input",Ct),O.addEventListener("input",Ct),R.addEventListener("click",Yt);function vt(){u.value="",L.value="",w.value="EUR",H.value="",f=0,F.value="",M.querySelectorAll(".badge").forEach(function(e){e.classList.remove("active")}),h.textContent="",h.classList.remove("error"),u.classList.remove("valid","invalid"),tt.disabled=!0,U.classList.remove("visible"),_&&clearInterval(_),v.innerHTML="",et.textContent="",q.value="",T=null,N.classList.remove("open"),E.value="",O.value="",R.disabled=!0,m.innerHTML="",m.className="proof-result",W.innerHTML="",W.className="payment-status",ut.innerHTML="",document.title="xmrpay.link \u2014 Monero Invoice Generator",history.replaceState(null,"",location.pathname),window.scrollTo({top:0,behavior:"smooth"}),u.focus()}function A(e){return It.test(e)||_t.test(e)}function at(){const e=u.value.trim();u.classList.remove("valid","invalid"),e.length!==0&&(A(e)?u.classList.add("valid"):e.length>=10&&u.classList.add("invalid"),Xt())}function Xt(){const e=u.value.trim();tt.disabled=!A(e)}function G(){const e=parseFloat(L.value),t=w.value;if(!e||e<=0){h.textContent="",h.classList.remove("error");return}if(t!=="XMR"&&!y){h.textContent=B?I18n.t("rates_offline"):"",h.classList.toggle("error",B);return}if(h.classList.remove("error"),t==="XMR")if(y){const n=(e*y.eur).toFixed(2);h.textContent="\u2248 "+n+" EUR"}else h.textContent="";else{const n=y[t.toLowerCase()];if(n&&n>0){const a=(e/n).toFixed(8);h.textContent="\u2248 "+a+" XMR"}}}function ot(){const e=parseFloat(L.value),t=w.value;if(!e||e<=0)return null;if(t==="XMR")return e;if(y){const n=y[t.toLowerCase()];if(n&&n>0)return e/n}return null}function Dt(e,t,n){let a="monero:"+e;const o=[];return t&&o.push("tx_amount="+t.toFixed(12)),n&&o.push("tx_description="+encodeURIComponent(n)),o.length&&(a+="?"+o.join("&")),a}function Ht(e,t,n,a){const o=new URLSearchParams;return o.set("a",e),t&&o.set("x",t.toFixed(12)),n&&o.set("d",n),a&&o.set("t",a),o.toString()}async function Mt(e){try{const t=await fetch("/api/shorten.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hash:e})});if(!t.ok)throw new Error("HTTP "+t.status);const n=await t.json();return T||(T=n.code),location.origin+"/s/"+n.code}catch(t){return console.warn("Short URL failed:",t),null}}function mt(){const e=u.value.trim();if(!A(e))return;const t=ot(),n=H.value.trim(),a=f,o=Dt(e,t,n);U.classList.add("visible"),et.textContent=o,dt.onclick=function(){window.location.href=o},pt(t,n,a),ht(t,n);const c=Ht(e,t,n,a);q.value=location.origin+"/#"+c,Mt(c).then(function(l){l&&(q.value=l)}),v.innerHTML="",new QRCode(v,{text:o,width:256,height:256,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.M});const d=document.createElement("div");d.className="qr-hint",d.textContent=I18n.t("qr_hint"),v.appendChild(d),Nt(),zt(e),U.scrollIntoView({behavior:"smooth",block:"start"})}function qt(){const e=location.hash.substring(1);if(!e)return!1;const t=new URLSearchParams(e),n=t.get("a");if(!n||!A(n))return!1;u.value=n,at();const a=t.get("x");a&&(L.value=parseFloat(a),w.value="XMR");const o=t.get("d");o&&(H.value=o);const c=t.get("t");if(c&&parseInt(c)>0){f=parseInt(c);const l=M.querySelector('.badge[data-days="'+f+'"]');l?l.classList.add("active"):F.value=f}const d=t.get("c");return d&&(T=d,setTimeout(function(){Jt(d)},200)),setTimeout(mt,100),!0}function pt(e,t,n){var a="";if(e){a+='
'+e.toFixed(8)+" XMR
";var o=parseFloat(L.value),c=w.value;c!=="XMR"&&o&&(a+='
\u2248 '+o.toFixed(2)+" "+c+"
")}t&&(a+='
'+t.replace(/"),ut.innerHTML=a}function ht(e,t){var n=[];e&&n.push(e.toFixed(4)+" XMR"),t&&n.push(t),n.length&&(document.title=n.join(" \u2014 ")+" | xmrpay.link")}function Nt(){if(_&&clearInterval(_),S.textContent="",S.className="countdown",!f||f<=0)return;const e=Date.now()+f*864e5;S.classList.add("active");function t(){const n=e-Date.now();if(n<=0){clearInterval(_),S.textContent=I18n.t("countdown_expired"),S.className="countdown expired";return}const a=Math.floor(n/864e5),o=Math.floor(n%864e5/36e5),c=Math.floor(n%36e5/6e4);a>0?S.textContent=I18n.t("countdown_remaining_days").replace("{d}",a).replace("{h}",o):S.textContent=I18n.t("countdown_remaining_hours").replace("{h}",yt(o)).replace("{m}",yt(c))}t(),_=setInterval(t,6e4)}function yt(e){return e<10?"0"+e:""+e}function At(){const e=v.querySelector("canvas");if(!e)return;const t=document.createElement("a");t.download="xmrpay-qr.png",t.href=e.toDataURL("image/png"),t.click()}function gt(e){navigator.clipboard.writeText(e).then(()=>{jt(I18n.t("toast_copied"))})}function jt(e){nt.textContent=e,nt.classList.add("show"),setTimeout(()=>nt.classList.remove("show"),2e3)}function zt(e){try{localStorage.setItem("xmrpay_addr",e)}catch{}}function Bt(){try{const e=localStorage.getItem("xmrpay_addr");e&&(u.value=e,at())}catch{}}async function xt(){if(!(y&&Date.now()-lt<6e4))try{const e=await fetch(St);if(!e.ok)throw new Error("HTTP "+e.status);y=(await e.json()).monero,lt=Date.now(),B=!1,G()}catch(e){console.warn("Kurse konnten nicht geladen werden:",e),B=!0,G(),setTimeout(xt,1e4)}}function Ut(){"serviceWorker"in navigator&&navigator.serviceWorker.register("sw.js").catch(function(){})}function Ot(){return new Promise(function(e,t){if(window.jspdf){e();return}var n=document.createElement("script");n.src="lib/jspdf.min.js",n.onload=function(){kt=!0,e()},n.onerror=function(){t(new Error("Failed to load jsPDF"))},document.head.appendChild(n)})}async function Wt(){await Ot();var e=window.jspdf.jsPDF,t=new e({orientation:"portrait",unit:"mm",format:"a4"}),n=u.value.trim(),a=ot(),o=H.value.trim(),c=parseFloat(L.value),d=w.value,l=t.internal.pageSize.getWidth(),s=20,x=l-s*2,r=s;t.setFillColor(242,104,33),t.rect(0,0,l,8,"F"),r=22,t.setFont("helvetica","bold"),t.setFontSize(22),t.setTextColor(242,104,33),t.text(I18n.t("pdf_title"),s,r),t.setFont("helvetica","normal"),t.setFontSize(10),t.setTextColor(120,120,120);var it=new Date().toLocaleDateString(I18n.getLang()==="de"?"de-CH":"en-US",{year:"numeric",month:"long",day:"numeric"});t.text(I18n.t("pdf_date")+": "+it,l-s,r,{align:"right"}),r+=6,t.setDrawColor(220,220,220),t.setLineWidth(.3),t.line(s,r,l-s,r);var Y=v.querySelector("canvas"),C=50,b=l-s-C,j=r+6;if(Y){var J=Y.toDataURL("image/png");t.addImage(J,"PNG",b,j,C,C),t.setFontSize(7),t.setTextColor(150,150,150),t.text(I18n.t("pdf_scan_qr"),b+C/2,j+C+4,{align:"center"})}var P=s,V=b-s-10;r+=14;function k($t,Qt){t.setFont("helvetica","normal"),t.setFontSize(9),t.setTextColor(150,150,150),t.text($t,P,r),r+=5,t.setFont("helvetica","bold"),t.setFontSize(11),t.setTextColor(40,40,40);var wt=t.splitTextToSize(Qt,V);t.text(wt,P,r),r+=wt.length*5+4}if(a){var p=a.toFixed(8)+" XMR";d!=="XMR"&&c&&(p+=" (~ "+c.toFixed(2)+" "+d+")"),k(I18n.t("pdf_amount"),p)}if(o&&k(I18n.t("pdf_desc"),o),f>0){var I=new Date(Date.now()+f*864e5),$=I.toLocaleDateString(I18n.getLang()==="de"?"de-CH":"en-US",{year:"numeric",month:"long",day:"numeric"});k(I18n.t("pdf_deadline"),$+" ("+I18n.t("pdf_deadline_days").replace("{d}",f)+")")}r=Math.max(r,j+C+12),t.setFont("helvetica","normal"),t.setFontSize(9),t.setTextColor(150,150,150),t.text(I18n.t("pdf_address"),s,r),r+=5,t.setFillColor(245,245,245),t.roundedRect(s,r-3.5,x,10,2,2,"F"),t.setFont("courier","normal"),t.setFontSize(8),t.setTextColor(60,60,60),t.text(n,s+3,r+2.5),r+=14;var Q=et.textContent;if(Q){t.setFillColor(245,245,245),t.roundedRect(s,r-3.5,x,10,2,2,"F"),t.setFont("courier","normal"),t.setFontSize(6.5),t.setTextColor(100,100,100);var Z=t.splitTextToSize(Q,x-6);t.text(Z,s+3,r+2),r+=Z.length*3+10}if(g){r+=4;var z="";if(g.verified_at){var st=new Date(g.verified_at*1e3);z=st.toLocaleDateString(I18n.getLang()==="de"?"de-CH":"en-US",{year:"numeric",month:"long",day:"numeric"})}var ct=g.amount.toFixed(6)+" XMR \u2014 TX "+g.tx_hash.substring(0,8)+"..."+(z?" \u2014 "+z:"");t.setFillColor(76,175,80),t.roundedRect(s,r-4,x,16,2,2,"F"),t.setFont("helvetica","bold"),t.setFontSize(12),t.setTextColor(255,255,255),t.text(I18n.t("status_paid").toUpperCase(),s+x/2,r+1,{align:"center"}),t.setFont("helvetica","normal"),t.setFontSize(7.5),t.text(ct,s+x/2,r+7,{align:"center"}),r+=22}t.setDrawColor(220,220,220),t.setLineWidth(.3);var X=t.internal.pageSize.getHeight()-15;t.line(s,X,l-s,X),t.setFont("helvetica","normal"),t.setFontSize(7),t.setTextColor(180,180,180),t.text(I18n.t("pdf_footer"),l/2,X+5,{align:"center"});var D=q.value;D&&t.text(D,l/2,X+9,{align:"center"});var Lt="xmrpay-"+(o?o.replace(/[^a-zA-Z0-9]/g,"-").substring(0,30):"invoice")+".pdf";t.save(Lt)}function Gt(){if(N.classList.contains("open")){N.classList.remove("open");return}if(!ft&&!window.XmrCrypto){Kt().then(function(){ft=!0,N.classList.add("open"),E.focus()});return}N.classList.add("open"),E.focus()}function Kt(){return new Promise(function(e,t){if(window.XmrCrypto){e();return}const n=document.createElement("script");n.src="lib/xmr-crypto.bundle.js",n.onload=e,n.onerror=function(){t(new Error("Failed to load crypto module"))},document.head.appendChild(n)})}function K(e){return/^[0-9a-fA-F]{64}$/.test(e)}function Ct(){const e=E.value.trim(),t=O.value.trim();R.disabled=!(K(e)&&K(t))}async function Yt(){const e=E.value.trim(),t=O.value.trim(),n=u.value.trim();if(!(!K(e)||!K(t)||!A(n))){R.disabled=!0,m.className="proof-result active",m.textContent=I18n.t("proof_verifying");try{var a=await fetch("/api/node.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:"gettransactions",params:{txs_hashes:[e],decode_as_json:!0}})}),o=await a.json(),c=o.txs||[];if(c.length===0){m.className="proof-result active error",m.textContent=I18n.t("proof_tx_not_found"),R.disabled=!1;return}for(var d=c[0],l=JSON.parse(d.as_json),s=XmrCrypto.getKeysFromAddress(n),x=s.publicViewKey,r=s.publicSpendKey,it=XmrCrypto.bytesToScalar(XmrCrypto.hexToBytes(t)),Y=XmrCrypto.Point.fromHex(x),C=Y.multiply(it).multiply(8n),b=C.toBytes(),j=XmrCrypto.Point.fromHex(r),J=l.vout||[],P=l.rct_signatures&&l.rct_signatures.ecdhInfo||[],V=0n,k=!1,p=0;pSource', + footer: 'Open Source · Kein Backend · Kein KYC · Source · Onion', aria_currency: 'Währung', label_uri_details: 'Monero-URI anzeigen', label_share_link: 'Teilbarer Link', @@ -57,7 +57,7 @@ var I18n = (function () { en: { subtitle: 'Monero payment request in seconds', label_addr: 'XMR Address', - placeholder_addr: '4...', + placeholder_addr: '8...', label_amount: 'Amount', label_desc: 'Description (optional)', placeholder_desc: 'e.g. Invoice #42, freelance work...', @@ -78,7 +78,7 @@ var I18n = (function () { pdf_scan_qr: 'Scan QR code to pay', pdf_footer: 'Created with xmrpay.link — No registration, no KYC', qr_hint: 'Click QR to save', - footer: 'Open Source · No Backend · No KYC · Source', + footer: 'Open Source · No Backend · No KYC · Source · Onion', aria_currency: 'Currency', label_uri_details: 'Show Monero URI', label_share_link: 'Shareable link', diff --git a/i18n.min.js b/i18n.min.js index 2d6904a..e2139de 100644 --- a/i18n.min.js +++ b/i18n.min.js @@ -1 +1 @@ -var I18n=(function(){"use strict";var d={de:{name:"Deutsch",flag:"DE"},en:{name:"English",flag:"EN"}},i={de:{subtitle:"Monero-Zahlungsanforderung in Sekunden",label_addr:"XMR-Adresse",placeholder_addr:"4...",label_amount:"Betrag",label_desc:"Beschreibung (optional)",placeholder_desc:"z.B. Rechnung #42, Freelance-Arbeit...",label_timer:"Zahlungsfrist (optional)",days:"Tage",placeholder_timer_custom:"Tage",btn_generate:"Zahlungsanforderung erstellen",btn_open_wallet:"In Wallet \xF6ffnen",btn_copy_addr:"Adresse kopieren",btn_download_pdf:"PDF Rechnung",pdf_title:"Zahlungsanforderung",pdf_address:"XMR-Adresse",pdf_amount:"Betrag",pdf_desc:"Beschreibung",pdf_deadline:"Zahlungsfrist",pdf_deadline_days:"{d} Tage",pdf_date:"Datum",pdf_scan_qr:"QR-Code scannen zum Bezahlen",pdf_footer:"Erstellt mit xmrpay.link \u2014 Keine Registrierung, kein KYC",qr_hint:"Klick auf QR zum Speichern",footer:'Open Source · Kein Backend · Kein KYC · Source',aria_currency:"W\xE4hrung",label_uri_details:"Monero-URI anzeigen",label_share_link:"Teilbarer Link",btn_new_request:"Neue Zahlungsanforderung",toast_copied:"Kopiert!",countdown_expired:"Zahlungsfrist abgelaufen",countdown_remaining_days:"Zahlungsfrist: {d} Tage, {h} Std.",countdown_remaining_hours:"Zahlungsfrist: {h}:{m} Std.",rates_offline:"Kurse nicht verf\xFCgbar \u2014 nur XMR-Betrag m\xF6glich",btn_prove_payment:"Zahlung nachweisen",label_tx_hash:"Transaction ID (TX Hash)",placeholder_tx_hash:"64 Hex-Zeichen...",label_tx_key:"Transaction Key (TX Key)",placeholder_tx_key:"64 Hex-Zeichen...",btn_verify_proof:"Zahlung verifizieren",proof_verifying:"Verifiziere...",proof_verified:"Zahlung best\xE4tigt: {amount} XMR",proof_no_match:"Kein passender Output gefunden \u2014 TX Key oder Adresse stimmt nicht",proof_tx_not_found:"Transaktion nicht gefunden",proof_error:"Fehler bei der Verifizierung",status_paid:"Bezahlt"},en:{subtitle:"Monero payment request in seconds",label_addr:"XMR Address",placeholder_addr:"4...",label_amount:"Amount",label_desc:"Description (optional)",placeholder_desc:"e.g. Invoice #42, freelance work...",label_timer:"Payment deadline (optional)",days:"days",placeholder_timer_custom:"Days",btn_generate:"Create payment request",btn_open_wallet:"Open in wallet",btn_copy_addr:"Copy address",btn_download_pdf:"PDF Invoice",pdf_title:"Payment Request",pdf_address:"XMR Address",pdf_amount:"Amount",pdf_desc:"Description",pdf_deadline:"Payment deadline",pdf_deadline_days:"{d} days",pdf_date:"Date",pdf_scan_qr:"Scan QR code to pay",pdf_footer:"Created with xmrpay.link \u2014 No registration, no KYC",qr_hint:"Click QR to save",footer:'Open Source · No Backend · No KYC · Source',aria_currency:"Currency",label_uri_details:"Show Monero URI",label_share_link:"Shareable link",btn_new_request:"New payment request",toast_copied:"Copied!",countdown_expired:"Payment deadline expired",countdown_remaining_days:"Deadline: {d} days, {h} hrs",countdown_remaining_hours:"Deadline: {h}:{m} hrs",rates_offline:"Rates unavailable \u2014 XMR amount only",btn_prove_payment:"Prove payment",label_tx_hash:"Transaction ID (TX Hash)",placeholder_tx_hash:"64 hex characters...",label_tx_key:"Transaction Key (TX Key)",placeholder_tx_key:"64 hex characters...",btn_verify_proof:"Verify payment",proof_verifying:"Verifying...",proof_verified:"Payment confirmed: {amount} XMR",proof_no_match:"No matching output found \u2014 TX key or address mismatch",proof_tx_not_found:"Transaction not found",proof_error:"Verification error",status_paid:"Paid"}},o="de";function u(){var e=null;try{e=localStorage.getItem("xmrpay_lang")}catch{}if(e&&i[e])return e;for(var n=navigator.languages||[navigator.language||"de"],t=0;tSource · Onion',aria_currency:"W\xE4hrung",label_uri_details:"Monero-URI anzeigen",label_share_link:"Teilbarer Link",btn_new_request:"Neue Zahlungsanforderung",toast_copied:"Kopiert!",countdown_expired:"Zahlungsfrist abgelaufen",countdown_remaining_days:"Zahlungsfrist: {d} Tage, {h} Std.",countdown_remaining_hours:"Zahlungsfrist: {h}:{m} Std.",rates_offline:"Kurse nicht verf\xFCgbar \u2014 nur XMR-Betrag m\xF6glich",btn_prove_payment:"Zahlung nachweisen",label_tx_hash:"Transaction ID (TX Hash)",placeholder_tx_hash:"64 Hex-Zeichen...",label_tx_key:"Transaction Key (TX Key)",placeholder_tx_key:"64 Hex-Zeichen...",btn_verify_proof:"Zahlung verifizieren",proof_verifying:"Verifiziere...",proof_verified:"Zahlung best\xE4tigt: {amount} XMR",proof_no_match:"Kein passender Output gefunden \u2014 TX Key oder Adresse stimmt nicht",proof_tx_not_found:"Transaktion nicht gefunden",proof_error:"Fehler bei der Verifizierung",status_paid:"Bezahlt"},en:{subtitle:"Monero payment request in seconds",label_addr:"XMR Address",placeholder_addr:"8...",label_amount:"Amount",label_desc:"Description (optional)",placeholder_desc:"e.g. Invoice #42, freelance work...",label_timer:"Payment deadline (optional)",days:"days",placeholder_timer_custom:"Days",btn_generate:"Create payment request",btn_open_wallet:"Open in wallet",btn_copy_addr:"Copy address",btn_download_pdf:"PDF Invoice",pdf_title:"Payment Request",pdf_address:"XMR Address",pdf_amount:"Amount",pdf_desc:"Description",pdf_deadline:"Payment deadline",pdf_deadline_days:"{d} days",pdf_date:"Date",pdf_scan_qr:"Scan QR code to pay",pdf_footer:"Created with xmrpay.link \u2014 No registration, no KYC",qr_hint:"Click QR to save",footer:'Open Source · No Backend · No KYC · Source · Onion',aria_currency:"Currency",label_uri_details:"Show Monero URI",label_share_link:"Shareable link",btn_new_request:"New payment request",toast_copied:"Copied!",countdown_expired:"Payment deadline expired",countdown_remaining_days:"Deadline: {d} days, {h} hrs",countdown_remaining_hours:"Deadline: {h}:{m} hrs",rates_offline:"Rates unavailable \u2014 XMR amount only",btn_prove_payment:"Prove payment",label_tx_hash:"Transaction ID (TX Hash)",placeholder_tx_hash:"64 hex characters...",label_tx_key:"Transaction Key (TX Key)",placeholder_tx_key:"64 hex characters...",btn_verify_proof:"Verify payment",proof_verifying:"Verifying...",proof_verified:"Payment confirmed: {amount} XMR",proof_no_match:"No matching output found \u2014 TX key or address mismatch",proof_tx_not_found:"Transaction not found",proof_error:"Verification error",status_paid:"Paid"}},o="de";function u(){var e=null;try{e=localStorage.getItem("xmrpay_lang")}catch{}if(e&&i[e])return e;for(var n=navigator.languages||[navigator.language||"de"],t=0;t
- +
@@ -102,7 +102,7 @@
-

Open Source · No Backend · No KYC · Source

+

Open Source · No Backend · No KYC · Source · Onion