mirror of
https://github.com/Coldcard/push-tx.git
synced 2026-10-22 00:33:05 +00:00
fix: remediate DOM-based XSS in PushTX
- Refactor renderMessage to return HTMLElement and accept Node content - Add textMessage helper for plain-text messages - Replace innerHTML assignments with replaceChildren + DOM APIs - Stop reflecting raw network parameter in parseFragment error - Convert provider-error HTML construction to ProviderErrorsError class - Escape API-returned values in renderTxDetails via textContent - Add restrictive CSP meta tag to index.html - Rebuild website and single-file artifacts - Regenerate SHA256SUMS
This commit is contained in:
1 parent
7a9a47caa8
commit
e22edc2813
5 files changed
+231
-314
No files matched your search
@@ -1,14 +1,14 @@
|
||||
b9baf7ada4b80d2878b52ab0cf56f878aeb774aec62de88b8b02a168be82cbb5 ./index.html
|
||||
528961798b8f5db3f50d0770d3bc209fd71ae2c859c833696d7ac6106aa69ed1 ./build-single-file/index.html
|
||||
2b915af9a34ce84b58a6e1f276c574ed2abbfc31c1e84ee94cfa858666d075c2 ./package-lock.json
|
||||
0ae5bf24ae009f15406a324b68804f217feb526a54dd8258c921c0e881b47b7c ./package.json
|
||||
68df121854e628c7d84ee41b7d86875626cc342aa0c8b0f939af322eb4ba1723 ./tsconfig.json
|
||||
39c8001f6300c1ff63e29639a8b513fa888e61a58053a19716ed6df497a48ed8 ./build/index.html
|
||||
18920c92e08b5fc0b0a5d7ee575f08eecc1e47b4f1e8d892e8f17540072aac35 ./build/pushtx.js
|
||||
31ebc58b766680c1000cabd7b7da7eeb943aff58ebc805beba608e15ffc7a3f6 ./build/pushtx.css
|
||||
2ede67555dd622a2be580b3e15fdde6463413f63e79913f54faa75d819a4cc01 ./vite.config.ts
|
||||
2bdc9fe7c30746da1546442b83fb693357603f411df930e86c740f4ad79fc275 ./src/main.ts
|
||||
b41fd5552c271453ce7ee1c661e72495705e5da0e005828b17f4ad057ba91e87 ./src/types.ts
|
||||
65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5 ./src/vite-env.d.ts
|
||||
e5d5594f5d0a14fbe4b038073b9bc9d040343272a536c51c31612d3fb6fff5ac ./build-single-file/index.html
|
||||
6a2a7a9a445429aedd06173bf65c9d31e30256f0680d499f6b7cdc18a32e550b ./index.html
|
||||
8f16321bfc6b41c04c9c48d20b47cbd1cfac4b089a7b355ccbed371c59f8a096 ./src/main.ts
|
||||
4e6dd4e5d1689110a3645a7ee5f82fac8ec32d4aad8c00d906be60f64ebca678 ./src/style.css
|
||||
b41fd5552c271453ce7ee1c661e72495705e5da0e005828b17f4ad057ba91e87 ./src/types.ts
|
||||
54cc1fff898ecd3f437d82947889bbcab5f861904e61c9c1eea9f792a3f32582 ./src/config.ts
|
||||
65996936fbb042915f7b74a200fcdde7e410f32a669b1ab9597cfaa4b0faddb5 ./src/vite-env.d.ts
|
||||
68df121854e628c7d84ee41b7d86875626cc342aa0c8b0f939af322eb4ba1723 ./tsconfig.json
|
||||
2b915af9a34ce84b58a6e1f276c574ed2abbfc31c1e84ee94cfa858666d075c2 ./package-lock.json
|
||||
31ebc58b766680c1000cabd7b7da7eeb943aff58ebc805beba608e15ffc7a3f6 ./build/pushtx.css
|
||||
a02328217505d49c7fd0df58b7baf2d6a4c25d558d4952dc253c1d6bc0a97727 ./build/index.html
|
||||
3f0fbf0710fb7e682f57bbf1e2a60ee42f0c0b25c68776506ca7999017e64db3 ./build/pushtx.js
|
||||
0ae5bf24ae009f15406a324b68804f217feb526a54dd8258c921c0e881b47b7c ./package.json
|
||||
@@ -4,19 +4,23 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; connect-src https://mempool.space https://blockstream.info; img-src 'none'; font-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';"
|
||||
/>
|
||||
<title>COLDCARD NFC Push TX</title>
|
||||
<script type="module" crossorigin>var Ws=Object.defineProperty;var js=(e,t,r)=>t in e?Ws(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Zt=(e,t,r)=>js(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const s of c.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function n(i){if(i.ep)return;i.ep=!0;const c=r(i);fetch(i.href,c)}})();function Vs(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var lo={},se={},Vr={};Vr.byteLength=qs;Vr.toByteArray=Ys;Vr.fromByteArray=Zs;var $e=[],Pe=[],Gs=typeof Uint8Array<"u"?Uint8Array:Array,wn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Lt=0,Xs=wn.length;Lt<Xs;++Lt)$e[Lt]=wn[Lt],Pe[wn.charCodeAt(Lt)]=Lt;Pe[45]=62;Pe[95]=63;function yo(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function qs(e){var t=yo(e),r=t[0],n=t[1];return(r+n)*3/4-n}function zs(e,t,r){return(t+r)*3/4-r}function Ys(e){var t,r=yo(e),n=r[0],i=r[1],c=new Gs(zs(e,n,i)),s=0,a=i>0?n-4:n,p;for(p=0;p<a;p+=4)t=Pe[e.charCodeAt(p)]<<18|Pe[e.charCodeAt(p+1)]<<12|Pe[e.charCodeAt(p+2)]<<6|Pe[e.charCodeAt(p+3)],c[s++]=t>>16&255,c[s++]=t>>8&255,c[s++]=t&255;return i===2&&(t=Pe[e.charCodeAt(p)]<<2|Pe[e.charCodeAt(p+1)]>>4,c[s++]=t&255),i===1&&(t=Pe[e.charCodeAt(p)]<<10|Pe[e.charCodeAt(p+1)]<<4|Pe[e.charCodeAt(p+2)]>>2,c[s++]=t>>8&255,c[s++]=t&255),c}function Js(e){return $e[e>>18&63]+$e[e>>12&63]+$e[e>>6&63]+$e[e&63]}function Qs(e,t,r){for(var n,i=[],c=t;c<r;c+=3)n=(e[c]<<16&16711680)+(e[c+1]<<8&65280)+(e[c+2]&255),i.push(Js(n));return i.join("")}function Zs(e){for(var t,r=e.length,n=r%3,i=[],c=16383,s=0,a=r-n;s<a;s+=c)i.push(Qs(e,s,s+c>a?a:s+c));return n===1?(t=e[r-1],i.push($e[t>>2]+$e[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push($e[t>>10]+$e[t>>4&63]+$e[t<<2&63]+"=")),i.join("")}var Vn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Vn.read=function(e,t,r,n,i){var c,s,a=i*8-n-1,p=(1<<a)-1,w=p>>1,f=-7,d=r?i-1:0,S=r?-1:1,y=e[t+d];for(d+=S,c=y&(1<<-f)-1,y>>=-f,f+=a;f>0;c=c*256+e[t+d],d+=S,f-=8);for(s=c&(1<<-f)-1,c>>=-f,f+=n;f>0;s=s*256+e[t+d],d+=S,f-=8);if(c===0)c=1-w;else{if(c===p)return s?NaN:(y?-1:1)*(1/0);s=s+Math.pow(2,n),c=c-w}return(y?-1:1)*s*Math.pow(2,c-n)};Vn.write=function(e,t,r,n,i,c){var s,a,p,w=c*8-i-1,f=(1<<w)-1,d=f>>1,S=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:c-1,_=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-s))<1&&(s--,p*=2),s+d>=1?t+=S/p:t+=S*Math.pow(2,1-d),t*p>=2&&(s++,p/=2),s+d>=f?(a=0,s=f):s+d>=1?(a=(t*p-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+y]=a&255,y+=_,a/=256,i-=8);for(s=s<<i|a,w+=i;w>0;e[r+y]=s&255,y+=_,s/=256,w-=8);e[r+y-_]|=T*128};/*!
|
||||
<script type="module" crossorigin>var Gs=Object.defineProperty;var Xs=(e,t,r)=>t in e?Gs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Lt=(e,t,r)=>Xs(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const s of c.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function n(i){if(i.ep)return;i.ep=!0;const c=r(i);fetch(i.href,c)}})();function qs(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var wo={},se={},Gr={};Gr.byteLength=Js;Gr.toByteArray=Zs;Gr.fromByteArray=rc;var Me=[],Oe=[],zs=typeof Uint8Array<"u"?Uint8Array:Array,gn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Mt=0,Ys=gn.length;Mt<Ys;++Mt)Me[Mt]=gn[Mt],Oe[gn.charCodeAt(Mt)]=Mt;Oe[45]=62;Oe[95]=63;function go(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Js(e){var t=go(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Qs(e,t,r){return(t+r)*3/4-r}function Zs(e){var t,r=go(e),n=r[0],i=r[1],c=new zs(Qs(e,n,i)),s=0,a=i>0?n-4:n,p;for(p=0;p<a;p+=4)t=Oe[e.charCodeAt(p)]<<18|Oe[e.charCodeAt(p+1)]<<12|Oe[e.charCodeAt(p+2)]<<6|Oe[e.charCodeAt(p+3)],c[s++]=t>>16&255,c[s++]=t>>8&255,c[s++]=t&255;return i===2&&(t=Oe[e.charCodeAt(p)]<<2|Oe[e.charCodeAt(p+1)]>>4,c[s++]=t&255),i===1&&(t=Oe[e.charCodeAt(p)]<<10|Oe[e.charCodeAt(p+1)]<<4|Oe[e.charCodeAt(p+2)]>>2,c[s++]=t>>8&255,c[s++]=t&255),c}function ec(e){return Me[e>>18&63]+Me[e>>12&63]+Me[e>>6&63]+Me[e&63]}function tc(e,t,r){for(var n,i=[],c=t;c<r;c+=3)n=(e[c]<<16&16711680)+(e[c+1]<<8&65280)+(e[c+2]&255),i.push(ec(n));return i.join("")}function rc(e){for(var t,r=e.length,n=r%3,i=[],c=16383,s=0,a=r-n;s<a;s+=c)i.push(tc(e,s,s+c>a?a:s+c));return n===1?(t=e[r-1],i.push(Me[t>>2]+Me[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Me[t>>10]+Me[t>>4&63]+Me[t<<2&63]+"=")),i.join("")}var Gn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Gn.read=function(e,t,r,n,i){var c,s,a=i*8-n-1,p=(1<<a)-1,w=p>>1,f=-7,d=r?i-1:0,E=r?-1:1,y=e[t+d];for(d+=E,c=y&(1<<-f)-1,y>>=-f,f+=a;f>0;c=c*256+e[t+d],d+=E,f-=8);for(s=c&(1<<-f)-1,c>>=-f,f+=n;f>0;s=s*256+e[t+d],d+=E,f-=8);if(c===0)c=1-w;else{if(c===p)return s?NaN:(y?-1:1)*(1/0);s=s+Math.pow(2,n),c=c-w}return(y?-1:1)*s*Math.pow(2,c-n)};Gn.write=function(e,t,r,n,i,c){var s,a,p,w=c*8-i-1,f=(1<<w)-1,d=f>>1,E=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:c-1,_=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-s))<1&&(s--,p*=2),s+d>=1?t+=E/p:t+=E*Math.pow(2,1-d),t*p>=2&&(s++,p/=2),s+d>=f?(a=0,s=f):s+d>=1?(a=(t*p-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+y]=a&255,y+=_,a/=256,i-=8);for(s=s<<i|a,w+=i;w>0;e[r+y]=s&255,y+=_,s/=256,w-=8);e[r+y-_]|=T*128};/*!
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <https://feross.org>
|
||||
* @license MIT
|
||||
*/(function(e){const t=Vr,r=Vn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=f,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i;const{Uint8Array:c,ArrayBuffer:s,SharedArrayBuffer:a}=globalThis;f.TYPED_ARRAY_SUPPORT=p(),!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{const h=new c(1),o={foo:function(){return 42}};return Object.setPrototypeOf(o,c.prototype),Object.setPrototypeOf(h,o),h.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function w(h){if(h>i)throw new RangeError('The value "'+h+'" is invalid for option "size"');const o=new c(h);return Object.setPrototypeOf(o,f.prototype),o}function f(h,o,u){if(typeof h=="number"){if(typeof o=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(h)}return d(h,o,u)}f.poolSize=8192;function d(h,o,u){if(typeof h=="string")return T(h,o);if(s.isView(h))return x(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(Ue(h,s)||h&&Ue(h.buffer,s)||typeof a<"u"&&(Ue(h,a)||h&&Ue(h.buffer,a)))return N(h,o,u);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=h.valueOf&&h.valueOf();if(l!=null&&l!==h)return f.from(l,o,u);const g=k(h);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return f.from(h[Symbol.toPrimitive]("string"),o,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}f.from=function(h,o,u){return d(h,o,u)},Object.setPrototypeOf(f.prototype,c.prototype),Object.setPrototypeOf(f,c);function S(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function y(h,o,u){return S(h),h<=0?w(h):o!==void 0?typeof u=="string"?w(h).fill(o,u):w(h).fill(o):w(h)}f.alloc=function(h,o,u){return y(h,o,u)};function _(h){return S(h),w(h<0?0:m(h)|0)}f.allocUnsafe=function(h){return _(h)},f.allocUnsafeSlow=function(h){return _(h)};function T(h,o){if((typeof o!="string"||o==="")&&(o="utf8"),!f.isEncoding(o))throw new TypeError("Unknown encoding: "+o);const u=I(h,o)|0;let l=w(u);const g=l.write(h,o);return g!==u&&(l=l.slice(0,g)),l}function P(h){const o=h.length<0?0:m(h.length)|0,u=w(o);for(let l=0;l<o;l+=1)u[l]=h[l]&255;return u}function x(h){if(Ue(h,c)){const o=new c(h);return N(o.buffer,o.byteOffset,o.byteLength)}return P(h)}function N(h,o,u){if(o<0||h.byteLength<o)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<o+(u||0))throw new RangeError('"length" is outside of buffer bounds');let l;return o===void 0&&u===void 0?l=new c(h):u===void 0?l=new c(h,o):l=new c(h,o,u),Object.setPrototypeOf(l,f.prototype),l}function k(h){if(f.isBuffer(h)){const o=m(h.length)|0,u=w(o);return u.length===0||h.copy(u,0,0,o),u}if(h.length!==void 0)return typeof h.length!="number"||yn(h.length)?w(0):P(h);if(h.type==="Buffer"&&Array.isArray(h.data))return P(h.data)}function m(h){if(h>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return h|0}function v(h){return+h!=h&&(h=0),f.alloc(+h)}f.isBuffer=function(o){return o!=null&&o._isBuffer===!0&&o!==f.prototype},f.compare=function(o,u){if(Ue(o,c)&&(o=f.from(o,o.offset,o.byteLength)),Ue(u,c)&&(u=f.from(u,u.offset,u.byteLength)),!f.isBuffer(o)||!f.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(o===u)return 0;let l=o.length,g=u.length;for(let b=0,A=Math.min(l,g);b<A;++b)if(o[b]!==u[b]){l=o[b],g=u[b];break}return l<g?-1:g<l?1:0},f.isEncoding=function(o){switch(String(o).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(o,u){if(!Array.isArray(o))throw new TypeError('"list" argument must be an Array of Buffers');if(o.length===0)return f.alloc(0);let l;if(u===void 0)for(u=0,l=0;l<o.length;++l)u+=o[l].length;const g=f.allocUnsafe(u);let b=0;for(l=0;l<o.length;++l){let A=o[l];if(Ue(A,c))b+A.length>g.length?(f.isBuffer(A)||(A=f.from(A)),A.copy(g,b)):c.prototype.set.call(g,A,b);else if(f.isBuffer(A))A.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=A.length}return g};funcLine truncated
|
||||
*/(function(e){const t=Gr,r=Gn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=f,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i;const{Uint8Array:c,ArrayBuffer:s,SharedArrayBuffer:a}=globalThis;f.TYPED_ARRAY_SUPPORT=p(),!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{const h=new c(1),o={foo:function(){return 42}};return Object.setPrototypeOf(o,c.prototype),Object.setPrototypeOf(h,o),h.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function w(h){if(h>i)throw new RangeError('The value "'+h+'" is invalid for option "size"');const o=new c(h);return Object.setPrototypeOf(o,f.prototype),o}function f(h,o,u){if(typeof h=="number"){if(typeof o=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(h)}return d(h,o,u)}f.poolSize=8192;function d(h,o,u){if(typeof h=="string")return T(h,o);if(s.isView(h))return x(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(Ue(h,s)||h&&Ue(h.buffer,s)||typeof a<"u"&&(Ue(h,a)||h&&Ue(h.buffer,a)))return U(h,o,u);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=h.valueOf&&h.valueOf();if(l!=null&&l!==h)return f.from(l,o,u);const g=I(h);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return f.from(h[Symbol.toPrimitive]("string"),o,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}f.from=function(h,o,u){return d(h,o,u)},Object.setPrototypeOf(f.prototype,c.prototype),Object.setPrototypeOf(f,c);function E(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function y(h,o,u){return E(h),h<=0?w(h):o!==void 0?typeof u=="string"?w(h).fill(o,u):w(h).fill(o):w(h)}f.alloc=function(h,o,u){return y(h,o,u)};function _(h){return E(h),w(h<0?0:S(h)|0)}f.allocUnsafe=function(h){return _(h)},f.allocUnsafeSlow=function(h){return _(h)};function T(h,o){if((typeof o!="string"||o==="")&&(o="utf8"),!f.isEncoding(o))throw new TypeError("Unknown encoding: "+o);const u=k(h,o)|0;let l=w(u);const g=l.write(h,o);return g!==u&&(l=l.slice(0,g)),l}function A(h){const o=h.length<0?0:S(h.length)|0,u=w(o);for(let l=0;l<o;l+=1)u[l]=h[l]&255;return u}function x(h){if(Ue(h,c)){const o=new c(h);return U(o.buffer,o.byteOffset,o.byteLength)}return A(h)}function U(h,o,u){if(o<0||h.byteLength<o)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<o+(u||0))throw new RangeError('"length" is outside of buffer bounds');let l;return o===void 0&&u===void 0?l=new c(h):u===void 0?l=new c(h,o):l=new c(h,o,u),Object.setPrototypeOf(l,f.prototype),l}function I(h){if(f.isBuffer(h)){const o=S(h.length)|0,u=w(o);return u.length===0||h.copy(u,0,0,o),u}if(h.length!==void 0)return typeof h.length!="number"||wn(h.length)?w(0):A(h);if(h.type==="Buffer"&&Array.isArray(h.data))return A(h.data)}function S(h){if(h>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return h|0}function v(h){return+h!=h&&(h=0),f.alloc(+h)}f.isBuffer=function(o){return o!=null&&o._isBuffer===!0&&o!==f.prototype},f.compare=function(o,u){if(Ue(o,c)&&(o=f.from(o,o.offset,o.byteLength)),Ue(u,c)&&(u=f.from(u,u.offset,u.byteLength)),!f.isBuffer(o)||!f.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(o===u)return 0;let l=o.length,g=u.length;for(let b=0,P=Math.min(l,g);b<P;++b)if(o[b]!==u[b]){l=o[b],g=u[b];break}return l<g?-1:g<l?1:0},f.isEncoding=function(o){switch(String(o).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(o,u){if(!Array.isArray(o))throw new TypeError('"list" argument must be an Array of Buffers');if(o.length===0)return f.alloc(0);let l;if(u===void 0)for(u=0,l=0;l<o.length;++l)u+=o[l].length;const g=f.allocUnsafe(u);let b=0;for(l=0;l<o.length;++l){let P=o[l];if(Ue(P,c))b+P.length>g.length?(f.isBuffer(P)||(P=f.from(P)),P.copy(g,b)):c.prototype.set.call(g,P,b);else if(f.isBuffer(P))P.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=P.length}return g};funcLine truncated
|
||||
`,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128};ae.regtest={messagePrefix:`Bitcoin Signed Message:
|
||||
`,bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};ae.testnet={messagePrefix:`Bitcoin Signed Message:
|
||||
`,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var gn={},Gr={},En={},ze={};Object.defineProperty(ze,"__esModule",{value:!0});ze.encode=ze.decode=ze.check=void 0;function gc(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}ze.check=gc;function Ec(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}ze.decode=Ec;function mc(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=E.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i}ze.encode=mc;var ft={};Object.defineProperty(ft,"__esModule",{value:!0});ft.REVERSE_OPS=ft.OPS=void 0;const Fn={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};ft.OPS=Fn;const go={};ft.REVERSE_OPS=go;for(const e of Object.keys(Fn)){const t=Fn[e];go[t]=e}var ut={};Object.defineProperty(ut,"__esModule",{value:!0});ut.decode=ut.encode=ut.encodingLength=void 0;const ct=ft;function Eo(e){return e<ct.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}ut.encodingLength=Eo;function Sc(e,t,r){const n=Eo(t);return n===1?e.writeUInt8(t,r):n===2?(e.writeUInt8(ct.OPS.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):n===3?(e.writeUInt8(ct.OPS.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(ct.OPS.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),n}ut.encode=Sc;function bc(e,t){const r=e.readUInt8(t);let n,i;if(r<ct.OPS.OP_PUSHDATA1)n=r,i=1;else if(r===ct.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;n=e.readUInt8(t+1),i=2}else if(r===ct.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;n=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(r!==ct.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=e.readUInt32LE(t+1),i=5}return{opcode:r,number:n,size:i}}ut.decode=bc;var zt={};Object.defineProperty(zt,"__esModule",{value:!0});zt.encode=zt.decode=void 0;function _c(e,t,r){t=t||4,r=r===void 0?!0:r;const n=e.length;if(n===0)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&!(e[n-1]&127)&&(n<=1||Line truncated
|
||||
`,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var mn={},Xr={},En={},ze={};Object.defineProperty(ze,"__esModule",{value:!0});ze.encode=ze.decode=ze.check=void 0;function Sc(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}ze.check=Sc;function bc(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}ze.decode=bc;function _c(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=m.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i}ze.encode=_c;var ft={};Object.defineProperty(ft,"__esModule",{value:!0});ft.REVERSE_OPS=ft.OPS=void 0;const Ln={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};ft.OPS=Ln;const Eo={};ft.REVERSE_OPS=Eo;for(const e of Object.keys(Ln)){const t=Ln[e];Eo[t]=e}var ut={};Object.defineProperty(ut,"__esModule",{value:!0});ut.decode=ut.encode=ut.encodingLength=void 0;const ct=ft;function So(e){return e<ct.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}ut.encodingLength=So;function Tc(e,t,r){const n=So(t);return n===1?e.writeUInt8(t,r):n===2?(e.writeUInt8(ct.OPS.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):n===3?(e.writeUInt8(ct.OPS.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(ct.OPS.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),n}ut.encode=Tc;function Ic(e,t){const r=e.readUInt8(t);let n,i;if(r<ct.OPS.OP_PUSHDATA1)n=r,i=1;else if(r===ct.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;n=e.readUInt8(t+1),i=2}else if(r===ct.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;n=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(r!==ct.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=e.readUInt32LE(t+1),i=5}return{opcode:r,number:n,size:i}}ut.decode=Ic;var zt={};Object.defineProperty(zt,"__esModule",{value:!0});zt.encode=zt.decode=void 0;function kc(e,t,r){t=t||4,r=r===void 0?!0:r;const n=e.length;if(n===0)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&!(e[n-1]&127)&&(n<=1||Line truncated
|
||||
*********************
|
||||
PROCEED WITH CAUTION!
|
||||
*********************`),a=c.hashForSignature(e,w,s)}return{script:w,sighashType:s,hash:a}}function yh(e,t,r,n){const i=[];if(t.tapInternalKey){const s=_s(e,t,n);s&&i.push(s)}if(t.tapScriptSig){const s=t.tapScriptSig.map(a=>a.pubkey);i.push(...s)}return i.map(s=>Wn(e,t,r,s,n)).flat()}function _s(e,t,r){const{script:n}=wi(e,t,r);return(0,re.isP2TR)(n)?n.subarray(2,34):null}function fo(e){return e.length===64?e:e.subarray(0,64)}function Wn(e,t,r,n,i,c,s){const a=i.__TX,p=t.sighashType||we.Transaction.SIGHASH_DEFAULT;Ts(p,s);const w=r.map((_,T)=>wi(T,_,i)),f=w.map(_=>_.script),d=w.map(_=>_.value),S=[];if(t.tapInternalKey&&!c){const _=_s(e,t,i)||E.from([]);if((0,J.toXOnly)(n).equals(_)){const T=a.hashForWitnessV1(e,f,d,p);S.push({pubkey:n,hash:T})}}const y=(t.tapLeafScript||[]).filter(_=>(0,re.pubkeyInScript)(n,_.script)).map(_=>{const T=(0,oh.tapleafHash)({output:_.script,version:_.leafVersion});return Object.assign({hash:T},_)}).filter(_=>!c||c.equals(_.hash)).map(_=>{const T=a.hashForWitnessV1(e,f,d,p,_.hash);return{pubkey:n,hash:T,leafHash:_.hash}});return S.concat(y)}function Ts(e,t){if(t&&t.indexOf(e)<0){const r=mh(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function wh(e,t,r){let n;switch(t){case"multisig":const i=Eh(e,r);n=ve.p2ms({output:e,signatures:i});break;case"pubkey":n=ve.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=ve.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=ve.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function gh(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const c=fn(r,t,e),s=n.ins[e].index;i.script=c.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||(0,re.isP2WPKH)(i.script))&&(i.isSegwit=!0),i}function ho(e,t,r){const n=(0,Se.checkForInput)(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(s=>{if(s.masterFingerprint.equals(r.fingerprint))return s}).filter(s=>!!s);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(s=>{const a=r.derivePath(s.path);if(!s.pubkey.equals(a.publicKey))throw new Error("pubkey did not match bip32Derivation");return a})}function Eh(e,t){return ve.p2ms({output:e}).pubkeys.map(n=>(t.filter(i=>i.pubkey.equals(n))[0]||{}).signature).filter(n=>!!n)}function Is(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=ro.decode(e,t);return t+=ro.decode.bytes,s}function i(){return r(n())}function c(){const s=n(),a=[];for(let p=0;p<s;p++)a.push(i());return a}return c()}function mh(e){let t=e&we.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case we.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case we.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case we.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function jn(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=we.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,c=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const s=i.__NON_WITNESS_UTXO_BUF_CACHE[c],a=i.__NON_WITNESS_UTXO_TX_CACHE[c];if(s!==void 0)return s;{const p=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[c]=p,p}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[c]=s}})}function ks(e,t,r,n){let i=0;e.forEach((p,w)=>{if(n&&p.finalScriptSig&&(t.ins[w].script=p.finalScriptSig),n&&p.finalScriptWitness&&(t.ins[w].witness=Is(p.finalScriptWitness)),p.witnessUtxo)i+=p.witnessUtxo.value;else if(p.nonWitnessUtxo){const f=fn(r,p,w),d=t.ins[w].index,S=f.outs[d];i+=S.value}});const c=t.outs.reduce((p,w)=>p+w.value,0),s=i-c;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(s/a)}function fn(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||jn(e,t,r),n[r]}function As(e,t,r){const{script:n}=wi(e,t,r);return n}function wi(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const i=fn(r,t,e).outs[r.__TX.ins[e].index];return{script:i.script,value:i.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function Sh(e,t,r,n){const i=As(r,t,n),{meaningfulScript:c}=hn(i,r,"input",t.redeemScript,t.witnessScript);return(0,re.pubkeyInScript)(e,c)}function bh(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:c}=hn(i,r,"output",t.redeemScript,t.witnessScript);return(0,re.pubkeyInScript)(e,c)}function _h(e){if(!e)return;const t=Ye.decompile(e);if(!tLine truncated
|
||||
*********************`),a=c.hashForSignature(e,w,s)}return{script:w,sighashType:s,hash:a}}function mh(e,t,r,n){const i=[];if(t.tapInternalKey){const s=Is(e,t,n);s&&i.push(s)}if(t.tapScriptSig){const s=t.tapScriptSig.map(a=>a.pubkey);i.push(...s)}return i.map(s=>jn(e,t,r,s,n)).flat()}function Is(e,t,r){const{script:n}=gi(e,t,r);return(0,re.isP2TR)(n)?n.subarray(2,34):null}function ho(e){return e.length===64?e:e.subarray(0,64)}function jn(e,t,r,n,i,c,s){const a=i.__TX,p=t.sighashType||we.Transaction.SIGHASH_DEFAULT;ks(p,s);const w=r.map((_,T)=>gi(T,_,i)),f=w.map(_=>_.script),d=w.map(_=>_.value),E=[];if(t.tapInternalKey&&!c){const _=Is(e,t,i)||m.from([]);if((0,J.toXOnly)(n).equals(_)){const T=a.hashForWitnessV1(e,f,d,p);E.push({pubkey:n,hash:T})}}const y=(t.tapLeafScript||[]).filter(_=>(0,re.pubkeyInScript)(n,_.script)).map(_=>{const T=(0,uh.tapleafHash)({output:_.script,version:_.leafVersion});return Object.assign({hash:T},_)}).filter(_=>!c||c.equals(_.hash)).map(_=>{const T=a.hashForWitnessV1(e,f,d,p,_.hash);return{pubkey:n,hash:T,leafHash:_.hash}});return E.concat(y)}function ks(e,t){if(t&&t.indexOf(e)<0){const r=_h(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function Eh(e,t,r){let n;switch(t){case"multisig":const i=bh(e,r);n=ve.p2ms({output:e,signatures:i});break;case"pubkey":n=ve.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=ve.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=ve.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function Sh(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const c=hn(r,t,e),s=n.ins[e].index;i.script=c.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||(0,re.isP2WPKH)(i.script))&&(i.isSegwit=!0),i}function po(e,t,r){const n=(0,Se.checkForInput)(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(s=>{if(s.masterFingerprint.equals(r.fingerprint))return s}).filter(s=>!!s);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(s=>{const a=r.derivePath(s.path);if(!s.pubkey.equals(a.publicKey))throw new Error("pubkey did not match bip32Derivation");return a})}function bh(e,t){return ve.p2ms({output:e}).pubkeys.map(n=>(t.filter(i=>i.pubkey.equals(n))[0]||{}).signature).filter(n=>!!n)}function As(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=no.decode(e,t);return t+=no.decode.bytes,s}function i(){return r(n())}function c(){const s=n(),a=[];for(let p=0;p<s;p++)a.push(i());return a}return c()}function _h(e){let t=e&we.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case we.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case we.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case we.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function Vn(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=we.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,c=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const s=i.__NON_WITNESS_UTXO_BUF_CACHE[c],a=i.__NON_WITNESS_UTXO_TX_CACHE[c];if(s!==void 0)return s;{const p=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[c]=p,p}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[c]=s}})}function Ps(e,t,r,n){let i=0;e.forEach((p,w)=>{if(n&&p.finalScriptSig&&(t.ins[w].script=p.finalScriptSig),n&&p.finalScriptWitness&&(t.ins[w].witness=As(p.finalScriptWitness)),p.witnessUtxo)i+=p.witnessUtxo.value;else if(p.nonWitnessUtxo){const f=hn(r,p,w),d=t.ins[w].index,E=f.outs[d];i+=E.value}});const c=t.outs.reduce((p,w)=>p+w.value,0),s=i-c;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(s/a)}function hn(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Vn(e,t,r),n[r]}function Os(e,t,r){const{script:n}=gi(e,t,r);return n}function gi(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const i=hn(r,t,e).outs[r.__TX.ins[e].index];return{script:i.script,value:i.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function Th(e,t,r,n){const i=Os(r,t,n),{meaningfulScript:c}=pn(i,r,"input",t.redeemScript,t.witnessScript);return(0,re.pubkeyInScript)(e,c)}function Ih(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:c}=pn(i,r,"output",t.redeemScript,t.witnessScript);return(0,re.pubkeyInScript)(e,c)}function kh(e){if(!e)return;const t=Ye.decompile(e);if(!tLine truncated
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
|
||||
<path d="m10.97 4.97-.02.022-3.473 4.425-2.093-2.094a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05"/>
|
||||
@@ -32,90 +36,7 @@ PROCEED WITH CAUTION!
|
||||
<svg class="pushtx-spin" width="32" height="32" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle style="opacity: 0.25;" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>`};async function dr(e){try{return[null,await e]}catch(t){return t instanceof Error?[t,null]:typeof t=="string"?[new Error(t),null]:[new Error,null]}}function po(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),r=atob(t);return new Uint8Array([...r].map(n=>n.charCodeAt(0)))}class Bs extends Error{constructor(r,n,i,c){super();Zt(this,"url");Zt(this,"status");Zt(this,"statusText");Zt(this,"body");this.url=r,this.name="FetchStatusError",this.status=n,this.statusText=i,this.body=c}}const xs=async(e,t)=>{const r=await fetch(e,t);if(!r.ok){const[n,i]=await dr(r.text());throw new Bs(e.toString(),r.status,r.statusText,i)}return r};async function Ph(e,t){if(t!=="BTC"&&t!=="XTN")throw new Error("Unsupported network: "+t);const n=vs[t].map(s=>xs(s,{method:"POST",body:e.toHex()})),[i,c]=await dr(Promise.any(n).then(s=>s.text()));if(c)return c;if(i instanceof AggregateError){const s=i.errors.filter(a=>a instanceof Bs);if(s.length>0){let a=`
|
||||
<p>The transaction was rejected by all providers:</p>
|
||||
|
||||
<ul>
|
||||
`;throw s.forEach(p=>{a+=`<li>${p.url}: ${p.body}</li>`}),a+="</ul>",new Error(a)}}throw new Error("<p>Could not connect to any push servers. Make sure you are connected to the Internet and try again.</p>")}async function vh(e){e[0]==="#"&&(e=e.slice(1));const t=new URLSearchParams(e),r=t.get("t"),n=t.get("c"),i=t.get("n")||"BTC";if(!r)throw new Error("Invalid URL - missing transaction.");if(!n||n.length!==11)throw new Error("Invalid URL - missing or incomplete checksum. The URL is probably truncated");let c;if(i==="BTC"||i==="XTN")c=i;else throw i==="XRT"?new Error("Regtest transactions are not supported."):new Error(`Invalid URL. The network "${i}" is not recognized.`);let s,a;try{s=po(r),a=po(n)}catch{throw new Error("Invalid URL encoding. The URL is probably corrupted.")}const p=new Uint8Array(await crypto.subtle.digest("SHA-256",s));if(!a.every((f,d)=>f===p[d+24]))throw new Error("Checksum mismatch in URL. Some bytes corrupted in transit. Try again.");return{tx:lo.Transaction.fromBuffer(wo.from(s)),network:c}}async function Bh(e,t){if(t!=="BTC"&&t!=="XTN")throw new Error("Unsupported network: "+t);const n=vs[t].map(i=>xs(i+"/"+e).then(c=>c.json()));return await Promise.any(n)}function xh(e){const t=e.vin.map(n=>`
|
||||
<tr>
|
||||
<td>
|
||||
<span class="address">
|
||||
<span>${n.prevout.scriptpubkey_address.slice(0,-8)}</span>
|
||||
<span>${n.prevout.scriptpubkey_address.slice(-8)}</span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="value">${(n.prevout.value/1e8).toFixed(8)}</span>
|
||||
</td>
|
||||
</tr>
|
||||
`).join(""),r=e.vout.map(n=>`
|
||||
<tr>
|
||||
<td>
|
||||
<span class="address">
|
||||
<span>${n.scriptpubkey_address.slice(0,-8)}</span>
|
||||
<span>${n.scriptpubkey_address.slice(-8)}</span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="value">${(n.value/1e8).toFixed(8)}</span>
|
||||
</td>
|
||||
</tr>
|
||||
`).join("");return`
|
||||
<div class="pushtx-details">
|
||||
<div class="inputs">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Inputs</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${t}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="outputs">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Outputs</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
${r}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="fee">
|
||||
<strong>Fee:</strong> <span class="value">${(e.fee/1e8).toFixed(8)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`}function Kt(e,t){const r=Oh[e];return`
|
||||
<div class="pushtx-message pushtx-message--${e}" role="alert">
|
||||
${r}
|
||||
<div>${t}</div>
|
||||
</div>
|
||||
`}async function Us(){const e=document.querySelector(".pushtx-message-area"),t=document.querySelector(".pushtx-details-area");if(!e||!t)throw new Error("Need message and details areas in HTML.");if(e.innerHTML="",t.innerHTML="",!window.location.hash){const S=`
|
||||
<p><strong>Did you get here by accident?</strong></p>
|
||||
<p>
|
||||
This page is meant to be loaded together with transaction data using the
|
||||
<strong>COLDCARD NFC Push TX feature</strong>. The complete URL should look something like this (but longer):
|
||||
</p>
|
||||
|
||||
<p><code>${window.location.origin+window.location.pathname}#t=AgAAAAMNCxXtp2GVYVhkRXHLMmdZFs4p3kbFK ⋯ ABf&c=uiSVRda-1tw</code></p>
|
||||
`;e.innerHTML=Kt("info",S);return}e.innerHTML=Kt("progress","Sending transaction, please wait...");const[r,n]=await dr(vh(window.location.hash));if(r){e.innerHTML=Kt("error",r.message);return}const{tx:i,network:c}=n,s=i.getId(),[a,p]=await dr(Ph(i,c)),[w,f]=await dr(Bh(s,c));if(p||f){const d=f!=null&&f.status.confirmed?"This transaction has already been confirmed.":"The transaction has been sent and is waiting to be confirmed.",S=Ah[c].map(([y,_])=>`<li><a href="${_}${s}" target="_blank" rel="noopener">${y}</a></li>`).join("");e.innerHTML=Kt("success",`<p>${d} Transaction ID:</p>
|
||||
|
||||
<p class="txid">${s}</p>
|
||||
|
||||
<p>Verify on a block explorer:</p>
|
||||
|
||||
<ul>${S}</ul>
|
||||
`),f&&(t.innerHTML=xh(f));return}if(a&&w)e.innerHTML=Kt("error",a.message);else if(w){e.innerHTML=Kt("error",w.message);return}}Us();window.addEventListener("hashchange",Us);
|
||||
</svg>`};async function lr(e){try{return[null,await e]}catch(t){return t instanceof Error?[t,null]:typeof t=="string"?[new Error(t),null]:[new Error,null]}}function lo(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),r=atob(t);return new Uint8Array([...r].map(n=>n.charCodeAt(0)))}class Us extends Error{constructor(r,n,i,c){super();Lt(this,"url");Lt(this,"status");Lt(this,"statusText");Lt(this,"body");this.url=r,this.name="FetchStatusError",this.status=n,this.statusText=i,this.body=c}}class Cs extends Error{constructor(r){super("The transaction was rejected by all providers.");Lt(this,"details");this.details=r}}const Ns=async(e,t)=>{const r=await fetch(e,t);if(!r.ok){const[n,i]=await lr(r.text());throw new Us(e.toString(),r.status,r.statusText,i)}return r};async function xh(e,t){if(t!=="BTC"&&t!=="XTN")throw new Error("Unsupported network: "+t);const n=xs[t].map(s=>Ns(s,{method:"POST",body:e.toHex()})),[i,c]=await lr(Promise.any(n).then(s=>s.text()));if(c)return c;if(i instanceof AggregateError){const s=i.errors.filter(a=>a instanceof Us);if(s.length>0)throw new Cs(s.map(a=>({url:a.url,body:a.body})))}throw new Error("Could not connect to any push servers. Make sure you are connected to the Internet and try again.")}async function Uh(e){e[0]==="#"&&(e=e.slice(1));const t=new URLSearchParams(e),r=t.get("t"),n=t.get("c"),i=t.get("n")||"BTC";if(!r)throw new Error("Invalid URL - missing transaction.");if(!n||n.length!==11)throw new Error("Invalid URL - missing or incomplete checksum. The URL is probably truncated");let c;if(i==="BTC"||i==="XTN")c=i;else throw i==="XRT"?new Error("Regtest transactions are not supported."):new Error("Invalid URL. The network parameter is not recognized.");let s,a;try{s=lo(r),a=lo(n)}catch{throw new Error("Invalid URL encoding. The URL is probably corrupted.")}const p=new Uint8Array(await crypto.subtle.digest("SHA-256",s));if(!a.every((f,d)=>f===p[d+24]))throw new Error("Checksum mismatch in URL. Some bytes corrupted in transit. Try again.");return{tx:wo.Transaction.fromBuffer(mo.from(s)),network:c}}async function Ch(e,t){if(t!=="BTC"&&t!=="XTN")throw new Error("Unsupported network: "+t);const n=xs[t].map(i=>Ns(i+"/"+e).then(c=>c.json()));return await Promise.any(n)}function yo(e,t){const r=document.createElement("tr"),n=document.createElement("td"),i=document.createElement("span");i.className="address";const c=document.createElement("span");c.textContent=e.slice(0,-8);const s=document.createElement("span");s.textContent=e.slice(-8),i.appendChild(c),i.appendChild(s),n.appendChild(i),r.appendChild(n);const a=document.createElement("td"),p=document.createElement("span");return p.className="value",p.textContent=(t/1e8).toFixed(8),a.appendChild(p),r.appendChild(a),r}function Nh(e){const t=document.createElement("div");t.className="pushtx-details";const r=(p,w)=>{const f=document.createElement("div"),d=document.createElement("table"),E=document.createElement("thead"),y=document.createElement("tr"),_=document.createElement("th");_.textContent=p;const T=document.createElement("th");y.appendChild(_),y.appendChild(T),E.appendChild(y),d.appendChild(E);const A=document.createElement("tbody");return w.forEach(x=>A.appendChild(x)),d.appendChild(A),f.appendChild(d),f},n=e.vin.map(p=>yo(p.prevout.scriptpubkey_address,p.prevout.value));t.appendChild(r("Inputs",n));const i=e.vout.map(p=>yo(p.scriptpubkey_address,p.value));t.appendChild(r("Outputs",i));const c=document.createElement("div");c.className="fee";const s=document.createElement("strong");s.textContent="Fee:";const a=document.createElement("span");return a.className="value",a.textContent=(e.fee/1e8).toFixed(8),c.appendChild(s),c.appendChild(document.createTextNode(" ")),c.appendChild(a),t.appendChild(c),t}function Fr(e,t){const r=document.createElement("div");r.className=`pushtx-message pushtx-message--${e}`,r.setAttribute("role","alert");const n=document.createElement("div");n.innerHTML=Bh[e],r.appendChild(n);const i=document.createElement("div");return i.appendChild(t),r.appendChild(i),r}function xr(e,t){const r=document.createDocumentFragment();return r.appendChild(document.createTextNode(t)),Fr(e,r)}async function Hs(){const e=document.querySelector(".pushtx-message-area"),t=document.querySelector(".pushtx-details-area");if(!e||!t)throw new Error("Need message and details areas in HTML.");if(e.replaceChildren(),t.replaceChildren(),!window.location.hash){const d=window.location.origin+window.location.pathname,E=document.createDocumentFragment(),y=document.createElement("p"),_=document.createElement("strong");_.textContent="Did you get here by accident?",y.appendChild(_),E.appendChild(y);const T=document.createElement("p");T.textContent="This page is meant to be loaded together with transaction data using the ";const A=document.createElement("strong");A.textContent="COLDCARD NFC Push TX feature",T.appendChild(A),T.appendChild(document.createTextNode(". The complete URL should look something like Line truncated
|
||||
</script>
|
||||
<style rel="stylesheet" crossorigin>.pushtx *{margin:0;padding:0;box-sizing:border-box;color:inherit!important}.pushtx ul{list-style-position:inside}.pushtx .monospace{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.pushtx-spin{animation:spin 1s linear infinite}.pushtx-message{display:flex;gap:1rem;padding:1rem;border:1px solid transparent;border-radius:.25rem;width:100%}.pushtx-message>:first-child{flex-shrink:0}.pushtx-message>:last-child{overflow:hidden;overflow-wrap:break-word;display:flex;flex-direction:column;gap:.5rem}.pushtx-message--success{color:#155724;background-color:#d4edda;border-color:#c3e6cb}.pushtx-message--info{color:#0c5460;background-color:#d1ecf1;border-color:#bee5eb}.pushtx-message--progress{color:#004085;background-color:#cce5ff;border-color:#b8daff}.pushtx-message--error{color:#721c24;background-color:#f8d7da;border-color:#f5c6cb}.pushtx-message .txid{font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:.875em;font-weight:700}.pushtx-details{display:flex;flex-direction:column;margin-block:2rem;padding:.5rem;border-radius:.25rem;overflow:hidden;gap:.5rem;border:1px solid #e2e8f0}.pushtx-details table{border-collapse:collapse;width:100%}.pushtx-details th{text-align:left}.pushtx-details :is(th,td){border-width:0px;padding-block:.125rem}.pushtx-details :is(td:first-child,th:first-child){width:75%;max-width:0px}.pushtx-details :is(td:last-child,th:last-child){text-align:right}.pushtx-details :is(.address,.value){font-family:SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.pushtx-details .address{display:flex;padding-right:1em}.pushtx-details .address :first-child{overflow:hidden;text-overflow:ellipsis}.pushtx-details .fee{text-align:right}
|
||||
</style>
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
var Ws=Object.defineProperty;var js=(e,t,r)=>t in e?Ws(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Zt=(e,t,r)=>js(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const s of c.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function n(i){if(i.ep)return;i.ep=!0;const c=r(i);fetch(i.href,c)}})();function Vs(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var lo={},se={},Vr={};Vr.byteLength=qs;Vr.toByteArray=Ys;Vr.fromByteArray=Zs;var $e=[],Pe=[],Gs=typeof Uint8Array<"u"?Uint8Array:Array,wn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Lt=0,Xs=wn.length;Lt<Xs;++Lt)$e[Lt]=wn[Lt],Pe[wn.charCodeAt(Lt)]=Lt;Pe[45]=62;Pe[95]=63;function yo(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function qs(e){var t=yo(e),r=t[0],n=t[1];return(r+n)*3/4-n}function zs(e,t,r){return(t+r)*3/4-r}function Ys(e){var t,r=yo(e),n=r[0],i=r[1],c=new Gs(zs(e,n,i)),s=0,a=i>0?n-4:n,p;for(p=0;p<a;p+=4)t=Pe[e.charCodeAt(p)]<<18|Pe[e.charCodeAt(p+1)]<<12|Pe[e.charCodeAt(p+2)]<<6|Pe[e.charCodeAt(p+3)],c[s++]=t>>16&255,c[s++]=t>>8&255,c[s++]=t&255;return i===2&&(t=Pe[e.charCodeAt(p)]<<2|Pe[e.charCodeAt(p+1)]>>4,c[s++]=t&255),i===1&&(t=Pe[e.charCodeAt(p)]<<10|Pe[e.charCodeAt(p+1)]<<4|Pe[e.charCodeAt(p+2)]>>2,c[s++]=t>>8&255,c[s++]=t&255),c}function Js(e){return $e[e>>18&63]+$e[e>>12&63]+$e[e>>6&63]+$e[e&63]}function Qs(e,t,r){for(var n,i=[],c=t;c<r;c+=3)n=(e[c]<<16&16711680)+(e[c+1]<<8&65280)+(e[c+2]&255),i.push(Js(n));return i.join("")}function Zs(e){for(var t,r=e.length,n=r%3,i=[],c=16383,s=0,a=r-n;s<a;s+=c)i.push(Qs(e,s,s+c>a?a:s+c));return n===1?(t=e[r-1],i.push($e[t>>2]+$e[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push($e[t>>10]+$e[t>>4&63]+$e[t<<2&63]+"=")),i.join("")}var Vn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Vn.read=function(e,t,r,n,i){var c,s,a=i*8-n-1,p=(1<<a)-1,w=p>>1,f=-7,d=r?i-1:0,S=r?-1:1,y=e[t+d];for(d+=S,c=y&(1<<-f)-1,y>>=-f,f+=a;f>0;c=c*256+e[t+d],d+=S,f-=8);for(s=c&(1<<-f)-1,c>>=-f,f+=n;f>0;s=s*256+e[t+d],d+=S,f-=8);if(c===0)c=1-w;else{if(c===p)return s?NaN:(y?-1:1)*(1/0);s=s+Math.pow(2,n),c=c-w}return(y?-1:1)*s*Math.pow(2,c-n)};Vn.write=function(e,t,r,n,i,c){var s,a,p,w=c*8-i-1,f=(1<<w)-1,d=f>>1,S=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:c-1,_=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-s))<1&&(s--,p*=2),s+d>=1?t+=S/p:t+=S*Math.pow(2,1-d),t*p>=2&&(s++,p/=2),s+d>=f?(a=0,s=f):s+d>=1?(a=(t*p-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+y]=a&255,y+=_,a/=256,i-=8);for(s=s<<i|a,w+=i;w>0;e[r+y]=s&255,y+=_,s/=256,w-=8);e[r+y-_]|=T*128};/*!
|
||||
var Gs=Object.defineProperty;var Xs=(e,t,r)=>t in e?Gs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Lt=(e,t,r)=>Xs(e,typeof t!="symbol"?t+"":t,r);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const s of c.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function n(i){if(i.ep)return;i.ep=!0;const c=r(i);fetch(i.href,c)}})();function qs(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var wo={},se={},Gr={};Gr.byteLength=Js;Gr.toByteArray=Zs;Gr.fromByteArray=rc;var Me=[],Oe=[],zs=typeof Uint8Array<"u"?Uint8Array:Array,gn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var Mt=0,Ys=gn.length;Mt<Ys;++Mt)Me[Mt]=gn[Mt],Oe[gn.charCodeAt(Mt)]=Mt;Oe[45]=62;Oe[95]=63;function go(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function Js(e){var t=go(e),r=t[0],n=t[1];return(r+n)*3/4-n}function Qs(e,t,r){return(t+r)*3/4-r}function Zs(e){var t,r=go(e),n=r[0],i=r[1],c=new zs(Qs(e,n,i)),s=0,a=i>0?n-4:n,p;for(p=0;p<a;p+=4)t=Oe[e.charCodeAt(p)]<<18|Oe[e.charCodeAt(p+1)]<<12|Oe[e.charCodeAt(p+2)]<<6|Oe[e.charCodeAt(p+3)],c[s++]=t>>16&255,c[s++]=t>>8&255,c[s++]=t&255;return i===2&&(t=Oe[e.charCodeAt(p)]<<2|Oe[e.charCodeAt(p+1)]>>4,c[s++]=t&255),i===1&&(t=Oe[e.charCodeAt(p)]<<10|Oe[e.charCodeAt(p+1)]<<4|Oe[e.charCodeAt(p+2)]>>2,c[s++]=t>>8&255,c[s++]=t&255),c}function ec(e){return Me[e>>18&63]+Me[e>>12&63]+Me[e>>6&63]+Me[e&63]}function tc(e,t,r){for(var n,i=[],c=t;c<r;c+=3)n=(e[c]<<16&16711680)+(e[c+1]<<8&65280)+(e[c+2]&255),i.push(ec(n));return i.join("")}function rc(e){for(var t,r=e.length,n=r%3,i=[],c=16383,s=0,a=r-n;s<a;s+=c)i.push(tc(e,s,s+c>a?a:s+c));return n===1?(t=e[r-1],i.push(Me[t>>2]+Me[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Me[t>>10]+Me[t>>4&63]+Me[t<<2&63]+"=")),i.join("")}var Gn={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Gn.read=function(e,t,r,n,i){var c,s,a=i*8-n-1,p=(1<<a)-1,w=p>>1,f=-7,d=r?i-1:0,E=r?-1:1,y=e[t+d];for(d+=E,c=y&(1<<-f)-1,y>>=-f,f+=a;f>0;c=c*256+e[t+d],d+=E,f-=8);for(s=c&(1<<-f)-1,c>>=-f,f+=n;f>0;s=s*256+e[t+d],d+=E,f-=8);if(c===0)c=1-w;else{if(c===p)return s?NaN:(y?-1:1)*(1/0);s=s+Math.pow(2,n),c=c-w}return(y?-1:1)*s*Math.pow(2,c-n)};Gn.write=function(e,t,r,n,i,c){var s,a,p,w=c*8-i-1,f=(1<<w)-1,d=f>>1,E=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=n?0:c-1,_=n?1:-1,T=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-s))<1&&(s--,p*=2),s+d>=1?t+=E/p:t+=E*Math.pow(2,1-d),t*p>=2&&(s++,p/=2),s+d>=f?(a=0,s=f):s+d>=1?(a=(t*p-1)*Math.pow(2,i),s=s+d):(a=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+y]=a&255,y+=_,a/=256,i-=8);for(s=s<<i|a,w+=i;w>0;e[r+y]=s&255,y+=_,s/=256,w-=8);e[r+y-_]|=T*128};/*!
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <https://feross.org>
|
||||
* @license MIT
|
||||
*/(function(e){const t=Vr,r=Vn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=f,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i;const{Uint8Array:c,ArrayBuffer:s,SharedArrayBuffer:a}=globalThis;f.TYPED_ARRAY_SUPPORT=p(),!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{const h=new c(1),o={foo:function(){return 42}};return Object.setPrototypeOf(o,c.prototype),Object.setPrototypeOf(h,o),h.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function w(h){if(h>i)throw new RangeError('The value "'+h+'" is invalid for option "size"');const o=new c(h);return Object.setPrototypeOf(o,f.prototype),o}function f(h,o,u){if(typeof h=="number"){if(typeof o=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(h)}return d(h,o,u)}f.poolSize=8192;function d(h,o,u){if(typeof h=="string")return T(h,o);if(s.isView(h))return x(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(Ue(h,s)||h&&Ue(h.buffer,s)||typeof a<"u"&&(Ue(h,a)||h&&Ue(h.buffer,a)))return N(h,o,u);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=h.valueOf&&h.valueOf();if(l!=null&&l!==h)return f.from(l,o,u);const g=k(h);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return f.from(h[Symbol.toPrimitive]("string"),o,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}f.from=function(h,o,u){return d(h,o,u)},Object.setPrototypeOf(f.prototype,c.prototype),Object.setPrototypeOf(f,c);function S(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function y(h,o,u){return S(h),h<=0?w(h):o!==void 0?typeof u=="string"?w(h).fill(o,u):w(h).fill(o):w(h)}f.alloc=function(h,o,u){return y(h,o,u)};function _(h){return S(h),w(h<0?0:m(h)|0)}f.allocUnsafe=function(h){return _(h)},f.allocUnsafeSlow=function(h){return _(h)};function T(h,o){if((typeof o!="string"||o==="")&&(o="utf8"),!f.isEncoding(o))throw new TypeError("Unknown encoding: "+o);const u=I(h,o)|0;let l=w(u);const g=l.write(h,o);return g!==u&&(l=l.slice(0,g)),l}function P(h){const o=h.length<0?0:m(h.length)|0,u=w(o);for(let l=0;l<o;l+=1)u[l]=h[l]&255;return u}function x(h){if(Ue(h,c)){const o=new c(h);return N(o.buffer,o.byteOffset,o.byteLength)}return P(h)}function N(h,o,u){if(o<0||h.byteLength<o)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<o+(u||0))throw new RangeError('"length" is outside of buffer bounds');let l;return o===void 0&&u===void 0?l=new c(h):u===void 0?l=new c(h,o):l=new c(h,o,u),Object.setPrototypeOf(l,f.prototype),l}function k(h){if(f.isBuffer(h)){const o=m(h.length)|0,u=w(o);return u.length===0||h.copy(u,0,0,o),u}if(h.length!==void 0)return typeof h.length!="number"||yn(h.length)?w(0):P(h);if(h.type==="Buffer"&&Array.isArray(h.data))return P(h.data)}function m(h){if(h>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return h|0}function v(h){return+h!=h&&(h=0),f.alloc(+h)}f.isBuffer=function(o){return o!=null&&o._isBuffer===!0&&o!==f.prototype},f.compare=function(o,u){if(Ue(o,c)&&(o=f.from(o,o.offset,o.byteLength)),Ue(u,c)&&(u=f.from(u,u.offset,u.byteLength)),!f.isBuffer(o)||!f.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(o===u)return 0;let l=o.length,g=u.length;for(let b=0,A=Math.min(l,g);b<A;++b)if(o[b]!==u[b]){l=o[b],g=u[b];break}return l<g?-1:g<l?1:0},f.isEncoding=function(o){switch(String(o).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(o,u){if(!Array.isArray(o))throw new TypeError('"list" argument must be an Array of Buffers');if(o.length===0)return f.alloc(0);let l;if(u===void 0)for(u=0,l=0;l<o.length;++l)u+=o[l].length;const g=f.allocUnsafe(u);let b=0;for(l=0;l<o.length;++l){let A=o[l];if(Ue(A,c))b+A.length>g.length?(f.isBuffer(A)||(A=f.from(A)),A.copy(g,b)):c.prototype.set.call(g,A,b);else if(f.isBuffer(A))A.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=A.length}return g};funcLine truncated
|
||||
*/(function(e){const t=Gr,r=Gn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=f,e.SlowBuffer=v,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i;const{Uint8Array:c,ArrayBuffer:s,SharedArrayBuffer:a}=globalThis;f.TYPED_ARRAY_SUPPORT=p(),!f.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{const h=new c(1),o={foo:function(){return 42}};return Object.setPrototypeOf(o,c.prototype),Object.setPrototypeOf(h,o),h.foo()===42}catch{return!1}}Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){if(f.isBuffer(this))return this.byteOffset}});function w(h){if(h>i)throw new RangeError('The value "'+h+'" is invalid for option "size"');const o=new c(h);return Object.setPrototypeOf(o,f.prototype),o}function f(h,o,u){if(typeof h=="number"){if(typeof o=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return _(h)}return d(h,o,u)}f.poolSize=8192;function d(h,o,u){if(typeof h=="string")return T(h,o);if(s.isView(h))return x(h);if(h==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h);if(Ue(h,s)||h&&Ue(h.buffer,s)||typeof a<"u"&&(Ue(h,a)||h&&Ue(h.buffer,a)))return U(h,o,u);if(typeof h=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=h.valueOf&&h.valueOf();if(l!=null&&l!==h)return f.from(l,o,u);const g=I(h);if(g)return g;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof h[Symbol.toPrimitive]=="function")return f.from(h[Symbol.toPrimitive]("string"),o,u);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof h)}f.from=function(h,o,u){return d(h,o,u)},Object.setPrototypeOf(f.prototype,c.prototype),Object.setPrototypeOf(f,c);function E(h){if(typeof h!="number")throw new TypeError('"size" argument must be of type number');if(h<0)throw new RangeError('The value "'+h+'" is invalid for option "size"')}function y(h,o,u){return E(h),h<=0?w(h):o!==void 0?typeof u=="string"?w(h).fill(o,u):w(h).fill(o):w(h)}f.alloc=function(h,o,u){return y(h,o,u)};function _(h){return E(h),w(h<0?0:S(h)|0)}f.allocUnsafe=function(h){return _(h)},f.allocUnsafeSlow=function(h){return _(h)};function T(h,o){if((typeof o!="string"||o==="")&&(o="utf8"),!f.isEncoding(o))throw new TypeError("Unknown encoding: "+o);const u=k(h,o)|0;let l=w(u);const g=l.write(h,o);return g!==u&&(l=l.slice(0,g)),l}function A(h){const o=h.length<0?0:S(h.length)|0,u=w(o);for(let l=0;l<o;l+=1)u[l]=h[l]&255;return u}function x(h){if(Ue(h,c)){const o=new c(h);return U(o.buffer,o.byteOffset,o.byteLength)}return A(h)}function U(h,o,u){if(o<0||h.byteLength<o)throw new RangeError('"offset" is outside of buffer bounds');if(h.byteLength<o+(u||0))throw new RangeError('"length" is outside of buffer bounds');let l;return o===void 0&&u===void 0?l=new c(h):u===void 0?l=new c(h,o):l=new c(h,o,u),Object.setPrototypeOf(l,f.prototype),l}function I(h){if(f.isBuffer(h)){const o=S(h.length)|0,u=w(o);return u.length===0||h.copy(u,0,0,o),u}if(h.length!==void 0)return typeof h.length!="number"||wn(h.length)?w(0):A(h);if(h.type==="Buffer"&&Array.isArray(h.data))return A(h.data)}function S(h){if(h>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return h|0}function v(h){return+h!=h&&(h=0),f.alloc(+h)}f.isBuffer=function(o){return o!=null&&o._isBuffer===!0&&o!==f.prototype},f.compare=function(o,u){if(Ue(o,c)&&(o=f.from(o,o.offset,o.byteLength)),Ue(u,c)&&(u=f.from(u,u.offset,u.byteLength)),!f.isBuffer(o)||!f.isBuffer(u))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(o===u)return 0;let l=o.length,g=u.length;for(let b=0,P=Math.min(l,g);b<P;++b)if(o[b]!==u[b]){l=o[b],g=u[b];break}return l<g?-1:g<l?1:0},f.isEncoding=function(o){switch(String(o).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(o,u){if(!Array.isArray(o))throw new TypeError('"list" argument must be an Array of Buffers');if(o.length===0)return f.alloc(0);let l;if(u===void 0)for(u=0,l=0;l<o.length;++l)u+=o[l].length;const g=f.allocUnsafe(u);let b=0;for(l=0;l<o.length;++l){let P=o[l];if(Ue(P,c))b+P.length>g.length?(f.isBuffer(P)||(P=f.from(P)),P.copy(g,b)):c.prototype.set.call(g,P,b);else if(f.isBuffer(P))P.copy(g,b);else throw new TypeError('"list" argument must be an Array of Buffers');b+=P.length}return g};funcLine truncated
|
||||
`,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128};ae.regtest={messagePrefix:`Bitcoin Signed Message:
|
||||
`,bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};ae.testnet={messagePrefix:`Bitcoin Signed Message:
|
||||
`,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var gn={},Gr={},En={},ze={};Object.defineProperty(ze,"__esModule",{value:!0});ze.encode=ze.decode=ze.check=void 0;function gc(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}ze.check=gc;function Ec(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}ze.decode=Ec;function mc(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=E.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i}ze.encode=mc;var ft={};Object.defineProperty(ft,"__esModule",{value:!0});ft.REVERSE_OPS=ft.OPS=void 0;const Fn={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};ft.OPS=Fn;const go={};ft.REVERSE_OPS=go;for(const e of Object.keys(Fn)){const t=Fn[e];go[t]=e}var ut={};Object.defineProperty(ut,"__esModule",{value:!0});ut.decode=ut.encode=ut.encodingLength=void 0;const ct=ft;function Eo(e){return e<ct.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}ut.encodingLength=Eo;function Sc(e,t,r){const n=Eo(t);return n===1?e.writeUInt8(t,r):n===2?(e.writeUInt8(ct.OPS.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):n===3?(e.writeUInt8(ct.OPS.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(ct.OPS.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),n}ut.encode=Sc;function bc(e,t){const r=e.readUInt8(t);let n,i;if(r<ct.OPS.OP_PUSHDATA1)n=r,i=1;else if(r===ct.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;n=e.readUInt8(t+1),i=2}else if(r===ct.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;n=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(r!==ct.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=e.readUInt32LE(t+1),i=5}return{opcode:r,number:n,size:i}}ut.decode=bc;var zt={};Object.defineProperty(zt,"__esModule",{value:!0});zt.encode=zt.decode=void 0;function _c(e,t,r){t=t||4,r=r===void 0?!0:r;const n=e.length;if(n===0)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&!(e[n-1]&127)&&(n<=1||
Line truncated
|
||||
`,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var mn={},Xr={},En={},ze={};Object.defineProperty(ze,"__esModule",{value:!0});ze.encode=ze.decode=ze.check=void 0;function Sc(e){if(e.length<8||e.length>72||e[0]!==48||e[1]!==e.length-2||e[2]!==2)return!1;const t=e[3];if(t===0||5+t>=e.length||e[4+t]!==2)return!1;const r=e[5+t];return!(r===0||6+t+r!==e.length||e[4]&128||t>1&&e[4]===0&&!(e[5]&128)||e[t+6]&128||r>1&&e[t+6]===0&&!(e[t+7]&128))}ze.check=Sc;function bc(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(e[0]!==48)throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(e[2]!==2)throw new Error("Expected DER integer");const t=e[3];if(t===0)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(e[4+t]!==2)throw new Error("Expected DER integer (2)");const r=e[5+t];if(r===0)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(e[4]&128)throw new Error("R value is negative");if(t>1&&e[4]===0&&!(e[5]&128))throw new Error("R value excessively padded");if(e[t+6]&128)throw new Error("S value is negative");if(r>1&&e[t+6]===0&&!(e[t+7]&128))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}}ze.decode=bc;function _c(e,t){const r=e.length,n=t.length;if(r===0)throw new Error("R length is zero");if(n===0)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(e[0]&128)throw new Error("R value is negative");if(t[0]&128)throw new Error("S value is negative");if(r>1&&e[0]===0&&!(e[1]&128))throw new Error("R value excessively padded");if(n>1&&t[0]===0&&!(t[1]&128))throw new Error("S value excessively padded");const i=m.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i}ze.encode=_c;var ft={};Object.defineProperty(ft,"__esModule",{value:!0});ft.REVERSE_OPS=ft.OPS=void 0;const Ln={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};ft.OPS=Ln;const Eo={};ft.REVERSE_OPS=Eo;for(const e of Object.keys(Ln)){const t=Ln[e];Eo[t]=e}var ut={};Object.defineProperty(ut,"__esModule",{value:!0});ut.decode=ut.encode=ut.encodingLength=void 0;const ct=ft;function So(e){return e<ct.OPS.OP_PUSHDATA1?1:e<=255?2:e<=65535?3:5}ut.encodingLength=So;function Tc(e,t,r){const n=So(t);return n===1?e.writeUInt8(t,r):n===2?(e.writeUInt8(ct.OPS.OP_PUSHDATA1,r),e.writeUInt8(t,r+1)):n===3?(e.writeUInt8(ct.OPS.OP_PUSHDATA2,r),e.writeUInt16LE(t,r+1)):(e.writeUInt8(ct.OPS.OP_PUSHDATA4,r),e.writeUInt32LE(t,r+1)),n}ut.encode=Tc;function Ic(e,t){const r=e.readUInt8(t);let n,i;if(r<ct.OPS.OP_PUSHDATA1)n=r,i=1;else if(r===ct.OPS.OP_PUSHDATA1){if(t+2>e.length)return null;n=e.readUInt8(t+1),i=2}else if(r===ct.OPS.OP_PUSHDATA2){if(t+3>e.length)return null;n=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(r!==ct.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");n=e.readUInt32LE(t+1),i=5}return{opcode:r,number:n,size:i}}ut.decode=Ic;var zt={};Object.defineProperty(zt,"__esModule",{value:!0});zt.encode=zt.decode=void 0;function kc(e,t,r){t=t||4,r=r===void 0?!0:r;const n=e.length;if(n===0)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&!(e[n-1]&127)&&(n<=1||
Line truncated
|
||||
*********************
|
||||
PROCEED WITH CAUTION!
|
||||
*********************`),a=c.hashForSignature(e,w,s)}return{script:w,sighashType:s,hash:a}}function yh(e,t,r,n){const i=[];if(t.tapInternalKey){const s=_s(e,t,n);s&&i.push(s)}if(t.tapScriptSig){const s=t.tapScriptSig.map(a=>a.pubkey);i.push(...s)}return i.map(s=>Wn(e,t,r,s,n)).flat()}function _s(e,t,r){const{script:n}=wi(e,t,r);return(0,re.isP2TR)(n)?n.subarray(2,34):null}function fo(e){return e.length===64?e:e.subarray(0,64)}function Wn(e,t,r,n,i,c,s){const a=i.__TX,p=t.sighashType||we.Transaction.SIGHASH_DEFAULT;Ts(p,s);const w=r.map((_,T)=>wi(T,_,i)),f=w.map(_=>_.script),d=w.map(_=>_.value),S=[];if(t.tapInternalKey&&!c){const _=_s(e,t,i)||E.from([]);if((0,J.toXOnly)(n).equals(_)){const T=a.hashForWitnessV1(e,f,d,p);S.push({pubkey:n,hash:T})}}const y=(t.tapLeafScript||[]).filter(_=>(0,re.pubkeyInScript)(n,_.script)).map(_=>{const T=(0,oh.tapleafHash)({output:_.script,version:_.leafVersion});return Object.assign({hash:T},_)}).filter(_=>!c||c.equals(_.hash)).map(_=>{const T=a.hashForWitnessV1(e,f,d,p,_.hash);return{pubkey:n,hash:T,leafHash:_.hash}});return S.concat(y)}function Ts(e,t){if(t&&t.indexOf(e)<0){const r=mh(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function wh(e,t,r){let n;switch(t){case"multisig":const i=Eh(e,r);n=ve.p2ms({output:e,signatures:i});break;case"pubkey":n=ve.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=ve.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=ve.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function gh(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const c=fn(r,t,e),s=n.ins[e].index;i.script=c.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||(0,re.isP2WPKH)(i.script))&&(i.isSegwit=!0),i}function ho(e,t,r){const n=(0,Se.checkForInput)(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(s=>{if(s.masterFingerprint.equals(r.fingerprint))return s}).filter(s=>!!s);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(s=>{const a=r.derivePath(s.path);if(!s.pubkey.equals(a.publicKey))throw new Error("pubkey did not match bip32Derivation");return a})}function Eh(e,t){return ve.p2ms({output:e}).pubkeys.map(n=>(t.filter(i=>i.pubkey.equals(n))[0]||{}).signature).filter(n=>!!n)}function Is(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=ro.decode(e,t);return t+=ro.decode.bytes,s}function i(){return r(n())}function c(){const s=n(),a=[];for(let p=0;p<s;p++)a.push(i());return a}return c()}function mh(e){let t=e&we.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case we.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case we.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case we.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function jn(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=we.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,c=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const s=i.__NON_WITNESS_UTXO_BUF_CACHE[c],a=i.__NON_WITNESS_UTXO_TX_CACHE[c];if(s!==void 0)return s;{const p=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[c]=p,p}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[c]=s}})}function ks(e,t,r,n){let i=0;e.forEach((p,w)=>{if(n&&p.finalScriptSig&&(t.ins[w].script=p.finalScriptSig),n&&p.finalScriptWitness&&(t.ins[w].witness=Is(p.finalScriptWitness)),p.witnessUtxo)i+=p.witnessUtxo.value;else if(p.nonWitnessUtxo){const f=fn(r,p,w),d=t.ins[w].index,S=f.outs[d];i+=S.value}});const c=t.outs.reduce((p,w)=>p+w.value,0),s=i-c;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(s/a)}function fn(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||jn(e,t,r),n[r]}function As(e,t,r){const{script:n}=wi(e,t,r);return n}function wi(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const i=fn(r,t,e).outs[r.__TX.ins[e].index];return{script:i.script,value:i.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function Sh(e,t,r,n){const i=As(r,t,n),{meaningfulScript:c}=hn(i,r,"input",t.redeemScript,t.witnessScript);return(0,re.pubkeyInScript)(e,c)}function bh(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:c}=hn(i,r,"output",t.redeemScript,t.witnessScript);return(0,re.pubkeyInScript)(e,c)}function _h(e){if(!e)return;const t=Ye.decompile(e);if(!t
Line truncated
|
||||
*********************`),a=c.hashForSignature(e,w,s)}return{script:w,sighashType:s,hash:a}}function mh(e,t,r,n){const i=[];if(t.tapInternalKey){const s=Is(e,t,n);s&&i.push(s)}if(t.tapScriptSig){const s=t.tapScriptSig.map(a=>a.pubkey);i.push(...s)}return i.map(s=>jn(e,t,r,s,n)).flat()}function Is(e,t,r){const{script:n}=gi(e,t,r);return(0,re.isP2TR)(n)?n.subarray(2,34):null}function ho(e){return e.length===64?e:e.subarray(0,64)}function jn(e,t,r,n,i,c,s){const a=i.__TX,p=t.sighashType||we.Transaction.SIGHASH_DEFAULT;ks(p,s);const w=r.map((_,T)=>gi(T,_,i)),f=w.map(_=>_.script),d=w.map(_=>_.value),E=[];if(t.tapInternalKey&&!c){const _=Is(e,t,i)||m.from([]);if((0,J.toXOnly)(n).equals(_)){const T=a.hashForWitnessV1(e,f,d,p);E.push({pubkey:n,hash:T})}}const y=(t.tapLeafScript||[]).filter(_=>(0,re.pubkeyInScript)(n,_.script)).map(_=>{const T=(0,uh.tapleafHash)({output:_.script,version:_.leafVersion});return Object.assign({hash:T},_)}).filter(_=>!c||c.equals(_.hash)).map(_=>{const T=a.hashForWitnessV1(e,f,d,p,_.hash);return{pubkey:n,hash:T,leafHash:_.hash}});return E.concat(y)}function ks(e,t){if(t&&t.indexOf(e)<0){const r=_h(e);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${r}`)}}function Eh(e,t,r){let n;switch(t){case"multisig":const i=bh(e,r);n=ve.p2ms({output:e,signatures:i});break;case"pubkey":n=ve.p2pk({output:e,signature:r[0].signature});break;case"pubkeyhash":n=ve.p2pkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=ve.p2wpkh({output:e,pubkey:r[0].pubkey,signature:r[0].signature});break}return n}function Sh(e,t,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!t.redeemScript,i.isP2WSH=!!t.witnessScript,t.witnessScript)i.script=t.witnessScript;else if(t.redeemScript)i.script=t.redeemScript;else if(t.nonWitnessUtxo){const c=hn(r,t,e),s=n.ins[e].index;i.script=c.outs[s].script}else t.witnessUtxo&&(i.script=t.witnessUtxo.script);return(t.witnessScript||(0,re.isP2WPKH)(i.script))&&(i.isSegwit=!0),i}function po(e,t,r){const n=(0,Se.checkForInput)(t,e);if(!n.bip32Derivation||n.bip32Derivation.length===0)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map(s=>{if(s.masterFingerprint.equals(r.fingerprint))return s}).filter(s=>!!s);if(i.length===0)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map(s=>{const a=r.derivePath(s.path);if(!s.pubkey.equals(a.publicKey))throw new Error("pubkey did not match bip32Derivation");return a})}function bh(e,t){return ve.p2ms({output:e}).pubkeys.map(n=>(t.filter(i=>i.pubkey.equals(n))[0]||{}).signature).filter(n=>!!n)}function As(e){let t=0;function r(s){return t+=s,e.slice(t-s,t)}function n(){const s=no.decode(e,t);return t+=no.decode.bytes,s}function i(){return r(n())}function c(){const s=n(),a=[];for(let p=0;p<s;p++)a.push(i());return a}return c()}function _h(e){let t=e&we.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(e&31){case we.Transaction.SIGHASH_ALL:t+="SIGHASH_ALL";break;case we.Transaction.SIGHASH_SINGLE:t+="SIGHASH_SINGLE";break;case we.Transaction.SIGHASH_NONE:t+="SIGHASH_NONE";break}return t}function Vn(e,t,r){e.__NON_WITNESS_UTXO_BUF_CACHE[r]=t.nonWitnessUtxo;const n=we.Transaction.fromBuffer(t.nonWitnessUtxo);e.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=e,c=r;delete t.nonWitnessUtxo,Object.defineProperty(t,"nonWitnessUtxo",{enumerable:!0,get(){const s=i.__NON_WITNESS_UTXO_BUF_CACHE[c],a=i.__NON_WITNESS_UTXO_TX_CACHE[c];if(s!==void 0)return s;{const p=a.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[c]=p,p}},set(s){i.__NON_WITNESS_UTXO_BUF_CACHE[c]=s}})}function Ps(e,t,r,n){let i=0;e.forEach((p,w)=>{if(n&&p.finalScriptSig&&(t.ins[w].script=p.finalScriptSig),n&&p.finalScriptWitness&&(t.ins[w].witness=As(p.finalScriptWitness)),p.witnessUtxo)i+=p.witnessUtxo.value;else if(p.nonWitnessUtxo){const f=hn(r,p,w),d=t.ins[w].index,E=f.outs[d];i+=E.value}});const c=t.outs.reduce((p,w)=>p+w.value,0),s=i-c;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=t.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=t,r.__FEE_RATE=Math.floor(s/a)}function hn(e,t,r){const n=e.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||Vn(e,t,r),n[r]}function Os(e,t,r){const{script:n}=gi(e,t,r);return n}function gi(e,t,r){if(t.witnessUtxo!==void 0)return{script:t.witnessUtxo.script,value:t.witnessUtxo.value};if(t.nonWitnessUtxo!==void 0){const i=hn(r,t,e).outs[r.__TX.ins[e].index];return{script:i.script,value:i.value}}else throw new Error("Can't find pubkey in input without Utxo data")}function Th(e,t,r,n){const i=Os(r,t,n),{meaningfulScript:c}=pn(i,r,"input",t.redeemScript,t.witnessScript);return(0,re.pubkeyInScript)(e,c)}function Ih(e,t,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:c}=pn(i,r,"output",t.redeemScript,t.witnessScript);return(0,re.pubkeyInScript)(e,c)}function kh(e){if(!e)return;const t=Ye.decompile(e);if(!t
Line truncated
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" viewBox="0 0 16 16">
|
||||
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
|
||||
<path d="m10.97 4.97-.02.022-3.473 4.425-2.093-2.094a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-1.071-1.05"/>
|
||||
@@ -25,87 +25,4 @@ PROCEED WITH CAUTION!
|
||||
<svg class="pushtx-spin" width="32" height="32" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
||||
<circle style="opacity: 0.25;" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>`};async function dr(e){try{return[null,await e]}catch(t){return t instanceof Error?[t,null]:typeof t=="string"?[new Error(t),null]:[new Error,null]}}function po(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),r=atob(t);return new Uint8Array([...r].map(n=>n.charCodeAt(0)))}class Bs extends Error{constructor(r,n,i,c){super();Zt(this,"url");Zt(this,"status");Zt(this,"statusText");Zt(this,"body");this.url=r,this.name="FetchStatusError",this.status=n,this.statusText=i,this.body=c}}const xs=async(e,t)=>{const r=await fetch(e,t);if(!r.ok){const[n,i]=await dr(r.text());throw new Bs(e.toString(),r.status,r.statusText,i)}return r};async function Ph(e,t){if(t!=="BTC"&&t!=="XTN")throw new Error("Unsupported network: "+t);const n=vs[t].map(s=>xs(s,{method:"POST",body:e.toHex()})),[i,c]=await dr(Promise.any(n).then(s=>s.text()));if(c)return c;if(i instanceof AggregateError){const s=i.errors.filter(a=>a instanceof Bs);if(s.length>0){let a=`
|
||||
<p>The transaction was rejected by all providers:</p>
|
||||
|
||||
<ul>
|
||||
`;throw s.forEach(p=>{a+=`<li>${p.url}: ${p.body}</li>`}),a+="</ul>",new Error(a)}}throw new Error("<p>Could not connect to any push servers. Make sure you are connected to the Internet and try again.</p>")}async function vh(e){e[0]==="#"&&(e=e.slice(1));const t=new URLSearchParams(e),r=t.get("t"),n=t.get("c"),i=t.get("n")||"BTC";if(!r)throw new Error("Invalid URL - missing transaction.");if(!n||n.length!==11)throw new Error("Invalid URL - missing or incomplete checksum. The URL is probably truncated");let c;if(i==="BTC"||i==="XTN")c=i;else throw i==="XRT"?new Error("Regtest transactions are not supported."):new Error(`Invalid URL. The network "${i}" is not recognized.`);let s,a;try{s=po(r),a=po(n)}catch{throw new Error("Invalid URL encoding. The URL is probably corrupted.")}const p=new Uint8Array(await crypto.subtle.digest("SHA-256",s));if(!a.every((f,d)=>f===p[d+24]))throw new Error("Checksum mismatch in URL. Some bytes corrupted in transit. Try again.");return{tx:lo.Transaction.fromBuffer(wo.from(s)),network:c}}async function Bh(e,t){if(t!=="BTC"&&t!=="XTN")throw new Error("Unsupported network: "+t);const n=vs[t].map(i=>xs(i+"/"+e).then(c=>c.json()));return await Promise.any(n)}function xh(e){const t=e.vin.map(n=>`
|
||||
<tr>
|
||||
<td>
|
||||
<span class="address">
|
||||
<span>${n.prevout.scriptpubkey_address.slice(0,-8)}</span>
|
||||
<span>${n.prevout.scriptpubkey_address.slice(-8)}</span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="value">${(n.prevout.value/1e8).toFixed(8)}</span>
|
||||
</td>
|
||||
</tr>
|
||||
`).join(""),r=e.vout.map(n=>`
|
||||
<tr>
|
||||
<td>
|
||||
<span class="address">
|
||||
<span>${n.scriptpubkey_address.slice(0,-8)}</span>
|
||||
<span>${n.scriptpubkey_address.slice(-8)}</span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="value">${(n.value/1e8).toFixed(8)}</span>
|
||||
</td>
|
||||
</tr>
|
||||
`).join("");return`
|
||||
<div class="pushtx-details">
|
||||
<div class="inputs">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Inputs</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${t}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="outputs">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Outputs</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
${r}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="fee">
|
||||
<strong>Fee:</strong> <span class="value">${(e.fee/1e8).toFixed(8)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`}function Kt(e,t){const r=Oh[e];return`
|
||||
<div class="pushtx-message pushtx-message--${e}" role="alert">
|
||||
${r}
|
||||
<div>${t}</div>
|
||||
</div>
|
||||
`}async function Us(){const e=document.querySelector(".pushtx-message-area"),t=document.querySelector(".pushtx-details-area");if(!e||!t)throw new Error("Need message and details areas in HTML.");if(e.innerHTML="",t.innerHTML="",!window.location.hash){const S=`
|
||||
<p><strong>Did you get here by accident?</strong></p>
|
||||
<p>
|
||||
This page is meant to be loaded together with transaction data using the
|
||||
<strong>COLDCARD NFC Push TX feature</strong>. The complete URL should look something like this (but longer):
|
||||
</p>
|
||||
|
||||
<p><code>${window.location.origin+window.location.pathname}#t=AgAAAAMNCxXtp2GVYVhkRXHLMmdZFs4p3kbFK ⋯ ABf&c=uiSVRda-1tw</code></p>
|
||||
`;e.innerHTML=Kt("info",S);return}e.innerHTML=Kt("progress","Sending transaction, please wait...");const[r,n]=await dr(vh(window.location.hash));if(r){e.innerHTML=Kt("error",r.message);return}const{tx:i,network:c}=n,s=i.getId(),[a,p]=await dr(Ph(i,c)),[w,f]=await dr(Bh(s,c));if(p||f){const d=f!=null&&f.status.confirmed?"This transaction has already been confirmed.":"The transaction has been sent and is waiting to be confirmed.",S=Ah[c].map(([y,_])=>`<li><a href="${_}${s}" target="_blank" rel="noopener">${y}</a></li>`).join("");e.innerHTML=Kt("success",`<p>${d} Transaction ID:</p>
|
||||
|
||||
<p class="txid">${s}</p>
|
||||
|
||||
<p>Verify on a block explorer:</p>
|
||||
|
||||
<ul>${S}</ul>
|
||||
`),f&&(t.innerHTML=xh(f));return}if(a&&w)e.innerHTML=Kt("error",a.message);else if(w){e.innerHTML=Kt("error",w.message);return}}Us();window.addEventListener("hashchange",Us);
|
||||
</svg>`};async function lr(e){try{return[null,await e]}catch(t){return t instanceof Error?[t,null]:typeof t=="string"?[new Error(t),null]:[new Error,null]}}function lo(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),r=atob(t);return new Uint8Array([...r].map(n=>n.charCodeAt(0)))}class Us extends Error{constructor(r,n,i,c){super();Lt(this,"url");Lt(this,"status");Lt(this,"statusText");Lt(this,"body");this.url=r,this.name="FetchStatusError",this.status=n,this.statusText=i,this.body=c}}class Cs extends Error{constructor(r){super("The transaction was rejected by all providers.");Lt(this,"details");this.details=r}}const Ns=async(e,t)=>{const r=await fetch(e,t);if(!r.ok){const[n,i]=await lr(r.text());throw new Us(e.toString(),r.status,r.statusText,i)}return r};async function xh(e,t){if(t!=="BTC"&&t!=="XTN")throw new Error("Unsupported network: "+t);const n=xs[t].map(s=>Ns(s,{method:"POST",body:e.toHex()})),[i,c]=await lr(Promise.any(n).then(s=>s.text()));if(c)return c;if(i instanceof AggregateError){const s=i.errors.filter(a=>a instanceof Us);if(s.length>0)throw new Cs(s.map(a=>({url:a.url,body:a.body})))}throw new Error("Could not connect to any push servers. Make sure you are connected to the Internet and try again.")}async function Uh(e){e[0]==="#"&&(e=e.slice(1));const t=new URLSearchParams(e),r=t.get("t"),n=t.get("c"),i=t.get("n")||"BTC";if(!r)throw new Error("Invalid URL - missing transaction.");if(!n||n.length!==11)throw new Error("Invalid URL - missing or incomplete checksum. The URL is probably truncated");let c;if(i==="BTC"||i==="XTN")c=i;else throw i==="XRT"?new Error("Regtest transactions are not supported."):new Error("Invalid URL. The network parameter is not recognized.");let s,a;try{s=lo(r),a=lo(n)}catch{throw new Error("Invalid URL encoding. The URL is probably corrupted.")}const p=new Uint8Array(await crypto.subtle.digest("SHA-256",s));if(!a.every((f,d)=>f===p[d+24]))throw new Error("Checksum mismatch in URL. Some bytes corrupted in transit. Try again.");return{tx:wo.Transaction.fromBuffer(mo.from(s)),network:c}}async function Ch(e,t){if(t!=="BTC"&&t!=="XTN")throw new Error("Unsupported network: "+t);const n=xs[t].map(i=>Ns(i+"/"+e).then(c=>c.json()));return await Promise.any(n)}function yo(e,t){const r=document.createElement("tr"),n=document.createElement("td"),i=document.createElement("span");i.className="address";const c=document.createElement("span");c.textContent=e.slice(0,-8);const s=document.createElement("span");s.textContent=e.slice(-8),i.appendChild(c),i.appendChild(s),n.appendChild(i),r.appendChild(n);const a=document.createElement("td"),p=document.createElement("span");return p.className="value",p.textContent=(t/1e8).toFixed(8),a.appendChild(p),r.appendChild(a),r}function Nh(e){const t=document.createElement("div");t.className="pushtx-details";const r=(p,w)=>{const f=document.createElement("div"),d=document.createElement("table"),E=document.createElement("thead"),y=document.createElement("tr"),_=document.createElement("th");_.textContent=p;const T=document.createElement("th");y.appendChild(_),y.appendChild(T),E.appendChild(y),d.appendChild(E);const A=document.createElement("tbody");return w.forEach(x=>A.appendChild(x)),d.appendChild(A),f.appendChild(d),f},n=e.vin.map(p=>yo(p.prevout.scriptpubkey_address,p.prevout.value));t.appendChild(r("Inputs",n));const i=e.vout.map(p=>yo(p.scriptpubkey_address,p.value));t.appendChild(r("Outputs",i));const c=document.createElement("div");c.className="fee";const s=document.createElement("strong");s.textContent="Fee:";const a=document.createElement("span");return a.className="value",a.textContent=(e.fee/1e8).toFixed(8),c.appendChild(s),c.appendChild(document.createTextNode(" ")),c.appendChild(a),t.appendChild(c),t}function Fr(e,t){const r=document.createElement("div");r.className=`pushtx-message pushtx-message--${e}`,r.setAttribute("role","alert");const n=document.createElement("div");n.innerHTML=Bh[e],r.appendChild(n);const i=document.createElement("div");return i.appendChild(t),r.appendChild(i),r}function xr(e,t){const r=document.createDocumentFragment();return r.appendChild(document.createTextNode(t)),Fr(e,r)}async function Hs(){const e=document.querySelector(".pushtx-message-area"),t=document.querySelector(".pushtx-details-area");if(!e||!t)throw new Error("Need message and details areas in HTML.");if(e.replaceChildren(),t.replaceChildren(),!window.location.hash){const d=window.location.origin+window.location.pathname,E=document.createDocumentFragment(),y=document.createElement("p"),_=document.createElement("strong");_.textContent="Did you get here by accident?",y.appendChild(_),E.appendChild(y);const T=document.createElement("p");T.textContent="This page is meant to be loaded together with transaction data using the ";const A=document.createElement("strong");A.textContent="COLDCARD NFC Push TX feature",T.appendChild(A),T.appendChild(document.createTextNode(". The complete URL should look something like Line truncated
|
||||
@@ -4,6 +4,10 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; connect-src https://mempool.space https://blockstream.info; img-src 'none'; font-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none';"
|
||||
/>
|
||||
<title>COLDCARD NFC Push TX</title>
|
||||
</head>
|
||||
|
||||
|
||||
+202
-127
@@ -53,6 +53,19 @@ class FetchStatusError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Carries provider-specific rejection details so the UI can render them
|
||||
* as plain text instead of embedding them in an HTML string.
|
||||
*/
|
||||
class ProviderErrorsError extends Error {
|
||||
details: { url: string; body: string | null }[];
|
||||
|
||||
constructor(details: { url: string; body: string | null }[]) {
|
||||
super('The transaction was rejected by all providers.');
|
||||
this.details = details;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper around fetch that throws an error if the response is not 2xx.
|
||||
*/
|
||||
@@ -93,24 +106,14 @@ async function pushTx(tx: Transaction, network: Network): Promise<string> {
|
||||
);
|
||||
|
||||
if (fetchStatusErrors.length > 0) {
|
||||
let errMsg = `
|
||||
<p>The transaction was rejected by all providers:</p>
|
||||
|
||||
<ul>
|
||||
`;
|
||||
|
||||
fetchStatusErrors.forEach((e) => {
|
||||
errMsg += `<li>${e.url}: ${e.body}</li>`;
|
||||
});
|
||||
|
||||
errMsg += `</ul>`;
|
||||
|
||||
throw new Error(errMsg);
|
||||
throw new ProviderErrorsError(
|
||||
fetchStatusErrors.map((e) => ({ url: e.url, body: e.body }))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`<p>Could not connect to any push servers. Make sure you are connected to the Internet and try again.</p>`
|
||||
'Could not connect to any push servers. Make sure you are connected to the Internet and try again.'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -144,7 +147,7 @@ async function parseFragment(fragment: string) {
|
||||
} else if (n === 'XRT') {
|
||||
throw new Error('Regtest transactions are not supported.');
|
||||
} else {
|
||||
throw new Error(`Invalid URL. The network "${n}" is not recognized.`);
|
||||
throw new Error('Invalid URL. The network parameter is not recognized.');
|
||||
}
|
||||
|
||||
let txBytes: Uint8Array;
|
||||
@@ -189,97 +192,121 @@ async function fetchTxData(txid: string, network: Network): Promise<MempoolTxDat
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML for the transaction details that can be rendered on the page.
|
||||
* Build a table row for an address/value pair, setting dynamic values via
|
||||
* textContent so API-returned strings are never interpreted as HTML.
|
||||
*/
|
||||
function renderTxDetails(txData: MempoolTxData): string {
|
||||
const inputRows = txData.vin
|
||||
.map((input) => {
|
||||
return `
|
||||
<tr>
|
||||
<td>
|
||||
<span class="address">
|
||||
<span>${input.prevout.scriptpubkey_address.slice(0, -8)}</span>
|
||||
<span>${input.prevout.scriptpubkey_address.slice(-8)}</span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="value">${(input.prevout.value / 1e8).toFixed(8)}</span>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
})
|
||||
.join('');
|
||||
function createTxRow(address: string, value: number): HTMLTableRowElement {
|
||||
const row = document.createElement('tr');
|
||||
|
||||
const outputRows = txData.vout
|
||||
.map((output) => {
|
||||
return `
|
||||
<tr>
|
||||
<td>
|
||||
<span class="address">
|
||||
<span>${output.scriptpubkey_address.slice(0, -8)}</span>
|
||||
<span>${output.scriptpubkey_address.slice(-8)}</span>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="value">${(output.value / 1e8).toFixed(8)}</span>
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
})
|
||||
.join('');
|
||||
const addressCell = document.createElement('td');
|
||||
const addressSpan = document.createElement('span');
|
||||
addressSpan.className = 'address';
|
||||
const addressStart = document.createElement('span');
|
||||
addressStart.textContent = address.slice(0, -8);
|
||||
const addressEnd = document.createElement('span');
|
||||
addressEnd.textContent = address.slice(-8);
|
||||
addressSpan.appendChild(addressStart);
|
||||
addressSpan.appendChild(addressEnd);
|
||||
addressCell.appendChild(addressSpan);
|
||||
row.appendChild(addressCell);
|
||||
|
||||
return `
|
||||
<div class="pushtx-details">
|
||||
<div class="inputs">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Inputs</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${inputRows}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
const valueCell = document.createElement('td');
|
||||
const valueSpan = document.createElement('span');
|
||||
valueSpan.className = 'value';
|
||||
valueSpan.textContent = (value / 1e8).toFixed(8);
|
||||
valueCell.appendChild(valueSpan);
|
||||
row.appendChild(valueCell);
|
||||
|
||||
<div class="outputs">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Outputs</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
${outputRows}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="fee">
|
||||
<strong>Fee:</strong> <span class="value">${(txData.fee / 1e8).toFixed(8)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML for a message box that can be rendered on the page.
|
||||
* @param type - The type of message, e.g. 'success', 'error', 'info'
|
||||
* @param message - The message to display - can be HTML
|
||||
* Get the DOM element for the transaction details that can be rendered on the page.
|
||||
*/
|
||||
function renderMessage(type: 'success' | 'error' | 'info' | 'progress', message: string): string {
|
||||
const icon = MESSAGE_ICONS[type];
|
||||
function renderTxDetails(txData: MempoolTxData): HTMLElement {
|
||||
const container = document.createElement('div');
|
||||
container.className = 'pushtx-details';
|
||||
|
||||
return `
|
||||
<div class="pushtx-message pushtx-message--${type}" role="alert">
|
||||
${icon}
|
||||
<div>${message}</div>
|
||||
</div>
|
||||
`;
|
||||
const createTable = (title: string, rows: HTMLTableRowElement[]) => {
|
||||
const wrapper = document.createElement('div');
|
||||
const table = document.createElement('table');
|
||||
const thead = document.createElement('thead');
|
||||
const headerRow = document.createElement('tr');
|
||||
const titleHeader = document.createElement('th');
|
||||
titleHeader.textContent = title;
|
||||
const emptyHeader = document.createElement('th');
|
||||
headerRow.appendChild(titleHeader);
|
||||
headerRow.appendChild(emptyHeader);
|
||||
thead.appendChild(headerRow);
|
||||
table.appendChild(thead);
|
||||
const tbody = document.createElement('tbody');
|
||||
rows.forEach((row) => tbody.appendChild(row));
|
||||
table.appendChild(tbody);
|
||||
wrapper.appendChild(table);
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
const inputRows = txData.vin.map((input) =>
|
||||
createTxRow(input.prevout.scriptpubkey_address, input.prevout.value)
|
||||
);
|
||||
container.appendChild(createTable('Inputs', inputRows));
|
||||
|
||||
const outputRows = txData.vout.map((output) =>
|
||||
createTxRow(output.scriptpubkey_address, output.value)
|
||||
);
|
||||
container.appendChild(createTable('Outputs', outputRows));
|
||||
|
||||
const feeDiv = document.createElement('div');
|
||||
feeDiv.className = 'fee';
|
||||
const strong = document.createElement('strong');
|
||||
strong.textContent = 'Fee:';
|
||||
const feeSpan = document.createElement('span');
|
||||
feeSpan.className = 'value';
|
||||
feeSpan.textContent = (txData.fee / 1e8).toFixed(8);
|
||||
feeDiv.appendChild(strong);
|
||||
feeDiv.appendChild(document.createTextNode(' '));
|
||||
feeDiv.appendChild(feeSpan);
|
||||
container.appendChild(feeDiv);
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message box element that can be rendered on the page.
|
||||
* The caller supplies the content as a DOM Node/DocumentFragment; dynamic text
|
||||
* must be set via textContent before calling this helper.
|
||||
* @param type - The type of message, e.g. 'success', 'error', 'info'
|
||||
* @param content - The content to display inside the message box
|
||||
*/
|
||||
function renderMessage(
|
||||
type: 'success' | 'error' | 'info' | 'progress',
|
||||
content: Node
|
||||
): HTMLElement {
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.className = `pushtx-message pushtx-message--${type}`;
|
||||
wrapper.setAttribute('role', 'alert');
|
||||
|
||||
const iconContainer = document.createElement('div');
|
||||
iconContainer.innerHTML = MESSAGE_ICONS[type];
|
||||
wrapper.appendChild(iconContainer);
|
||||
|
||||
const contentContainer = document.createElement('div');
|
||||
contentContainer.appendChild(content);
|
||||
wrapper.appendChild(contentContainer);
|
||||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience helper for messages that are plain text only.
|
||||
*/
|
||||
function textMessage(
|
||||
type: 'success' | 'error' | 'info' | 'progress',
|
||||
text: string
|
||||
): HTMLElement {
|
||||
const fragment = document.createDocumentFragment();
|
||||
fragment.appendChild(document.createTextNode(text));
|
||||
return renderMessage(type, fragment);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,32 +340,51 @@ async function run() {
|
||||
throw new Error('Need message and details areas in HTML.');
|
||||
}
|
||||
|
||||
messageArea.innerHTML = '';
|
||||
detailsArea.innerHTML = '';
|
||||
messageArea.replaceChildren();
|
||||
detailsArea.replaceChildren();
|
||||
|
||||
if (!window.location.hash) {
|
||||
const path = window.location.origin + window.location.pathname;
|
||||
|
||||
const msg = `
|
||||
<p><strong>Did you get here by accident?</strong></p>
|
||||
<p>
|
||||
This page is meant to be loaded together with transaction data using the
|
||||
<strong>COLDCARD NFC Push TX feature</strong>. The complete URL should look something like this (but longer):
|
||||
</p>
|
||||
const fragment = document.createDocumentFragment();
|
||||
|
||||
<p><code>${path}#t=AgAAAAMNCxXtp2GVYVhkRXHLMmdZFs4p3kbFK ⋯ ABf&c=uiSVRda-1tw</code></p>
|
||||
`;
|
||||
const p1 = document.createElement('p');
|
||||
const strong1 = document.createElement('strong');
|
||||
strong1.textContent = 'Did you get here by accident?';
|
||||
p1.appendChild(strong1);
|
||||
fragment.appendChild(p1);
|
||||
|
||||
messageArea.innerHTML = renderMessage('info', msg);
|
||||
const p2 = document.createElement('p');
|
||||
p2.textContent =
|
||||
'This page is meant to be loaded together with transaction data using the ';
|
||||
const strong2 = document.createElement('strong');
|
||||
strong2.textContent = 'COLDCARD NFC Push TX feature';
|
||||
p2.appendChild(strong2);
|
||||
p2.appendChild(
|
||||
document.createTextNode(
|
||||
'. The complete URL should look something like this (but longer):'
|
||||
)
|
||||
);
|
||||
fragment.appendChild(p2);
|
||||
|
||||
const p3 = document.createElement('p');
|
||||
const code = document.createElement('code');
|
||||
code.textContent = `${path}#t=AgAAAAMNCxXtp2GVYVhkRXHLMmdZFs4p3kbFK ⋯ ABf&c=uiSVRda-1tw`;
|
||||
p3.appendChild(code);
|
||||
fragment.appendChild(p3);
|
||||
|
||||
messageArea.replaceChildren(renderMessage('info', fragment));
|
||||
return;
|
||||
}
|
||||
|
||||
messageArea.innerHTML = renderMessage('progress', 'Sending transaction, please wait...');
|
||||
messageArea.replaceChildren(
|
||||
textMessage('progress', 'Sending transaction, please wait...')
|
||||
);
|
||||
|
||||
const [parseErr, parseResult] = await collect(parseFragment(window.location.hash));
|
||||
|
||||
if (parseErr) {
|
||||
messageArea.innerHTML = renderMessage('error', parseErr.message);
|
||||
messageArea.replaceChildren(textMessage('error', parseErr.message));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -360,27 +406,38 @@ async function run() {
|
||||
? 'This transaction has already been confirmed.'
|
||||
: 'The transaction has been sent and is waiting to be confirmed.';
|
||||
|
||||
const listHtml = BLOCK_EXPLORER_CONFIG[network]
|
||||
.map(
|
||||
([name, url]) =>
|
||||
`<li><a href="${url}${txid}" target="_blank" rel="noopener">${name}</a></li>`
|
||||
)
|
||||
.join('');
|
||||
const fragment = document.createDocumentFragment();
|
||||
|
||||
messageArea.innerHTML = renderMessage(
|
||||
'success',
|
||||
`<p>${msg} Transaction ID:</p>
|
||||
const p1 = document.createElement('p');
|
||||
p1.textContent = `${msg} Transaction ID:`;
|
||||
fragment.appendChild(p1);
|
||||
|
||||
<p class="txid">${txid}</p>
|
||||
const txidP = document.createElement('p');
|
||||
txidP.className = 'txid';
|
||||
txidP.textContent = txid;
|
||||
fragment.appendChild(txidP);
|
||||
|
||||
<p>Verify on a block explorer:</p>
|
||||
const p2 = document.createElement('p');
|
||||
p2.textContent = 'Verify on a block explorer:';
|
||||
fragment.appendChild(p2);
|
||||
|
||||
<ul>${listHtml}</ul>
|
||||
`
|
||||
);
|
||||
const ul = document.createElement('ul');
|
||||
BLOCK_EXPLORER_CONFIG[network].forEach(([name, url]) => {
|
||||
const li = document.createElement('li');
|
||||
const a = document.createElement('a');
|
||||
a.href = `${url}${txid}`;
|
||||
a.target = '_blank';
|
||||
a.rel = 'noopener';
|
||||
a.textContent = name;
|
||||
li.appendChild(a);
|
||||
ul.appendChild(li);
|
||||
});
|
||||
fragment.appendChild(ul);
|
||||
|
||||
messageArea.replaceChildren(renderMessage('success', fragment));
|
||||
|
||||
if (mempoolTxData) {
|
||||
detailsArea.innerHTML = renderTxDetails(mempoolTxData);
|
||||
detailsArea.replaceChildren(renderTxDetails(mempoolTxData));
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -388,9 +445,27 @@ async function run() {
|
||||
|
||||
if (pushErr && mempoolErr) {
|
||||
// pushing failed and we also couldn't fetch the TX details
|
||||
messageArea.innerHTML = renderMessage('error', pushErr.message);
|
||||
if (pushErr instanceof ProviderErrorsError) {
|
||||
const fragment = document.createDocumentFragment();
|
||||
|
||||
const p = document.createElement('p');
|
||||
p.textContent = pushErr.message;
|
||||
fragment.appendChild(p);
|
||||
|
||||
const ul = document.createElement('ul');
|
||||
pushErr.details.forEach((detail) => {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = `${detail.url}: ${detail.body ?? ''}`;
|
||||
ul.appendChild(li);
|
||||
});
|
||||
fragment.appendChild(ul);
|
||||
|
||||
messageArea.replaceChildren(renderMessage('error', fragment));
|
||||
} else {
|
||||
messageArea.replaceChildren(textMessage('error', pushErr.message));
|
||||
}
|
||||
} else if (mempoolErr) {
|
||||
messageArea.innerHTML = renderMessage('error', mempoolErr.message);
|
||||
messageArea.replaceChildren(textMessage('error', mempoolErr.message));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user