(function(e){vari=function(e,i){Object.defineProperty(module.exports,e,{get:function(){returnrequire(i)}})};i("Bignum","bignum"),Object.defineProperty(module.exports,"bignum",{get:function(){returnconsole.log('bignum (with a lower-case "b") is deprecated. Use bitcore.Bignum (capital "B") instead.'),require("bignum")}}),i("Base58","./lib/Base58"),Object.defineProperty(module.exports,"base58",{get:function(){returnconsole.log('base58 (with a lower-case "b") is deprecated. Use bitcore.Base58 (capital "B") instead.'),require("./lib/Base58")}}),i("bufferput","bufferput"),i("buffertools","buffertools"),i("Buffers.monkey","./patches/Buffers.monkey"),i("config","./config"),i("const","./const"),i("Curve","./lib/Curve"),i("Deserialize","./lib/Deserialize"),i("ECIES","./lib/ECIES"),i("log","./util/log"),i("networks","./networks"),i("SecureRandom","./lib/SecureRandom"),i("sjcl","./lib/sjcl"),i("util","./util/util"),i("EncodedData","./util/EncodedData"),i("VersionedData","./util/VersionedData"),i("BinaryParser","./util/BinaryParser"),i("Address","./lib/Address"),i("HierarchicalKey","./lib/HierarchicalKey"),Object.defineProperty(module.exports,"BIP32",{get:function(){returnconsole.log("BIP32 is deprecated. Use bitcore.HierarchicalKey instead."),require("./lib/HierarchicalKey")}}),i("BIP39","./lib/BIP39"),i("BIP39WordlistEn","./lib/BIP39WordlistEn"),i("Point","./lib/Point"),i("Opcode","./lib/Opcode"),i("Script","./lib/Script"),i("Transaction","./lib/Transaction"),i("TransactionBuilder","./lib/TransactionBuilder"),i("Connection","./lib/Connection"),i("Peer","./lib/Peer"),i("Block","./lib/Block"),i("ScriptInterpreter","./lib/ScriptInterpreter"),i("Bloom","./lib/Bloom"),i("Key","./lib/Key"),Object.defineProperty(module.exports,"KeyModule",{get:function(){returnconsole.log("KeyModule is deprecated."),require("bindings")("KeyModule")}}),i("SINKey","./lib/SINKey"),i("SIN","./lib/SIN"),i("PrivateKey","./lib/PrivateKey"),i("RpcClient","./lib/RpcClient"),i("Wallet","./lib/Wallet"),i("WalletKey","./lib/WalletKey"),i("PeerManager","./lib/PeerManager"),i("Message","./lib/Message"),i("Electrum","./lib/Electrum"),i("Armory","./lib/Armory"),module.exports.Buffer=e}).call(this,require("buffer").Buffer);
},_doProcessBlock:function(t,e){for(varr=0;16>r;r++){vari=e+r,a=t[i];t[i]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}varF,g,f,c,l,B,m,y,d,v,i=this._hash.words,a=p.words,b=h.words,I=n.words,E=o.words,C=s.words,T=u.words;B=F=i[0],m=g=i[1],y=f=i[2],d=c=i[3],v=l=i[4];for(varw,r=0;80>r;r+=1)w=F+t[e+I[r]]|0,w=16>r?w+((g^f^c)+a[0]):32>r?w+((g&f|~g&c)+a[1]):48>r?w+(((g|~f)^c)+a[2]):64>r?w+((g&c|f&~c)+a[3]):w+((g^(f|~c))+a[4]),w|=0,w=w<<C[r]|w>>>32-C[r],w=w+l|0,F=l,l=c,c=f<<10|f>>>22,f=g,g=w,w=B+t[e+E[r]]|0,w=16>r?w+((m^(y|~d))+b[0]):32>r?w+((m&d|y&~d)+b[1]):48>r?w+(((m|~y)^d)+b[2]):64>r?w+((m&y|~m&d)+b[3]):w+((m^y^d)+b[4]),w|=0,w=w<<T[r]|w>>>32-T[r],w=w+v|0,B=v,v=d,d=y<<10|y>>>22,y=m,m=w;w=i[1]+f+d|0,i[1]=i[2]+c+v|0,i[2]=i[3]+l+B|0,i[3]=i[4]+F+m|0,i[4]=i[0]+g+y|0,i[0]=w},_doFinalize:function(){vart=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;for(e[i>>>5]|=128<<24-i%32,e[(i+64>>>9<<4)+14]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),t=this._hash,e=t.words,r=0;5>r;r++)i=e[r],e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);returnt},clone:function(){vart=i.clone.call(this);returnt._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(e),t.HmacRIPEMD160=i._createHmacHelper(e)}(Math),module.exports.crypto31=CryptoJS;vardbits,canary=0xdeadbeefcafe,j_lm=15715070==(16777215&canary);j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<<dbits)-1,BigInteger.prototype.DV=1<<dbits;varBI_FP=52;BigInteger.prototype.FV=Math.pow(2,BI_FP),BigInteger.prototype.F1=BI_FP-dbits,BigInteger.prototype.F2=2*dbits-BI_FP;varBI_RM="0123456789abcdefghijklmnopqrstuvwxyz",BI_RC=newArray,rr,vv;for(rr="0".charCodeAt(0),vv=0;9>=vv;++vv)BI_RC[rr++]=vv;for(rr="a".charCodeAt(0),vv=10;36>vv;++vv)BI_RC[rr++]=vv;for(rr="A".charCodeAt(0),vv=10;36>vv;++vv)BI_RC[rr++]=vv;Classic.prototype.convert=cConvert,Classic.prototype.revert=cRevert,Classic.prototype.reduce=cReduce,Classic.prototype.mulTo=cMulTo,Classic.prototype.sqrTo=cSqrTo,Montgomery.prototype.convert=montConvert,Montgomery.prototype.revert=montRevert,Montgomery.prototype.reduce=montReduce,Montgomery.prototype.mulTo=montMulTo,Montgomery.prototype.sqrTo=montSqrTo,BigInteger.prototype.copyTo=bnpCopyTo,BigInteger.prototype.fromInt=bnpFromInt,BigInteger.prototype.fromString=bnpFromString,BigInteger.prototype.clamp=bnpClamp,BigInteger.prototype.dlShiftTo=bnpDLShiftTo,BigInteger.prototype.drShiftTo=bnpDRShiftTo,BigInteger.prototype.lShiftTo=bnpLShiftTo,BigInteger.prototype.rShiftTo=bnpRShiftTo,BigInteger.prototype.subTo=bnpSubTo,BigInteger.prototype.multiplyTo=bnpMultiplyTo,BigInteger.prototype.squareTo=bnpSquareTo,BigInteger.prototype.divRemTo=bnpDivRemTo,BigInteger.prototype.invDigit=bnpInvDigit,BigInteger.prototype.isEven=bnpIsEven,BigInteger.prototype.exp=bnpExp,BigInteger.prototype.toString=bnToString,BigInteger.prototype.negate=bnNegate,BigInteger.prototype.abs=bnAbs,BigInteger.prototype.compareTo=bnCompareTo,BigInteger.prototype.bitLength=bnBitLength,BigInteger.prototype.mod=bnMod,BigInteger.prototype.modPowInt=bnModPowInt,BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=nMulTo,NullExp.prototype.sqrTo=nSqrTo,Barrett.prototype.convert=barrettConvert,Barrett.prototype.revert=barrettRevert,Barrett.prototype.reduce=barrettReduce,Barrett.prototype.mulTo=barrettMulTo,Barrett.prototype.sqrTo=barrettSqrTo;varlowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,
(function(e){"use strict";functionr(e,t){if(t&&t.length&&20!=t.length)thrownewError("Hash must be 20 bytes");r.super(this,arguments)}vart=require("soop").imports(),i=t.coinUtil||require("../util"),n=t.parent||require("../util/VersionedData"),s=t.networks||require("../networks"),o=t.Script||require("./Script");r.parent=n,n.applyEncodingsTo(r),r.fromPubKey=function(e,t){if(t||(t="livenet"),33!==e.length&&65!==e.length)thrownewError("Invalid public key");varn=s[t].addressVersion,o=i.sha256ripe160(e);returnnewr(n,o)},r.fromKey=function(e,t){returnr.fromPubKey(e.public,t)},r.fromPubKeys=function(e,t,i,n){i||(i="livenet");for(varsint){vara=t[s];if(33!=a.length&&65!=a.length)thrownewError("Invalid public key")}varu=o.createMultisig(e,t,n);returnr.fromScript(u,i)},r.fromScript=function(t,n){n||(n="livenet"),"string"==typeoft&&(t=newo(newe(t,"hex")));vara=s[n].P2SHVersion,u=t.getBuffer(),f=i.sha256ripe160(u);returnnewr(a,f)},r.fromScriptPubKey=function(t,n){"string"==typeoft&&(t=newo(newe(t,"hex"))),n||(n="livenet");vara,u=[],f=t.capture();if(f){varp=t.classify();switch(p){caseo.TX_PUBKEY:f[0]=i.sha256ripe160(f[0]),a=s[n].addressVersion;break;caseo.TX_PUBKEYHASH:a=s[n].addressVersion;break;caseo.TX_MULTISIG:a=s[n].addressVersion;for(varlinf)f[l]=i.sha256ripe160(f[l]);break;caseo.TX_SCRIPTHASH:a=s[n].P2SHVersion}for(varlinf)u.push(newr(a,f[l]))}returnu},r.prototype.validate=function(){if(this.doAsBinary(function(){if(r.super(this,"validate",arguments),21!==this.data.length)thrownewError("invalid data length")}),"undefined"==typeofthis.network())thrownewError("invalid network")},r.prototype.isValid=function(){vare=r.super(this,"isValid",arguments);returne},r.prototype.network=function(){vare,r=this.version(),t=s.livenet,i=s.testnet;returnr===t.addressVersion||r===t.P2SHVersion?e=t:(r===i.addressVersion||r===i.P2SHVersion)&&(e=i),e},r.prototype.isScript=function(){returnthis.isValid()&&this.version()===this.network().P2SHVersion},r.prototype.getScriptPubKey=function(){vare,r=this.version(),t=s.livenet,i=s.testnet;if(r===t.addressVersion||r===i.addressVersion)e=o.createPubKeyHashOut(this.payload());else{if(r!==t.P2SHVersion&&r!==i.P2SHVersion)thrownewError("invalid address - unknown version");e=o.createP2SH(this.payload())}returne},module.exports=require("soop")(r)}).call(this,require("buffer").Buffer);
(function(e){functionr(r){returnnewe(t.createHash("sha256").update(r).digest("binary"),"binary")}functionn(e){returnr(r(e))}for(vart=require("crypto"),o=require("bignum"),i=newe(1024),c=newe(0),f="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",u=f[0],a=newe(f,"ascii"),d={},h=0;h<f.length;h++)d[f[h]]=h;varl={encode:function(r){varn,t,c=o.fromBuffer(r);n=r.length<512?i:newe(r.length<<1);for(varf=n.length-1;c.gt(0);)t=c.mod(58),c=c.div(58),n[f]=a[t.toNumber()],f--;for(varu=0;0==r[u];)n[f]=a[0],u++,f--;returnn.slice(f+1,n.length).toString("ascii")},decode:function(r){if(0==r.length)returnc;for(varn=o(0),t=0;t<r.length;t++)n=n.mul(58),n=n.add(d[r[t]]);for(vart=0;t<r.length&&r[t]==u;)t++;if(t>0){vari=newe(t);returni.fill(0),t==r.length?i:(n=n.toBuffer(),e.concat([i,n],t+n.length))}returnn.toBuffer()}},s={encode:function(r){vart=newe(r.length+4),o=n(r);returnr.copy(t),o.copy(t,r.length),l.encode(t)},decode:function(e){varr=l.decode(e);if(r.length<4)thrownewError("invalid input: too short");vart=r.slice(0,-4),o=r.slice(-4),i=n(t),c=i.slice(0,4);if(o.toString()!=c.toString())thrownewError("checksum mismatch");returnt}};exports.setBuffer=function(e){i=e},exports.base58=l,exports.base58Check=s,exports.encode=l.encode,exports.decode=l.decode}).call(this,require("buffer").Buffer);
(function(t){functione(t){"object"!=typeoft&&(t={}),this.hash=t.hash||null,this.prev_hash=t.prev_hash||i.NULL_HASH,this.merkle_root=t.merkle_root||i.NULL_HASH,this.timestamp=t.timestamp||0,this.bits=t.bits||0,this.nonce=t.nonce||0,this.version=t.version||0,this.height=t.height||0,this.size=t.size||0,this.active=t.active||!1,this.chainWork=t.chainWork||i.EMPTY_BUFFER,this.txs=t.txs||[]}varr=require("soop").imports(),i=r.util||require("../util"),o=(r.Debug1||function(){},r.Script||require("./Script")),s=r.Bignum||require("bignum"),h=(r.Binary||require("binary"),r.Step||require("step"),r.buffertools||require("buffertools")),n=r.Transaction||require("./Transaction"),a=n.In,c=n.Out,u=n.COINBASE_OP,l=r.VerificationError||require("../util/error").VerificationError,f={maxTimeOffset:7200,largestHash:s(2).pow(256)};e.prototype.getHeader=function(){vare=newt(80),r=0;returne.writeUInt32LE(this.version,r),r+=4,this.prev_hash.copy(e,r),r+=32,this.merkle_root.copy(e,r),r+=32,e.writeUInt32LE(this.timestamp,r),r+=4,e.writeUInt32LE(this.bits,r),r+=4,e.writeUInt32LE(this.nonce,r),r+=4,e},e.prototype.parse=function(t,e){if(this.version=t.word32le(),this.prev_hash=t.buffer(32),this.merkle_root=t.buffer(32),this.timestamp=t.word32le(),this.bits=t.word32le(),this.nonce=t.word32le(),this.txs=[],this.size=0,!e)for(varr=t.varInt(),i=0;r>i;i++){varo=newn;o.parse(t),this.txs.push(o)}},e.prototype.calcHash=function(){vart=this.getHeader();returni.twoSha256(t)},e.prototype.checkHash=function(){returnthis.hash&&this.hash.length?0==h.compare(this.calcHash(),this.hash):!1},e.prototype.getHash=function(){returnthis.hash&&this.hash.length||(this.hash=this.calcHash()),this.hash},e.prototype.checkProofOfWork=function(){vart=i.decodeDiffBits(this.bits),e=h.reverse(this.hash);if(h.compare(e,t)>0)thrownewl("Difficulty target not met");return!0},e.prototype.getWork=function(){vart=i.decodeDiffBits(this.bits,!0);returnf.largestHash.div(t.add(1))},e.prototype.checkTimestamp=function(){vart=(newDate).getTime()/1e3;if(this.timestamp>t+f.maxTimeOffset)thrownewl("Timestamp too far into the future");return!0},e.prototype.checkTransactions=function(t){if(!Array.isArray(t)||t.length<=0)thrownewl("No transactions");if(!t[0].isCoinBase())thrownewl("First tx must be coinbase");for(vare=1;e<t.length;e++)if(t[e].isCoinBase())thrownewl("Tx index "+e+" must not be coinbase");return!0},e.prototype.getMerkleTree=function(e){if(0==e.length)return[i.NULL_HASH.slice(0)];for(varr=e.map(function(t){returntinstanceofn?t.getHash():t}),o=0,s=e.length;s>1;s=Math.floor((s+1)/2)){for(varh=0;s>h;h+=2){vara=Math.min(h+1,s-1),c=r[o+h],u=r[o+a];r.push(i.twoSha256(t.concat([c,u])))}o+=s}returnr},e.prototype.calcMerkleRoot=function(t){vare=this.getMerkleTree(t);returne[e.length-1]},e.prototype.checkMerkleRoot=function(e){if(!this.merkle_root||!this.merkle_root.length)thrownewl("No merkle root");if(0!==h.compare(this.calcMerkleRoot(e),newt(this.merkle_root)))thrownewl("Merkle root incorrect");return!0},e.prototype.checkBlock=function(t){if(!this.checkHash())thrownewl("Block hash invalid");if(this.checkProofOfWork(),this.checkTimestamp(),t&&(this.checkTransactions(t),!this.checkMerkleRoot(t)))thrownewl("Merkle hash invalid");return!0},e.getBlockValue=function(t){vare=s(50).mul(i.COIN);returne=e.div(s(2).pow(Math.floor(t/21e4)))},e.prototype.getBlockValue=function(){returne.getBlockValue(this.height)},e.prototype.toString=function(){return"<Block "+i.formatHashAlt(this.hash)+" height="+this.height+">"},e.prototype.createCoinbaseTx=function(t){vare=newn;returne.ins.push(newa({s:i.EMPTY_BUFFER,q:4294967295,o:u})),e.outs.push(newc({v:i.bigIntToValue(this.getBlockValue()),s:o.createPubKeyOut(t).getBuffer()})),e},e.prototype.solve=function(t,e){varr=this.getHeader(),o=i.decodeDiffBits(this.bits);t.solve(r,o,e)},e.prototype.getStandardizedObject=function(t){vare={hash:i.formatHashFull(this.getHash()),version:this.version,prev_block:i.formatHashFull(this.prev_hash),mrkl_root:i.formatHashFull(this.merkle_root),time:this.timestamp,bits:this.bits,nonc
(function(e){functiont(e,s,n){if(t.super(this,arguments),this.config=n||h,this.network=c[this.config.network]||c.livenet,this.socket=e,this.peer=s,this.config.proxy){vari=r.Socks5Client||require("socks5-client");this.socket=newi(this.config.proxy.host,this.config.proxy.port)}this.active=!1,this.recvVer=0,this.sendVer=0,this.bestHeight=0,this.inbound=!!this.socket.server,this.getaddr=!1,this.buffers=newa,(newDate).getTime()>1329696e6&&(this.recvVer=209,this.sendVer=209),this.setupHandlers()}varr=require("soop").imports(),s=r.log||require("../util/log"),n=1e7,i=7e4,o=r.Put||require("bufferput"),a=r.Buffers||require("buffers");require("../patches/Buffers.monkey").patch(a);varh=r.config||require("../config"),c=r.networks||require("../networks"),f=r.Block||require("./Block"),d=r.Transaction||require("./Transaction"),u=r.util||require("../util"),p=r.Parser||require("../util/BinaryParser"),g=r.buffertools||require("buffertools"),l=r.doubleSha256||u.twoSha256,v=r.SecureRandom||require("./SecureRandom"),b=v.getPseudoRandomBuffer(8),k=6e4;t.parent=r.parent||require("events").EventEmitter,t.prototype.open=function(e){return"function"==typeofe&&this.once("connect",e),this.socket.connect(this.peer.port,this.peer.host),this},t.prototype.setupHandlers=function(){this.socket.addListener("connect",this.handleConnect.bind(this)),this.socket.addListener("error",this.handleError.bind(this)),this.socket.addListener("end",this.handleDisconnect.bind(this)),this.socket.addListener("data",function(e){vart=35;s.debug("["+this.peer+"] Recieved "+e.length+" bytes of data:"),s.debug("... "+g.toHex(e.slice(0,t>e.length?e.length:t))+(e.length>t?"...":""))}.bind(this)),this.socket.addListener("data",this.handleData.bind(this))},t.prototype.handleConnect=function(){this.inbound||this.sendVersion(),this.emit("connect",{conn:this,socket:this.socket,peer:this.peer})},t.prototype.handleError=function(e){110==e.errno||"ETIMEDOUT"==e.errno?s.info("connection timed out for "+this.peer):111==e.errno||"ECONNREFUSED"==e.errno?s.info("connection refused for "+this.peer):s.warn("connection with "+this.peer+" "+e.toString()),this.emit("error",{conn:this,socket:this.socket,peer:this.peer,err:e})},t.prototype.handleDisconnect=function(){this.emit("disconnect",{conn:this,socket:this.socket,peer:this.peer})},t.prototype.handleMessage=function(t){if(t){try{switch(t.command){case"version":if(0===g.compare(b,t.nonce))returnvoidthis.socket.end();this.inbound&&this.sendVersion(),t.version>=209&&this.sendMessage("verack",newe([])),this.sendVer=Math.min(t.version,i),t.version<209?this.recvVer=Math.min(t.version,i):this.once("verack",function(){this.recvVer=t.version}.bind(this)),this.bestHeight=t.start_height;break;case"verack":this.recvVer=Math.min(t.version,i),this.active=!0;break;case"ping":"object"==typeoft.nonce&&this.sendPong(t.nonce)}}catch(r){returnvoids.err('Error while handling "'+t.command+'" message from '+this.peer+":\n"+(r.stack?r.stack:r.toString()))}this.emit(t.command,{conn:this,socket:this.socket,peer:this.peer,message:t})}},t.prototype.sendPong=function(e){this.sendMessage("pong",e)},t.prototype.sendVersion=function(){vart="/BitcoinX:0.1/",r=newo;r.word32le(i),r.word64le(1),r.word64le(Math.round((newDate).getTime()/1e3)),r.pad(26),r.pad(26),r.put(b),r.varint(t.length),r.put(newe(t,"ascii")),r.word32le(0),this.sendMessage("version",r.buffer())},t.prototype.sendGetBlocks=function(t,r,s){r=r||u.NULL_HASH;varn=newo;n.word32le(this.sendVer),n.varint(t.length);for(vari=0;i<t.length;i++){if(32!=t[i].length)thrownewError("Invalid hash length");n.put(t[i])}vara=newe(r,"binary");if(32!=a.length)thrownewError("Invalid hash length");n.put(a);varh="getblocks";s&&(h="getheaders"),this.sendMessage(h,n.buffer())},t.prototype.sendGetHeaders=function(e,t){this.sendGetBlocks(e,t,!0)},t.prototype.sendGetData=function(e){vart=newo;t.varint(e.length);for(varr=0;r<e.length;r++)t.word32le(e[r].type),t.put(e[r].hash);this.sendMessage("getdata",t.buffer())},t.prototype.sendGetAddr=function(){vare=newo;this.sendMessage("getaddr",e.buffer())},t.protot
(function(e){"use strict";vari=require("soop").imports(),n=i.coinUtil||require("../util"),r=i.Key||require("./Key"),t=function(){};t.sign=function(e,i){varn=t.magicHash(e),r=i.signSync(n);returnr},t.verifyWithPubKey=function(e,i,n){varu=t.magicHash(i),c=newr;return65==e.length&&(c.compressed=!1),c.public=e,c.verifySignatureSync(u,n)},t.magicBytes=newe("Bitcoin Signed Message:\n"),t.magicHash=function(i){varr=t.magicBytes,u=n.varIntBuf(r.length),c=newe(i),a=n.varIntBuf(c.length),s=e.concat([u,r,a,c]),o=n.twoSha256(s);returno},module.exports=require("soop")(t)}).call(this,require("buffer").Buffer);
functionPeerManager(e){this.config=e||{};for(varninbitcoreDefaults)bitcoreDefaults.hasOwnProperty(n)&&void0===this.config[n]&&(this.config[n]=bitcoreDefaults[n]);this.active=!1,this.timer=null,this.peers=[],this.pool=[],this.connections=[],this.isConnected=!1,this.peerDiscovery=!1,this.interval=5e3,this.minConnections=8,this.minKnownPeers=10,this.seeds={resolved:[],failed:[]}}varimports=require("soop").imports(),log=imports.log||require("../util/log"),bitcoreDefaults=imports.config||require("../config"),Connection=imports.Connection||require("./Connection"),Peer=imports.Peer||require("./Peer");GetAdjustedTime=imports.GetAdjustedTime||function(){returnMath.floor((newDate).getTime()/1e3)},PeerManager.parent=imports.parent||require("events").EventEmitter,PeerManager.Connection=Connection,PeerManager.prototype.start=function(){this.active=!0,this.timer||(this.timer=setInterval(this.checkStatus.bind(this),this.interval))},PeerManager.prototype.stop=function(){this.active=!1,this.timer&&(clearInterval(this.timer),this.timer=null);for(vare=0;e<this.connections.length;e++)this.connections[e].socket.end()},PeerManager.prototype.addPeer=function(e,n){if(einstanceofPeer)this.peers.push(e);else{if("string"!=typeofe)throwlog.err("Node.addPeer(): Invalid value provided for peer",{val:e}),"Node.addPeer(): Invalid value provided for peer.";this.addPeer(newPeer(e,n))}},PeerManager.prototype.removePeer=function(e){varn=this.peers.indexOf(e),t=!!~n;returnt&&this.peers.splice(n,1),t},PeerManager.prototype.checkStatus=function(){if(this.peers.length){vare={};this.peers.forEach(function(n){e[n.toString()]=n}),this.connections.forEach(function(n){vart=n.peer.toString();"undefined"!==e[t]&&deletee[t]});varn=0;this.peers.forEach(function(e){e.connection&&!e.connection._connecting&&n++}),log.debug(n+" of "+this.peers.length+" peers connected"),Object.keys(e).forEach(function(n){this.connectTo(e[n])}.bind(this))}},PeerManager.prototype.connectTo=function(e){log.info("connecting to "+e);try{returnthis.addConnection(e.createConnection(),e)}catch(n){returnlog.err("creating connection",n),null}},PeerManager.prototype.addConnection=function(e,n){vart=newConnection(e,n,this.config);returnthis.connections.push(t),this.emit("connection",t),t.addListener("version",this.handleVersion.bind(this)),t.addListener("verack",this.handleReady.bind(this)),t.addListener("addr",this.handleAddr.bind(this)),t.addListener("getaddr",this.handleGetAddr.bind(this)),t.addListener("error",this.handleError.bind(this)),t.addListener("disconnect",this.handleDisconnect.bind(this)),t},PeerManager.prototype.handleVersion=function(e){e.peer.version=e.message.version,e.peer.start_height=e.message.start_height,!e.conn.inbound,this.peerDiscovery&&(e.message.version>=31402||this.peers.length<1e3)&&(e.conn.sendGetAddr(),e.conn.getaddr=!0)},PeerManager.prototype.handleReady=function(e){log.info("connected to "+e.conn.peer.host+":"+e.conn.peer.port),this.emit("connect",{pm:this,conn:e.conn,socket:e.socket,peer:e.peer}),0==this.isConnected&&(this.emit("netConnected",e),this.isConnected=!0)},PeerManager.prototype.handleAddr=function(e){if(this.peerDiscovery){varn=GetAdjustedTime();e.message.addrs.forEach(function(e){try{(e.time<=1e8||e.time>n+600)&&(e.time=n-432e3);vart=newPeer(e.ip,e.port,e.services);t.lastSeen=e.time,this.peers.push(t)}catch(r){log.warn("Invalid addr received: "+r.message)}}.bind(this)),e.message.addrs.length<1e3&&(e.conn.getaddr=!1)}},PeerManager.prototype.handleGetAddr=function(){},PeerManager.prototype.handleError=function(e){log.err("unkown error with peer "+e.peer+" (disconnecting): "+e.err),this.handleDisconnect.apply(this,[].slice.call(arguments))},PeerManager.prototype.handleDisconnect=function(e){log.info("disconnected from peer "+e.peer);varn=this.connections.indexOf(e.conn);-1!=n&&this.connections.splice(n,1),this.removePeer(e.peer),this.pool.length&&(log.info("replacing peer using the pool of "+this.pool.length+" seeds"),this.addPeer(this.pool.pop())),this.connections.length||(this.emit("netDisconnected"),this.isConnected=!1)},Peer
(function(t){functioni(n,r){return"number"!=typeofn?voidi.super(this,arguments):(this.data=newt(2+r.length),this.__proto__=this.encodings.binary,this.prefix(15),this.type(n),voidthis.payload(r))}varn=require("soop").imports(),r=n.parent||require("../util/VersionedData");i.parent=r,r.applyEncodingsTo(i),i.SIN_PERSIST_MAINNET=1,i.SIN_PERSIST_TESTNET=17,i.SIN_EPHEM=2,i.prototype.prefix=function(t){returnt||0===t?(this.doAsBinary(function(){this.data.writeUInt8(t,0)}),t):this.as("binary").readUInt8(0)},i.prototype.type=function(t){returnt||0===t?(this.doAsBinary(function(){this.data.writeUInt8(t,1)}),t):this.as("binary").readUInt8(1)},i.prototype.payload=function(t){returnt?(this.doAsBinary(function(){t.copy(this.data,2)}),t):this.as("binary").slice(1)},i.prototype.validate=function(){this.doAsBinary(function(){if(i.super(this,"validate",arguments),22!=this.data.length)thrownewError("invalid data length")})},module.exports=require("soop")(i)}).call(this,require("buffer").Buffer);
(function(t){functione(t){this.buffer=t?t:c.EMPTY_BUFFER,this.chunks=[],this.parse()}functionr(t){returnt==o.map.OP_0||t>=o.map.OP_1&&t<=o.map.OP_16}functionn(t){returnt<o.map.OP_PUSHDATA1?1:255>=t?2:65535>=t?3:5}functions(e){varr=void0;returne<o.map.OP_PUSHDATA1?(r=newt(1),r.writeUInt8(e,0)):255>=e?(r=newt(2),r.writeUInt8(o.map.OP_PUSHDATA1,0),r.writeUInt8(e,1)):65535>=e?(r=newt(3),r.writeUInt8(o.map.OP_PUSHDATA2,0),r.writeUInt16LE(e,1)):(r=newt(5),r.writeUInt8(o.map.OP_PUSHDATA4,0),r.writeUInt32LE(e,1)),r}varu=require("soop").imports(),h=(u.config||require("../config"),u.log||require("../util/log")),o=u.Opcode||require("./Opcode"),f=u.buffertools||require("buffertools"),c=u.util||require("../util/util"),p=u.Parser||require("../util/BinaryParser"),a=u.Put||require("bufferput"),l=0,g=1,k=2,w=3,P=4,y=["unknown","pubkey","pubkeyhash","multisig","scripthash"];e.TX_UNKNOWN=l,e.TX_PUBKEY=g,e.TX_PUBKEYHASH=k,e.TX_MULTISIG=w,e.TX_SCRIPTHASH=P,e.prototype.parse=function(){this.chunks=[];for(vart=newp(this.buffer);!t.eof();){vare,r,n=t.word8();n>0&&n<o.map.OP_PUSHDATA1?this.chunks.push(t.buffer(n)):n===o.map.OP_PUSHDATA1?(e=t.word8(),r=t.buffer(e),this.chunks.push(r)):n===o.map.OP_PUSHDATA2?(e=t.word16le(),r=t.buffer(e),this.chunks.push(r)):n===o.map.OP_PUSHDATA4?(e=t.word32le(),r=t.buffer(e),this.chunks.push(r)):this.chunks.push(n)}},e.prototype.isPushOnly=function(){for(vare=0;e<this.chunks.length;e++){varr=this.chunks[e];if(!t.isBuffer(r)&&r>o.map.OP_16)return!1}return!0},e.prototype.isP2SH=function(){return3==this.chunks.length&&this.chunks[0]==o.map.OP_HASH160&&t.isBuffer(this.chunks[1])&&20==this.chunks[1].length&&this.chunks[2]==o.map.OP_EQUAL},e.prototype.isPubkey=function(){return2==this.chunks.length&&t.isBuffer(this.chunks[0])&&this.chunks[1]==o.map.OP_CHECKSIG},e.prototype.isPubkeyHash=function(){return5==this.chunks.length&&this.chunks[0]==o.map.OP_DUP&&this.chunks[1]==o.map.OP_HASH160&&t.isBuffer(this.chunks[2])&&20==this.chunks[2].length&&this.chunks[3]==o.map.OP_EQUALVERIFY&&this.chunks[4]==o.map.OP_CHECKSIG},e.prototype.isMultiSig=function(){returnthis.chunks.length>3&&r(this.chunks[0])&&this.chunks.slice(1,this.chunks.length-2).every(function(e){returnt.isBuffer(e)})&&r(this.chunks[this.chunks.length-2])&&this.chunks[this.chunks.length-1]==o.map.OP_CHECKMULTISIG},e.prototype.isP2shScriptSig=function(){if(!r(this.chunks[0])||0!==this.chunks[0])return!1;vart=newe(this.chunks[this.chunks.length-1]),n=t.classify();returnn!==l},e.prototype.isMultiSigScriptSig=function(){returnr(this.chunks[0])&&0===this.chunks[0]?!this.isP2shScriptSig():!1},e.prototype.countSignatures=function(){vart=0,e=this.chunks.length;returnt=this.isMultiSigScriptSig()?e-1:this.isP2shScriptSig()?e-2:0===f.compare(this.getBuffer(),c.EMPTY_BUFFER)?0:1},e.prototype.countMissingSignatures=function(){if(this.isMultiSig())returnh.debug("Can not count missing signatures on normal Multisig script"),null;vart=0,n=this.chunks.length;if(r(this.chunks[0])&&0===this.chunks[0]){vari=newe(this.chunks[n-1]);if(r(i.chunks[0])){vars=i.chunks[0]-80;t=s-(n-2)}elseh.debug("Unrecognized script type")}else0===f.compare(this.getBuffer(),c.EMPTY_BUFFER)&&(t=1);returnt},e.prototype.finishedMultiSig=function(){vart=this.countMissingSignatures();returnnull===t?null:0===t},e.prototype.getMultiSigInfo=function(){if(!this.isMultiSig())thrownewError("Script.getMultiSigInfo(): Not a multiSig script.");for(vart=this.chunks[0]-80,e=this.chunks[this.chunks.length-2]-80,r=[],n=1;n<this.chunks.length-2;n++)r.push(this.chunks[n]);if(r.length!=e)thrownewError("Script.getMultiSigInfo(): Amount of PKs does not match what the script specifies.");return{nsigs:t,npubkeys:e,pubkeys:r}},e.prototype.prependOp0=function(){vart=[0];for(iinthis.chunks)this.chunks.hasOwnProperty(i)&&t.push(this.chunks[i]);returnthis.chunks=t,this.updateBuffer(),this},e.prototype.classify=function(){returnthis.isPubkeyHash()?k:this.isP2SH()?P:this.isMultiSig()?w:this.isPubkey()?g:l},e.prototype.capture=function(){vart=this.classify(),e=[];switch(t){caseg:e.push(
(function(t){"use strict";functione(t){returnt=t||{},this.lockTime=t.lockTime||0,this.spendUnconfirmed=t.spendUnconfirmed||!1,(t.fee||t.feeSat)&&(this.givenFeeSat=t.fee?t.fee*s.COIN:t.feeSat),this.remainderOut=t.remainderOut,this.signhash=t.signhash||d.SIGHASH_ALL,this.tx={},this.inputsSigned=0,this.signaturesAdded=0,this}varr=require("soop").imports(),i=r.Address||require("./Address"),n=r.Script||require("./Script"),s=r.util||require("../util"),u=r.bignum||require("bignum"),a=r.buffertools||require("buffertools"),o=r.networks||require("../networks"),h=r.WalletKey||require("./WalletKey"),p=r.PrivateKey||require("./PrivateKey"),c=r.Key||require("./Key"),f=r.log||require("../util/log"),d=r.Transaction||require("./Transaction"),g=parseInt(1e-4*s.COIN);e.FEE_PER_1000B_SAT=g,e._scriptForPubkeys=function(e){for(varr=e.pubkeys.length,i=[],s=0;r>s;s++)i.push(newt(e.pubkeys[s],"hex"));returnn.createMultisig(e.nreq,i)},e._scriptForOut=function(t){vare;if(t.address)e=newi(t.address).getScriptPubKey();else{if(!(t.pubkeys||t.nreq||t.nreq>1))thrownewError("unknown out type");e=this._scriptForPubkeys(t)}returne},e.infoForP2sh=function(t,e){varr=this._scriptForOut(t),n=s.sha256ripe160(r.getBuffer()),u="testnet"===e?o.testnet.P2SHVersion:o.livenet.P2SHVersion,a=newi(u,n),h=a.as("base58");return{script:r,scriptBufHex:r.getBuffer().toString("hex"),hash:n,address:h}},e.prototype.setUnspent=function(t){returnthis.utxos=t,this},e.prototype._setInputMap=function(){for(vare=[],r=this.selectedUtxos.length,i=0;r>i;i++){vars=this.selectedUtxos[i],u=newt(s.scriptPubKey,"hex"),a=newn(u),o=a.classify();if(o===n.TX_UNKNOWN)thrownewError("unkown output type at:"+i+" Type:"+a.getRawOutType());e.push({address:s.address,scriptPubKey:a,scriptType:o,i:i})}returnthis.inputMap=e,this},e.prototype.getSelectedUnspent=function(){returnthis.selectedUtxos},e.prototype._selectUnspent=function(t){if(!this.utxos||!this.utxos.length)thrownewError("unspent not set");vare=[6,1];this.spendUnconfirmed&&e.push(0);varr=[],i=u(0),n=!1,a=null,o=this.utxos.length;do{for(varh=e.shift(),p=0;o>p;p++){varc=this.utxos[p],f=c.confirmations||0;if(!(h>f||a&&f>=a)){vard=c.amountSat||s.parseValue(c.amount);if(i=i.add(d),r.push(c),i.cmp(t)>=0){n=!0;break}}}a=h}while(!n&&e.length);if(!n)thrownewError("not enough unspent tx outputs to fulfill totalNeededAmount [SAT]:"+t);returnthis.selectedUtxos=r,this._setInputMap(),this},e.prototype._setInputs=function(e){varr=this.selectedUtxos,i=r.length,n=u(0);e.ins=[];for(varo=0;i>o;o++){n=n.add(s.parseValue(r[o].amount));varh={};h.s=s.EMPTY_BUFFER,h.q=4294967295;varp=newt(r[o].txid,"hex"),c=a.reverse(p),f=parseInt(r[o].vout),d=newt(4);d.writeUInt32LE(f,0),h.o=t.concat([c,d]),e.ins.push(h)}returnthis.valueInSat=n,this},e.prototype._setFee=function(t){if("undefined"==typeofthis.valueOutSat)thrownewError("valueOutSat undefined");vare=this.valueOutSat.add(t);if(this.valueInSat.cmp(e)<0){varr=this.valueInSat.toString(),i=e.toString();thrownewError("transaction input amount is less than outputs: "+r+" < "+i+" [SAT]")}returnthis.feeSat=t,this},e.prototype._setRemainder=function(t,r){if("undefined"==typeofthis.valueInSat||"undefined"==typeofthis.valueOutSat)thrownewError("valueInSat / valueOutSat undefined");vari=this.valueInSat.sub(this.valueOutSat).sub(this.feeSat),n=t.outs.length;if(this.remainderSat=u(0),n>r&&t.outs.pop(),i.cmp(0)>0){vara=this.remainderOut||this.selectedUtxos[0],o=s.bigIntToValue(i),h=e._scriptForOut(a),p={v:o,s:h.getBuffer()};t.outs.push(p),this.remainderSat=i}returnthis},e.prototype._setFeeAndRemainder=function(t){vare,r=500,i=t.outs.length;do{e=parseInt(r/1e3)+1;varn=this.givenFeeSat?this.givenFeeSat:e*g,s=this.valueOutSat.add(n);this._selectUnspent(s)._setInputs(t)._setFee(n)._setRemainder(t,i),r=newd(t).getSize()}while(r>1e3*(e+1));returnthis},e.prototype.setOutputs=function(t){varr=u(0),i={};i.version=1,i.lock_time=this.lockTime||0,i.ins=[],i.outs=[];for(varn=t.length,a=0;n>a;a++){varo=t[a].amountSat||s.parseValue(t[a].amount),h=s.bigIntToValue(o),p=e._scriptForOut(t[a]
(function(e){functionr(e){if(e||(e={}),!e.network)thrownewError("network parameter is required");this.network=e.network,this.created=e.created,this.privKey=e.privKey}vari=(require("soop").imports(),require("../util")),t=require("../util/time"),s=require("./Key"),p=require("./PrivateKey"),o=require("./Address");r.prototype.generate=function(){this.privKey=s.generateSync(),this.created=t.curtime()},r.prototype.storeObj=function(){vare=this.privKey.public.toString("hex"),r=i.sha256ripe160(this.privKey.public),t=newo(this.network.addressVersion,r),s=newp(this.network.privKeyVersion,this.privKey.private,this.privKey.compressed),n={created:this.created,priv:s.toString(),pub:e,addr:t.toString()};returnn},r.prototype.fromObj=function(r){if(this.created=r.created,this.privKey=news,64==r.priv.length)this.privKey.private=newe(r.priv,"hex"),this.privKey.compressed="undefined"==typeofr.compressed?!0:r.compressed;else{vari=newp(r.priv);i.validate(),this.privKey.private=newe(i.payload()),this.privKey.compressed=i.compressed()}this.privKey.regenerateSync()},module.exports=require("soop")(r)}).call(this,require("buffer").Buffer);
(function(e){functionn(e,i){vars,o,l,c,g,p,d=this;if(!(dinstanceofn))returnnewn(e,i);if(einstanceofn){if(O=0,i===s)returnd.s=e.s,d.e=e.e,void(d.c=(e=e.c)?e.slice():e);e+=""}if(""===e&&(e=0),"string"!=typeofe&&(e=(l="number"==typeofe||"[object Number]"==Object.prototype.toString.call(e))&&0===e&&0>1/e?"-0":e+""),p=e,i===s&&E.test(e))d.s="-"==e.charAt(0)?(e=e.slice(1),-1):1;else{if(10==i)returnu(e,h,a);if(e=S.call(e).replace(/^\+(?!-)/,""),d.s="-"==e.charAt(0)?(e=e.replace(/^-(?!-)/,""),-1):1,null!=i?i!=(0|i)&&w||(f=!(i>=2&&65>i))?(t(i,2),g=E.test(e)):(c="["+N.slice(0,i=0|i)+"]+",e=e.replace(/\.$/,"").replace(/^\./,"0."),(g=newRegExp("^"+c+"(?:\\."+c+")?$",37>i?"i":"").test(e))?(l&&(e.replace(/^0\.0*|\./,"").length>15&&t(p,0),l=!l),e=r(e,10,i,d.s)):"Infinity"!=e&&"NaN"!=e&&(t(p,1,i),e="NaN")):g=E.test(e),!g)returnd.c=d.e=null,"Infinity"!=e&&("NaN"!=e&&t(p,3),d.s=null),void(O=0)}for((s=e.indexOf("."))>-1&&(e=e.replace(".","")),(o=e.search(/e/i))>0?(0>s&&(s=o),s+=+e.slice(o+1),e=e.substring(0,o)):0>s&&(s=e.length),o=0;"0"==e.charAt(o);o++);if(i=e.length,l&&i>15&&e.slice(o).length>15&&t(p,0),O=0,(s-=o+1)>v)d.c=d.e=null;elseif(o==i||m>s)d.c=[d.e=0];else{for(;"0"==e.charAt(--i););for(d.e=s,d.c=[],s=0;i>=o;d.c[s++]=+e.charAt(o++));}}functiont(e,n,t,r,i,s){if(w){varo,u=["new BigNumber","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFr"][O?0>O?-O:O:0>1/O?1:0]+"()",l=f?" out of range":" not a"+(i?" non-zero":"n")+" integer";throwl=([u+" number type has more than 15 significant digits",u+" not a base "+t+" number",u+" base"+l,u+" not a number"][n]||t+"() "+n+(s?" not a boolean or binary digit":l+(r?" or not ["+(f?" negative, positive":" integer, integer")+" ]":"")))+": "+e,f=O=0,o=newError(l),o.name="BigNumber Error",o}}functionr(e,t,r,s){functiono(e,n){vari,s,o=0,u=e.length,f=[0];for(n=n||r;u>o;o++){for(s=f.length,i=0;s>i;f[i]*=n,i++);for(f[0]+=N.indexOf(e.charAt(o)),i=0;i<f.length;i++)f[i]>t-1&&(null==f[i+1]&&(f[i+1]=0),f[i+1]+=f[i]/t^0,f[i]%=t)}returnf.reverse()}functionu(e){for(varn=0,t=e.length,r="";t>n;r+=N.charAt(e[n++]));returnr}varf,l,c,h,a,g;if(37>r&&(e=e.toLowerCase()),(f=e.indexOf("."))>-1)if(f=e.length-f-1,l=o(newn(r).pow(f).toF(),10),h=e.split("."),c=o(h[1]),h=o(h[0]),g=i(c,l,c.length-l.length,s,t,1&h[h.length-1]),a=g.c,f=g.e){for(;++f;a.unshift(0));e=u(h)+"."+u(a)}elsea[0]?h[f=h.length-1]<t-1?(++h[f],e=u(h)):e=newn(u(h),t).plus(A).toS(t):e=u(h);elsee=u(o(e));returne}functioni(e,t,r,i,s,u){varf,l,c,a,g,p=t.slice(),w=f=t.length,d=e.length,b=e.slice(0,f),N=b.length,O=newn(A),E=O.c=[],S=0,R=h+(O.e=r)+1;for(O.s=i,i=0>R?0:R;N++<f;b.push(0));p.unshift(0);do{for(c=0;s>c;c++){if(f!=(N=b.length))a=f>N?1:-1;elsefor(g=-1,a=0;++g<f;)if(t[g]!=b[g]){a=t[g]>b[g]?1:-1;break}if(!(0>a))break;for(l=N==f?t:p;N;){if(b[--N]<l[N]){for(g=N;g&&!b[--g];b[g]=s-1);--b[g],b[N]+=s}b[N]-=l[N]}for(;!b[0];b.shift());}E[S++]=a?c:++c,b[0]&&a?b[N]=e[w]||0:b=[e[w]]}while((w++<d||null!=b[0])&&i--);returnE[0]||1==S||(--O.e,E.shift()),S>R&&o(O,h,s,u,null!=b[0]),O.e>v?O.c=O.e=null:O.e<m&&(O.c=[O.e=0]),O}functions(e,t,r){vari=t-(e=newn(e)).e,s=e.c;if(!s)returne.toS();for(s.length>++t&&o(e,i,10),i=0==s[0]?i+1:r?t:e.e+i+1;s.length<i;s.push(0));returni=e.e,1==r||2==r&&(--t<i||g>=i)?(e.s<0&&s[0]?"-":"")+(s.length>1?(s.splice(1,0,"."),s.join("")):s[0])+(0>i?"e":"e+")+i:e.toS()}functiono(e,n,t,r,i){vars=e.c,o=e.s<0,u=t/2,f=e.e+n+1,l=s[f],c=i||0>f||null!=s[f+1];if(i=4>a?(null!=l||c)&&(0==a||2==a&&!o||3==a&&o):l>u||l==u&&(4==a||c||6==a&&(1&s[f-1]||!n&&r)||7==a&&!o||8==a&&o),1>f||!s[0])returns.length=0,s.push(0),i?(s[0]=1,e.e=-n):e.e=0,e;if(s.length=f--,i)for(--t;++s[f]>t;)s[f]=0,f--||(++e.e,s.unshift(1));for(f=s.length;!s[--f];s.pop());returne}functionu(e,t,r){vari=a;returna=r,e=newn(e),e.c&&o(e,t,10),a=i,e}varf,l=1e9,c=1e6,h=20,a=4,g=-7,p=21,m=-l,v=l,w=!0,d=parseInt,b=n.prototype,N="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",O=0,E=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,S=String.prototype.trim||function(){returnthis.replace(/^\s+|\s+$/g,"")},A=n(1);n.ROUND_UP=0,n.ROUND_
(function(e){"use strict";vart=(require("soop").imports(),require("../sjcl")),r=require("../common/ECIES");r.symmetricEncrypt=function(r,o,c){vari=t.codec.hex.toBits(r.toString("hex")),s=t.codec.hex.toBits(o.toString("hex")),n=t.codec.hex.toBits(c.toString("hex"));t.beware["CBC mode is dangerous because it doesn't protect message integrity."]();vara={iv:s,ks:256,ts:128,iter:1e3,mode:"cbc"},d=t.encrypt(i,n,a),u=t.codec.hex.fromBits(t.codec.base64.toBits(JSON.parse(d).ct)),h=newe(u,"hex"),m=e.concat([o,h]);returnm},r.symmetricDecrypt=function(r,o){varc=t.codec.hex.toBits(r.toString("hex")),i=o.slice(0,16),s=o.slice(16,o.length),n=t.codec.base64.fromBits(t.codec.hex.toBits(i.toString("hex"))),a=t.codec.base64.fromBits(t.codec.hex.toBits(s.toString("hex")));t.beware["CBC mode is dangerous because it doesn't protect message integrity."]();vard={iv:n,v:1,iter:1e3,ks:256,ts:128,mode:"cbc",adata:"",cipher:"aes",ct:a},u=JSON.stringify(d),h=t.decrypt(c,u),m=newe(h);returnm},module.exports=require("soop")(r)}).call(this,require("buffer").Buffer);
(function(e){varr=require("../../browser/vendor-bundle.js").ECKey,t=require("../SecureRandom"),n=require("../Curve"),o=require("bignum"),s=function(){this._pub=null,this._compressed=!0},i=s.bufferToArray=function(e){for(varr=[],t=e.length,n=0;t>n;n++)r.push(e.readUInt8(n));returnr};Object.defineProperty(s.prototype,"public",{set:function(r){if(!e.isBuffer(r))thrownewError("Arg should be a buffer");vart=r[0];this._compressed=4!==t,this._pub=r},get:function(){returnthis._pub}}),Object.defineProperty(s.prototype,"compressed",{set:function(t){varn=this._compressed;if(this._compressed=!!t,n!=this._compressed){{this._pub}if(this._pub){varo=newr;o.setPub(i(this.public)),o.setCompressed(this._compressed),this._pub=newe(o.getPub())}!this._compressed}},get:function(){returnthis._compressed}}),s.generateSync=function(){for(vari;;)if(i=t.getRandomBuffer(32),o.fromBuffer(i,{size:32}).cmp(n.getN())<0)break;varu=i.toString("hex"),f=newr(u);f.setCompressed(!0);f.getPub();returnret=news,ret.private=i,ret._compressed=!0,ret.public=newe(f.getPub()),ret},s.prototype.regenerateSync=function(){if(!this.private)thrownewError("Key does not have a private key set");vart=newr(this.private.toString("hex"));returnt.setCompressed(this._compressed),this._pub=newe(t.getPub()),this},s.prototype.signSync=function(r){varn=require("../../browser/vendor-bundle.js").getSECCurveByName,o=require("../../browser/vendor-bundle.js").BigInteger,s=newt,u=n("secp256k1"),s={};s.nextBytes=function(e){varr=(t.getRandomBuffer(e.length),i(t.getRandomBuffer(e.length)));for(varninr)e[n]=r[n]};varf=function(e){returnnewo(e.bitLength(),s).mod(e.subtract(o.ONE)).add(o.ONE)},a=function(e,r){vart=r,n=u.getN(),s=o.fromByteArrayUnsigned(e);dovari=f(n),a=u.getG(),p=a.multiply(i),c=p.getX().toBigInteger().mod(n),d=i.modInverse(n).multiply(s.add(t.multiply(c))).mod(n);while(c.compareTo(o.ZERO)<=0||d.compareTo(o.ZERO)<=0);returnh(c,d)},h=function(e,r){vart=e.toByteArraySigned(),n=r.toByteArraySigned(),o=[];returno.push(2),o.push(t.length),o=o.concat(t),o.push(2),o.push(n.length),o=o.concat(n),o.unshift(o.length),o.unshift(48),o};if(!this.private)thrownewError("Key does not have a private key set");if(!e.isBuffer(r)||32!==r.length)thrownewError("Arg should be a 32 bytes hash buffer");varp=this.private.toString("hex"),c=newo(p,16),d=a(i(r),c);returnnewe(d)},s.prototype.verifySignature=function(e,r,t){try{varn=this.verifySignatureSync(e,r);t(null,n)}catch(o){t(o)}},s.prototype.verifySignatureSync=function(t,n){varo=this;if(!e.isBuffer(t)||32!==t.length)thrownewError("Arg 1 should be a 32 bytes hash buffer");if(!e.isBuffer(n))thrownewError("Arg 2 should be a buffer");if(!o.public)thrownewError("Key does not have a public key set");vars=newr;s.setPub(i(o.public)),s.setCompressed(o._compressed);varu=i(n),f=s.verify(i(t),u);returnf},module.exports=s}).call(this,require("buffer").Buffer);
(function(o){varr=(require("soop"),require("../common/SecureRandom"));r.getRandomBuffer=function(r){if(!window.crypto&&!window.msCrypto)thrownewError("window.crypto not available");if(window.crypto&&window.crypto.getRandomValues)vare=window.crypto;else{if(!window.msCrypto||!window.msCrypto.getRandomValues)thrownewError("window.crypto.getRandomValues not available");vare=window.msCrypto}varn=newUint8Array(r);e.getRandomValues(n);varw=newo(n);returnw},module.exports=require("soop")(r)}).call(this,require("buffer").Buffer);
(function(e){"use strict";varr=require("soop").imports(),t=r.coinUtil||require("../../util"),i=r.Point||require("../Point"),n=r.SecureRandom||require("../SecureRandom"),c=r.Key||require("../Key"),o=function(){};o.encryptObj=function(e,r,t,i){varc=newo;c.KB=e,c.message=r,t=c.getRandomSeed(t);vars=(c.R,c.S=c.getSfromPubkey()),u=o.kdf(s),p=c.kE=u.slice(0,32),a=c.kM=u.slice(32,64);i=i||n.getRandomBuffer(16);{varf=c.c=o.symmetricEncrypt(p,i,r);c.d=o.mac(a,f)}returnc},o.encrypt=function(r,t,i,n){vars=o.encryptObj(r,t,i,n),u=newc;u.compressed=!1,u.public=s.R.toUncompressedPubKey(),u.compressed=!0;varp=u.public,a=e.concat([p,s.c,s.d]);returna},o.decryptObj=function(e){varr=e.kB,t=e.R,n=e.c,c=e.d,s=i.multiply(t,r),u=s.x.toBuffer({size:32}),p=o.kdf(u),a=e.kE=p.slice(0,32),f=e.kM=p.slice(32,64),y=o.mac(f,n);if(c.toString("hex")!==y.toString("hex"))thrownewError("MAC check incorrect. Data is invalid.");varm=o.symmetricDecrypt(a,n);returnm},o.decrypt=function(e,r){if(r.length<97)thrownewError("invalid length of encrypted data");vart=newo;t.kB=e;varn=r.slice(0,33),s=newc;returns.public=n,s.compressed=!1,t.R=i.fromUncompressedPubKey(s.public),t.c=r.slice(33,r.length-64),t.d=r.slice(r.length-64,r.length),o.decryptObj(t)},o.kdf=function(e){varr=t.sha512(e);returnr},o.mac=function(e,r){vari=t.sha512hmac(e,r);returni},o.prototype.getRandomSeed=function(e){returne?(this.key=newc,this.key.private=e,this.key.regenerateSync()):this.key=c.generateSync(),this.r=this.key.private,this.key.compressed=!1,this.R=i.fromUncompressedPubKey(this.key.public),this.r},o.prototype.getSfromPubkey=function(){vare=newc;e.public=this.KB,e.compressed=!1;varr=i.fromUncompressedPubKey(e.public);returnthis.P=i.multiply(r,this.r),this.S=this.P.x.toBuffer({size:32}),this.S},o.prototype.getSfromPrivkey=function(){vare=this.R,r=this.kB,t=i.multiply(e,r),n=t.x.toBuffer({size:32});returnn},module.exports=require("soop")(o)}).call(this,require("buffer").Buffer);
(function(n){!function(){functiont(n){vart=!1;returnfunction(){if(t)thrownewError("Callback was already called.");t=!0,n.apply(e,arguments)}}vare,r,u={};e=this,null!=e&&(r=e.async),u.noConflict=function(){returne.async=r,u};vari=function(n,t){if(n.forEach)returnn.forEach(t);for(vare=0;e<n.length;e+=1)t(n[e],e,n)},c=function(n,t){if(n.map)returnn.map(t);vare=[];returni(n,function(n,r,u){e.push(t(n,r,u))}),e},o=function(n,t,e){returnn.reduce?n.reduce(t,e):(i(n,function(n,r,u){e=t(e,n,r,u)}),e)},a=function(n){if(Object.keys)returnObject.keys(n);vart=[];for(vareinn)n.hasOwnProperty(e)&&t.push(e);returnt};"undefined"!=typeofn&&n.nextTick?(u.nextTick=n.nextTick,u.setImmediate="undefined"!=typeofsetImmediate?function(n){setImmediate(n)}:u.nextTick):"function"==typeofsetImmediate?(u.nextTick=function(n){setImmediate(n)},u.setImmediate=u.nextTick):(u.nextTick=function(n){setTimeout(n,0)},u.setImmediate=u.nextTick),u.each=function(n,e,r){if(r=r||function(){},!n.length)returnr();varu=0;i(n,function(i){e(i,t(function(t){t?(r(t),r=function(){}):(u+=1,u>=n.length&&r(null))}))})},u.forEach=u.each,u.eachSeries=function(n,t,e){if(e=e||function(){},!n.length)returne();varr=0,u=function(){t(n[r],function(t){t?(e(t),e=function(){}):(r+=1,r>=n.length?e(null):u())})};u()},u.forEachSeries=u.eachSeries,u.eachLimit=function(n,t,e,r){varu=l(t);u.apply(null,[n,e,r])},u.forEachLimit=u.eachLimit;varl=function(n){returnfunction(t,e,r){if(r=r||function(){},!t.length||0>=n)returnr();varu=0,i=0,c=0;!functiono(){if(u>=t.length)returnr();for(;n>c&&i<t.length;)i+=1,c+=1,e(t[i-1],function(n){n?(r(n),r=function(){}):(u+=1,c-=1,u>=t.length?r():o())})}()}},f=function(n){returnfunction(){vart=Array.prototype.slice.call(arguments);returnn.apply(null,[u.each].concat(t))}},s=function(n,t){returnfunction(){vare=Array.prototype.slice.call(arguments);returnt.apply(null,[l(n)].concat(e))}},p=function(n){returnfunction(){vart=Array.prototype.slice.call(arguments);returnn.apply(null,[u.eachSeries].concat(t))}},m=function(n,t,e,r){varu=[];t=c(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e,r){u[n.index]=r,t(e)})},function(n){r(n,u)})};u.map=f(m),u.mapSeries=p(m),u.mapLimit=function(n,t,e,r){returny(t)(n,e,r)};vary=function(n){returns(n,m)};u.reduce=function(n,t,e,r){u.eachSeries(n,function(n,r){e(t,n,function(n,e){t=e,r(n)})},function(n){r(n,t)})},u.inject=u.reduce,u.foldl=u.reduce,u.reduceRight=function(n,t,e,r){vari=c(n,function(n){returnn}).reverse();u.reduce(i,t,e,r)},u.foldr=u.reduceRight;varv=function(n,t,e,r){varu=[];t=c(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e&&u.push(n),t()})},function(){r(c(u.sort(function(n,t){returnn.index-t.index}),function(n){returnn.value}))})};u.filter=f(v),u.filterSeries=p(v),u.select=u.filter,u.selectSeries=u.filterSeries;varh=function(n,t,e,r){varu=[];t=c(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e||u.push(n),t()})},function(){r(c(u.sort(function(n,t){returnn.index-t.index}),function(n){returnn.value}))})};u.reject=f(h),u.rejectSeries=p(h);vard=function(n,t,e,r){n(t,function(n,t){e(n,function(e){e?(r(n),r=function(){}):t()})},function(){r()})};u.detect=f(d),u.detectSeries=p(d),u.some=function(n,t,e){u.each(n,function(n,r){t(n,function(n){n&&(e(!0),e=function(){}),r()})},function(){e(!1)})},u.any=u.some,u.every=function(n,t,e){u.each(n,function(n,r){t(n,function(n){n||(e(!1),e=function(){}),r()})},function(){e(!0)})},u.all=u.every,u.sortBy=function(n,t,e){u.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){if(n)returne(n);varr=function(n,t){vare=n.criteria,r=t.criteria;returnr>e?-1:e>r?1:0};e(null,c(t.sort(r),function(n){returnn.value}))})},u.auto=function(n,t){t=t||function(){};vare=a(n);if(!e.length)returnt(null);varr={},c=[],l=function(n){c.unshift(n)},f=function(n){for(vart=0;t<c.length;t+=1)if(c[t]===n)returnvoidc.splice(t,1)},s=function(){i(c.slice(0),function(n){n()})};l(function(){a(r).length===e.length&&(
(function(t){functionn(t){for(varn=0,e=0;e<t.length;e++)n+=Math.pow(256,e)*t[e];returnn}functione(t){for(varn=0,e=0;e<t.length;e++)n+=Math.pow(256,t.length-e-1)*t[e];returnn}functionr(t){varn=e(t);return128==(128&t[0])&&(n-=Math.pow(256,t.length)),n}functiono(t){vare=n(t);return128==(128&t[t.length-1])&&(e-=Math.pow(256,t.length)),e}functioni(t){vari={};return[1,2,4,8].forEach(function(u){vars=8*u;i["word"+s+"le"]=i["word"+s+"lu"]=t(u,n),i["word"+s+"ls"]=t(u,o),i["word"+s+"be"]=i["word"+s+"bu"]=t(u,e),i["word"+s+"bs"]=t(u,r)}),i.word8=i.word8u=i.word8be,i.word8s=i.word8bs,i}varu=require("chainsaw"),s=require("events").EventEmitter,f=require("buffers"),c=require("./lib/vars.js"),l=require("stream").Stream;exports=module.exports=function(n,e){if(t.isBuffer(n))returnexports.parse(n);varr=exports.stream();returnn&&n.pipe?n.pipe(r):n&&(n.on(e||"data",function(t){r.write(t)}),n.on("end",function(){r.end()})),r},exports.stream=function(n){functione(t,n,e){a={bytes:t,skip:e,cb:function(t){a=null,n(t)}},r()}functionr(){if(!a)returnvoid(b&&(w=!0));if("function"==typeofa)a();else{vart=p+a.bytes;if(g.length>=t){varn;null==p?(n=g.splice(0,t),a.skip||(n=n.slice())):(a.skip||(n=g.slice(p,t)),p=t),a.skip?a.cb():a.cb(n)}}}functiono(n){functiono(){w||n.next()}varu=i(function(t,n){returnfunction(r){e(t,function(t){v.set(r,n(t)),o()})}});returnu.tap=function(t){n.nest(t,v.store)},u.into=function(t,e){v.get(t)||v.set(t,{});varr=v;v=c(r.get(t)),n.nest(function(){e.apply(this,arguments),this.tap(function(){v=r})},v.store)},u.flush=function(){v.store={},o()},u.loop=function(t){vare=!1;n.nest(!1,functionr(){this.vars=v.store,t.call(this,function(){e=!0,o()},v.store),this.tap(function(){e?n.next():r.call(this)}.bind(this))},v.store)},u.buffer=function(t,n){"string"==typeofn&&(n=v.get(n)),e(n,function(n){v.set(t,n),o()})},u.skip=function(t){"string"==typeoft&&(t=v.get(t)),e(t,function(){o()})},u.scan=function(n,e){if("string"==typeofe)e=newt(e);elseif(!t.isBuffer(e))thrownewError("search must be a Buffer or a string");vari=0;a=function(){vart=g.indexOf(e,p+i),u=t-p-i;-1!==t?(a=null,null!=p?(v.set(n,g.slice(p,p+i+u)),p+=i+u+e.length):(v.set(n,g.slice(0,i+u)),g.splice(0,i+u+e.length)),o(),r()):u=Math.max(g.length-e.length-p-i,0),i+=u},r()},u.peek=function(t){p=0,n.nest(function(){t.call(this,v.store),this.tap(function(){p=null})})},u}if(n)returnexports.apply(null,arguments);vara=null,p=null,h=u.light(o);h.writable=!0;varg=f();h.write=function(t){g.push(t),r()};varv=c(),w=!1,b=!1;returnh.end=function(){b=!0},h.pipe=l.prototype.pipe,Object.getOwnPropertyNames(s.prototype).forEach(function(t){h[t]=s.prototype[t]}),h},exports.parse=function(n){vare=i(function(t,i){returnfunction(u){if(r+t<=n.length){vars=n.slice(r,r+t);r+=t,o.set(u,i(s))}elseo.set(u,null);returne}}),r=0,o=c();returne.vars=o.store,e.tap=function(t){returnt.call(e,o.store),e},e.into=function(t,n){o.get(t)||o.set(t,{});varr=o;returno=c(r.get(t)),n.call(e,o.store),o=r,e},e.loop=function(t){for(varn=!1,r=function(){n=!0};n===!1;)t.call(e,r,o.store);returne},e.buffer=function(t,i){"string"==typeofi&&(i=o.get(i));varu=n.slice(r,Math.min(n.length,r+i));returnr+=i,o.set(t,u),e},e.skip=function(t){return"string"==typeoft&&(t=o.get(t)),r+=t,e},e.scan=function(i,u){if("string"==typeofu)u=newt(u);elseif(!t.isBuffer(u))thrownewError("search must be a Buffer or a string");o.set(i,null);for(vars=0;s+r<=n.length-u.length+1;s++){for(varf=0;f<u.length&&n[r+s+f]===u[f];f++);if(f===u.length)break}returno.set(i,n.slice(r,r+s)),r+=s+u.length,e},e.peek=function(t){varn=r;returnt.call(e,o.store),r=n,e},e.flush=function(){returno.store={},e},e.eof=function(){returnr>=n.length},e}}).call(this,require("buffer").Buffer);
(function(n){functiont(n){vare=t.saw(n,{}),r=n.call(e.handlers,e);returnvoid0!==r&&(e.handlers=r),e.record(),e.chain()}functione(n){n.step=0,n.pop=function(){returnn.actions[n.step++]},n.trap=function(t,e){varr=Array.isArray(t)?t:[t];n.actions.push({path:r,step:n.step,cb:e,trap:!0})},n.down=function(t){vare=(Array.isArray(t)?t:[t]).join("/"),r=n.actions.slice(n.step).map(function(t){returnt.trap&&t.step<=n.step?!1:t.path.join("/")==e}).indexOf(!0);r>=0?n.step+=r:n.step=n.actions.length;vara=n.actions[n.step-1];a&&a.trap?(n.step=a.step,a.cb()):n.next()},n.jump=function(t){n.step=t,n.next()}}varr=require("traverse"),a=require("events").EventEmitter;module.exports=t,t.light=function(n){vare=t.saw(n,{}),r=n.call(e.handlers,e);returnvoid0!==r&&(e.handlers=r),e.chain()},t.saw=function(s,o){vari=newa;returni.handlers=o,i.actions=[],i.chain=function(){vart=r(i.handlers).map(function(n){if(this.isRoot)returnn;vare=this.path;"function"==typeofn&&this.update(function(){returni.actions.push({path:e,args:[].slice.call(arguments)}),t})});returnn.nextTick(function(){i.emit("begin"),i.next()}),t},i.pop=function(){returni.actions.shift()},i.next=function(){varn=i.pop();if(n){if(!n.trap){vart=i.handlers;n.path.forEach(function(n){t=t[n]}),t.apply(i.handlers,n.args)}}elsei.emit("end")},i.nest=function(n){vare=[].slice.call(arguments,1),r=!0;if("boolean"==typeofn){varr=n;n=e.shift()}vara=t.saw(s,{}),o=s.call(a.handlers,a);void0!==o&&(a.handlers=o),"undefined"!=typeofi.step&&a.record(),n.apply(a.chain(),e),r!==!1&&a.on("end",i.next)},i.record=function(){e(i)},["trap","down","jump"].forEach(function(n){i[n]=function(){thrownewError("To use the trap, down and jump features, please call record() first to start recording actions.")}}),i}}).call(this,require("/Users/ryanxcharles/dev/bitcore/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"));
functionTraverse(e){returnthisinstanceofTraverse?void(this.value=e):newTraverse(e)}functionwalk(e,t,r){varn=[],o=[],a=!0;returnfunctioni(e){varc=r?copy(e):e,s={},f={node:c,node_:e,path:[].concat(n),parent:o.slice(-1)[0],key:n.slice(-1)[0],isRoot:0===n.length,level:n.length,circular:null,update:function(e){f.isRoot||(f.parent.node[f.key]=e),f.node=e},"delete":function(){deletef.parent.node[f.key]},remove:function(){Array.isArray(f.parent.node)?f.parent.node.splice(f.key,1):deletef.parent.node[f.key]},before:function(e){s.before=e},after:function(e){s.after=e},pre:function(e){s.pre=e},post:function(e){s.post=e},stop:function(){a=!1}};if(!a)returnf;if("object"==typeofc&&null!==c){f.isLeaf=0==Object.keys(c).length;for(varu=0;u<o.length;u++)if(o[u].node_===e){f.circular=o[u];break}}elsef.isLeaf=!0;f.notLeaf=!f.isLeaf,f.notRoot=!f.isRoot;varl=t.call(f,f.node);if(void0!==l&&f.update&&f.update(l),s.before&&s.before.call(f,f.node),"object"==typeoff.node&&null!==f.node&&!f.circular){o.push(f);varp=Object.keys(f.node);p.forEach(function(e,t){n.push(e),s.pre&&s.pre.call(f,f.node[e],e);varo=i(f.node[e]);r&&Object.hasOwnProperty.call(f.node,e)&&(f.node[e]=o.node),o.isLast=t==p.length-1,o.isFirst=0==t,s.post&&s.post.call(f,o),n.pop()}),o.pop()}returns.after&&s.after.call(f,f.node),f}(e).node}functioncopy(e){if("object"==typeofe&&null!==e){vart;returnt=Array.isArray(e)?[]:einstanceofDate?newDate(e):einstanceofBoolean?newBoolean(e):einstanceofNumber?newNumber(e):einstanceofString?newString(e):Object.create(Object.getPrototypeOf(e)),Object.keys(e).forEach(function(r){t[r]=e[r]}),t}returne}module.exports=Traverse,Traverse.prototype.get=function(e){for(vart=this.value,r=0;r<e.length;r++){varn=e[r];if(!Object.hasOwnProperty.call(t,n)){t=void0;break}t=t[n]}returnt},Traverse.prototype.set=function(e,t){for(varr=this.value,n=0;n<e.length-1;n++){varo=e[n];Object.hasOwnProperty.call(r,o)||(r[o]={}),r=r[o]}returnr[e[n]]=t,t},Traverse.prototype.map=function(e){returnwalk(this.value,e,!0)},Traverse.prototype.forEach=function(e){returnthis.value=walk(this.value,e,!1),this.value},Traverse.prototype.reduce=function(e,t){varr=1===arguments.length,n=r?this.value:t;returnthis.forEach(function(t){this.isRoot&&r||(n=e.call(this,n,t))}),n},Traverse.prototype.deepEqual=function(e){if(1!==arguments.length)thrownewError("deepEqual requires exactly one object to compare against");vart=!0,r=e;returnthis.forEach(function(n){varo=function(){returnvoid(t=!1)}.bind(this);if(!this.isRoot){if("object"!=typeofr)returno();r=r[this.key]}vara=r;this.post(function(){r=a});vari=function(e){returnObject.prototype.toString.call(e)};if(this.circular)Traverse(e).get(this.circular.path)!==a&&o();elseif(typeofa!=typeofn)o();elseif(null===a||null===n||void0===a||void0===n)a!==n&&o();elseif(a.__proto__!==n.__proto__)o();elseif(a===n);elseif("function"==typeofa)ainstanceofRegExp?a.toString()!=n.toString()&&o():a!==n&&o();elseif("object"==typeofa)if("[object Arguments]"===i(n)||"[object Arguments]"===i(a))i(a)!==i(n)&&o();elseif(ainstanceofDate||ninstanceofDate)ainstanceofDate&&ninstanceofDate&&a.getTime()===n.getTime()||o();else{varc=Object.keys(a),s=Object.keys(n);if(c.length!==s.length)returno();for(varf=0;f<c.length;f++){varu=c[f];Object.hasOwnProperty.call(n,u)||o()}}}),t},Traverse.prototype.paths=function(){vare=[];returnthis.forEach(function(){e.push(this.path)}),e},Traverse.prototype.nodes=function(){vare=[];returnthis.forEach(function(){e.push(this.node)}),e},Traverse.prototype.clone=function(){vare=[],t=[];returnfunctionr(n){for(varo=0;o<e.length;o++)if(e[o]===n)returnt[o];if("object"==typeofn&&null!==n){vara=copy(n);returne.push(n),t.push(a),Object.keys(n).forEach(function(e){a[e]=r(n[e])}),e.pop(),t.pop(),a}returnn}(this.value)},Object.keys(Traverse.prototype).forEach(function(e){Traverse[e]=function(t){varr=[].slice.call(arguments,1),n=Traverse(t);returnn[e].apply(n,r)}});
(function(e,r){functiono(e){"string"==typeofe?e={bindings:e}:e||(e={}),e.__proto__=d,e.module_root||(e.module_root=exports.getRoot(exports.getFileName())),".node"!=i.extname(e.bindings)&&(e.bindings+=".node");for(varr,o,n,s=[],a=0,l=e.try.length;l>a;a++){r=t.apply(null,e.try[a].map(function(r){returne[r]||r})),s.push(r);try{returno=e.path?require.resolve(r):require(r),e.path||(o.path=r),o}catch(u){if(!/not find/i.test(u.message))throwu}}thrown=newError("Could not locate the bindings file. Tried:\n"+s.map(function(r){returne.arrow+r}).join("\n")),n.tries=s,n}varn=require("fs"),i=require("path"),t=i.join,s=i.dirname,a=n.existsSync||i.existsSync,d={arrow:e.env.NODE_BINDINGS_ARROW||" → ",compiled:e.env.NODE_BINDINGS_COMPILED_DIR||"compiled",platform:e.platform,arch:e.arch,version:e.versions.node,bindings:"bindings.node","try":[["module_root","build","bindings"],["module_root","build","Debug","bindings"],["module_root","build","Release","bindings"],["module_root","out","Debug","bindings"],["module_root","Debug","bindings"],["module_root","out","Release","bindings"],["module_root","Release","bindings"],["module_root","build","default","bindings"],["module_root","compiled","version","platform","arch","bindings"]]};module.exports=exports=o,exports.getFileName=function(){vare,o=Error.prepareStackTrace,n=Error.stackTraceLimit,i={};returnError.stackTraceLimit=10,Error.prepareStackTrace=function(o,n){for(vari=0,t=n.length;t>i;i++)if(e=n[i].getFileName(),e!==r)return},Error.captureStackTrace(i),i.stack,Error.prepareStackTrace=o,Error.stackTraceLimit=n,e},exports.getRoot=function(r){for(varo,n=s(r);;){if("."===n&&(n=e.cwd()),a(t(n,"package.json"))||a(t(n,"node_modules")))returnn;if(o===n)thrownewError('Could not find module root given file: "'+r+'". Do you have a `package.json` file? ');o=n,n=t(n,"..")}}}).call(this,require("/Users/ryanxcharles/dev/bitcore/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"),"/node_modules/bindings/bindings.js");
(function(t){"use strict";functionr(){this.writable=!0,this.buffer=null}vare=require("events"),n=require("util"),i={};module.exports.Buffer=t;varo=function(r){returnrinstanceoft||rinstanceofUint8Array},f=function(t){returnfunction(){varr=this;if(o(r));else{if(!o(arguments[0]))thrownewError("Argument should be a buffer object.");r=arguments[0],Array.prototype.shift.apply(arguments)}returnt.apply(r,arguments)}},u=function(t){returnfunction(){varr=this;if(o(r));else{if(!o(arguments[0]))throwError("Argument should be a buffer object.");r=arguments[0],Array.prototype.shift.apply(arguments)}vare=arguments[0];if("string"==typeofe||einstanceofString||o(e))returnt.apply(r,arguments);thrownewError("Second argument must be a string or a buffer.")}};i.clear=f(function(){for(vart=0;t<this.length;t++)this[t]=0;returnthis}),i.fill=f(function(t){for(varr="undefined"==typeoft.length?1:t.length,e=0;e<this.length;e+=r)for(varn=0;r>n;n++)this[e+n]="undefined"==typeoft.length?t:"string"==typeoft[n]?t[n].charCodeAt(0):t[n];returnthis}),i.indexOf=f(function(t,r){if(r=r||0,0===t.length)return-1;for(vare=r;e<this.length-t.length+1;e+=1){for(varn=!0,i=0;i<t.length;i++){varo=this[e+i],f=t[i];if("string"==typeoff&&(f=f.charCodeAt(0)),o!==f){n=!1;break}}if(n)returne}return-1}),i.equals=u(function(t){return0===i.compare(this,t)}),i.compare=u(function(t){varr=this,e=r.length,n=t.length;if(e!==n)returne>n?1:-1;for(vari=0;e>i;i++){varo=r[i],f=t[i];if("string"==typeoff&&(f=f.charCodeAt(0)),o!==f)returno>f?1:-1}return0}),i.concat=function(){for(varr=0,e=0;e<arguments.length;e++){if(void0===arguments[e].length)throwError("all arguments must be strings or Buffers");r+=arguments[e].length}for(varn=newt(r),i=0,e=0;e<arguments.length;e++)for(varo=0;o<arguments[e].length;o++)n[i++]="string"==typeofarguments[e][o]?arguments[e][o].charCodeAt(0):arguments[e][o];returnn},i.reverse=f(function(){for(varr=newt(this.length),e=0;e<this.length;e++)r[e]=this[this.length-e-1];returnr}),i.toHex=f(function(){for(vart="",r=0;r<this.length;r++){vare=this[r].toString(16);1==e.length&&(e="0"+e),e.length>2&&(e=e.substring(1,3)),t+=e}returnt}),i.fromHex=f(function(){varr=this.length;if(r%2!==0)thrownewError("Invalid hex string length");for(vare=newt(r/2),n=0;n<e.length;n++){vari=String.fromCharCode(this[2*n]),o=String.fromCharCode(this[2*n+1]);e[n]=parseInt(i+o,16)}returne}),exports.extend=function(){varr;r=arguments.length>0?Array.prototype.slice.call(arguments):"function"==typeofUint8Array?[t.prototype,Uint8Array.prototype]:[t.prototype];for(vare=0,n=r.length;n>e;e+=1){varo=r[e];for(varfini)o[f]=i[f];o!==exports&&(o.concat=function(){vart=[this].concat(Array.prototype.slice.call(arguments));returni.concat.apply(i,t)})}},exports.extend(exports),n.inherits(r,e.EventEmitter),r.prototype._append=function(r,e){if(!this.writable)thrownewError("Stream is not writable.");if(t.isBuffer(r));else{if("string"!=typeofr)thrownewError("Argument should be either a buffer or a string.");r=newt(r,e||"utf8")}this.buffer?this.buffer=i.concat(this.buffer,r):(this.buffer=newt(r.length),r.copy(this.buffer))},r.prototype.write=function(t,r){returnthis._append(t,r),!0},r.prototype.end=function(t,r){t&&this._append(t,r),this.emit("close"),this.writable=!1},r.prototype.getBuffer=function(){returnthis.buffer?this.buffer:newt(0)},r.prototype.toString=function(){returnthis.getBuffer().toString()},exports.WritableBufferStream=r}).call(this,require("buffer").Buffer);
functionBuffer(e,t,r){if(!(thisinstanceofBuffer))returnnewBuffer(e,t,r);varn=typeofe;if("base64"===t&&"string"===n)for(e=stringtrim(e);e.length%4!==0;)e+="=";vari;if("number"===n)i=coerce(e);elseif("string"===n)i=Buffer.byteLength(e,t);else{if("object"!==n)thrownewError("First argument needs to be a number, array or string.");i=coerce(e.length)}vars;Buffer._useTypedArrays?s=Buffer._augment(newUint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);vara;if(Buffer._useTypedArrays&&"number"==typeofe.byteLength)s._set(e);elseif(isArrayish(e))for(a=0;i>a;a++)s[a]=Buffer.isBuffer(e)?e.readUInt8(a):e[a];elseif("string"===n)s.write(e,0,t);elseif("number"===n&&!Buffer._useTypedArrays&&!r)for(a=0;i>a;a++)s[a]=0;returns}function_hexWrite(e,t,r,n){r=Number(r)||0;vari=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;vars=t.length;assert(s%2===0,"Invalid hex string"),n>s/2&&(n=s/2);for(vara=0;n>a;a++){varo=parseInt(t.substr(2*a,2),16);assert(!isNaN(o),"Invalid hex string"),e[r+a]=o}returnBuffer._charsWritten=2*a,a}function_utf8Write(e,t,r,n){vari=Buffer._charsWritten=blitBuffer(utf8ToBytes(t),e,r,n);returni}function_asciiWrite(e,t,r,n){vari=Buffer._charsWritten=blitBuffer(asciiToBytes(t),e,r,n);returni}function_binaryWrite(e,t,r,n){return_asciiWrite(e,t,r,n)}function_base64Write(e,t,r,n){vari=Buffer._charsWritten=blitBuffer(base64ToBytes(t),e,r,n);returni}function_utf16leWrite(e,t,r,n){vari=Buffer._charsWritten=blitBuffer(utf16leToBytes(t),e,r,n);returni}function_base64Slice(e,t,r){returnbase64.fromByteArray(0===t&&r===e.length?e:e.slice(t,r))}function_utf8Slice(e,t,r){varn="",i="";r=Math.min(e.length,r);for(vars=t;r>s;s++)e[s]<=127?(n+=decodeUtf8Char(i)+String.fromCharCode(e[s]),i=""):i+="%"+e[s].toString(16);returnn+decodeUtf8Char(i)}function_asciiSlice(e,t,r){varn="";r=Math.min(e.length,r);for(vari=t;r>i;i++)n+=String.fromCharCode(e[i]);returnn}function_binarySlice(e,t,r){return_asciiSlice(e,t,r)}function_hexSlice(e,t,r){varn=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>n)&&(r=n);for(vari="",s=t;r>s;s++)i+=toHex(e[s]);returni}function_utf16leSlice(e,t,r){for(varn=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);returni}function_readUInt16(e,t,r,n){n||(assert("boolean"==typeofr,"missing or invalid endian"),assert(void0!==t&&null!==t,"missing offset"),assert(t+1<e.length,"Trying to read beyond buffer length"));vari=e.length;if(!(t>=i)){vars;returnr?(s=e[t],i>t+1&&(s|=e[t+1]<<8)):(s=e[t]<<8,i>t+1&&(s|=e[t+1])),s}}function_readUInt32(e,t,r,n){n||(assert("boolean"==typeofr,"missing or invalid endian"),assert(void0!==t&&null!==t,"missing offset"),assert(t+3<e.length,"Trying to read beyond buffer length"));vari=e.length;if(!(t>=i)){vars;returnr?(i>t+2&&(s=e[t+2]<<16),i>t+1&&(s|=e[t+1]<<8),s|=e[t],i>t+3&&(s+=e[t+3]<<24>>>0)):(i>t+1&&(s=e[t+1]<<16),i>t+2&&(s|=e[t+2]<<8),i>t+3&&(s|=e[t+3]),s+=e[t]<<24>>>0),s}}function_readInt16(e,t,r,n){n||(assert("boolean"==typeofr,"missing or invalid endian"),assert(void0!==t&&null!==t,"missing offset"),assert(t+1<e.length,"Trying to read beyond buffer length"));vari=e.length;if(!(t>=i)){vars=_readUInt16(e,t,r,!0),a=32768&s;returna?-1*(65535-s+1):s}}function_readInt32(e,t,r,n){n||(assert("boolean"==typeofr,"missing or invalid endian"),assert(void0!==t&&null!==t,"missing offset"),assert(t+3<e.length,"Trying to read beyond buffer length"));vari=e.length;if(!(t>=i)){vars=_readUInt32(e,t,r,!0),a=2147483648&s;returna?-1*(4294967295-s+1):s}}function_readFloat(e,t,r,n){returnn||(assert("boolean"==typeofr,"missing or invalid endian"),assert(t+3<e.length,"Trying to read beyond buffer length")),ieee754.read(e,t,r,23,4)}function_readDouble(e,t,r,n){returnn||(assert("boolean"==typeofr,"missing or invalid endian"),assert(t+7<e.length,"Trying to read beyond buffer length")),ieee754.read(e,t,r,52,8)}function_writeUInt16(e,t,r,n,i){i||(assert(void0!==t&&null!==t,"missing value"),assert("boolean"==typeofn,"missing or invalid endian"),assert(void0!==r&&null!==r,"missing offset"),assert(r+1<e.length,"tryingtowritebeyondb
varlookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(t){"use strict";functionr(t){varr=t.charCodeAt(0);returnr===h?62:r===c?63:o>r?-1:o+10>r?r-o+26+26:i+26>r?r-i:A+26>r?r-A+26:void0}functione(t){functione(t){i[f++]=t}varn,h,c,o,A,i;if(t.length%4>0)thrownewError("Invalid string. Length must be a multiple of 4");varu=t.length;A="="===t.charAt(u-2)?2:"="===t.charAt(u-1)?1:0,i=newa(3*t.length/4-A),c=A>0?t.length-4:t.length;varf=0;for(n=0,h=0;c>n;n+=4,h+=3)o=r(t.charAt(n))<<18|r(t.charAt(n+1))<<12|r(t.charAt(n+2))<<6|r(t.charAt(n+3)),e((16711680&o)>>16),e((65280&o)>>8),e(255&o);return2===A?(o=r(t.charAt(n))<<2|r(t.charAt(n+1))>>4,e(255&o)):1===A&&(o=r(t.charAt(n))<<10|r(t.charAt(n+1))<<4|r(t.charAt(n+2))>>2,e(o>>8&255),e(255&o)),i}functionn(t){functionr(t){returnlookup.charAt(t)}functione(t){returnr(t>>18&63)+r(t>>12&63)+r(t>>6&63)+r(63&t)}varn,a,h,c=t.length%3,o="";for(n=0,h=t.length-c;h>n;n+=3)a=(t[n]<<16)+(t[n+1]<<8)+t[n+2],o+=e(a);switch(c){case1:a=t[t.length-1],o+=r(a>>2),o+=r(a<<4&63),o+="==";break;case2:a=(t[t.length-2]<<8)+t[t.length-1],o+=r(a>>10),o+=r(a>>4&63),o+=r(a<<2&63),o+="="}returno}vara="undefined"!=typeofUint8Array?Uint8Array:Array,h="+".charCodeAt(0),c="/".charCodeAt(0),o="0".charCodeAt(0),A="a".charCodeAt(0),i="A".charCodeAt(0);t.toByteArray=e,t.fromByteArray=n}("undefined"==typeofexports?this.base64js={}:exports);
functionEventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void0}functionisFunction(e){return"function"==typeofe}functionisNumber(e){return"number"==typeofe}functionisObject(e){return"object"==typeofe&&null!==e}functionisUndefined(e){returnvoid0===e}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void0,EventEmitter.prototype._maxListeners=void0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(e){if(!isNumber(e)||0>e||isNaN(e))throwTypeError("n must be a positive number");returnthis._maxListeners=e,this},EventEmitter.prototype.emit=function(e){vart,n,s,i,r,o;if(this._events||(this._events={}),"error"===e&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length))throwt=arguments[1],tinstanceofError?t:TypeError('Uncaught, unspecified "error" event.');if(n=this._events[e],isUndefined(n))return!1;if(isFunction(n))switch(arguments.length){case1:n.call(this);break;case2:n.call(this,arguments[1]);break;case3:n.call(this,arguments[1],arguments[2]);break;default:for(s=arguments.length,i=newArray(s-1),r=1;s>r;r++)i[r-1]=arguments[r];n.apply(this,i)}elseif(isObject(n)){for(s=arguments.length,i=newArray(s-1),r=1;s>r;r++)i[r-1]=arguments[r];for(o=n.slice(),s=o.length,r=0;s>r;r++)o[r].apply(this,i)}return!0},EventEmitter.prototype.addListener=function(e,t){varn;if(!isFunction(t))throwTypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,isFunction(t.listener)?t.listener:t),this._events[e]?isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,isObject(this._events[e])&&!this._events[e].warned){varn;n=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeofconsole.trace&&console.trace())}returnthis},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){functionn(){this.removeListener(e,n),s||(s=!0,t.apply(this,arguments))}if(!isFunction(t))throwTypeError("listener must be a function");vars=!1;returnn.listener=t,this.on(e,n),this},EventEmitter.prototype.removeListener=function(e,t){varn,s,i,r;if(!isFunction(t))throwTypeError("listener must be a function");if(!this._events||!this._events[e])returnthis;if(n=this._events[e],i=n.length,s=-1,n===t||isFunction(n.listener)&&n.listener===t)deletethis._events[e],this._events.removeListener&&this.emit("removeListener",e,t);elseif(isObject(n)){for(r=i;r-->0;)if(n[r]===t||n[r].listener&&n[r].listener===t){s=r;break}if(0>s)returnthis;1===n.length?(n.length=0,deletethis._events[e]):n.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}returnthis},EventEmitter.prototype.removeAllListeners=function(e){vart,n;if(!this._events)returnthis;if(!this._events.removeListener)return0===arguments.length?this._events={}:this._events[e]&&deletethis._events[e],this;if(0===arguments.length){for(tinthis._events)"removeListener"!==t&&this.removeAllListeners(t);returnthis.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],isFunction(n))this.removeListener(e,n);elsefor(;n.length;)this.removeListener(e,n[n.length-1]);returndeletethis._events[e],this},EventEmitter.prototype.listeners=function(e){vart;returnt=this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.listenerCount=function(e,t){varn;returnn=e._events&&e._events[t]?isFunction(e._events[t])?1:e._events[t].length:0};
varhttp=module.exports,EventEmitter=require("events").EventEmitter,Request=require("./lib/request"),url=require("url");http.request=function(e,t){"string"==typeofe&&(e=url.parse(e)),e||(e={}),e.host||e.port||(e.port=parseInt(window.location.port,10)),!e.host&&e.hostname&&(e.host=e.hostname),e.scheme||(e.scheme=window.location.protocol.split(":")[0]),e.host||(e.host=window.location.hostname||window.location.host),/:/.test(e.host)&&(e.port||(e.port=e.host.split(":")[1]),e.host=e.host.split(":")[0]),e.port||(e.port="https"==e.scheme?443:80);varo=newRequest(newxhrHttp,e);returnt&&o.on("response",t),o},http.get=function(e,t){e.method="GET";varo=http.request(e,t);returno.end(),o},http.Agent=function(){},http.Agent.defaultMaxSockets=4;varxhrHttp=function(){if("undefined"==typeofwindow)thrownewError("no window object present");if(window.XMLHttpRequest)returnwindow.XMLHttpRequest;if(window.ActiveXObject){for(vare=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"],t=0;t<e.length;t++)try{varo=newwindow.ActiveXObject(e[t]);returnfunction(){if(o){varr=o;returno=null,r}returnnewwindow.ActiveXObject(e[t])}}catch(r){}thrownewError("ajax not supported in this browser")}thrownewError("ajax not supported in this browser")}();http.STATUS_CODES={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};
!function(){functiont(t){this.message=t}vare="undefined"!=typeofexports?exports:this,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.prototype=newError,t.prototype.name="InvalidCharacterError",e.btoa||(e.btoa=function(e){for(varo,n,a=0,i=r,c="";e.charAt(0|a)||(i="=",a%1);c+=i.charAt(63&o>>8-a%1*8)){if(n=e.charCodeAt(a+=.75),n>255)thrownewt("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|n}returnc}),e.atob||(e.atob=function(e){if(e=e.replace(/=+$/,""),e.length%4==1)thrownewt("'atob' failed: The string to be decoded is not correctly encoded.");for(varo,n,a=0,i=0,c="";n=e.charAt(i++);~n&&(o=a%4?64*o+n:n,a++%4)?c+=String.fromCharCode(255&o>>(-2*a&6)):0)n=r.indexOf(n);returnc})}();
functionnoop(){}varprocess=module.exports={};process.nextTick=function(){varo="undefined"!=typeofwindow&&window.setImmediate,e="undefined"!=typeofwindow&&window.postMessage&&window.addEventListener;if(o)returnfunction(o){returnwindow.setImmediate(o)};if(e){varn=[];returnwindow.addEventListener("message",function(o){vare=o.source;if((e===window||null===e)&&"process-tick"===o.data&&(o.stopPropagation(),n.length>0)){vars=n.shift();s()}},!0),function(o){n.push(o),window.postMessage("process-tick","*")}}returnfunction(o){setTimeout(o,0)}}(),process.title="browser",process.browser=!0,process.env={},process.argv=[],process.on=noop,process.once=noop,process.off=noop,process.emit=noop,process.binding=function(){thrownewError("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(){thrownewError("process.chdir is not supported")};
(function(r){functiont(r,t){for(vare=0,n=r.length-1;n>=0;n--){vars=r[n];"."===s?r.splice(n,1):".."===s?(r.splice(n,1),e++):e&&(r.splice(n,1),e--)}if(t)for(;e--;e)r.unshift("..");returnr}functione(r,t){if(r.filter)returnr.filter(t);for(vare=[],n=0;n<r.length;n++)t(r[n],n,r)&&e.push(r[n]);returne}varn=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,s=function(r){returnn.exec(r).slice(1)};exports.resolve=function(){for(varn="",s=!1,o=arguments.length-1;o>=-1&&!s;o--){vari=o>=0?arguments[o]:r.cwd();if("string"!=typeofi)thrownewTypeError("Arguments to path.resolve must be strings");i&&(n=i+"/"+n,s="/"===i.charAt(0))}returnn=t(e(n.split("/"),function(r){return!!r}),!s).join("/"),(s?"/":"")+n||"."},exports.normalize=function(r){varn=exports.isAbsolute(r),s="/"===o(r,-1);returnr=t(e(r.split("/"),function(r){return!!r}),!n).join("/"),r||n||(r="."),r&&s&&(r+="/"),(n?"/":"")+r},exports.isAbsolute=function(r){return"/"===r.charAt(0)},exports.join=function(){varr=Array.prototype.slice.call(arguments,0);returnexports.normalize(e(r,function(r){if("string"!=typeofr)thrownewTypeError("Arguments to path.join must be strings");returnr}).join("/"))},exports.relative=function(r,t){functione(r){for(vart=0;t<r.length&&""===r[t];t++);for(vare=r.length-1;e>=0&&""===r[e];e--);returnt>e?[]:r.slice(t,e-t+1)}r=exports.resolve(r).substr(1),t=exports.resolve(t).substr(1);for(varn=e(r.split("/")),s=e(t.split("/")),o=Math.min(n.length,s.length),i=o,u=0;o>u;u++)if(n[u]!==s[u]){i=u;break}for(varl=[],u=i;u<n.length;u++)l.push("..");returnl=l.concat(s.slice(i)),l.join("/")},exports.sep="/",exports.delimiter=":",exports.dirname=function(r){vart=s(r),e=t[0],n=t[1];returne||n?(n&&(n=n.substr(0,n.length-1)),e+n):"."},exports.basename=function(r,t){vare=s(r)[2];returnt&&e.substr(-1*t.length)===t&&(e=e.substr(0,e.length-t.length)),e},exports.extname=function(r){returns(r)[3]};varo="b"==="ab".substr(-1)?function(r,t,e){returnr.substr(t,e)}:function(r,t,e){return0>t&&(t=r.length+t),r.substr(t,e)}}).call(this,require("/Users/ryanxcharles/dev/bitcore/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"));
varprocess=module.exports={};process.nextTick=function(){vare="undefined"!=typeofwindow&&window.setImmediate,n="undefined"!=typeofwindow&&window.postMessage&&window.addEventListener;if(e)returnfunction(e){returnwindow.setImmediate(e)};if(n){varo=[];returnwindow.addEventListener("message",function(e){varn=e.source;if((n===window||null===n)&&"process-tick"===e.data&&(e.stopPropagation(),o.length>0)){varr=o.shift();r()}},!0),function(e){o.push(e),window.postMessage("process-tick","*")}}returnfunction(e){setTimeout(e,0)}}(),process.title="browser",process.browser=!0,process.env={},process.argv=[],process.binding=function(){thrownewError("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(){thrownewError("process.chdir is not supported")};
(function(e){functiont(e){e=e||{};vart=e.highWaterMark;this.highWaterMark=t||0===t?t:16384,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=!1,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.calledRead=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!e.objectMode,this.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(_||(_=require("string_decoder").StringDecoder),this.decoder=new_(e.encoding),this.encoding=e.encoding)}functionn(e){returnthisinstanceofn?(this._readableState=newt(e,this),this.readable=!0,voidS.call(this)):newn(e)}functionr(e,t,n,r,a){varo=d(t,n);if(o)e.emit("error",o);elseif(null===n||void0===n)t.reading=!1,t.ended||s(e,t);elseif(t.objectMode||n&&n.length>0)if(t.ended&&!a){varu=newError("stream.push() after EOF");e.emit("error",u)}elseif(t.endEmitted&&a){varu=newError("stream.unshift() after end event");e.emit("error",u)}else!t.decoder||a||r||(n=t.decoder.write(n)),t.length+=t.objectMode?1:n.length,a?t.buffer.unshift(n):(t.reading=!1,t.buffer.push(n)),t.needReadable&&l(e),h(e,t);elsea||(t.reading=!1);returni(t)}functioni(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}functiona(e){if(e>=L)e=L;else{e--;for(vart=1;32>t;t<<=1)e|=e>>t;e++}returne}functiono(e,t){return0===t.length&&t.ended?0:t.objectMode?0===e?0:1:isNaN(e)||null===e?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}functiond(e,t){varn=null;returnR.isBuffer(t)||"string"==typeoft||null===t||void0===t||e.objectMode||n||(n=newTypeError("Invalid non-string/buffer chunk")),n}functions(e,t){if(t.decoder&&!t.ended){varn=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.length>0?l(e):v(e)}functionl(e){vart=e._readableState;t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,t.sync?E(function(){u(e)}):u(e))}functionu(e){e.emit("readable")}functionh(e,t){t.readingMore||(t.readingMore=!0,E(function(){f(e,t)}))}functionf(e,t){for(varn=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}functionp(e){returnfunction(){vart=e._readableState;t.awaitDrain--,0===t.awaitDrain&&c(e)}}functionc(e){functiont(e){vart=e.write(n);!1===t&&r.awaitDrain++}varn,r=e._readableState;for(r.awaitDrain=0;r.pipesCount&&null!==(n=e.read());)if(1===r.pipesCount?t(r.pipes,0,null):w(r.pipes,t),e.emit("data",n),r.awaitDrain>0)return;return0===r.pipesCount?(r.flowing=!1,void(M.listenerCount(e,"data")>0&&b(e))):void(r.ranOut=!0)}functiong(){this._readableState.ranOut&&(this._readableState.ranOut=!1,c(this))}functionb(e,t){varn=e._readableState;if(n.flowing)thrownewError("Cannot switch to old mode now.");varr=t||!1,i=!1;e.readable=!0,e.pipe=S.prototype.pipe,e.on=e.addListener=S.prototype.on,e.on("readable",function(){i=!0;for(vart;!r&&null!==(t=e.read());)e.emit("data",t);null===t&&(i=!1,e._readableState.needReadable=!0)}),e.pause=function(){r=!0,this.emit("pause")},e.resume=function(){r=!1,i?E(function(){e.emit("readable")}):this.read(0),this.emit("resume")},e.emit("readable")}functionm(e,t){varn,r=t.buffer,i=t.length,a=!!t.decoder,o=!!t.objectMode;if(0===r.length)returnnull;if(0===i)n=null;elseif(o)n=r.shift();elseif(!e||e>=i)n=a?r.join(""):R.concat(r,i),r.length=0;elseif(e<r[0].length){vard=r[0];n=d.slice(0,e),r[0]=d.slice(e)}elseif(e===r[0].length)n=r.shift();else{n=a?"":newR(e);for(vars=0,l=0,u=r.length;u>l&&e>s;l++){vard=r[0],h=Math.min(e-s,d.length);a?n+=d.slice(0,h):d.copy(n,s,0,h),h<d.length?r[0]=d.slice(h):r.shift(),s+=h}}returnn}functionv(e){vart=e._readableState;if(t.length>0)thrownewError("endReadable called on non-empty stream");!t.endEmitted&&t.calledRead&&(t.ended=!0,E(function(){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.r
functionTransformState(r,t){this.afterTransform=function(r,n){returnafterTransform(t,r,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}functionafterTransform(r,t,n){vare=r._transformState;e.transforming=!1;vara=e.writecb;if(!a)returnr.emit("error",newError("no writecb in Transform class"));e.writechunk=null,e.writecb=null,null!==n&&void0!==n&&r.push(n),a&&a(t);vari=r._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&r._read(i.highWaterMark)}functionTransform(r){if(!(thisinstanceofTransform))returnnewTransform(r);Duplex.call(this,r);vart=(this._transformState=newTransformState(r,this),this);this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("finish",function(){"function"==typeofthis._flush?this._flush(function(r){done(t,r)}):done(t)})}functiondone(r,t){if(t)returnr.emit("error",t);varn=r._writableState,e=(r._readableState,r._transformState);if(n.length)thrownewError("calling transform done when ws.length != 0");if(e.transforming)thrownewError("calling transform done when still transforming");returnr.push(null)}module.exports=Transform;varDuplex=require("./duplex.js"),inherits=require("inherits");inherits(Transform,Duplex),Transform.prototype.push=function(r,t){returnthis._transformState.needTransform=!1,Duplex.prototype.push.call(this,r,t)},Transform.prototype._transform=function(){thrownewError("not implemented")},Transform.prototype._write=function(r,t,n){vare=this._transformState;if(e.writecb=n,e.writechunk=r,e.writeencoding=t,!e.transforming){vara=this._readableState;(e.needTransform||a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}},Transform.prototype._read=function(){varr=this._transformState;r.writechunk&&r.writecb&&!r.transforming?(r.transforming=!0,this._transform(r.writechunk,r.writeencoding,r.afterTransform)):r.needTransform=!0};
functionWriteReq(e,t,r){this.chunk=e,this.encoding=t,this.callback=r}functionWritableState(e,t){e=e||{};varr=e.highWaterMark;this.highWaterMark=r||0===r?r:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;vari=e.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){onwrite(t,e)},this.writecb=null,this.writelen=0,this.buffer=[]}functionWritable(e){returnthisinstanceofWritable||thisinstanceofStream.Duplex?(this._writableState=newWritableState(e,this),this.writable=!0,voidStream.call(this)):newWritable(e)}functionwriteAfterEnd(e,t,r){vari=newError("write after end");e.emit("error",i),setImmediate(function(){r(i)})}functionvalidChunk(e,t,r,i){varn=!0;if(!Buffer.isBuffer(r)&&"string"!=typeofr&&null!==r&&void0!==r&&!t.objectMode){varf=newTypeError("Invalid non-string/buffer chunk");e.emit("error",f),setImmediate(function(){i(f)}),n=!1}returnn}functiondecodeChunk(e,t,r){returne.objectMode||e.decodeStrings===!1||"string"!=typeoft||(t=newBuffer(t,r)),t}functionwriteOrBuffer(e,t,r,i,n){r=decodeChunk(t,r,i);varf=t.objectMode?1:r.length;t.length+=f;varo=t.length<t.highWaterMark;returnt.needDrain=!o,t.writing?t.buffer.push(newWriteReq(r,i,n)):doWrite(e,t,f,r,i,n),o}functiondoWrite(e,t,r,i,n,f){t.writelen=r,t.writecb=f,t.writing=!0,t.sync=!0,e._write(i,n,t.onwrite),t.sync=!1}functiononwriteError(e,t,r,i,n){r?setImmediate(function(){n(i)}):n(i),e.emit("error",i)}functiononwriteStateUpdate(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}functiononwrite(e,t){varr=e._writableState,i=r.sync,n=r.writecb;if(onwriteStateUpdate(r),t)onwriteError(e,r,i,t,n);else{varf=needFinish(e,r);f||r.bufferProcessing||!r.buffer.length||clearBuffer(e,r),i?setImmediate(function(){afterWrite(e,r,f,n)}):afterWrite(e,r,f,n)}}functionafterWrite(e,t,r,i){r||onwriteDrain(e,t),i(),r&&finishMaybe(e,t)}functiononwriteDrain(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}functionclearBuffer(e,t){t.bufferProcessing=!0;for(varr=0;r<t.buffer.length;r++){vari=t.buffer[r],n=i.chunk,f=i.encoding,o=i.callback,a=t.objectMode?1:n.length;if(doWrite(e,t,a,n,f,o),t.writing){r++;break}}t.bufferProcessing=!1,r<t.buffer.length?t.buffer=t.buffer.slice(r):t.buffer.length=0}functionneedFinish(e,t){returnt.ending&&0===t.length&&!t.finished&&!t.writing}functionfinishMaybe(e,t){varr=needFinish(e,t);returnr&&(t.finished=!0,e.emit("finish")),r}functionendWritable(e,t,r){t.ending=!0,finishMaybe(e,t),r&&(t.finished?setImmediate(r):e.once("finish",r)),t.ended=!0}module.exports=Writable,Writable.WritableState=WritableState;varisUint8Array="undefined"!=typeofUint8Array?function(e){returneinstanceofUint8Array}:function(e){returne&&e.constructor&&"Uint8Array"===e.constructor.name},isArrayBuffer="undefined"!=typeofArrayBuffer?function(e){returneinstanceofArrayBuffer}:function(e){returne&&e.constructor&&"ArrayBuffer"===e.constructor.name},inherits=require("inherits"),Stream=require("./index.js"),setImmediate=require("process/browser.js").nextTick,Buffer=require("buffer").Buffer;inherits(Writable,Stream),Writable.prototype.pipe=function(){this.emit("error",newError("Cannot pipe. Not readable."))},Writable.prototype.write=function(e,t,r){vari=this._writableState,n=!1;return"function"==typeoft&&(r=t,t=null),!Buffer.isBuffer(e)&&isUint8Array(e)&&(e=newBuffer(e)),isArrayBuffer(e)&&"undefined"!=typeofUint8Array&&(e=newBuffer(newUint8Array(e))),Buffer.isBuffer(e)?t="buffer":t||(t=i.defaultEncoding),"function"!=typeofr&&(r=function(){}),i.ended?writeAfterEnd(this,i,r):validChunk(this,i,e,r)&&(n=writeOrBuffer(this,i,e,t,r)),n},Writable.prototype._write=function(e,t,r){r(newError("not implemented"))},Writable.prototype.end=function(e,t,r){vari=this._writableState;"function"==typeofe?(r=e,e=null,t=null):"function"==typeoft&&(r=t,t=null),"undefined"!=typeofe&&null!==e&&this.write(e,t),i.endin
!function(){"use strict";functiont(t,h,a){if(t&&"object"==typeoft&&t.href)returnt;if("string"!=typeoft)thrownewTypeError("Parameter 'url' must be a string, not "+typeoft);varn={},p=t;p=p.trim();vari=r.exec(p);if(i){i=i[0];varq=i.toLowerCase();n.protocol=q,p=p.substr(i.length)}if(a||i||p.match(/^\/\/[^@\/]+@[^@\/]+/)){varj="//"===p.substr(0,2);!j||i&&g[i]||(p=p.substr(2),n.slashes=!0)}if(!g[i]&&(j||i&&!y[i])){varx=p.indexOf("@");if(-1!==x){for(varA=p.slice(0,x),O=!0,z=0,C=m.length;C>z;z++)if(-1!==A.indexOf(m[z])){O=!1;break}O&&(n.auth=decodeURIComponent(A),p=p.substr(x+1))}for(varZ=-1,z=0,C=f.length;C>z;z++){vark=p.indexOf(f[z]);-1!==k&&(0>Z||Z>k)&&(Z=k)}-1!==Z?(n.host=p.substr(0,Z),p=p.substr(Z)):(n.host=p,p="");for(varw=s(n.host),I=Object.keys(w),z=0,C=I.length;C>z;z++){varR=I[z];n[R]=w[R]}n.hostname=n.hostname||"";varU="["===n.hostname[0]&&"]"===n.hostname[n.hostname.length-1];if(n.hostname.length>l)n.hostname="";elseif(!U)for(var$=n.hostname.split(/\./),z=0,C=$.length;C>z;z++){var_=$[z];if(_&&!_.match(u)){for(varL="",E=0,P=_.length;P>E;E++)L+=_.charCodeAt(E)>127?"x":_[E];if(!L.match(u)){varT=$.slice(0,z),B=$.slice(z+1),D=_.match(v);D&&(T.push(D[1]),B.unshift(D[2])),B.length&&(p="/"+B.join(".")+p),n.hostname=T.join(".");break}}}if(n.hostname=n.hostname.toLowerCase(),!U){for(varF=n.hostname.split("."),G=[],z=0;z<F.length;++z){varH=F[z];G.push(H.match(/[^A-Za-z0-9_-]/)?"xn--"+o.encode(H):H)}n.hostname=G.join(".")}n.host=(n.hostname||"")+(n.port?":"+n.port:""),n.href+=n.host,U&&(n.hostname=n.hostname.substr(1,n.hostname.length-2),"/"!==p[0]&&(p="/"+p))}if(!d[q])for(varz=0,C=c.length;C>z;z++){varJ=c[z],K=encodeURIComponent(J);K===J&&(K=escape(J)),p=p.split(J).join(K)}varM=p.indexOf("#");-1!==M&&(n.hash=p.substr(M),p=p.slice(0,M));varN=p.indexOf("?");return-1!==N?(n.search=p.substr(N),n.query=p.substr(N+1),h&&(n.query=b.parse(n.query)),p=p.slice(0,N)):h&&(n.search="",n.query={}),p&&(n.pathname=p),y[i]&&n.hostname&&!n.pathname&&(n.pathname="/"),(n.pathname||n.search)&&(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=e(n),n}functione(e){"string"==typeofe&&(e=t(e));varh=e.auth||"";h&&(h=encodeURIComponent(h),h=h.replace(/%3A/i,":"),h+="@");vara=e.protocol||"",s=e.pathname||"",o=e.hash||"",r=!1,n="";void0!==e.host?r=h+e.host:void0!==e.hostname&&(r=h+(-1===e.hostname.indexOf(":")?e.hostname:"["+e.hostname+"]"),e.port&&(r+=":"+e.port)),e.query&&"object"==typeofe.query&&Object.keys(e.query).length&&(n=b.stringify(e.query));varp=e.search||n&&"?"+n||"";returna&&":"!==a.substr(-1)&&(a+=":"),e.slashes||(!a||y[a])&&r!==!1?(r="//"+(r||""),s&&"/"!==s.charAt(0)&&(s="/"+s)):r||(r=""),o&&"#"!==o.charAt(0)&&(o="#"+o),p&&"?"!==p.charAt(0)&&(p="?"+p),a+r+s+p+o}functionh(t,h){returne(a(t,h))}functiona(h,a){if(!h)returna;if(h=t(e(h),!1,!0),a=t(e(a),!1,!0),h.hash=a.hash,""===a.href)returnh.href=e(h),h;if(a.slashes&&!a.protocol)returna.protocol=h.protocol,y[a.protocol]&&a.hostname&&!a.pathname&&(a.path=a.pathname="/"),a.href=e(a),a;if(a.protocol&&a.protocol!==h.protocol){if(!y[a.protocol])returna.href=e(a),a;if(h.protocol=a.protocol,!a.host&&!g[a.protocol]){for(vars=(a.pathname||"").split("/");s.length&&!(a.host=s.shift()););a.host||(a.host=""),a.hostname||(a.hostname=""),""!==s[0]&&s.unshift(""),s.length<2&&s.unshift(""),a.pathname=s.join("/")}returnh.pathname=a.pathname,h.search=a.search,h.query=a.query,h.host=a.host||"",h.auth=a.auth,h.hostname=a.hostname||a.host,h.port=a.port,(void0!==h.pathname||void0!==h.search)&&(h.path=(h.pathname?h.pathname:"")+(h.search?h.search:"")),h.slashes=h.slashes||a.slashes,h.href=e(h),h}varo=h.pathname&&"/"===h.pathname.charAt(0),r=void0!==a.host||a.pathname&&"/"===a.pathname.charAt(0),n=r||o||h.host&&a.pathname,p=n,i=h.pathname&&h.pathname.split("/")||[],s=a.pathname&&a.pathname.split("/")||[],c=h.protocol&&!y[h.protocol];if(c&&(deleteh.hostname,deleteh.port,h.host&&(""===i[0]?i[0]=h.host:i.unshift(h.host)),deleteh.host,a.protocol&&(deletea.hostname,deletea.port,a.host&&(""===s[0]?s[0]=a.host:s.unshift(a.host)),deletea.host),n=n&&(""===s[
(function(t){functione(t){returnthisinstanceofe?(this.buffers=t||[],void(this.length=this.buffers.reduce(function(t,e){returnt+e.length},0))):newe(t)}module.exports=e,e.prototype.push=function(){for(vare=0;e<arguments.length;e++)if(!t.isBuffer(arguments[e]))thrownewTypeError("Tried to push a non-buffer");for(vare=0;e<arguments.length;e++){varr=arguments[e];this.buffers.push(r),this.length+=r.length}returnthis.length},e.prototype.unshift=function(){for(vare=0;e<arguments.length;e++)if(!t.isBuffer(arguments[e]))thrownewTypeError("Tried to unshift a non-buffer");for(vare=0;e<arguments.length;e++){varr=arguments[e];this.buffers.unshift(r),this.length+=r.length}returnthis.length},e.prototype.copy=function(t,e,r,n){returnthis.slice(r,n).copy(t,e,0,n-r)},e.prototype.splice=function(r,n){vars=this.buffers,i=r>=0?r:this.length-r,h=[].slice.call(arguments,2);void0===n?n=this.length-i:n>this.length-i&&(n=this.length-i);for(varr=0;r<h.length;r++)this.length+=h[r].length;for(varf=newe,o=0,l=0;l<s.length&&o+s[l].length<i;l++)o+=s[l].length;if(i-o>0){varu=i-o;if(u+n<s[l].length){f.push(s[l].slice(u,u+n));for(varg=s[l],p=newt(u),r=0;u>r;r++)p[r]=g[r];for(vara=newt(g.length-u-n),r=u+n;r<g.length;r++)a[r-n-u]=g[r];if(h.length>0){varc=h.slice();c.unshift(p),c.push(a),s.splice.apply(s,[l,1].concat(c)),l+=c.length,h=[]}elses.splice(l,1,p,a),l+=2}elsef.push(s[l].slice(u)),s[l]=s[l].slice(0,u),l++}for(h.length>0&&(s.splice.apply(s,[l,0].concat(h)),l+=h.length);f.length<n;){varv=s[l],b=v.length,y=Math.min(b,n-f.length);y===b?(f.push(v),s.splice(l,1)):(f.push(v.slice(0,y)),s[l]=s[l].slice(y))}returnthis.length-=f.length,f},e.prototype.slice=function(e,r){varn=this.buffers;void0===r&&(r=this.length),void0===e&&(e=0),r>this.length&&(r=this.length);for(vars=0,i=0;i<n.length&&s+n[i].length<=e;i++)s+=n[i].length;for(varh=newt(r-e),f=0,o=i;r-e>f&&o<n.length;o++){varl=n[o].length,u=0===f?e-s:0,g=f+l>=r-e?Math.min(u+(r-e)-f,l):l;n[o].copy(h,f,u,g),f+=g-u}returnh},e.prototype.pos=function(t){if(0>t||t>=this.length)thrownewError("oob");for(vare=t,r=0,n=null;;){if(n=this.buffers[r],e<n.length)return{buf:r,offset:e};e-=n.length,r++}},e.prototype.get=function(t){vare=this.pos(t);returnthis.buffers[e.buf].get(e.offset)},e.prototype.set=function(t,e){varr=this.pos(t);returnthis.buffers[r.buf].set(r.offset,e)},e.prototype.indexOf=function(e,r){if("string"==typeofe)e=newt(e);elseif(!(einstanceoft))thrownewError("Invalid type for a search string");if(!e.length)return0;if(!this.length)return-1;varn,s=0,i=0,h=0,f=0;if(r){varo=this.pos(r);s=o.buf,i=o.offset,f=r}for(;;){for(;i>=this.buffers[s].length;)if(i=0,s++,s>=this.buffers.length)return-1;varl=this.buffers[s][i];if(l==e[h]){if(0==h&&(n={i:s,j:i,pos:f}),h++,h==e.length)returnn.pos}else0!=h&&(s=n.i,i=n.j,f=n.pos,h=0);i++,f++}},e.prototype.toBuffer=function(){returnthis.slice()},e.prototype.toString=function(t,e,r){returnthis.slice(e,r).toString(t)}}).call(this,require("buffer").Buffer);
(function(e){"use strict";functiont(e,t){varo=this;u.call(o),o.socket=newi.Socket,o.socksHost=e,o.socksPort=t,o.socket.on("error",function(e){o.emit("error",e)}),o.on("error",function(){o.socket.destroyed||o.socket.destroy()})}functiono(e,t){varo,n,r=e.split(".");for(o=0;o<r.length;o++)n=parseInt(r[o],10),t.push(n)}functionn(e,t){varo,n,r,s,c,i,u;if(i=newd.Address(e).canonicalForm(),!i)return!1;for(u=i.split(":"),o=0;o<u.length;o++)s=u[o].substr(0,2),c=u[o].substr(2,2),n=parseInt(s,16),r=parseInt(c,16),t.push(n),t.push(r);return!0}functionr(e,t){varo,n;for(t.push(e.length),o=0;o<e.length;o++)n=e.charCodeAt(o),t.push(n)}functions(e,t){p(t,t.length,e)}functionc(e){switch(e){case1:return"General SOCKS server failure";case2:return"Connection not allowed by ruleset";case3:return"Network unreachable";case4:return"Host unreachable";case5:return"Connection refused";case6:return"TTL expired";case7:return"Command not supported";case8:return"Address type not supported";default:return"Unknown status code "+e}}vari=require("net"),u=require("events").EventEmitter,a=require("util").inherits,p=require("network-byte-order").htons,d=require("ipv6").v6;module.exports=exports=t,exports.createConnection=function(e){varo,n,r;returnn=e.socksHost||"localhost",r=e.socksPort||1080,o=newt(n,r),o.connect(e.port,e.host)},a(t,u),t.prototype.setTimeout=function(e,t){returnthis.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(){returnthis.socket.setNoDelay()},t.prototype.setKeepAlive=function(e,t){returnthis.socket.setKeepAlive(e,t)},t.prototype.address=function(){returnthis.socket.address()},t.prototype.pause=function(){returnthis.socket.pause()},t.prototype.resume=function(){returnthis.socket.resume()},t.prototype.end=function(e,t){returnthis.socket.end(e,t)},t.prototype.destroy=function(e){returnthis.socket.destroy(e)},t.prototype.destroySoon=function(){vare=this.socket.destroySoon();returnthis.writable=!1,e},t.prototype.setEncoding=function(e){returnthis.socket.setEncoding(e)},t.prototype.write=function(e,t,o){returnthis.socket.write(e,t,o)},t.prototype.connect=function(e,t){varo=this;returno.socket.connect(o.socksPort,o.socksHost,function(){o.establishSocksConnection(t,e)}),o},t.prototype.handleSocksConnectToHost=function(){vare=this;e.socket.on("close",function(t){e.emit("close",t)}),e.socket.on("end",function(){e.emit("end")}),e.socket.on("data",function(t){e.emit("data",t)}),e.socket._httpMessage=e._httpMessage,e.socket.parser=e.parser,e.socket.ondata=e.ondata,e.writable=!0,e.readable=!0,e.emit("connect")},t.prototype.establishSocksConnection=function(e,t){varo=this;o.authenticateWithSocks(function(){o.connectSocksToHost(e,t,function(){o.handleSocksConnectToHost()})})},t.prototype.authenticateWithSocks=function(t){varo,n=this;n.socket.ondata=function(e,o,r){vars;returnr-o!==2?s=newError("SOCKS authentication failed. Unexpected number of bytes received."):5!==e[o]?s=newError("SOCKS authentication failed. Unexpected SOCKS version number: "+e[o]+"."):0!==e[o+1]&&(s=newError("SOCKS authentication failed. Unexpected SOCKS authentication method: "+e[o+1]+".")),s?voidn.emit("error",s):void(t&&t())},o=newe(3),o[0]=5,o[1]=1,o[2]=0,n.socket.write(o)},t.prototype.connectSocksToHost=function(t,u,a){varp,d,h=this;switch(this.socket.ondata=function(e,t){varo,n,r,s;if(5!==e[t]?s=newError("SOCKS connection failed. Unexpected SOCKS version number: "+e[t]+"."):0!==e[t+1]?s=newError("SOCKS connection failed. "+c(e[t+1])+"."):0!==e[t+2]&&(s=newError("SOCKS connection failed. The reserved byte must be 0x00.")),s)returnvoidh.emit("error",s);switch(n="",r=0,e[t+3]){case1:n=e[t+4]+"."+e[t+5]+"."+e[t+6]+"."+e[t+7],r=4;break;case3:for(r=e[t+4]+1,o=t+5;t+r>o;o++)n+=String.fromCharCode(e[o]);break;case4:r=16;break;default:returnvoidh.emit("error",newError("SOCKS connection failed. Unknown addres type: "+e[t+3]+"."))}a&&a()},p=[],p.push(5),p.push(1),p.push(0),i.isIP(t)){case0:p.push(3),r(t,p);break;case4:p.push(1),o(t,p);break;case6:if(p.push(4),n(t,p)===!1)returnvoidh.emit("error",newError("IPv6ho
varutil=require("util"),sprintf=function(){functionr(r){returnObject.prototype.toString.call(r).slice(8,-1).toLowerCase()}functione(r,e){for(vart=[];e>0;t[--e]=r);returnt.join("")}vart=function(){returnt.cache.hasOwnProperty(arguments[0])||(t.cache[arguments[0]]=t.parse(arguments[0])),t.format.call(null,t.cache[arguments[0]],arguments)};returnt.object_stringify=function(r,e,n,i){vars="";if(null!=r)switch(typeofr){case"function":return"[Function"+(r.name?": "+r.name:"")+"]";case"object":if(rinstanceofError)return"["+r.toString()+"]";if(e>=n)return"[Object]";if(i&&(i=i.slice(0),i.push(r)),null!=r.length){s+="[";vara=[];for(varoinr)a.push(i&&i.indexOf(r[o])>=0?"[Circular]":t.object_stringify(r[o],e+1,n,i));s+=a.join(", ")+"]"}else{if("getMonth"inr)return"Date("+r+")";s+="{";vara=[];for(varfinr)r.hasOwnProperty(f)&&a.push(i&&i.indexOf(r[f])>=0?f+": [Circular]":f+": "+t.object_stringify(r[f],e+1,n,i));s+=a.join(", ")+"}"}returns;case"string":return'"'+r+'"'}return""+r},t.format=function(n,i){vars,a,o,f,u,c,p,l=1,h=n.length,g="",b=[];for(a=0;h>a;a++)if(g=r(n[a]),"string"===g)b.push(n[a]);elseif("array"===g){if(f=n[a],f[2])for(s=i[l],o=0;o<f[2].length;o++){if(!s.hasOwnProperty(f[2][o]))thrownewError(sprintf('[sprintf] property "%s" does not exist',f[2][o]));s=s[f[2][o]]}elses=f[1]?i[f[1]]:i[l++];if(/[^sO]/.test(f[8])&&"number"!=r(s))thrownewError(sprintf('[sprintf] expecting number but found %s "'+s+'"',r(s)));switch(f[8]){case"b":s=s.toString(2);break;case"c":s=String.fromCharCode(s);break;case"d":s=parseInt(s,10);break;case"e":s=f[7]?s.toExponential(f[7]):s.toExponential();break;case"f":s=f[7]?parseFloat(s).toFixed(f[7]):parseFloat(s);break;case"O":s=t.object_stringify(s,0,parseInt(f[7])||5);break;case"o":s=s.toString(8);break;case"s":s=(s=String(s))&&f[7]?s.substring(0,f[7]):s;break;case"u":s=Math.abs(s);break;case"x":s=s.toString(16);break;case"X":s=s.toString(16).toUpperCase()}s=/[def]/.test(f[8])&&f[3]&&s>=0?"+"+s:s,c=f[4]?"0"==f[4]?"0":f[4].charAt(1):" ",p=f[6]-String(s).length,u=f[6]?e(c,p):"",b.push(f[5]?s+u:u+s)}returnb.join("")},t.cache={},t.parse=function(r){for(vare=r,t=[],n=[],i=0;e;){if(null!==(t=/^[^\x25]+/.exec(e)))n.push(t[0]);elseif(null!==(t=/^\x25{2}/.exec(e)))n.push("%");else{if(null===(t=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosOuxX])/.exec(e)))thrownewError("[sprintf] "+e);if(t[2]){i|=1;vars=[],a=t[2],o=[];if(null===(o=/^([a-z_][a-z_\d]*)/i.exec(a)))thrownewError("[sprintf] "+a);for(s.push(o[1]);""!==(a=a.substring(o[0].length));)if(null!==(o=/^\.([a-z_][a-z_\d]*)/i.exec(a)))s.push(o[1]);else{if(null===(o=/^\[(\d+)\]/.exec(a)))thrownewError("[sprintf] "+a);s.push(o[1])}t[2]=s}elsei|=2;if(3===i)thrownewError("[sprintf] mixing positional and named placeholders is not (yet) supported");n.push(t)}e=e.substring(t[0].length)}returnn},t}(),vsprintf=function(r,e){vart=e.slice();returnt.unshift(r),sprintf.apply(null,t)};module.exports=sprintf,sprintf.sprintf=sprintf,sprintf.vsprintf=vsprintf;
(function(e,r){functiont(e){for(e=e.substr(0,8);e.length<8;)e+="0";returne}functionn(e){returns(e[1]).mul("100000000").add(t(e[2]))}functiono(e){returns(t(e[1]))}functionf(e){returns(e[1]).mul("100000000")}varu,i=require("crypto"),s=require("bignum"),a=require("binary"),c=require("bufferput"),l=require("buffertools"),h=require("../lib/sjcl"),p=!e.versions;p&&(u=require("../browser/vendor-bundle.js"));{varv=exports.sha256=function(e){returnnewr(i.createHash("sha256").update(e).digest("binary"),"binary")},d=(exports.sha512=function(e){if(p){vart=e.toString("hex"),n=h.codec.hex.toBits(t),o=h.hash.sha512.hash(n),f=h.codec.hex.fromBits(o),u=newr(f,"hex");returnu}returnnewr(i.createHash("sha512").update(e).digest("binary"),"binary")},exports.sha512hmac=function(e,t){if(p){varn=h.codec.hex.toBits(t.toString("hex")),o=h.codec.hex.toBits(e.toString("hex")),f=newh.misc.hmac(n,h.hash.sha512),u=f.encrypt(o),s=h.codec.hex.fromBits(u),a=newr(s,"hex");returna}varf=i.createHmac("sha512",t),c=f.update(e).digest();returnc},exports.ripe160=function(e){if(!r.isBuffer(e))thrownewError("arg should be a buffer");if(p){for(vart=newu.crypto31.lib.WordArray.init(Crypto.util.bytesToWords(e),e.length),n=u.crypto31.RIPEMD160(t),o=n.words,f=[],s=0;s<32*o.length;s+=8)f.push(o[s>>>5]>>>24-s%32&255);returnnewr(f,"hex")}returnnewr(i.createHash("rmd160").update(e).digest("binary"),"binary")}),g=(exports.sha1=function(e){returnnewr(i.createHash("sha1").update(e).digest("binary"),"binary")},exports.twoSha256=function(e){returnv(v(e))},exports.sha256ripe160=function(e){returnd(v(e))},exports.formatHash=function(e){vart=newr(10);returne.copy(t,0,22,32),l.reverse(t).toString("hex")},exports.formatHashFull=function(e){vart=newr(e.length);e.copy(t);varn=l.toHex(l.reverse(t));returnn}),w=(exports.formatHashAlt=function(e){varr=g(e);returnr=r.replace(/^0*/,""),r.substr(0,10)},exports.formatBuffer=function(e,t){null===t&&(t=10),(t>e.length||0===t)&&(t=e.length);varn=newr(t);e.copy(n,0,0,t);varo=l.toHex(n);returnn.length<e.length&&(o+="..."),o},exports.valueToBigInt=function(e){returnr.isBuffer(e)?s.fromBuffer(e,{endian:"little",size:8}):e});exports.bigIntToValue=function(e){returnr.isBuffer(e)?e:e.toBuffer({endian:"little",size:8})}}exports.bytesNeededToStore=bytesNeededToStore=function(e){return0===e?0:Math.ceil((e.toString(2).replace("-","").length+1)/8)},exports.negativeBuffer=negativeBuffer=function(e){for(vart=newr(e.length),n=0;n<e.length;n++)t[n]=~e[n],t[n]<0&&(t[n]+=256);for(varn=e.length-1;n>=0&&(t[n]+=1,t[n]>=256&&(t[n]-=256),0===t[n]);n--);returnt},exports.intToBuffer2C=function(e){varr=bytesNeededToStore(e),t=newc,n=e.toString(16),o="-"===n[0];n=n.replace("-","");for(varf=0;r>f;f++){varu=n.substring(n.length-2*(f+1),n.length-2*f);1===u.lenght&&(u="0"+u);vari=parseInt(u,16);t.word8(i)}vars=t.buffer();returno&&(s=l.reverse(s),s=negativeBuffer(s),s=l.reverse(s)),s};varx=function(e){vart;return128&e[0]?(t=newr(e.length+1),e.copy(t,1),t[0]=0):t=e,t};exports.intToBufferSM=function(e){"number"==typeofe&&(e=s(e));vart,n,o=e.cmp(0);returno>0?(t=e.toBuffer(),n=x(t),n=l.reverse(n)):0==o?n=newr([]):(t=e.neg().toBuffer(),n=x(t),n[0]|=128,n=l.reverse(n)),n},exports.bufferSMToInt=function(e){if(!e.length)returns(0);if(e.length>4)thrownewError("Bigint cast overflow (> 4 bytes)");vart=newr(e.length);e.copy(t),t=l.reverse(t);varn=128&t[0];returnn?(t[0]&=127,s.fromBuffer(t).neg()):s.fromBuffer(t)};varb=(exports.formatValue=function(e){for(varr=w(e).toString(),t=r.length>8?r.substr(0,r.length-8):"0",n=r.length>8?r.substr(r.length-8):r;n.length<8;)n="0"+n;for(n=n.replace(/0*$/,"");n.length<2;)n+="0";returnt+"."+n},/^\s*(\d+)\.(\d+)/),y=/^\s*\.(\d+)/,B=/^\s*(\d+)/;exports.parseValue=function(e){"string"!=typeofe&&(e=e.toString());varr=e.match(b);returnr?n(r):(r=e.match(y))?o(r):(r=e.match(B),r?f(r):void0)};{varm=(exports.createSynchrotron=function(e){varr={};returnfunction(t){varn=Array.prototype.slice.call(arguments),o=function(){n[0]=function(){r[t]&&(r[t].length?r[t].shift()():delete