Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitcoin-address-validation

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitcoin-address-validation - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

2

lib/index.cjs.js

@@ -16,2 +16,2 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});

***************************************************************************** */
var t=function(){return t=Object.assign||function(t){for(var r,e=1,s=arguments.length;e<s;e++)for(var n in r=arguments[e])Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n]);return t},t.apply(this,arguments)};var r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var e=t=>{if(!t||"string"!=typeof t)throw new Error(`Expected base58 string but got “${t}”`);if(t.match(/[IOl0]/gm))throw new Error(`Invalid base58 character “${t.match(/[IOl0]/gm)}”`);const e=t.match(/^1+/gm),s=e?e[0].length:0,n=(t.length-s)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(s),...t.match(/.{1}/g).map((t=>r.indexOf(t))).reduce(((t,r)=>t=t.map((t=>{const e=58*t+r;return r=e>>8,e}))),new Uint8Array(n)).reverse().filter((o=!1,t=>o=o||t))]);var o};(()=>{const t=Array(256).fill(-1);for(let e=0;e<r.length;++e)t[r.charCodeAt(e)]=e})();var s=e;function n(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function o(t,r){return t(r={exports:{}},r.exports),r.exports}var i=o((function(t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bech32m=r.bech32=void 0;const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l",s={};for(let t=0;t<e.length;t++){const r=e.charAt(t);s[r]=t}function n(t){const r=t>>25;return(33554431&t)<<5^996825010&-(r>>0&1)^642813549&-(r>>1&1)^513874426&-(r>>2&1)^1027748829&-(r>>3&1)^705979059&-(r>>4&1)}function o(t){let r=1;for(let e=0;e<t.length;++e){const s=t.charCodeAt(e);if(s<33||s>126)return"Invalid prefix ("+t+")";r=n(r)^s>>5}r=n(r);for(let e=0;e<t.length;++e){const s=t.charCodeAt(e);r=n(r)^31&s}return r}function i(t,r,e,s){let n=0,o=0;const i=(1<<e)-1,h=[];for(let s=0;s<t.length;++s)for(n=n<<r|t[s],o+=r;o>=e;)o-=e,h.push(n>>o&i);if(s)o>0&&h.push(n<<e-o&i);else{if(o>=r)return"Excess padding";if(n<<e-o&i)return"Non-zero padding"}return h}function h(t){return i(t,8,5,!0)}function c(t){const r=i(t,5,8,!1);if(Array.isArray(r))return r}function a(t){const r=i(t,5,8,!1);if(Array.isArray(r))return r;throw new Error(r)}function f(t){let r;function i(t,e){if(e=e||90,t.length<8)return t+" too short";if(t.length>e)return"Exceeds length limit";const i=t.toLowerCase(),h=t.toUpperCase();if(t!==i&&t!==h)return"Mixed-case string "+t;const c=(t=i).lastIndexOf("1");if(-1===c)return"No separator character for "+t;if(0===c)return"Missing prefix for "+t;const a=t.slice(0,c),f=t.slice(c+1);if(f.length<6)return"Data too short";let p=o(a);if("string"==typeof p)return p;const d=[];for(let t=0;t<f.length;++t){const r=f.charAt(t),e=s[r];if(void 0===e)return"Unknown character "+r;p=n(p)^e,t+6>=f.length||d.push(e)}return p!==r?"Invalid checksum for "+t:{prefix:a,words:d}}return r="bech32"===t?1:734539939,{decodeUnsafe:function(t,r){const e=i(t,r);if("object"==typeof e)return e},decode:function(t,r){const e=i(t,r);if("object"==typeof e)return e;throw new Error(e)},encode:function(t,s,i){if(i=i||90,t.length+7+s.length>i)throw new TypeError("Exceeds length limit");let h=o(t=t.toLowerCase());if("string"==typeof h)throw new Error(h);let c=t+"1";for(let t=0;t<s.length;++t){const r=s[t];if(r>>5!=0)throw new Error("Non 5-bit word");h=n(h)^r,c+=e.charAt(r)}for(let t=0;t<6;++t)h=n(h);h^=r;for(let t=0;t<6;++t){c+=e.charAt(h>>5*(5-t)&31)}return c},toWords:h,fromWordsUnsafe:c,fromWords:a}}r.bech32=f("bech32"),r.bech32m=f("bech32m")}));n(i);var h=i.bech32m,c=i.bech32,a=o((function(t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.Hash=r.createHash=void 0;const e=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],s={sha256:1};r.createHash=function(t){if(t&&!s[t]&&!s[t.toLowerCase()])throw new Error("Digest method not supported");return new n};class n{constructor(){this.A=1779033703,this.B=-1150833019,this.C=1013904242,this.D=-1521486534,this.E=1359893119,this.F=-1694144372,this.G=528734635,this.H=1541459225,this._size=0,this._sp=0,(!i||h>=8e3)&&(i=new ArrayBuffer(8e3),h=0),this._byte=new Uint8Array(i,h,80),this._word=new Int32Array(i,h,20),h+=80}update(t){if("string"==typeof t)return this._utf8(t);if(null==t)throw new TypeError("Invalid type: "+typeof t);const r=t.byteOffset,e=t.byteLength;let s=e/64|0,n=0;if(s&&!(3&r)&&!(this._size%64)){const e=new Int32Array(t.buffer,r,16*s);for(;s--;)this._int32(e,n>>2),n+=64;this._size+=n}if(1!==t.BYTES_PER_ELEMENT&&t.buffer){const s=new Uint8Array(t.buffer,r+n,e-n);return this._uint8(s)}return n===e?this:this._uint8(t,n)}_uint8(t,r){const{_byte:e,_word:s}=this,n=t.length;for(r|=0;r<n;){const o=this._size%64;let i=o;for(;r<n&&i<64;)e[i++]=t[r++];i>=64&&this._int32(s),this._size+=i-o}return this}_utf8(t){const{_byte:r,_word:e}=this,s=t.length;let n=this._sp;for(let o=0;o<s;){const i=this._size%64;let h=i;for(;o<s&&h<64;){let e=0|t.charCodeAt(o++);e<128?r[h++]=e:e<2048?(r[h++]=192|e>>>6,r[h++]=128|63&e):e<55296||e>57343?(r[h++]=224|e>>>12,r[h++]=128|e>>>6&63,r[h++]=128|63&e):n?(e=((1023&n)<<10)+(1023&e)+65536,r[h++]=240|e>>>18,r[h++]=128|e>>>12&63,r[h++]=128|e>>>6&63,r[h++]=128|63&e,n=0):n=e}h>=64&&(this._int32(e),e[0]=e[16]),this._size+=h-i}return this._sp=n,this}_int32(t,r){let{A:s,B:n,C:i,D:h,E:c,F:y,G:g,H:b}=this,_=0;for(r|=0;_<16;)o[_++]=a(t[r++]);for(_=16;_<64;_++)o[_]=w(o[_-2])+o[_-7]+l(o[_-15])+o[_-16]|0;for(_=0;_<64;_++){const t=b+u(c)+f(c,y,g)+e[_]+o[_]|0,r=d(s)+p(s,n,i)|0;b=g,g=y,y=c,c=h+t|0,h=i,i=n,n=s,s=t+r|0}this.A=s+this.A|0,this.B=n+this.B|0,this.C=i+this.C|0,this.D=h+this.D|0,this.E=c+this.E|0,this.F=y+this.F|0,this.G=g+this.G|0,this.H=b+this.H|0}digest(t){const{_byte:r,_word:e}=this;let s=this._size%64|0;for(r[s++]=128;3&s;)r[s++]=0;if(s>>=2,s>14){for(;s<16;)e[s++]=0;s=0,this._int32(e)}for(;s<16;)e[s++]=0;const n=8*this._size,o=(4294967295&n)>>>0,i=(n-o)/4294967296;return i&&(e[14]=a(i)),o&&(e[15]=a(o)),this._int32(e),"hex"===t?this._hex():this._bin()}_hex(){const{A:t,B:r,C:e,D:s,E:n,F:o,G:i,H:h}=this;return c(t)+c(r)+c(e)+c(s)+c(n)+c(o)+c(i)+c(h)}_bin(){const{A:t,B:r,C:e,D:s,E:n,F:o,G:i,H:h,_byte:c,_word:f}=this;return f[0]=a(t),f[1]=a(r),f[2]=a(e),f[3]=a(s),f[4]=a(n),f[5]=a(o),f[6]=a(i),f[7]=a(h),c.slice(0,32)}}r.Hash=n;const o=new Int32Array(64);let i,h=0;const c=t=>(t+4294967296).toString(16).substr(-8),a=254===new Uint8Array(new Uint16Array([65279]).buffer)[0]?t=>t:t=>t<<24&4278190080|t<<8&16711680|t>>8&65280|t>>24&255,f=(t,r,e)=>e^t&(r^e),p=(t,r,e)=>t&r|e&(t|r),d=t=>(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),u=t=>(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7),l=t=>(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,w=t=>(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}));n(a),a.Hash;var f,p,d=a.createHash,u=function(t){return d().update(t).digest()};exports.Network=void 0,(f=exports.Network||(exports.Network={})).mainnet="mainnet",f.testnet="testnet",f.regtest="regtest",exports.AddressType=void 0,(p=exports.AddressType||(exports.AddressType={})).p2pkh="p2pkh",p.p2sh="p2sh",p.p2wpkh="p2wpkh",p.p2wsh="p2wsh",p.p2tr="p2tr";var l={0:{type:exports.AddressType.p2pkh,network:exports.Network.mainnet},111:{type:exports.AddressType.p2pkh,network:exports.Network.testnet},5:{type:exports.AddressType.p2sh,network:exports.Network.mainnet},196:{type:exports.AddressType.p2sh,network:exports.Network.testnet}},w=function(r){var e,n=r.substr(0,2).toLowerCase();if("bc"===n||"tb"===n)return function(t){var r;try{r=t.startsWith("bc1p")||t.startsWith("tb1p")||t.startsWith("bcrt1p")?h.decode(t):c.decode(t)}catch(t){throw new Error("Invalid address")}var e={bc:exports.Network.mainnet,tb:exports.Network.testnet,bcrt:exports.Network.regtest}[r.prefix];if(void 0===e)throw new Error("Invalid address");var s=r.words[0];if(s<0||s>16)throw new Error("Invalid address");return{bech32:!0,network:e,address:t,type:20===c.fromWords(r.words.slice(1)).length?exports.AddressType.p2wpkh:1===s?exports.AddressType.p2tr:exports.AddressType.p2wsh}}(r);try{e=s(r)}catch(t){throw new Error("Invalid address")}var o=e.length;if(25!==o)throw new Error("Invalid address");var i=e[0],a=e.slice(o-4,o),f=e.slice(0,o-4),p=u(u(f)).slice(0,4);if(a.some((function(t,r){return t!==p[r]})))throw new Error("Invalid address");if(!Object.keys(l).map(Number).includes(i))throw new Error("Invalid address");return t(t({},l[i]),{address:r,bech32:!1})},y=function(t,r){try{var e=w(t);return!r||r===e.network}catch(t){return!1}};exports.default=y,exports.getAddressInfo=w,exports.validate=y;
var t=function(){return t=Object.assign||function(t){for(var r,e=1,s=arguments.length;e<s;e++)for(var n in r=arguments[e])Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n]);return t},t.apply(this,arguments)};var r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var e=t=>{if(!t||"string"!=typeof t)throw new Error(`Expected base58 string but got “${t}”`);if(t.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character “${t.match(/[IOl0]/gmu)}”`);const e=t.match(/^1+/gmu),s=e?e[0].length:0,n=(t.length-s)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(s),...t.match(/.{1}/gmu).map((t=>r.indexOf(t))).reduce(((t,r)=>t=t.map((t=>{const e=58*t+r;return r=e>>8,e}))),new Uint8Array(n)).reverse().filter((o=!1,t=>o=o||t))]);var o};(()=>{const t=Array(256).fill(-1);for(let e=0;e<r.length;++e)t[r.charCodeAt(e)]=e})();var s=e;var n,o,i,h=(n=function(t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bech32m=r.bech32=void 0;const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l",s={};for(let t=0;t<32;t++){const r=e.charAt(t);s[r]=t}function n(t){const r=t>>25;return(33554431&t)<<5^996825010&-(r>>0&1)^642813549&-(r>>1&1)^513874426&-(r>>2&1)^1027748829&-(r>>3&1)^705979059&-(r>>4&1)}function o(t){let r=1;for(let e=0;e<t.length;++e){const s=t.charCodeAt(e);if(s<33||s>126)return"Invalid prefix ("+t+")";r=n(r)^s>>5}r=n(r);for(let e=0;e<t.length;++e){const s=t.charCodeAt(e);r=n(r)^31&s}return r}function i(t,r,e,s){let n=0,o=0;const i=(1<<e)-1,h=[];for(let s=0;s<t.length;++s)for(n=n<<r|t[s],o+=r;o>=e;)o-=e,h.push(n>>o&i);if(s)o>0&&h.push(n<<e-o&i);else{if(o>=r)return"Excess padding";if(n<<e-o&i)return"Non-zero padding"}return h}function h(t){return i(t,8,5,!0)}function c(t){const r=i(t,5,8,!1);if(Array.isArray(r))return r}function a(t){const r=i(t,5,8,!1);if(Array.isArray(r))return r;throw new Error(r)}function f(t){let r;function i(t,e){if(e=e||90,t.length<8)return t+" too short";if(t.length>e)return"Exceeds length limit";const i=t.toLowerCase(),h=t.toUpperCase();if(t!==i&&t!==h)return"Mixed-case string "+t;const c=(t=i).lastIndexOf("1");if(-1===c)return"No separator character for "+t;if(0===c)return"Missing prefix for "+t;const a=t.slice(0,c),f=t.slice(c+1);if(f.length<6)return"Data too short";let p=o(a);if("string"==typeof p)return p;const d=[];for(let t=0;t<f.length;++t){const r=f.charAt(t),e=s[r];if(void 0===e)return"Unknown character "+r;p=n(p)^e,t+6>=f.length||d.push(e)}return p!==r?"Invalid checksum for "+t:{prefix:a,words:d}}return r="bech32"===t?1:734539939,{decodeUnsafe:function(t,r){const e=i(t,r);if("object"==typeof e)return e},decode:function(t,r){const e=i(t,r);if("object"==typeof e)return e;throw new Error(e)},encode:function(t,s,i){if(i=i||90,t.length+7+s.length>i)throw new TypeError("Exceeds length limit");let h=o(t=t.toLowerCase());if("string"==typeof h)throw new Error(h);let c=t+"1";for(let t=0;t<s.length;++t){const r=s[t];if(r>>5!=0)throw new Error("Non 5-bit word");h=n(h)^r,c+=e.charAt(r)}for(let t=0;t<6;++t)h=n(h);h^=r;for(let t=0;t<6;++t)c+=e.charAt(h>>5*(5-t)&31);return c},toWords:h,fromWordsUnsafe:c,fromWords:a}}r.bech32=f("bech32"),r.bech32m=f("bech32m")},n(o={exports:{}},o.exports),o.exports);(i=h)&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")&&i.default;var c=h.bech32m,a=h.bech32;const f=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],p={sha256:1};class d{constructor(){this.A=1779033703,this.B=-1150833019,this.C=1013904242,this.D=-1521486534,this.E=1359893119,this.F=-1694144372,this.G=528734635,this.H=1541459225,this._size=0,this._sp=0,(!l||w>=8e3)&&(l=new ArrayBuffer(8e3),w=0),this._byte=new Uint8Array(l,w,80),this._word=new Int32Array(l,w,20),w+=80}update(t){if("string"==typeof t)return this._utf8(t);if(null==t)throw new TypeError("Invalid type: "+typeof t);const r=t.byteOffset,e=t.byteLength;let s=e/64|0,n=0;if(s&&!(3&r)&&!(this._size%64)){const e=new Int32Array(t.buffer,r,16*s);for(;s--;)this._int32(e,n>>2),n+=64;this._size+=n}if(1!==t.BYTES_PER_ELEMENT&&t.buffer){const s=new Uint8Array(t.buffer,r+n,e-n);return this._uint8(s)}return n===e?this:this._uint8(t,n)}_uint8(t,r){const{_byte:e,_word:s}=this,n=t.length;for(r|=0;r<n;){const o=this._size%64;let i=o;for(;r<n&&i<64;)e[i++]=t[r++];i>=64&&this._int32(s),this._size+=i-o}return this}_utf8(t){const{_byte:r,_word:e}=this,s=t.length;let n=this._sp;for(let o=0;o<s;){const i=this._size%64;let h=i;for(;o<s&&h<64;){let e=0|t.charCodeAt(o++);e<128?r[h++]=e:e<2048?(r[h++]=192|e>>>6,r[h++]=128|63&e):e<55296||e>57343?(r[h++]=224|e>>>12,r[h++]=128|e>>>6&63,r[h++]=128|63&e):n?(e=((1023&n)<<10)+(1023&e)+65536,r[h++]=240|e>>>18,r[h++]=128|e>>>12&63,r[h++]=128|e>>>6&63,r[h++]=128|63&e,n=0):n=e}h>=64&&(this._int32(e),e[0]=e[16]),this._size+=h-i}return this._sp=n,this}_int32(t,r){let{A:e,B:s,C:n,D:o,E:i,F:h,G:c,H:a}=this,p=0;for(r|=0;p<16;)u[p++]=g(t[r++]);for(p=16;p<64;p++)u[p]=E(u[p-2])+u[p-7]+v(u[p-15])+u[p-16]|0;for(p=0;p<64;p++){const t=a+A(i)+b(i,h,c)+f[p]+u[p]|0,r=x(e)+_(e,s,n)|0;a=c,c=h,h=i,i=o+t|0,o=n,n=s,s=e,e=t+r|0}this.A=e+this.A|0,this.B=s+this.B|0,this.C=n+this.C|0,this.D=o+this.D|0,this.E=i+this.E|0,this.F=h+this.F|0,this.G=c+this.G|0,this.H=a+this.H|0}digest(t){const{_byte:r,_word:e}=this;let s=this._size%64|0;for(r[s++]=128;3&s;)r[s++]=0;if(s>>=2,s>14){for(;s<16;)e[s++]=0;s=0,this._int32(e)}for(;s<16;)e[s++]=0;const n=8*this._size,o=(4294967295&n)>>>0,i=(n-o)/4294967296;return i&&(e[14]=g(i)),o&&(e[15]=g(o)),this._int32(e),"hex"===t?this._hex():this._bin()}_hex(){const{A:t,B:r,C:e,D:s,E:n,F:o,G:i,H:h}=this;return y(t)+y(r)+y(e)+y(s)+y(n)+y(o)+y(i)+y(h)}_bin(){const{A:t,B:r,C:e,D:s,E:n,F:o,G:i,H:h,_byte:c,_word:a}=this;return a[0]=g(t),a[1]=g(r),a[2]=g(e),a[3]=g(s),a[4]=g(n),a[5]=g(o),a[6]=g(i),a[7]=g(h),c.slice(0,32)}}const u=new Int32Array(64);let l,w=0;const y=t=>(t+4294967296).toString(16).substr(-8),g=254===new Uint8Array(new Uint16Array([65279]).buffer)[0]?t=>t:t=>t<<24&4278190080|t<<8&16711680|t>>8&65280|t>>24&255,b=(t,r,e)=>e^t&(r^e),_=(t,r,e)=>t&r|e&(t|r),x=t=>(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),A=t=>(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7),v=t=>(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,E=t=>(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10;var m,k,I=function(t){return function(t){if(t&&!p[t]&&!p[t.toLowerCase()])throw new Error("Digest method not supported");return new d}().update(t).digest()};exports.Network=void 0,(m=exports.Network||(exports.Network={})).mainnet="mainnet",m.testnet="testnet",m.regtest="regtest",exports.AddressType=void 0,(k=exports.AddressType||(exports.AddressType={})).p2pkh="p2pkh",k.p2sh="p2sh",k.p2wpkh="p2wpkh",k.p2wsh="p2wsh",k.p2tr="p2tr";var C={0:{type:exports.AddressType.p2pkh,network:exports.Network.mainnet},111:{type:exports.AddressType.p2pkh,network:exports.Network.testnet},5:{type:exports.AddressType.p2sh,network:exports.Network.mainnet},196:{type:exports.AddressType.p2sh,network:exports.Network.testnet}},N=function(r){var e,n=r.substr(0,2).toLowerCase();if("bc"===n||"tb"===n)return function(t){var r;try{r=t.startsWith("bc1p")||t.startsWith("tb1p")||t.startsWith("bcrt1p")?c.decode(t):a.decode(t)}catch(t){throw new Error("Invalid address")}var e={bc:exports.Network.mainnet,tb:exports.Network.testnet,bcrt:exports.Network.regtest}[r.prefix];if(void 0===e)throw new Error("Invalid address");var s=r.words[0];if(s<0||s>16)throw new Error("Invalid address");return{bech32:!0,network:e,address:t,type:20===a.fromWords(r.words.slice(1)).length?exports.AddressType.p2wpkh:1===s?exports.AddressType.p2tr:exports.AddressType.p2wsh}}(r);try{e=s(r)}catch(t){throw new Error("Invalid address")}var o=e.length;if(25!==o)throw new Error("Invalid address");var i=e[0],h=e.slice(o-4,o),f=e.slice(0,o-4),p=I(I(f)).slice(0,4);if(h.some((function(t,r){return t!==p[r]})))throw new Error("Invalid address");if(!Object.keys(C).map(Number).includes(i))throw new Error("Invalid address");return t(t({},C[i]),{address:r,bech32:!1})},T=function(t,r){try{var e=N(t);return!r||r===e.network}catch(t){return!1}};exports.default=T,exports.getAddressInfo=N,exports.validate=T;

@@ -13,3 +13,3 @@ declare enum Network {

}
declare type AddressInfo = {
type AddressInfo = {
bech32: boolean;

@@ -21,4 +21,4 @@ network: Network;

declare const getAddressInfo: (address: string) => AddressInfo;
declare const validate: (address: string, network?: Network | undefined) => boolean;
declare const validate: (address: string, network?: Network) => boolean;
export { getAddressInfo, Network, AddressType, AddressInfo, validate };
export default validate;

@@ -15,2 +15,2 @@ /*! *****************************************************************************

***************************************************************************** */
var t=function(){return t=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var s in r=arguments[e])Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s]);return t},t.apply(this,arguments)};var r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var e=t=>{if(!t||"string"!=typeof t)throw new Error(`Expected base58 string but got “${t}”`);if(t.match(/[IOl0]/gm))throw new Error(`Invalid base58 character “${t.match(/[IOl0]/gm)}”`);const e=t.match(/^1+/gm),n=e?e[0].length:0,s=(t.length-n)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(n),...t.match(/.{1}/g).map((t=>r.indexOf(t))).reduce(((t,r)=>t=t.map((t=>{const e=58*t+r;return r=e>>8,e}))),new Uint8Array(s)).reverse().filter((o=!1,t=>o=o||t))]);var o};(()=>{const t=Array(256).fill(-1);for(let e=0;e<r.length;++e)t[r.charCodeAt(e)]=e})();var n=e;function s(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function o(t,r){return t(r={exports:{}},r.exports),r.exports}var i=o((function(t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bech32m=r.bech32=void 0;const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<e.length;t++){const r=e.charAt(t);n[r]=t}function s(t){const r=t>>25;return(33554431&t)<<5^996825010&-(r>>0&1)^642813549&-(r>>1&1)^513874426&-(r>>2&1)^1027748829&-(r>>3&1)^705979059&-(r>>4&1)}function o(t){let r=1;for(let e=0;e<t.length;++e){const n=t.charCodeAt(e);if(n<33||n>126)return"Invalid prefix ("+t+")";r=s(r)^n>>5}r=s(r);for(let e=0;e<t.length;++e){const n=t.charCodeAt(e);r=s(r)^31&n}return r}function i(t,r,e,n){let s=0,o=0;const i=(1<<e)-1,h=[];for(let n=0;n<t.length;++n)for(s=s<<r|t[n],o+=r;o>=e;)o-=e,h.push(s>>o&i);if(n)o>0&&h.push(s<<e-o&i);else{if(o>=r)return"Excess padding";if(s<<e-o&i)return"Non-zero padding"}return h}function h(t){return i(t,8,5,!0)}function c(t){const r=i(t,5,8,!1);if(Array.isArray(r))return r}function a(t){const r=i(t,5,8,!1);if(Array.isArray(r))return r;throw new Error(r)}function f(t){let r;function i(t,e){if(e=e||90,t.length<8)return t+" too short";if(t.length>e)return"Exceeds length limit";const i=t.toLowerCase(),h=t.toUpperCase();if(t!==i&&t!==h)return"Mixed-case string "+t;const c=(t=i).lastIndexOf("1");if(-1===c)return"No separator character for "+t;if(0===c)return"Missing prefix for "+t;const a=t.slice(0,c),f=t.slice(c+1);if(f.length<6)return"Data too short";let u=o(a);if("string"==typeof u)return u;const l=[];for(let t=0;t<f.length;++t){const r=f.charAt(t),e=n[r];if(void 0===e)return"Unknown character "+r;u=s(u)^e,t+6>=f.length||l.push(e)}return u!==r?"Invalid checksum for "+t:{prefix:a,words:l}}return r="bech32"===t?1:734539939,{decodeUnsafe:function(t,r){const e=i(t,r);if("object"==typeof e)return e},decode:function(t,r){const e=i(t,r);if("object"==typeof e)return e;throw new Error(e)},encode:function(t,n,i){if(i=i||90,t.length+7+n.length>i)throw new TypeError("Exceeds length limit");let h=o(t=t.toLowerCase());if("string"==typeof h)throw new Error(h);let c=t+"1";for(let t=0;t<n.length;++t){const r=n[t];if(r>>5!=0)throw new Error("Non 5-bit word");h=s(h)^r,c+=e.charAt(r)}for(let t=0;t<6;++t)h=s(h);h^=r;for(let t=0;t<6;++t){c+=e.charAt(h>>5*(5-t)&31)}return c},toWords:h,fromWordsUnsafe:c,fromWords:a}}r.bech32=f("bech32"),r.bech32m=f("bech32m")}));s(i);var h=i.bech32m,c=i.bech32,a=o((function(t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.Hash=r.createHash=void 0;const e=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],n={sha256:1};r.createHash=function(t){if(t&&!n[t]&&!n[t.toLowerCase()])throw new Error("Digest method not supported");return new s};class s{constructor(){this.A=1779033703,this.B=-1150833019,this.C=1013904242,this.D=-1521486534,this.E=1359893119,this.F=-1694144372,this.G=528734635,this.H=1541459225,this._size=0,this._sp=0,(!i||h>=8e3)&&(i=new ArrayBuffer(8e3),h=0),this._byte=new Uint8Array(i,h,80),this._word=new Int32Array(i,h,20),h+=80}update(t){if("string"==typeof t)return this._utf8(t);if(null==t)throw new TypeError("Invalid type: "+typeof t);const r=t.byteOffset,e=t.byteLength;let n=e/64|0,s=0;if(n&&!(3&r)&&!(this._size%64)){const e=new Int32Array(t.buffer,r,16*n);for(;n--;)this._int32(e,s>>2),s+=64;this._size+=s}if(1!==t.BYTES_PER_ELEMENT&&t.buffer){const n=new Uint8Array(t.buffer,r+s,e-s);return this._uint8(n)}return s===e?this:this._uint8(t,s)}_uint8(t,r){const{_byte:e,_word:n}=this,s=t.length;for(r|=0;r<s;){const o=this._size%64;let i=o;for(;r<s&&i<64;)e[i++]=t[r++];i>=64&&this._int32(n),this._size+=i-o}return this}_utf8(t){const{_byte:r,_word:e}=this,n=t.length;let s=this._sp;for(let o=0;o<n;){const i=this._size%64;let h=i;for(;o<n&&h<64;){let e=0|t.charCodeAt(o++);e<128?r[h++]=e:e<2048?(r[h++]=192|e>>>6,r[h++]=128|63&e):e<55296||e>57343?(r[h++]=224|e>>>12,r[h++]=128|e>>>6&63,r[h++]=128|63&e):s?(e=((1023&s)<<10)+(1023&e)+65536,r[h++]=240|e>>>18,r[h++]=128|e>>>12&63,r[h++]=128|e>>>6&63,r[h++]=128|63&e,s=0):s=e}h>=64&&(this._int32(e),e[0]=e[16]),this._size+=h-i}return this._sp=s,this}_int32(t,r){let{A:n,B:s,C:i,D:h,E:c,F:y,G:g,H:b}=this,_=0;for(r|=0;_<16;)o[_++]=a(t[r++]);for(_=16;_<64;_++)o[_]=w(o[_-2])+o[_-7]+p(o[_-15])+o[_-16]|0;for(_=0;_<64;_++){const t=b+d(c)+f(c,y,g)+e[_]+o[_]|0,r=l(n)+u(n,s,i)|0;b=g,g=y,y=c,c=h+t|0,h=i,i=s,s=n,n=t+r|0}this.A=n+this.A|0,this.B=s+this.B|0,this.C=i+this.C|0,this.D=h+this.D|0,this.E=c+this.E|0,this.F=y+this.F|0,this.G=g+this.G|0,this.H=b+this.H|0}digest(t){const{_byte:r,_word:e}=this;let n=this._size%64|0;for(r[n++]=128;3&n;)r[n++]=0;if(n>>=2,n>14){for(;n<16;)e[n++]=0;n=0,this._int32(e)}for(;n<16;)e[n++]=0;const s=8*this._size,o=(4294967295&s)>>>0,i=(s-o)/4294967296;return i&&(e[14]=a(i)),o&&(e[15]=a(o)),this._int32(e),"hex"===t?this._hex():this._bin()}_hex(){const{A:t,B:r,C:e,D:n,E:s,F:o,G:i,H:h}=this;return c(t)+c(r)+c(e)+c(n)+c(s)+c(o)+c(i)+c(h)}_bin(){const{A:t,B:r,C:e,D:n,E:s,F:o,G:i,H:h,_byte:c,_word:f}=this;return f[0]=a(t),f[1]=a(r),f[2]=a(e),f[3]=a(n),f[4]=a(s),f[5]=a(o),f[6]=a(i),f[7]=a(h),c.slice(0,32)}}r.Hash=s;const o=new Int32Array(64);let i,h=0;const c=t=>(t+4294967296).toString(16).substr(-8),a=254===new Uint8Array(new Uint16Array([65279]).buffer)[0]?t=>t:t=>t<<24&4278190080|t<<8&16711680|t>>8&65280|t>>24&255,f=(t,r,e)=>e^t&(r^e),u=(t,r,e)=>t&r|e&(t|r),l=t=>(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),d=t=>(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7),p=t=>(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,w=t=>(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}));s(a),a.Hash;var f,u,l=a.createHash,d=function(t){return l().update(t).digest()};!function(t){t.mainnet="mainnet",t.testnet="testnet",t.regtest="regtest"}(f||(f={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr"}(u||(u={}));var p={0:{type:u.p2pkh,network:f.mainnet},111:{type:u.p2pkh,network:f.testnet},5:{type:u.p2sh,network:f.mainnet},196:{type:u.p2sh,network:f.testnet}},w=function(r){var e,s=r.substr(0,2).toLowerCase();if("bc"===s||"tb"===s)return function(t){var r;try{r=t.startsWith("bc1p")||t.startsWith("tb1p")||t.startsWith("bcrt1p")?h.decode(t):c.decode(t)}catch(t){throw new Error("Invalid address")}var e={bc:f.mainnet,tb:f.testnet,bcrt:f.regtest}[r.prefix];if(void 0===e)throw new Error("Invalid address");var n=r.words[0];if(n<0||n>16)throw new Error("Invalid address");return{bech32:!0,network:e,address:t,type:20===c.fromWords(r.words.slice(1)).length?u.p2wpkh:1===n?u.p2tr:u.p2wsh}}(r);try{e=n(r)}catch(t){throw new Error("Invalid address")}var o=e.length;if(25!==o)throw new Error("Invalid address");var i=e[0],a=e.slice(o-4,o),l=e.slice(0,o-4),w=d(d(l)).slice(0,4);if(a.some((function(t,r){return t!==w[r]})))throw new Error("Invalid address");if(!Object.keys(p).map(Number).includes(i))throw new Error("Invalid address");return t(t({},p[i]),{address:r,bech32:!1})},y=function(t,r){try{var e=w(t);return!r||r===e.network}catch(t){return!1}};export{u as AddressType,f as Network,y as default,w as getAddressInfo,y as validate};
var t=function(){return t=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var s in r=arguments[e])Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s]);return t},t.apply(this,arguments)};var r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var e=t=>{if(!t||"string"!=typeof t)throw new Error(`Expected base58 string but got “${t}”`);if(t.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character “${t.match(/[IOl0]/gmu)}”`);const e=t.match(/^1+/gmu),n=e?e[0].length:0,s=(t.length-n)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(n),...t.match(/.{1}/gmu).map((t=>r.indexOf(t))).reduce(((t,r)=>t=t.map((t=>{const e=58*t+r;return r=e>>8,e}))),new Uint8Array(s)).reverse().filter((i=!1,t=>i=i||t))]);var i};(()=>{const t=Array(256).fill(-1);for(let e=0;e<r.length;++e)t[r.charCodeAt(e)]=e})();var n=e;var s,i,o,h=(s=function(t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.bech32m=r.bech32=void 0;const e="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const r=e.charAt(t);n[r]=t}function s(t){const r=t>>25;return(33554431&t)<<5^996825010&-(r>>0&1)^642813549&-(r>>1&1)^513874426&-(r>>2&1)^1027748829&-(r>>3&1)^705979059&-(r>>4&1)}function i(t){let r=1;for(let e=0;e<t.length;++e){const n=t.charCodeAt(e);if(n<33||n>126)return"Invalid prefix ("+t+")";r=s(r)^n>>5}r=s(r);for(let e=0;e<t.length;++e){const n=t.charCodeAt(e);r=s(r)^31&n}return r}function o(t,r,e,n){let s=0,i=0;const o=(1<<e)-1,h=[];for(let n=0;n<t.length;++n)for(s=s<<r|t[n],i+=r;i>=e;)i-=e,h.push(s>>i&o);if(n)i>0&&h.push(s<<e-i&o);else{if(i>=r)return"Excess padding";if(s<<e-i&o)return"Non-zero padding"}return h}function h(t){return o(t,8,5,!0)}function c(t){const r=o(t,5,8,!1);if(Array.isArray(r))return r}function a(t){const r=o(t,5,8,!1);if(Array.isArray(r))return r;throw new Error(r)}function f(t){let r;function o(t,e){if(e=e||90,t.length<8)return t+" too short";if(t.length>e)return"Exceeds length limit";const o=t.toLowerCase(),h=t.toUpperCase();if(t!==o&&t!==h)return"Mixed-case string "+t;const c=(t=o).lastIndexOf("1");if(-1===c)return"No separator character for "+t;if(0===c)return"Missing prefix for "+t;const a=t.slice(0,c),f=t.slice(c+1);if(f.length<6)return"Data too short";let u=i(a);if("string"==typeof u)return u;const l=[];for(let t=0;t<f.length;++t){const r=f.charAt(t),e=n[r];if(void 0===e)return"Unknown character "+r;u=s(u)^e,t+6>=f.length||l.push(e)}return u!==r?"Invalid checksum for "+t:{prefix:a,words:l}}return r="bech32"===t?1:734539939,{decodeUnsafe:function(t,r){const e=o(t,r);if("object"==typeof e)return e},decode:function(t,r){const e=o(t,r);if("object"==typeof e)return e;throw new Error(e)},encode:function(t,n,o){if(o=o||90,t.length+7+n.length>o)throw new TypeError("Exceeds length limit");let h=i(t=t.toLowerCase());if("string"==typeof h)throw new Error(h);let c=t+"1";for(let t=0;t<n.length;++t){const r=n[t];if(r>>5!=0)throw new Error("Non 5-bit word");h=s(h)^r,c+=e.charAt(r)}for(let t=0;t<6;++t)h=s(h);h^=r;for(let t=0;t<6;++t)c+=e.charAt(h>>5*(5-t)&31);return c},toWords:h,fromWordsUnsafe:c,fromWords:a}}r.bech32=f("bech32"),r.bech32m=f("bech32m")},s(i={exports:{}},i.exports),i.exports);(o=h)&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")&&o.default;var c=h.bech32m,a=h.bech32;const f=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],u={sha256:1};class l{constructor(){this.A=1779033703,this.B=-1150833019,this.C=1013904242,this.D=-1521486534,this.E=1359893119,this.F=-1694144372,this.G=528734635,this.H=1541459225,this._size=0,this._sp=0,(!p||w>=8e3)&&(p=new ArrayBuffer(8e3),w=0),this._byte=new Uint8Array(p,w,80),this._word=new Int32Array(p,w,20),w+=80}update(t){if("string"==typeof t)return this._utf8(t);if(null==t)throw new TypeError("Invalid type: "+typeof t);const r=t.byteOffset,e=t.byteLength;let n=e/64|0,s=0;if(n&&!(3&r)&&!(this._size%64)){const e=new Int32Array(t.buffer,r,16*n);for(;n--;)this._int32(e,s>>2),s+=64;this._size+=s}if(1!==t.BYTES_PER_ELEMENT&&t.buffer){const n=new Uint8Array(t.buffer,r+s,e-s);return this._uint8(n)}return s===e?this:this._uint8(t,s)}_uint8(t,r){const{_byte:e,_word:n}=this,s=t.length;for(r|=0;r<s;){const i=this._size%64;let o=i;for(;r<s&&o<64;)e[o++]=t[r++];o>=64&&this._int32(n),this._size+=o-i}return this}_utf8(t){const{_byte:r,_word:e}=this,n=t.length;let s=this._sp;for(let i=0;i<n;){const o=this._size%64;let h=o;for(;i<n&&h<64;){let e=0|t.charCodeAt(i++);e<128?r[h++]=e:e<2048?(r[h++]=192|e>>>6,r[h++]=128|63&e):e<55296||e>57343?(r[h++]=224|e>>>12,r[h++]=128|e>>>6&63,r[h++]=128|63&e):s?(e=((1023&s)<<10)+(1023&e)+65536,r[h++]=240|e>>>18,r[h++]=128|e>>>12&63,r[h++]=128|e>>>6&63,r[h++]=128|63&e,s=0):s=e}h>=64&&(this._int32(e),e[0]=e[16]),this._size+=h-o}return this._sp=s,this}_int32(t,r){let{A:e,B:n,C:s,D:i,E:o,F:h,G:c,H:a}=this,u=0;for(r|=0;u<16;)d[u++]=g(t[r++]);for(u=16;u<64;u++)d[u]=A(d[u-2])+d[u-7]+m(d[u-15])+d[u-16]|0;for(u=0;u<64;u++){const t=a+E(o)+b(o,h,c)+f[u]+d[u]|0,r=v(e)+_(e,n,s)|0;a=c,c=h,h=o,o=i+t|0,i=s,s=n,n=e,e=t+r|0}this.A=e+this.A|0,this.B=n+this.B|0,this.C=s+this.C|0,this.D=i+this.D|0,this.E=o+this.E|0,this.F=h+this.F|0,this.G=c+this.G|0,this.H=a+this.H|0}digest(t){const{_byte:r,_word:e}=this;let n=this._size%64|0;for(r[n++]=128;3&n;)r[n++]=0;if(n>>=2,n>14){for(;n<16;)e[n++]=0;n=0,this._int32(e)}for(;n<16;)e[n++]=0;const s=8*this._size,i=(4294967295&s)>>>0,o=(s-i)/4294967296;return o&&(e[14]=g(o)),i&&(e[15]=g(i)),this._int32(e),"hex"===t?this._hex():this._bin()}_hex(){const{A:t,B:r,C:e,D:n,E:s,F:i,G:o,H:h}=this;return y(t)+y(r)+y(e)+y(n)+y(s)+y(i)+y(o)+y(h)}_bin(){const{A:t,B:r,C:e,D:n,E:s,F:i,G:o,H:h,_byte:c,_word:a}=this;return a[0]=g(t),a[1]=g(r),a[2]=g(e),a[3]=g(n),a[4]=g(s),a[5]=g(i),a[6]=g(o),a[7]=g(h),c.slice(0,32)}}const d=new Int32Array(64);let p,w=0;const y=t=>(t+4294967296).toString(16).substr(-8),g=254===new Uint8Array(new Uint16Array([65279]).buffer)[0]?t=>t:t=>t<<24&4278190080|t<<8&16711680|t>>8&65280|t>>24&255,b=(t,r,e)=>e^t&(r^e),_=(t,r,e)=>t&r|e&(t|r),v=t=>(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),E=t=>(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7),m=t=>(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,A=t=>(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10;var x,k,I=function(t){return function(t){if(t&&!u[t]&&!u[t.toLowerCase()])throw new Error("Digest method not supported");return new l}().update(t).digest()};!function(t){t.mainnet="mainnet",t.testnet="testnet",t.regtest="regtest"}(x||(x={})),function(t){t.p2pkh="p2pkh",t.p2sh="p2sh",t.p2wpkh="p2wpkh",t.p2wsh="p2wsh",t.p2tr="p2tr"}(k||(k={}));var C={0:{type:k.p2pkh,network:x.mainnet},111:{type:k.p2pkh,network:x.testnet},5:{type:k.p2sh,network:x.mainnet},196:{type:k.p2sh,network:x.testnet}},z=function(r){var e,s=r.substr(0,2).toLowerCase();if("bc"===s||"tb"===s)return function(t){var r;try{r=t.startsWith("bc1p")||t.startsWith("tb1p")||t.startsWith("bcrt1p")?c.decode(t):a.decode(t)}catch(t){throw new Error("Invalid address")}var e={bc:x.mainnet,tb:x.testnet,bcrt:x.regtest}[r.prefix];if(void 0===e)throw new Error("Invalid address");var n=r.words[0];if(n<0||n>16)throw new Error("Invalid address");return{bech32:!0,network:e,address:t,type:20===a.fromWords(r.words.slice(1)).length?k.p2wpkh:1===n?k.p2tr:k.p2wsh}}(r);try{e=n(r)}catch(t){throw new Error("Invalid address")}var i=e.length;if(25!==i)throw new Error("Invalid address");var o=e[0],h=e.slice(i-4,i),f=e.slice(0,i-4),u=I(I(f)).slice(0,4);if(h.some((function(t,r){return t!==u[r]})))throw new Error("Invalid address");if(!Object.keys(C).map(Number).includes(o))throw new Error("Invalid address");return t(t({},C[o]),{address:r,bech32:!1})},O=function(t,r){try{var e=z(t);return!r||r===e.network}catch(t){return!1}};export{k as AddressType,x as Network,O as default,z as getAddressInfo,O as validate};

@@ -15,2 +15,2 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).AddressValidation={})}(this,(function(t){"use strict";window;

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var e=function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var s in e=arguments[r])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},e.apply(this,arguments)};var r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var n=t=>{if(!t||"string"!=typeof t)throw new Error(`Expected base58 string but got “${t}”`);if(t.match(/[IOl0]/gm))throw new Error(`Invalid base58 character “${t.match(/[IOl0]/gm)}”`);const e=t.match(/^1+/gm),n=e?e[0].length:0,s=(t.length-n)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(n),...t.match(/.{1}/g).map((t=>r.indexOf(t))).reduce(((t,e)=>t=t.map((t=>{const r=58*t+e;return e=r>>8,r}))),new Uint8Array(s)).reverse().filter((o=!1,t=>o=o||t))]);var o};(()=>{const t=Array(256).fill(-1);for(let e=0;e<r.length;++e)t[r.charCodeAt(e)]=e})();var s=n;function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t,e){return t(e={exports:{}},e.exports),e.exports}var h=i((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.bech32m=e.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<r.length;t++){const e=r.charAt(t);n[e]=t}function s(t){const e=t>>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=s(e)^n>>5}e=s(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=s(e)^31&n}return e}function i(t,e,r,n){let s=0,o=0;const i=(1<<r)-1,h=[];for(let n=0;n<t.length;++n)for(s=s<<e|t[n],o+=e;o>=r;)o-=r,h.push(s>>o&i);if(n)o>0&&h.push(s<<r-o&i);else{if(o>=e)return"Excess padding";if(s<<r-o&i)return"Non-zero padding"}return h}function h(t){return i(t,8,5,!0)}function c(t){const e=i(t,5,8,!1);if(Array.isArray(e))return e}function a(t){const e=i(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function f(t){let e;function i(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const i=t.toLowerCase(),h=t.toUpperCase();if(t!==i&&t!==h)return"Mixed-case string "+t;const c=(t=i).lastIndexOf("1");if(-1===c)return"No separator character for "+t;if(0===c)return"Missing prefix for "+t;const a=t.slice(0,c),f=t.slice(c+1);if(f.length<6)return"Data too short";let d=o(a);if("string"==typeof d)return d;const u=[];for(let t=0;t<f.length;++t){const e=f.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;d=s(d)^r,t+6>=f.length||u.push(r)}return d!==e?"Invalid checksum for "+t:{prefix:a,words:u}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=i(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=i(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,i){if(i=i||90,t.length+7+n.length>i)throw new TypeError("Exceeds length limit");let h=o(t=t.toLowerCase());if("string"==typeof h)throw new Error(h);let c=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5!=0)throw new Error("Non 5-bit word");h=s(h)^e,c+=r.charAt(e)}for(let t=0;t<6;++t)h=s(h);h^=e;for(let t=0;t<6;++t){c+=r.charAt(h>>5*(5-t)&31)}return c},toWords:h,fromWordsUnsafe:c,fromWords:a}}e.bech32=f("bech32"),e.bech32m=f("bech32m")}));o(h);var c=h.bech32m,a=h.bech32,f=i((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.createHash=void 0;const r=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],n={sha256:1};e.createHash=function(t){if(t&&!n[t]&&!n[t.toLowerCase()])throw new Error("Digest method not supported");return new s};class s{constructor(){this.A=1779033703,this.B=-1150833019,this.C=1013904242,this.D=-1521486534,this.E=1359893119,this.F=-1694144372,this.G=528734635,this.H=1541459225,this._size=0,this._sp=0,(!i||h>=8e3)&&(i=new ArrayBuffer(8e3),h=0),this._byte=new Uint8Array(i,h,80),this._word=new Int32Array(i,h,20),h+=80}update(t){if("string"==typeof t)return this._utf8(t);if(null==t)throw new TypeError("Invalid type: "+typeof t);const e=t.byteOffset,r=t.byteLength;let n=r/64|0,s=0;if(n&&!(3&e)&&!(this._size%64)){const r=new Int32Array(t.buffer,e,16*n);for(;n--;)this._int32(r,s>>2),s+=64;this._size+=s}if(1!==t.BYTES_PER_ELEMENT&&t.buffer){const n=new Uint8Array(t.buffer,e+s,r-s);return this._uint8(n)}return s===r?this:this._uint8(t,s)}_uint8(t,e){const{_byte:r,_word:n}=this,s=t.length;for(e|=0;e<s;){const o=this._size%64;let i=o;for(;e<s&&i<64;)r[i++]=t[e++];i>=64&&this._int32(n),this._size+=i-o}return this}_utf8(t){const{_byte:e,_word:r}=this,n=t.length;let s=this._sp;for(let o=0;o<n;){const i=this._size%64;let h=i;for(;o<n&&h<64;){let r=0|t.charCodeAt(o++);r<128?e[h++]=r:r<2048?(e[h++]=192|r>>>6,e[h++]=128|63&r):r<55296||r>57343?(e[h++]=224|r>>>12,e[h++]=128|r>>>6&63,e[h++]=128|63&r):s?(r=((1023&s)<<10)+(1023&r)+65536,e[h++]=240|r>>>18,e[h++]=128|r>>>12&63,e[h++]=128|r>>>6&63,e[h++]=128|63&r,s=0):s=r}h>=64&&(this._int32(r),r[0]=r[16]),this._size+=h-i}return this._sp=s,this}_int32(t,e){let{A:n,B:s,C:i,D:h,E:c,F:y,G:b,H:g}=this,_=0;for(e|=0;_<16;)o[_++]=a(t[e++]);for(_=16;_<64;_++)o[_]=w(o[_-2])+o[_-7]+p(o[_-15])+o[_-16]|0;for(_=0;_<64;_++){const t=g+l(c)+f(c,y,b)+r[_]+o[_]|0,e=u(n)+d(n,s,i)|0;g=b,b=y,y=c,c=h+t|0,h=i,i=s,s=n,n=t+e|0}this.A=n+this.A|0,this.B=s+this.B|0,this.C=i+this.C|0,this.D=h+this.D|0,this.E=c+this.E|0,this.F=y+this.F|0,this.G=b+this.G|0,this.H=g+this.H|0}digest(t){const{_byte:e,_word:r}=this;let n=this._size%64|0;for(e[n++]=128;3&n;)e[n++]=0;if(n>>=2,n>14){for(;n<16;)r[n++]=0;n=0,this._int32(r)}for(;n<16;)r[n++]=0;const s=8*this._size,o=(4294967295&s)>>>0,i=(s-o)/4294967296;return i&&(r[14]=a(i)),o&&(r[15]=a(o)),this._int32(r),"hex"===t?this._hex():this._bin()}_hex(){const{A:t,B:e,C:r,D:n,E:s,F:o,G:i,H:h}=this;return c(t)+c(e)+c(r)+c(n)+c(s)+c(o)+c(i)+c(h)}_bin(){const{A:t,B:e,C:r,D:n,E:s,F:o,G:i,H:h,_byte:c,_word:f}=this;return f[0]=a(t),f[1]=a(e),f[2]=a(r),f[3]=a(n),f[4]=a(s),f[5]=a(o),f[6]=a(i),f[7]=a(h),c.slice(0,32)}}e.Hash=s;const o=new Int32Array(64);let i,h=0;const c=t=>(t+4294967296).toString(16).substr(-8),a=254===new Uint8Array(new Uint16Array([65279]).buffer)[0]?t=>t:t=>t<<24&4278190080|t<<8&16711680|t>>8&65280|t>>24&255,f=(t,e,r)=>r^t&(e^r),d=(t,e,r)=>t&e|r&(t|e),u=t=>(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),l=t=>(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7),p=t=>(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,w=t=>(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}));o(f),f.Hash;var d,u,l=f.createHash,p=function(t){return l().update(t).digest()};t.Network=void 0,(d=t.Network||(t.Network={})).mainnet="mainnet",d.testnet="testnet",d.regtest="regtest",t.AddressType=void 0,(u=t.AddressType||(t.AddressType={})).p2pkh="p2pkh",u.p2sh="p2sh",u.p2wpkh="p2wpkh",u.p2wsh="p2wsh",u.p2tr="p2tr";var w={0:{type:t.AddressType.p2pkh,network:t.Network.mainnet},111:{type:t.AddressType.p2pkh,network:t.Network.testnet},5:{type:t.AddressType.p2sh,network:t.Network.mainnet},196:{type:t.AddressType.p2sh,network:t.Network.testnet}},y=function(r){var n,o=r.substr(0,2).toLowerCase();if("bc"===o||"tb"===o)return function(e){var r;try{r=e.startsWith("bc1p")||e.startsWith("tb1p")||e.startsWith("bcrt1p")?c.decode(e):a.decode(e)}catch(t){throw new Error("Invalid address")}var n={bc:t.Network.mainnet,tb:t.Network.testnet,bcrt:t.Network.regtest}[r.prefix];if(void 0===n)throw new Error("Invalid address");var s=r.words[0];if(s<0||s>16)throw new Error("Invalid address");return{bech32:!0,network:n,address:e,type:20===a.fromWords(r.words.slice(1)).length?t.AddressType.p2wpkh:1===s?t.AddressType.p2tr:t.AddressType.p2wsh}}(r);try{n=s(r)}catch(t){throw new Error("Invalid address")}var i=n.length;if(25!==i)throw new Error("Invalid address");var h=n[0],f=n.slice(i-4,i),d=n.slice(0,i-4),u=p(p(d)).slice(0,4);if(f.some((function(t,e){return t!==u[e]})))throw new Error("Invalid address");if(!Object.keys(w).map(Number).includes(h))throw new Error("Invalid address");return e(e({},w[h]),{address:r,bech32:!1})},b=function(t,e){try{var r=y(t);return!e||e===r.network}catch(t){return!1}};t.default=b,t.getAddressInfo=y,t.validate=b,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */var e=function(){return e=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var s in e=arguments[r])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},e.apply(this,arguments)};var r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var n=t=>{if(!t||"string"!=typeof t)throw new Error(`Expected base58 string but got “${t}”`);if(t.match(/[IOl0]/gmu))throw new Error(`Invalid base58 character “${t.match(/[IOl0]/gmu)}”`);const e=t.match(/^1+/gmu),n=e?e[0].length:0,s=(t.length-n)*(Math.log(58)/Math.log(256))+1>>>0;return new Uint8Array([...new Uint8Array(n),...t.match(/.{1}/gmu).map((t=>r.indexOf(t))).reduce(((t,e)=>t=t.map((t=>{const r=58*t+e;return e=r>>8,r}))),new Uint8Array(s)).reverse().filter((o=!1,t=>o=o||t))]);var o};(()=>{const t=Array(256).fill(-1);for(let e=0;e<r.length;++e)t[r.charCodeAt(e)]=e})();var s=n;var o,i=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.bech32m=e.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function s(t){const e=t>>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=s(e)^n>>5}e=s(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=s(e)^31&n}return e}function i(t,e,r,n){let s=0,o=0;const i=(1<<r)-1,h=[];for(let n=0;n<t.length;++n)for(s=s<<e|t[n],o+=e;o>=r;)o-=r,h.push(s>>o&i);if(n)o>0&&h.push(s<<r-o&i);else{if(o>=e)return"Excess padding";if(s<<r-o&i)return"Non-zero padding"}return h}function h(t){return i(t,8,5,!0)}function c(t){const e=i(t,5,8,!1);if(Array.isArray(e))return e}function f(t){const e=i(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function a(t){let e;function i(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const i=t.toLowerCase(),h=t.toUpperCase();if(t!==i&&t!==h)return"Mixed-case string "+t;const c=(t=i).lastIndexOf("1");if(-1===c)return"No separator character for "+t;if(0===c)return"Missing prefix for "+t;const f=t.slice(0,c),a=t.slice(c+1);if(a.length<6)return"Data too short";let d=o(f);if("string"==typeof d)return d;const u=[];for(let t=0;t<a.length;++t){const e=a.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;d=s(d)^r,t+6>=a.length||u.push(r)}return d!==e?"Invalid checksum for "+t:{prefix:f,words:u}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=i(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=i(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,i){if(i=i||90,t.length+7+n.length>i)throw new TypeError("Exceeds length limit");let h=o(t=t.toLowerCase());if("string"==typeof h)throw new Error(h);let c=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5!=0)throw new Error("Non 5-bit word");h=s(h)^e,c+=r.charAt(e)}for(let t=0;t<6;++t)h=s(h);h^=e;for(let t=0;t<6;++t){c+=r.charAt(h>>5*(5-t)&31)}return c},toWords:h,fromWordsUnsafe:c,fromWords:f}}e.bech32=a("bech32"),e.bech32m=a("bech32m")}));(o=i)&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")&&o.default;var h=i.bech32m,c=i.bech32;const f=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],a={sha256:1};class d{constructor(){this.A=1779033703,this.B=-1150833019,this.C=1013904242,this.D=-1521486534,this.E=1359893119,this.F=-1694144372,this.G=528734635,this.H=1541459225,this._size=0,this._sp=0,(!l||p>=8e3)&&(l=new ArrayBuffer(8e3),p=0),this._byte=new Uint8Array(l,p,80),this._word=new Int32Array(l,p,20),p+=80}update(t){if("string"==typeof t)return this._utf8(t);if(null==t)throw new TypeError("Invalid type: "+typeof t);const e=t.byteOffset,r=t.byteLength;let n=r/64|0,s=0;if(n&&!(3&e)&&!(this._size%64)){const r=new Int32Array(t.buffer,e,16*n);for(;n--;)this._int32(r,s>>2),s+=64;this._size+=s}if(1!==t.BYTES_PER_ELEMENT&&t.buffer){const n=new Uint8Array(t.buffer,e+s,r-s);return this._uint8(n)}return s===r?this:this._uint8(t,s)}_uint8(t,e){const{_byte:r,_word:n}=this,s=t.length;for(e|=0;e<s;){const o=this._size%64;let i=o;for(;e<s&&i<64;)r[i++]=t[e++];i>=64&&this._int32(n),this._size+=i-o}return this}_utf8(t){const{_byte:e,_word:r}=this,n=t.length;let s=this._sp;for(let o=0;o<n;){const i=this._size%64;let h=i;for(;o<n&&h<64;){let r=0|t.charCodeAt(o++);r<128?e[h++]=r:r<2048?(e[h++]=192|r>>>6,e[h++]=128|63&r):r<55296||r>57343?(e[h++]=224|r>>>12,e[h++]=128|r>>>6&63,e[h++]=128|63&r):s?(r=((1023&s)<<10)+(1023&r)+65536,e[h++]=240|r>>>18,e[h++]=128|r>>>12&63,e[h++]=128|r>>>6&63,e[h++]=128|63&r,s=0):s=r}h>=64&&(this._int32(r),r[0]=r[16]),this._size+=h-i}return this._sp=s,this}_int32(t,e){let{A:r,B:n,C:s,D:o,E:i,F:h,G:c,H:a}=this,d=0;for(e|=0;d<16;)u[d++]=y(t[e++]);for(d=16;d<64;d++)u[d]=m(u[d-2])+u[d-7]+v(u[d-15])+u[d-16]|0;for(d=0;d<64;d++){const t=a+A(i)+b(i,h,c)+f[d]+u[d]|0,e=_(r)+g(r,n,s)|0;a=c,c=h,h=i,i=o+t|0,o=s,s=n,n=r,r=t+e|0}this.A=r+this.A|0,this.B=n+this.B|0,this.C=s+this.C|0,this.D=o+this.D|0,this.E=i+this.E|0,this.F=h+this.F|0,this.G=c+this.G|0,this.H=a+this.H|0}digest(t){const{_byte:e,_word:r}=this;let n=this._size%64|0;for(e[n++]=128;3&n;)e[n++]=0;if(n>>=2,n>14){for(;n<16;)r[n++]=0;n=0,this._int32(r)}for(;n<16;)r[n++]=0;const s=8*this._size,o=(4294967295&s)>>>0,i=(s-o)/4294967296;return i&&(r[14]=y(i)),o&&(r[15]=y(o)),this._int32(r),"hex"===t?this._hex():this._bin()}_hex(){const{A:t,B:e,C:r,D:n,E:s,F:o,G:i,H:h}=this;return w(t)+w(e)+w(r)+w(n)+w(s)+w(o)+w(i)+w(h)}_bin(){const{A:t,B:e,C:r,D:n,E:s,F:o,G:i,H:h,_byte:c,_word:f}=this;return f[0]=y(t),f[1]=y(e),f[2]=y(r),f[3]=y(n),f[4]=y(s),f[5]=y(o),f[6]=y(i),f[7]=y(h),c.slice(0,32)}}const u=new Int32Array(64);let l,p=0;const w=t=>(t+4294967296).toString(16).substr(-8),y=254===new Uint8Array(new Uint16Array([65279]).buffer)[0]?t=>t:t=>t<<24&4278190080|t<<8&16711680|t>>8&65280|t>>24&255,b=(t,e,r)=>r^t&(e^r),g=(t,e,r)=>t&e|r&(t|e),_=t=>(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),A=t=>(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7),v=t=>(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,m=t=>(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10;var E,k,x=function(t){return function(t){if(t&&!a[t]&&!a[t.toLowerCase()])throw new Error("Digest method not supported");return new d}().update(t).digest()};t.Network=void 0,(E=t.Network||(t.Network={})).mainnet="mainnet",E.testnet="testnet",E.regtest="regtest",t.AddressType=void 0,(k=t.AddressType||(t.AddressType={})).p2pkh="p2pkh",k.p2sh="p2sh",k.p2wpkh="p2wpkh",k.p2wsh="p2wsh",k.p2tr="p2tr";var I={0:{type:t.AddressType.p2pkh,network:t.Network.mainnet},111:{type:t.AddressType.p2pkh,network:t.Network.testnet},5:{type:t.AddressType.p2sh,network:t.Network.mainnet},196:{type:t.AddressType.p2sh,network:t.Network.testnet}},T=function(r){var n,o=r.substr(0,2).toLowerCase();if("bc"===o||"tb"===o)return function(e){var r;try{r=e.startsWith("bc1p")||e.startsWith("tb1p")||e.startsWith("bcrt1p")?h.decode(e):c.decode(e)}catch(t){throw new Error("Invalid address")}var n={bc:t.Network.mainnet,tb:t.Network.testnet,bcrt:t.Network.regtest}[r.prefix];if(void 0===n)throw new Error("Invalid address");var s=r.words[0];if(s<0||s>16)throw new Error("Invalid address");return{bech32:!0,network:n,address:e,type:20===c.fromWords(r.words.slice(1)).length?t.AddressType.p2wpkh:1===s?t.AddressType.p2tr:t.AddressType.p2wsh}}(r);try{n=s(r)}catch(t){throw new Error("Invalid address")}var i=n.length;if(25!==i)throw new Error("Invalid address");var f=n[0],a=n.slice(i-4,i),d=n.slice(0,i-4),u=x(x(d)).slice(0,4);if(a.some((function(t,e){return t!==u[e]})))throw new Error("Invalid address");if(!Object.keys(I).map(Number).includes(f))throw new Error("Invalid address");return e(e({},I[f]),{address:r,bech32:!1})},C=function(t,e){try{var r=T(t);return!e||e===r.network}catch(t){return!1}};t.default=C,t.getAddressInfo=T,t.validate=C,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "bitcoin-address-validation",
"version": "2.2.2",
"version": "2.2.3",
"description": "Validate any Bitcoin address - P2WSH, P2WPKH, P2SH, P2PKH - Mainnet & Testnet",

@@ -53,3 +53,3 @@ "homepage": "https://github.com/ruigomeseu/bitcoin-address-validation",

"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-node-resolve": "^5.2.0",

@@ -56,0 +56,0 @@ "rollup-plugin-peer-deps-external": "^2.2.4",

@@ -5,3 +5,2 @@ # bitcoin-address-validation

[![npm version](https://badge.fury.io/js/bitcoin-address-validation.svg)](https://www.npmjs.com/package/bitcoin-address-validation)
[![David](https://img.shields.io/david/ruigomeseu/bitcoin-address-validation.svg)](https://www.npmjs.com/package/bitcoin-address-validation)
[![npm](https://img.shields.io/npm/dt/bitcoin-address-validation.svg)](https://www.npmjs.com/package/bitcoin-address-validation)

@@ -8,0 +7,0 @@ [![Twitter Follow](https://img.shields.io/twitter/follow/8bitgomes.svg?style=social)](https://twitter.com/8bitgomes)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc