You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
652 KiB

(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.bch=e()}})(function(){var t=Math.LN2,r=Math.log,o=Math.pow,s=Math.abs,e=Math.clz32,f=Math.max,n=String.fromCharCode,p=Math.ceil,d=Math.round,u=Math.min,h=Math.floor,i,a,c;return function d(c,e,t){function r(i,o){if(!e[i]){if(!c[i]){var s="function"==typeof require&&require;if(!o&&s)return s(i,!0);if(n)return n(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var f=e[i]={exports:{}};c[i][0].call(f.exports,function(t){var e=c[i][1][t];return r(e?e:t)},f,f.exports,d,c,e,t)}return e[i].exports}for(var n="function"==typeof require&&require,i=0;i<t.length;i++)r(t[i]);return r}({1:[function(e,t){(function(r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function i(e,t,r){if(!(this instanceof i))return new i(e,t,r);if(o.isArray(e)&&o.isNumber(t))return i.createMultisig(e,t,r);if(e instanceof i)return e;if(d.checkArgument(e,"First argument is required, please include address data.","guide/address.html"),t&&!c.get(t))throw new TypeError("Second argument must be \"livenet\" or \"testnet\".");if(r&&r!==i.PayToPublicKeyHash&&r!==i.PayToScriptHash)throw new TypeError("Third argument must be \"pubkeyhash\" or \"scripthash\".");var n=this._classifyArguments(e,t,r);return n.network=n.network||c.get(t)||c.defaultNetwork,n.type=n.type||r||i.PayToPublicKeyHash,u.defineImmutable(this,{hashBuffer:n.hashBuffer,network:n.network,type:n.type}),this}var o=e("lodash"),d=e("./util/preconditions"),a=e("cashaddrjs"),s=e("./errors"),f=e("./encoding/base58check"),c=e("./networks"),p=e("./crypto/hash"),u=e("./util/js"),l=e("./publickey"),h=28,b=40;i.prototype._classifyArguments=function(e,t,n){if((e instanceof r||e instanceof Uint8Array)&&20===e.length)return i._transformHash(e);if((e instanceof r||e instanceof Uint8Array)&&21===e.length)return i._transformBuffer(e,t,n);if(e instanceof l)return i._transformPublicKey(e);if(e instanceof g)return i._transformScript(e,t);if("string"==typeof e)return i._transformString(e,t,n,i.DefaultFormat);if(o.isObject(e))return i._transformObject(e);throw new TypeError("First argument is an unrecognized data format.")},i.LegacyFormat="legacy",i.BitpayFormat="bitpay",i.CashAddrFormat="cashaddr",i.DefaultFormat=i.LegacyFormat,i.PayToPublicKeyHash="pubkeyhash",i.PayToScriptHash="scripthash",i._transformHash=function(e){var t={};if(!(e instanceof r)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(20!==e.length)throw new TypeError("Address hashbuffers must be exactly 20 bytes.");return t.hashBuffer=e,t},i._transformObject=function(e){return d.checkArgument(e.hash||e.hashBuffer,"Must provide a `hash` or `hashBuffer` property"),d.checkArgument(e.type,"Must provide a `type` property"),{hashBuffer:e.hash?new r(e.hash,"hex"):e.hashBuffer,network:c.get(e.network)||c.defaultNetwork,type:e.type}},i._classifyFromVersion=function(e){var t={},r=c.get(e[0],"pubkeyhash"),n=c.get(e[0],"scripthash");return r?(t.network=r,t.type=i.PayToPublicKeyHash):n&&(t.network=n,t.type=i.PayToScriptHash),t},i._transformBuffer=function(e,t,n){var o={};if(!(e instanceof r)&&!(e instanceof Uint8Array))throw new TypeError("Address supplied is not a buffer.");if(21!==e.length)throw new TypeError("Address buffers must be exactly 21 bytes.");t=c.get(t);var d=i._classifyFromVersion(e);if(!d.network||t&&t!==d.network)throw new TypeError("Address has mismatched network type.");if(!d.type||n&&n!==d.type)throw new TypeError("Address has mismatched type.");return o.hashBuffer=e.slice(1),o.network=d.network,o.type=d.type,o},i._transformPublicKey=function(e){var t={};if(!(e instanceof l))throw new TypeError("Address must be an instance of PublicKey.");return t.hashBuffer=p.sha256ripemd160(e.toBuffer()),t.type=i.PayToPublicKeyHash,t},i._transformSc