├── .gitignore ├── .nojekyll ├── 404.html ├── README.md ├── _next └── static │ ├── S1fzvPQO3B3QgTHg-h6sc │ ├── _buildManifest.js │ └── _ssgManifest.js │ ├── chunks │ ├── 246-95e3632316189152b0be.js │ ├── framework-c5113a73163ba9a6512c.js │ ├── main-26b720ade6669956fe85.js │ ├── pages │ │ ├── _app-4be02ffccdd9fceacfca.js │ │ ├── _error-b30902e13465df7c5366.js │ │ └── index-4dcdb47e998e1d3dbb57.js │ ├── polyfills-eef578260fd80f8fff94.js │ └── webpack-277c75ec70a3d22a400d.js │ └── css │ ├── 81350cacca8d21e80c3b.css │ └── 87aae87ad240e6ad30f4.css ├── components ├── layout.module.css └── layout.tsx ├── favicon.png ├── index.html ├── next-env.d.ts ├── next.config.js ├── package-lock.json ├── package.json ├── pages ├── _app.tsx └── index.tsx ├── postcss.config.js ├── public └── favicon.png ├── styles └── utils.module.css ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | /verifysignature 18 | 19 | # misc 20 | .DS_Store 21 | .idea 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env.local 30 | .env.development.local 31 | .env.test.local 32 | .env.production.local 33 | -------------------------------------------------------------------------------- /.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BlueWallet/VerifySignature/9943aca61e1f07260bbd80453c50967231796324/.nojekyll -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | 404: This page could not be found

404

This page could not be found.

-------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Verify bitcoin address signature online 2 | ======================================= 3 | 4 | Why? Because none of the existing pages on the interwebs are good. None of them could accept all the data via get parameters, 5 | and none of them were easily forkable to be hosted independently. 6 | 7 | This implementation can accept get parameters, so it is linkable externally, and users could easily copy-paste one link to their counterparties to verify. 8 | This should be useful for people who do OTC and regularly do proof-of-funds before the transaction. 9 | 10 | Try it 11 | ------ 12 | 13 | * hosted on https://bluewallet.github.io/VerifySignature 14 | * or try with get parameters: https://bluewallet.github.io/VerifySignature?a=1HvaxYmChk9nQUZx888a6hc7E8KnKP98ic&m=test&s=HCfgnEo8RNYTgcOXafAf11BQQ5LXSvlss0AbnezENbFJQzRl0dJRGOfYbOrOPkb2iPdj21Cty5G4paevOks%2FpJ4%3D 15 | * ...or short it https://bit.ly/3Gm85si 16 | 17 | Built with 18 | ---------- 19 | 20 | * Next.js 21 | * Bitcoinjs 22 | * Typescript 23 | * Blockstream API (address balance) 24 | * ..compiles into static html files so it can run completely offline 25 | 26 | ![image](https://user-images.githubusercontent.com/1913337/127367603-0bff2674-07f0-4a4f-846d-b3a6fc7860db.png) 27 | 28 | 29 | Build it yourself 30 | ----------------- 31 | 32 | ```js 33 | npm i 34 | npm run export 35 | ``` 36 | 37 | And it is ready to be hosted on the website (should be served from `/VerifySignature/` path, i.e. `http://localhost:3000/VerifySignature`). 38 | Use `npm run dev` for development. 39 | 40 | License 41 | ------- 42 | 43 | MIT 44 | -------------------------------------------------------------------------------- /_next/static/S1fzvPQO3B3QgTHg-h6sc/_buildManifest.js: -------------------------------------------------------------------------------- 1 | self.__BUILD_MANIFEST={__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":["static/chunks/246-95e3632316189152b0be.js","static/css/81350cacca8d21e80c3b.css","static/chunks/pages/index-4dcdb47e998e1d3dbb57.js"],"/_error":["static/chunks/pages/_error-b30902e13465df7c5366.js"],sortedPages:["/","/_app","/_error"]},self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB(); -------------------------------------------------------------------------------- /_next/static/S1fzvPQO3B3QgTHg-h6sc/_ssgManifest.js: -------------------------------------------------------------------------------- 1 | self.__SSG_MANIFEST=new Set,self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB(); -------------------------------------------------------------------------------- /_next/static/chunks/main-26b720ade6669956fe85.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[179],{7228:function(e){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r1&&t.some(Array.isArray)?t.flat(e-1):t},Array.prototype.flatMap=function(e,t){return this.map(e,t).flat()}),Promise.prototype.finally||(Promise.prototype.finally=function(e){if("function"!=typeof e)return this.then(e,e);var t=this.constructor||Promise;return this.then((function(r){return t.resolve(e()).then((function(){return r}))}),(function(r){return t.resolve(e()).then((function(){throw r}))}))})},6086:function(e){"use strict";var t=Object.assign.bind(Object);e.exports=t,e.exports.default=e.exports},2771:function(e,t){"use strict";t.__esModule=!0,t.default=function(){var e=null;return{mountedInstances:new Set,updateHead:function(t){var r=e=Promise.resolve().then((function(){if(r===e){e=null;var o={};t.forEach((function(e){"link"===e.type&&e.props["data-optimized-fonts"]&&!document.querySelector('style[data-href="'.concat(e.props["data-href"],'"]'))&&(e.props.href=e.props["data-href"],e.props["data-href"]=void 0);var t=o[e.type]||[];t.push(e),o[e.type]=t}));var a=o.title?o.title[0]:null,i="";if(a){var u=a.props.children;i="string"===typeof u?u:Array.isArray(u)?u.join(""):""}i!==document.title&&(document.title=i),["meta","base","link","style","script"].forEach((function(e){!function(e,t){var r=document.getElementsByTagName("head")[0],o=r.querySelector("meta[name=next-head-count]");0;for(var a=Number(o.content),i=[],u=0,c=o.previousElementSibling;u0&&void 0!==s[0]?s[0]:{},r=N,e.prev=3,e.next=6,Q.routeLoader.whenEntrypoint("/_app");case 6:if(!("error"in(o=e.sent))){e.next=9;break}throw o.error;case 9:a=o.component,i=o.exports,Z=a,i&&i.reportWebVitals&&(ee=function(e){var t,r=e.id,n=e.name,o=e.startTime,a=e.value,u=e.duration,c=e.entryType,s=e.entries,l="".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12);s&&s.length&&(t=s[0].startTime),i.reportWebVitals({id:r||l,name:n,startTime:o||t,value:null==a?u:a,label:"mark"===c||"measure"===c?"custom":"web-vital"})}),e.next=16;break;case 16:return e.next=18,Q.routeLoader.whenEntrypoint(I);case 18:e.t0=e.sent;case 19:if(!("error"in(u=e.t0))){e.next=22;break}throw u.error;case 22:ne=u.component,e.next=27;break;case 27:e.next=32;break;case 29:e.prev=29,e.t1=e.catch(3),r=e.t1;case 32:if(!window.__NEXT_PRELOADREADY){e.next=36;break}return e.next=36,window.__NEXT_PRELOADREADY(q);case 36:return t.router=K=(0,T.createRouter)(I,j,$,{initialProps:M,pageLoader:Q,App:Z,Component:ne,wrapApp:me,err:r,isFallback:Boolean(W),subscription:function(e,t,r){return ue(Object.assign({},e,{App:t,scroll:r}))},locale:B,locales:G,defaultLocale:X,domainLocales:H,isPreview:V}),ue(c={App:Z,initial:!0,Component:ne,props:M,err:r}),e.abrupt("return",ae);case 43:return e.abrupt("return",{emitter:ae,render:ue,renderCtx:c});case 44:case"end":return e.stop()}}),e,null,[[3,29]])})));return function(){return e.apply(this,arguments)}}();function ue(e){return ce.apply(this,arguments)}function ce(){return(ce=o(n.mark((function e(t){return n.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.err){e.next=4;break}return e.next=3,se(t);case 3:return e.abrupt("return");case 4:return e.prev=4,e.next=7,ye(t);case 7:e.next=16;break;case 9:if(e.prev=9,e.t0=e.catch(4),!e.t0.cancelled){e.next=13;break}throw e.t0;case 13:return e.next=16,se((0,d.default)({},t,{err:e.t0}));case 16:case"end":return e.stop()}}),e,null,[[4,9]])})))).apply(this,arguments)}function se(e){var t=e.App,r=e.err;return console.error(r),Q.loadPage("/_error").then((function(n){var o=n.page,a=n.styleSheets,i=me(t),u={Component:o,AppTree:i,router:K,ctx:{err:r,pathname:I,query:j,asPath:$,AppTree:i}};return Promise.resolve(e.props?e.props:(0,P.loadGetInitialProps)(t,u)).then((function(t){return ye((0,d.default)({},e,{err:r,Component:o,styleSheets:a,props:t}))}))}))}t.default=ie;var le="function"===typeof m.default.hydrate;function fe(){P.ST&&(performance.mark("afterHydrate"),performance.measure("Next.js-before-hydration","navigationStart","beforeRender"),performance.measure("Next.js-hydration","beforeRender","afterHydrate"),ee&&performance.getEntriesByName("Next.js-hydration").forEach(ee),pe())}function he(){if(P.ST){performance.mark("afterRender");var e=performance.getEntriesByName("routeChange","mark");e.length&&(performance.measure("Next.js-route-change-to-render",e[0].name,"beforeRender"),performance.measure("Next.js-render","beforeRender","afterRender"),ee&&(performance.getEntriesByName("Next.js-render").forEach(ee),performance.getEntriesByName("Next.js-route-change-to-render").forEach(ee)),pe(),["Next.js-route-change-to-render","Next.js-render"].forEach((function(e){return performance.clearMeasures(e)})))}}function pe(){["beforeRender","afterHydrate","afterRender","routeChange"].forEach((function(e){return performance.clearMarks(e)}))}function de(e){var t=e.children;return v.default.createElement(oe,{fn:function(e){return se({App:Z,err:e}).catch((function(e){return console.error("Error rendering page: ",e)}))}},v.default.createElement(b.RouterContext.Provider,{value:(0,T.makePublicRouterInstance)(K)},v.default.createElement(y.HeadManagerContext.Provider,{value:te},t)))}var ve,me=function(e){return function(t){var r=(0,d.default)({},t,{Component:ne,err:N,router:K});return v.default.createElement(de,null,v.default.createElement(e,r))}};function ye(e){var t=e.App,r=e.Component,n=e.props,o=e.err,a="initial"in e?void 0:e.styleSheets;r=r||ve.Component,n=n||ve.props;var i=(0,d.default)({},n,{Component:r,err:o,router:K});ve=i;var u,c=!1,s=new Promise((function(e,t){J&&J(),u=function(){J=null,e()},J=function(){c=!0,J=null;var e=new Error("Cancel rendering route");e.cancelled=!0,t(e)}}));function l(){u()}!function(){if(!a)return!1;var e=O(document.querySelectorAll("style[data-n-href]")),t=new Set(e.map((function(e){return e.getAttribute("data-n-href")}))),r=document.querySelector("noscript[data-n-css]"),n=null==r?void 0:r.getAttribute("data-n-css");a.forEach((function(e){var r=e.href,o=e.text;if(!t.has(r)){var a=document.createElement("style");a.setAttribute("data-n-href",r),a.setAttribute("media","x"),n&&a.setAttribute("nonce",n),document.head.appendChild(a),a.appendChild(document.createTextNode(o))}}))}();var f=v.default.createElement(v.default.Fragment,null,v.default.createElement(be,{callback:function(){if(a&&!c){for(var t=new Set(a.map((function(e){return e.href}))),r=O(document.querySelectorAll("style[data-n-href]")),n=r.map((function(e){return e.getAttribute("data-n-href")})),o=0;o=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return u=e.done,e},e:function(e){c=!0,i=e},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw i}}}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r>>0,1)},emit:function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o-1||r>-1)&&(e=e.substring(0,t>-1?t:r)),e}function E(e){return(e=P(e))===_||e.startsWith(_+"/")}function k(e){return function(e,t){return t&&e.startsWith("/")?"/"===e?(0,c.normalizePathTrailingSlash)(t):"".concat(t).concat("/"===P(e)?e.substring(1):e):e}(e,_)}function R(e){return(e=e.slice(_.length)).startsWith("/")||(e="/".concat(e)),e}function C(e){if(e.startsWith("/")||e.startsWith("#"))return!0;try{var t=(0,h.getLocationOrigin)(),r=new URL(e,t);return r.origin===t&&E(r.pathname)}catch(n){return!1}}function L(e,t,r){var n="",o=(0,g.getRouteRegex)(e),a=o.groups,i=(t!==e?(0,y.getRouteMatcher)(o)(t):"")||r;n=e;var u=Object.keys(a);return u.every((function(e){var t=i[e]||"",r=a[e],o=r.repeat,u=r.optional,c="[".concat(o?"...":"").concat(e,"]");return u&&(c="".concat(t?"":"/","[").concat(c,"]")),o&&!Array.isArray(t)&&(t=[t]),(u||e in i)&&(n=n.replace(c,o?t.map((function(e){return encodeURIComponent(e)})).join("/"):encodeURIComponent(t))||"/")}))||(n=""),{params:u,result:n}}function T(e,t){var r={};return Object.keys(e).forEach((function(n){t.includes(n)||(r[n]=e[n])})),r}function A(e,t,r){var n;try{n=new URL(e,"http://n")}catch(m){n=new URL("/","http://n")}var o="string"===typeof t?t:(0,h.formatWithValidation)(t);if(!C(o))return r?[o]:o;try{var a=new URL(o,n);a.pathname=(0,c.normalizePathTrailingSlash)(a.pathname);var i="";if((0,p.isDynamicRoute)(a.pathname)&&a.searchParams&&r){var u=(0,v.searchParamsToUrlQuery)(a.searchParams),s=L(a.pathname,a.pathname,u),l=s.result,f=s.params;l&&(i=(0,h.formatWithValidation)({pathname:l,hash:a.hash,query:T(u,f)}))}var d=a.origin===n.origin?a.href.slice(a.origin.length):a.href;return r?[d,i||d]:d}catch(m){return r?[o]:o}}function O(e){var t=(0,h.getLocationOrigin)();return e.startsWith(t)?e.substring(t.length):e}function M(e,t,r){var n=A(e.asPath,t,!0),o=u(n,2),a=o[0],i=o[1],c=(0,h.getLocationOrigin)(),s=a.startsWith(c),l=i&&i.startsWith(c);a=O(a),i=i?O(i):i;var f=s?a:k(a),p=r?O(A(e.asPath,r)):i||a;return{url:f,as:l?p:k(p)}}function N(e,t){var r=(0,c.removePathTrailingSlash)((0,l.denormalizePagePath)(e));return"/404"===r||"/_error"===r?e:(t.includes(r)||t.some((function(t){if((0,p.isDynamicRoute)(t)&&(0,g.getRouteRegex)(t).re.test(r))return e=t,!0})),(0,c.removePathTrailingSlash)(e))}var I=Symbol("SSG_DATA_NOT_FOUND");function j(e,t){return fetch(e,{credentials:"same-origin"}).then((function(r){if(!r.ok){if(t>1&&r.status>=500)return j(e,t-1);if(404===r.status)return r.json().then((function(e){if(e.notFound)return{notFound:I};throw new Error("Failed to load static props")}));throw new Error("Failed to load static props")}return r.json()}))}function D(e,t){return j(e,t?3:1).catch((function(e){throw t||(0,s.markAssetError)(e),e}))}var F=function(){function e(t,r,n,o){var i=this,u=o.initialProps,s=o.pageLoader,l=o.App,f=o.wrapApp,v=o.Component,m=o.err,y=o.subscription,g=o.isFallback,b=o.locale,w=(o.locales,o.defaultLocale,o.domainLocales,o.isPreview);a(this,e),this.route=void 0,this.pathname=void 0,this.query=void 0,this.asPath=void 0,this.basePath=void 0,this.components=void 0,this.sdc={},this.sdr={},this.sub=void 0,this.clc=void 0,this.pageLoader=void 0,this._bps=void 0,this.events=void 0,this._wrapApp=void 0,this.isSsr=void 0,this.isFallback=void 0,this._inFlightRoute=void 0,this._shallow=void 0,this.locale=void 0,this.locales=void 0,this.defaultLocale=void 0,this.domainLocales=void 0,this.isReady=void 0,this.isPreview=void 0,this.isLocaleDomain=void 0,this._idx=0,this.onPopState=function(e){var t=e.state;if(t){if(t.__N){var r=t.url,n=t.as,o=t.options,a=t.idx;i._idx=a;var u=(0,d.parseRelativeUrl)(r).pathname;i.isSsr&&n===i.asPath&&u===i.pathname||i._bps&&!i._bps(t)||i.change("replaceState",r,n,Object.assign({},o,{shallow:o.shallow&&i._shallow,locale:o.locale||i.defaultLocale}),undefined)}}else{var c=i.pathname,s=i.query;i.changeState("replaceState",(0,h.formatWithValidation)({pathname:k(c),query:s}),(0,h.getURL)())}},this.route=(0,c.removePathTrailingSlash)(t),this.components={},"/_error"!==t&&(this.components[this.route]={Component:v,initial:!0,props:u,err:m,__N_SSG:u&&u.__N_SSG,__N_SSP:u&&u.__N_SSP}),this.components["/_app"]={Component:l,styleSheets:[]},this.events=e.events,this.pageLoader=s,this.pathname=t,this.query=r;var x=(0,p.isDynamicRoute)(t)&&self.__NEXT_DATA__.autoExport;this.asPath=x?t:n,this.basePath=_,this.sub=y,this.clc=null,this._wrapApp=f,this.isSsr=!0,this.isFallback=g,this.isReady=!(!self.__NEXT_DATA__.gssp&&!self.__NEXT_DATA__.gip&&(x||self.location.search)),this.isPreview=!!w,this.isLocaleDomain=!1,"//"!==n.substr(0,2)&&this.changeState("replaceState",(0,h.formatWithValidation)({pathname:k(t),query:r}),(0,h.getURL)(),{locale:b}),window.addEventListener("popstate",this.onPopState)}return i(e,[{key:"reload",value:function(){window.location.reload()}},{key:"back",value:function(){window.history.back()}},{key:"push",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var n=M(this,e,t);return e=n.url,t=n.as,this.change("pushState",e,t,r)}},{key:"replace",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=M(this,e,t);return e=n.url,t=n.as,this.change("replaceState",e,t,r)}},{key:"change",value:function(){var t=o(n.mark((function t(r,o,a,i,u){var l,f,v,m,b,_,w,P,A,O,j,D,F,U,q,W,B,G,H,V,X,z,$,Q,Y,J,K,Z,ee,te,re,ne,oe,ae,ie;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(C(o)){t.next=3;break}return window.location.href=o,t.abrupt("return",!1);case 3:f=o===a||i._h,i._h&&(this.isReady=!0),i.scroll=!(null!=(l=i.scroll)&&!l),v=i.locale!==this.locale,t.next=19;break;case 19:if(i._h||(this.isSsr=!1),h.ST&&performance.mark("routeChange"),m=i.shallow,b={shallow:void 0!==m&&m},this._inFlightRoute&&this.abortComponentLoad(this._inFlightRoute,b),a=k(x(E(a)?R(a):a,i.locale,this.defaultLocale)),_=S(E(a)?R(a):a,this.locale),this._inFlightRoute=a,i._h||!this.onlyAHashChange(_)){t.next=35;break}return this.asPath=_,e.events.emit("hashChangeStart",a,b),this.changeState(r,o,a,i),this.scrollToHash(_),this.notify(this.components[this.route],null),e.events.emit("hashChangeComplete",a,b),t.abrupt("return",!0);case 35:return w=(0,d.parseRelativeUrl)(o),P=w.pathname,A=w.query,t.prev=37,t.next=40,this.pageLoader.getPageList();case 40:return O=t.sent,t.next=43,(0,s.getClientBuildManifest)();case 43:j=t.sent,j.__rewrites,t.next=51;break;case 47:return t.prev=47,t.t0=t.catch(37),window.location.href=a,t.abrupt("return",!1);case 51:if(this.urlIsNew(_)||v||(r="replaceState"),D=a,P=P?(0,c.removePathTrailingSlash)(R(P)):P,f&&"/_error"!==P&&(w.pathname=N(P,O),w.pathname!==P&&(P=w.pathname,o=(0,h.formatWithValidation)(w))),F=(0,c.removePathTrailingSlash)(P),C(a)){t.next=61;break}t.next=59;break;case 59:return window.location.href=a,t.abrupt("return",!1);case 61:if(D=S(R(D),this.locale),!(0,p.isDynamicRoute)(F)){t.next=77;break}if(U=(0,d.parseRelativeUrl)(D),q=U.pathname,W=(0,g.getRouteRegex)(F),B=(0,y.getRouteMatcher)(W)(q),H=(G=F===q)?L(F,q,A):{},B&&(!G||H.result)){t.next=76;break}if(!((V=Object.keys(W.groups).filter((function(e){return!A[e]}))).length>0)){t.next=74;break}throw new Error((G?"The provided `href` (".concat(o,") value is missing query values (").concat(V.join(", "),") to be interpolated properly. "):"The provided `as` value (".concat(q,") is incompatible with the `href` value (").concat(F,"). "))+"Read more: https://nextjs.org/docs/messages/".concat(G?"href-interpolation-failed":"incompatible-href-as"));case 74:t.next=77;break;case 76:G?a=(0,h.formatWithValidation)(Object.assign({},U,{pathname:H.result,query:T(A,H.params)})):Object.assign(A,B);case 77:return e.events.emit("routeChangeStart",a,b),t.prev=78,t.next=81,this.getRouteInfo(F,P,A,a,D,b);case 81:if($=t.sent,Y=(Q=$).error,J=Q.props,K=Q.__N_SSG,Z=Q.__N_SSP,!K&&!Z||!J){t.next=108;break}if(!J.pageProps||!J.pageProps.__N_REDIRECT){t.next=94;break}if(!(ee=J.pageProps.__N_REDIRECT).startsWith("/")){t.next=92;break}if((te=(0,d.parseRelativeUrl)(ee)).pathname=N(te.pathname,O),!O.includes(te.pathname)){t.next=92;break}return re=M(this,ee,ee),ne=re.url,oe=re.as,t.abrupt("return",this.change(r,ne,oe,i));case 92:return window.location.href=ee,t.abrupt("return",new Promise((function(){})));case 94:if(this.isPreview=!!J.__N_PREVIEW,J.notFound!==I){t.next=108;break}return t.prev=96,t.next=99,this.fetchComponent("/404");case 99:ae="/404",t.next=105;break;case 102:t.prev=102,t.t1=t.catch(96),ae="/_error";case 105:return t.next=107,this.getRouteInfo(ae,ae,A,a,D,{shallow:!1});case 107:$=t.sent;case 108:return e.events.emit("beforeHistoryChange",a,b),this.changeState(r,o,a,i),ie=i.shallow&&this.route===F,i._h&&"/_error"===P&&500===(null==(X=self.__NEXT_DATA__.props)||null==(z=X.pageProps)?void 0:z.statusCode)&&null!=J&&J.pageProps&&(J.pageProps.statusCode=500),t.next=115,this.set(F,P,A,_,$,u||(ie||!i.scroll?null:{x:0,y:0})).catch((function(e){if(!e.cancelled)throw e;Y=Y||e}));case 115:if(!Y){t.next=118;break}throw e.events.emit("routeChangeError",Y,_,b),Y;case 118:return e.events.emit("routeChangeComplete",a,b),t.abrupt("return",!0);case 123:if(t.prev=123,t.t2=t.catch(78),!t.t2.cancelled){t.next=127;break}return t.abrupt("return",!1);case 127:throw t.t2;case 128:case"end":return t.stop()}}),t,this,[[37,47],[78,123],[96,102]])})));return function(e,r,n,o,a){return t.apply(this,arguments)}}()},{key:"changeState",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};"pushState"===e&&(0,h.getURL)()===r||(this._shallow=n.shallow,window.history[e]({url:t,as:r,options:n,__N:!0,idx:this._idx="pushState"!==e?this._idx:this._idx+1},"",r))}},{key:"handleRouteInfoError",value:function(){var t=o(n.mark((function t(r,o,a,i,u,c){var l,f,h,p;return n.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r.cancelled){t.next=2;break}throw r;case 2:if(!(0,s.isAssetError)(r)&&!c){t.next=6;break}throw e.events.emit("routeChangeError",r,i,u),window.location.href=i,w();case 6:if(t.prev=6,"undefined"!==typeof l&&"undefined"!==typeof f){t.next=14;break}return t.next=11,this.fetchComponent("/_error");case 11:h=t.sent,l=h.page,f=h.styleSheets;case 14:if((p={props:undefined,Component:l,styleSheets:f,err:r,error:r}).props){t.next=26;break}return t.prev=16,t.next=19,this.getInitialProps(l,{err:r,pathname:o,query:a});case 19:p.props=t.sent,t.next=26;break;case 22:t.prev=22,t.t0=t.catch(16),console.error("Error in error page `getInitialProps`: ",t.t0),p.props={};case 26:return t.abrupt("return",p);case 29:return t.prev=29,t.t1=t.catch(6),t.abrupt("return",this.handleRouteInfoError(t.t1,o,a,i,u,!0));case 32:case"end":return t.stop()}}),t,this,[[6,29],[16,22]])})));return function(e,r,n,o,a,i){return t.apply(this,arguments)}}()},{key:"getRouteInfo",value:function(){var e=o(n.mark((function e(t,r,o,a,i,u){var c,s,l,f,p,d,v,m,y=this;return n.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,c=this.components[t],!u.shallow||!c||this.route!==t){e.next=4;break}return e.abrupt("return",c);case 4:if(!(s=c&&"initial"in c?void 0:c)){e.next=9;break}e.t0=s,e.next=12;break;case 9:return e.next=11,this.fetchComponent(t).then((function(e){return{Component:e.page,styleSheets:e.styleSheets,__N_SSG:e.mod.__N_SSG,__N_SSP:e.mod.__N_SSP}}));case 11:e.t0=e.sent;case 12:l=e.t0,f=l.Component,p=l.__N_SSG,d=l.__N_SSP,e.next=18;break;case 18:return(p||d)&&(v=this.pageLoader.getDataHref((0,h.formatWithValidation)({pathname:r,query:o}),i,p,this.locale)),e.next=21,this._getData((function(){return p?y._getStaticData(v):d?y._getServerData(v):y.getInitialProps(f,{pathname:r,query:o,asPath:a,locale:y.locale,locales:y.locales,defaultLocale:y.defaultLocale})}));case 21:return m=e.sent,l.props=m,this.components[t]=l,e.abrupt("return",l);case 27:return e.prev=27,e.t1=e.catch(0),e.abrupt("return",this.handleRouteInfoError(e.t1,r,o,a,u));case 30:case"end":return e.stop()}}),e,this,[[0,27]])})));return function(t,r,n,o,a,i){return e.apply(this,arguments)}}()},{key:"set",value:function(e,t,r,n,o,a){return this.isFallback=!1,this.route=e,this.pathname=t,this.query=r,this.asPath=n,this.notify(o,a)}},{key:"beforePopState",value:function(e){this._bps=e}},{key:"onlyAHashChange",value:function(e){if(!this.asPath)return!1;var t=this.asPath.split("#"),r=u(t,2),n=r[0],o=r[1],a=e.split("#"),i=u(a,2),c=i[0],s=i[1];return!(!s||n!==c||o!==s)||n===c&&o!==s}},{key:"scrollToHash",value:function(e){var t=e.split("#"),r=u(t,2)[1];if(""!==r&&"top"!==r){var n=document.getElementById(r);if(n)n.scrollIntoView();else{var o=document.getElementsByName(r)[0];o&&o.scrollIntoView()}}else window.scrollTo(0,0)}},{key:"urlIsNew",value:function(e){return this.asPath!==e}},{key:"prefetch",value:function(){var e=o(n.mark((function e(t){var r,o,a,i,u,s,l,f,p,v,y=this,g=arguments;return n.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=g.length>1&&void 0!==g[1]?g[1]:t,o=g.length>2&&void 0!==g[2]?g[2]:{},a=(0,d.parseRelativeUrl)(t),i=a.pathname,e.next=7,this.pageLoader.getPageList();case 7:u=e.sent,s=r,e.next=19;break;case 12:f=e.sent,l=f.__rewrites,p=(0,m.default)(k(x(r,this.locale)),u,l,a.query,(function(e){return N(e,u)}),this.locales),s=S(R(p.asPath),this.locale),p.matchedPage&&p.resolvedHref&&(i=p.resolvedHref,a.pathname=i,t=(0,h.formatWithValidation)(a)),e.next=21;break;case 19:a.pathname=N(a.pathname,u),a.pathname!==i&&(i=a.pathname,t=(0,h.formatWithValidation)(a));case 21:v=(0,c.removePathTrailingSlash)(i),e.next=24;break;case 24:return e.next=26,Promise.all([this.pageLoader._isSsg(v).then((function(e){return!!e&&y._getStaticData(y.pageLoader.getDataHref(t,s,!0,"undefined"!==typeof o.locale?o.locale:y.locale))})),this.pageLoader[o.priority?"loadPage":"prefetch"](v)]);case 26:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"fetchComponent",value:function(){var e=o(n.mark((function e(t){var r,o,a,i;return n.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=!1,o=this.clc=function(){r=!0},e.next=4,this.pageLoader.loadPage(t);case 4:if(a=e.sent,!r){e.next=9;break}throw(i=new Error('Abort fetching component for route: "'.concat(t,'"'))).cancelled=!0,i;case 9:return o===this.clc&&(this.clc=null),e.abrupt("return",a);case 11:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}()},{key:"_getData",value:function(e){var t=this,r=!1,n=function(){r=!0};return this.clc=n,e().then((function(e){if(n===t.clc&&(t.clc=null),r){var o=new Error("Loading initial props cancelled");throw o.cancelled=!0,o}return e}))}},{key:"_getStaticData",value:function(e){var t=this,r=new URL(e,window.location.href).href;return!this.isPreview&&this.sdc[r]?Promise.resolve(this.sdc[r]):D(e,this.isSsr).then((function(e){return t.sdc[r]=e,e}))}},{key:"_getServerData",value:function(e){var t=this,r=new URL(e,window.location.href).href;return this.sdr[r]?this.sdr[r]:this.sdr[r]=D(e,this.isSsr).then((function(e){return delete t.sdr[r],e})).catch((function(e){throw delete t.sdr[r],e}))}},{key:"getInitialProps",value:function(e,t){var r=this.components["/_app"].Component,n=this._wrapApp(r);return t.AppTree=n,(0,h.loadGetInitialProps)(r,{AppTree:n,Component:e,router:this,ctx:t})}},{key:"abortComponentLoad",value:function(t,r){this.clc&&(e.events.emit("routeChangeError",w(),t,r),this.clc(),this.clc=null)}},{key:"notify",value:function(e,t){return this.sub(e,this.components["/_app"].Component,t)}}]),e}();t.default=F,F.events=(0,f.default)()},7687:function(e,t,r){"use strict";t.__esModule=!0,t.formatUrl=function(e){var t=e.auth,r=e.hostname,o=e.protocol||"",i=e.pathname||"",u=e.hash||"",c=e.query||"",s=!1;t=t?encodeURIComponent(t).replace(/%3A/i,":")+"@":"",e.host?s=t+e.host:r&&(s=t+(~r.indexOf(":")?"[".concat(r,"]"):r),e.port&&(s+=":"+e.port));c&&"object"===typeof c&&(c=String(n.urlQueryToSearchParams(c)));var l=e.search||c&&"?".concat(c)||"";o&&":"!==o.substr(-1)&&(o+=":");e.slashes||(!o||a.test(o))&&!1!==s?(s="//"+(s||""),i&&"/"!==i[0]&&(i="/"+i)):s||(s="");u&&"#"!==u[0]&&(u="#"+u);l&&"?"!==l[0]&&(l="?"+l);return i=i.replace(/[?#]/g,encodeURIComponent),l=l.replace("#","%23"),"".concat(o).concat(s).concat(i).concat(l).concat(u)};var n=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==typeof e&&"function"!==typeof e)return{default:e};var t=o();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var i=n?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(r,a,i):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r(4915));function o(){if("function"!==typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}var a=/https?|ftp|gopher|file/},7892:function(e,t){"use strict";t.__esModule=!0,t.default=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r="/"===e?"/index":/^\/index(\/|$)/.test(e)?"/index".concat(e):"".concat(e);return r+t}},3288:function(e,t){"use strict";t.__esModule=!0,t.isDynamicRoute=function(e){return r.test(e)};var r=/\/\[[^/]+?\](?=\/|$)/},4436:function(e,t,r){"use strict";t.__esModule=!0,t.parseRelativeUrl=function(e,t){var r=new URL((0,n.getLocationOrigin)()),a=t?new URL(t,r):r,i=new URL(e,a),u=i.pathname,c=i.searchParams,s=i.search,l=i.hash,f=i.href;if(i.origin!==r.origin)throw new Error("invariant: invalid relative URL, router received ".concat(e));return{pathname:u,query:(0,o.searchParamsToUrlQuery)(c),search:s,hash:l,href:f.slice(r.origin.length)}};var n=r(3937),o=r(4915)},4915:function(e,t,r){"use strict";var n=r(3038);function o(e){return"string"===typeof e||"number"===typeof e&&!isNaN(e)||"boolean"===typeof e?String(e):""}t.__esModule=!0,t.searchParamsToUrlQuery=function(e){var t={};return e.forEach((function(e,r){"undefined"===typeof t[r]?t[r]=e:Array.isArray(t[r])?t[r].push(e):t[r]=[t[r],e]})),t},t.urlQueryToSearchParams=function(e){var t=new URLSearchParams;return Object.entries(e).forEach((function(e){var r=n(e,2),a=r[0],i=r[1];Array.isArray(i)?i.forEach((function(e){return t.append(a,o(e))})):t.set(a,o(i))})),t},t.assign=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n1&&void 0!==arguments[1]?arguments[1]:-1,delta:0,entries:[],id:n(),isFinal:!1}},a=function(e,t){try{if(PerformanceObserver.supportedEntryTypes.includes(e)){var r=new PerformanceObserver((function(e){return e.getEntries().map(t)}));return r.observe({type:e,buffered:!0}),r}}catch(e){}},i=!1,u=!1,c=function(e){i=!e.persisted},s=function(){addEventListener("pagehide",c),addEventListener("beforeunload",(function(){}))},l=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];u||(s(),u=!0),addEventListener("visibilitychange",(function(t){var r=t.timeStamp;"hidden"===document.visibilityState&&e({timeStamp:r,isUnloading:i})}),{capture:!0,once:t})},f=function(e,t,r,n){var o;return function(){r&&t.isFinal&&r.disconnect(),t.value>=0&&(n||t.isFinal||"hidden"===document.visibilityState)&&(t.delta=t.value-(o||0),(t.delta||t.isFinal||void 0===o)&&(e(t),o=t.value))}},h=function(){return void 0===t&&(t="hidden"===document.visibilityState?0:1/0,l((function(e){var r=e.timeStamp;return t=r}),!0)),{get timeStamp(){return t}}},p=function(){return r||(r=new Promise((function(e){return["scroll","keydown","pointerdown"].map((function(t){addEventListener(t,e,{once:!0,passive:!0,capture:!0})}))}))),r};e.getCLS=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=o("CLS",0),i=function(e){e.hadRecentInput||(n.value+=e.value,n.entries.push(e),t())},u=a("layout-shift",i);u&&(t=f(e,n,u,r),l((function(e){var r=e.isUnloading;u.takeRecords().map(i),r&&(n.isFinal=!0),t()})))},e.getFCP=function(e){var t,r=o("FCP"),n=h(),i=a("paint",(function(e){"first-contentful-paint"===e.name&&e.startTime1&&void 0!==arguments[1]&&arguments[1],n=o("LCP"),i=h(),u=function(e){var r=e.startTime;r=0;--a){var i=this.tryEntries[a],u=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var c=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(c&&s){if(this.prev=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),R(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;R(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}(e.exports);try{regeneratorRuntime=t}catch(r){Function("r","regeneratorRuntime = r")(t)}},4453:function(){}},function(e){e.O(0,[774],(function(){return t=5778,e(e.s=t);var t}));var t=e.O();_N_E=t}]); -------------------------------------------------------------------------------- /_next/static/chunks/pages/_app-4be02ffccdd9fceacfca.js: -------------------------------------------------------------------------------- 1 | (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[888],{2898:function(e,r,t){"use strict";function n(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}t.r(r),t.d(r,{default:function(){return u}});var o=t(5893);t(6390);function c(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function u(e){var r=e.Component,t=e.pageProps;return(0,o.jsx)(r,function(e){for(var r=1;r0&&void 0!==arguments[0]?arguments[0]:{},t=e.ampFirst,n=void 0!==t&&t,r=e.hybrid,a=void 0!==r&&r,o=e.hasQuery,i=void 0!==o&&o;return n||a&&i}},7947:function(e,t,n){"use strict";var r=n(9713);function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}t.__esModule=!0,t.defaultHead=d,t.default=void 0;var o,i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==typeof e&&"function"!==typeof e)return{default:e};var t=l();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=r?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(n,a,o):n[a]=e[a]}n.default=e,t&&t.set(e,n);return n}(n(7294)),u=(o=n(617))&&o.__esModule?o:{default:o},c=n(3367),s=n(4287),f=n(7845);function l(){if("function"!==typeof WeakMap)return null;var e=new WeakMap;return l=function(){return e},e}function d(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=[i.default.createElement("meta",{charSet:"utf-8"})];return e||t.push(i.default.createElement("meta",{name:"viewport",content:"width=device-width"})),t}function p(e,t){return"string"===typeof t||"number"===typeof t?e:t.type===i.default.Fragment?e.concat(i.default.Children.toArray(t.props.children).reduce((function(e,t){return"string"===typeof t||"number"===typeof t?e:e.concat(t)}),[])):e.concat(t)}var h=["name","httpEquiv","charSet","itemProp"];function y(e,t){return e.reduce((function(e,t){var n=i.default.Children.toArray(t.props.children);return e.concat(n)}),[]).reduce(p,[]).reverse().concat(d(t.inAmpMode)).filter(function(){var e=new Set,t=new Set,n=new Set,r={};return function(a){var o=!0,i=!1;if(a.key&&"number"!==typeof a.key&&a.key.indexOf("$")>0){i=!0;var u=a.key.slice(a.key.indexOf("$")+1);e.has(u)?o=!1:e.add(u)}switch(a.type){case"title":case"base":t.has(a.type)?o=!1:t.add(a.type);break;case"meta":for(var c=0,s=h.length;c0?ut:at)(t)},ct=Math.min,ft=function(t){return t>0?ct(st(t),9007199254740991):0},lt=Math.max,ht=Math.min,pt=function(t,e){var r=st(t);return r<0?lt(r+e,0):ht(r,e)},dt=function(t){return function(e,r,n){var o,i=g(e),a=ft(i.length),u=pt(n,a);if(t&&r!=r){for(;a>u;)if((o=i[u++])!=o)return!0}else for(;a>u;u++)if((t||u in i)&&i[u]===r)return t||u||0;return!t&&-1}},vt={includes:dt(!0),indexOf:dt(!1)},gt=vt.indexOf,yt=function(t,e){var r,n=g(t),o=0,i=[];for(r in n)!w(H,r)&&w(n,r)&&i.push(r);for(;e.length>o;)w(n,r=e[o++])&&(~gt(i,r)||i.push(r));return i},mt=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],bt=mt.concat("length","prototype"),wt={f:Object.getOwnPropertyNames||function(t){return yt(t,bt)}},St={f:Object.getOwnPropertySymbols},Et=it("Reflect","ownKeys")||function(t){var e=wt.f(j(t)),r=St.f;return r?e.concat(r(t)):e},xt=function(t,e){for(var r=Et(e),n=I.f,o=R.f,i=0;i2?arguments[2]:void 0,u=_t((void 0===a?n:pt(a,n))-i,n-o),s=1;for(i0;)i in r?r[o]=r[i]:delete r[o],o+=s,i+=s;return r},Nt=!!Object.getOwnPropertySymbols&&!i((function(){return!String(Symbol())})),Ct=Nt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Ft=z("wks"),Bt=o.Symbol,Dt=Ct?Bt:Bt&&Bt.withoutSetter||G,qt=function(t){return w(Ft,t)||(Ft[t]=Nt&&w(Bt,t)?Bt[t]:Dt("Symbol."+t)),Ft[t]},zt=Object.keys||function(t){return yt(t,mt)},Wt=a?Object.defineProperties:function(t,e){j(t);for(var r,n=zt(e),o=n.length,i=0;o>i;)I.f(t,r=n[i++],e[r]);return t},Kt=it("document","documentElement"),Gt=V("IE_PROTO"),$t=function(){},Vt=function(t){return" -------------------------------------------------------------------------------- /next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | basePath: '/VerifySignature', 3 | assetPrefix: '/VerifySignature/', 4 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "verifysignature", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next dev", 6 | "tslint": "tslint --fix -p . -c tslint.json ", 7 | "build": "next build", 8 | "export": "rm -r -f VerifySignature; rm -r -f .next; rm -r -f _next; next build && next export -o VerifySignature; mv VerifySignature/* ./", 9 | "start": "next start" 10 | }, 11 | "devDependencies": { 12 | "@types/react": "^17.0.8", 13 | "tslint": "^6.1.3", 14 | "tslint-config-airbnb": "^5.11.2", 15 | "tslint-react-hooks": "^2.2.2", 16 | "typescript": "^4.2.4", 17 | "bitcoinjs-message": "^2.2.0", 18 | "bootstrap": "^5.0.0-beta3", 19 | "next": "^10.0.0", 20 | "postcss-flexbugs-fixes": "^5.0.2", 21 | "postcss-preset-env": "^6.7.0", 22 | "react": "17.0.1", 23 | "react-dom": "17.0.1", 24 | "swr": "^0.5.6" 25 | }, 26 | "dependencies": {} 27 | } 28 | -------------------------------------------------------------------------------- /pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import 'bootstrap/dist/css/bootstrap.css'; 2 | import { AppProps } from 'next/app'; 3 | 4 | export default function App({ Component, pageProps }: AppProps) { 5 | return ; 6 | } 7 | -------------------------------------------------------------------------------- /pages/index.tsx: -------------------------------------------------------------------------------- 1 | import Head from 'next/head'; 2 | import Layout, { siteTitle } from '../components/layout'; 3 | import utilStyles from '../styles/utils.module.css'; 4 | import useSWR from 'swr'; 5 | import { useEffect, useState } from 'react'; 6 | import { useRouter } from 'next/router'; 7 | import bitcoinMessage from 'bitcoinjs-message'; 8 | 9 | const addressBalanceFetcher = async (address: string) => { 10 | if (!address) { 11 | return {}; 12 | } 13 | 14 | const res = await fetch(`https://blockstream.info/api/address/${address}`); 15 | return await res.json(); 16 | }; 17 | 18 | export default function Home() { 19 | 20 | const router = useRouter(); 21 | const { a, m, s } = router.query; 22 | 23 | const [address, setAddress] = useState(''); 24 | const [message, setMessage] = useState(''); 25 | const [signature, setSignature] = useState(''); 26 | const [isVerified, setIsVerified] = useState(false); 27 | 28 | const { data, error }: { data?: any, error?: any } = useSWR(`${address}`, addressBalanceFetcher); 29 | 30 | useEffect(() => { 31 | verify(); 32 | }, [address, message, signature]); 33 | 34 | useEffect(() => { 35 | if (a) setAddress(String(a)); 36 | if (m) setMessage(String(m)); 37 | if (s) setSignature(String(s)); 38 | verify(); 39 | }, [a, m, s]); 40 | 41 | const bitcoinMessageVerify = (message, address, signature) => { 42 | // undefined, true so it can verify Electrum signatures without errors 43 | try { 44 | return bitcoinMessage.verify(message, address, signature, undefined, true); 45 | } catch (e) { 46 | if (e.message === 'checkSegwitAlways can only be used with a compressed pubkey signature flagbyte') { 47 | // If message created with uncompressed private key, it will throw this error 48 | // in this case we should re-try with checkSegwitAlways flag off 49 | // node_modules/bitcoinjs-message/index.js:187 50 | return bitcoinMessage.verify(message, address, signature); 51 | } 52 | throw e; 53 | } 54 | }; 55 | 56 | const verify = () => { 57 | setIsVerified(false); 58 | try { 59 | router.push(`/?a=${address}&m=${encodeURIComponent(message)}&s=${encodeURIComponent(signature)}`, null, { shallow: true }); 60 | const verified = bitcoinMessageVerify(message, address, signature); 61 | console.log({ message, address, signature, verified }); 62 | setIsVerified(verified); 63 | 64 | } catch (error) { 65 | console.warn(error.message); 66 | } 67 | }; 68 | 69 | return ( 70 | 71 | 72 | {siteTitle} 73 | 74 | 75 |
76 | 77 |
78 | 79 |
{ 80 | event.preventDefault(); 81 | verify(); 82 | }}> 83 | 84 |
85 |
86 | address: 87 |
88 |
89 | setAddress(event.target.value)} /> 90 |
91 |
92 | 93 |
94 |
95 | message: 96 |
97 |
98 |