!function(a){if("object"==typeofexports&&"undefined"!=typeofmodule)module.exports=a();elseif("function"==typeofdefine&&define.amd)define([],a);else{varb;b="undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:this,b.Wallet=a()}}(function(){vara;returnfunctionb(a,c,d){functione(g,h){if(!c[g]){if(!a[g]){vari="function"==typeofrequire&&require;if(!h&&i)returni(g,!0);if(f)returnf(g,!0);varj=newError("Cannot find module '"+g+"'");throwj.code="MODULE_NOT_FOUND",j}vark=c[g]={exports:{}};a[g][0].call(k.exports,function(b){varc=a[g][1][b];returne(c?c:b)},k,k.exports,b,a,c,d)}returnc[g].exports}for(varf="function"==typeofrequire&&require,g=0;g<d.length;g++)e(d[g]);returne}({1:[function(a,b,c){(function(c){"use strict";vard=a("rlp"),e=(a("./lib/contract.js"),a("./lib/secret-storage.js")),f=a("./lib/randomish.js"),g=a("./lib/signing-key.js"),h=a("./lib/wallet.js"),i=a("./lib/utils.js"),j=i.BN,k={};i.defineProperty(h,"utils",k),i.defineProperty(k,"BN",j),i.defineProperty(k,"Buffer",c),i.defineProperty(k,"sha3",i.sha3),i.defineProperty(k,"sha256",i.sha256),i.defineProperty(k,"getContractAddress",function(a){returng.getAddress("0x"+i.sha3(d.encode([i.hexOrBuffer(i.getAddress(a.from)),i.hexOrBuffer(i.hexlify(a.nonce,"nonce"))])).slice(12).toString("hex"))}),b.exports=h,i.defineProperty(h,"getAddress",g.getAddress),i.defineProperty(h,"getIcapAddress",g.getIcapAddress),i.defineProperty(h,"isCrowdsaleWallet",e.isCrowdsaleWallet),i.defineProperty(h,"isValidWallet",e.isValidWallet),i.defineProperty(h,"decryptCrowdsale",function(a,b){returnnewh(e.decryptCrowdsale(a,b))}),i.defineProperty(h,"decrypt",function(a,b,c){if("function"!=typeofc)thrownewError("invalid callback");e.decrypt(a,b,function(a,b,d){returnb?c(a,newh(b),d):c(a,b,d)})}),i.defineProperty(h.prototype,"encrypt",function(a,b,c){if("function"!=typeofb||c||(c=b,b={}),"function"!=typeofc)thrownewError("invalid callback");e.encrypt(this.privateKey,a,b,c)}),i.defineProperty(h,"randomish",newf),b.exports=h}).call(this,a("buffer").Buffer)},{"./lib/contract.js":4,"./lib/randomish.js":6,"./lib/secret-storage.js":7,"./lib/signing-key.js":8,"./lib/utils.js":9,"./lib/wallet.js":10,buffer:40,rlp:83}],2:[function(a,b,c){(function(c,d){"use strict";functione(a){if(a<=0||a>1024||parseInt(a)!=a)thrownewError("invalid length");varb=newd(a);returng.getRandomValues(b),b}varf=a("./utils.js"),g=c.crypto||c.msCrypto;g&&g.getRandomValues?console.log("Found strong random number source"):(console.log("WARNING: Missing strong random number source; using weak randomBytes"),g={getRandomValues:function(a){for(varb=0;b<buffer.length;b++)buffer[b]=parseInt(256*Math.random());returnbuffer},_weakCrypto:!0}),g._weakCrypto===!0&&f.defineProperty(e,"_weakCrypto",!0),b.exports=e}).call(this,"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:"undefined"!=typeofwindow?window:{},a("buffer").Buffer)},{"./utils.js":9,buffer:40}],3:[function(a,b,c){"use strict";try{b.exports.XMLHttpRequest=XMLHttpRequest}catch(d){console.log("Warning: XMLHttpRequest is not defined"),b.exports.XMLHttpRequest=null}},{}],4:[function(a,b,c){(function(c){"use strict";functiond(a,b,c){vard=JSON.stringify(c);Object.defineProperty(a,b,{enumerable:!0,get:function(){returnJSON.parse(d)}})}functione(a,b){if(!Array.isArray(a))thrownewError("invalid params");for(varc=[],d=0;d<a.length;d++){if("string"!=typeofa[d][b])thrownewError("invalid abi");c.push(a[d][b])}returnc}functionf(a){if(!a.eq){if("number"!=typeofa)thrownewError("invalid number");a=newo.BN(a)}returna}functiong(a,b){return{encode:function(a){returna=f(a),a.toTwos(256).toArrayLike(c,"be",32)},decode:function(a,b){varc=newo.BN(a.slice(b,b+32));returnc=c.fromTwos(256),{consumed:32,value:c}}}}functionh(a){return{encode:function(b){if(b=o.hexOrBuffer(b),32===a)returnb;vard=newc(32);returnd.fill(0),b.copy(d),d},decode:function(b,c){if(b.length<c+32)thrownewError("invalid bytes"+a);return{consumed:32,value:"0x"+b.slice(c,c+a).toString("hex")}}}}functioni(a){varb=pa
this.key=f(a),this._prepare()};z.prototype._prepare=function(){vara=j[this.key.length];if(null==a)thrownewError("invalid key size (must be length 16, 24 or 32)");this._Ke=[],this._Kd=[];for(varc=0;c<=a;c++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);for(vard,e=4*(a+1),f=this.key.length/4,g=b(this.key),c=0;c<f;c++)d=c>>2,this._Ke[d][c%4]=g[c],this._Kd[a-d][c%4]=g[c];for(varh,i=0,m=f;m<e;){if(h=g[f-1],g[0]^=l[h>>16&255]<<24^l[h>>8&255]<<16^l[255&h]<<8^l[h>>24&255]^k[i]<<24,i+=1,8!=f)for(varc=1;c<f;c++)g[c]^=g[c-1];else{for(varc=1;c<f/2;c++)g[c]^=g[c-1];h=g[f/2-1],g[f/2]^=l[255&h]^l[h>>8&255]<<8^l[h>>16&255]<<16^l[h>>24&255]<<24;for(varc=f/2+1;c<f;c++)g[c]^=g[c-1]}for(varn,o,c=0;c<f&&m<e;)n=m>>2,o=m%4,this._Ke[n][o]=g[c],this._Kd[a-n][o]=g[c++],m++}for(varn=1;n<a;n++)for(varo=0;o<4;o++)h=this._Kd[n][o],this._Kd[n][o]=v[h>>24&255]^w[h>>16&255]^x[h>>8&255]^y[255&h]},z.prototype.encrypt=function(a){if(16!=a.length)returnnewError("plaintext must be a block of size 16");for(varc=this._Ke.length-1,d=[0,0,0,0],e=b(a),g=0;g<4;g++)e[g]^=this._Ke[0][g];for(varh=1;h<c;h++){for(varg=0;g<4;g++)d[g]=n[e[g]>>24&255]^o[e[(g+1)%4]>>16&255]^p[e[(g+2)%4]>>8&255]^q[255&e[(g+3)%4]]^this._Ke[h][g];e=d.slice(0)}for(vari,j=f(16),g=0;g<4;g++)i=this._Ke[c][g],j[4*g]=255&(l[e[g]>>24&255]^i>>24),j[4*g+1]=255&(l[e[(g+1)%4]>>16&255]^i>>16),j[4*g+2]=255&(l[e[(g+2)%4]>>8&255]^i>>8),j[4*g+3]=255&(l[255&e[(g+3)%4]]^i);returnj},z.prototype.decrypt=function(a){if(16!=a.length)returnnewError("ciphertext must be a block of size 16");for(varc=this._Kd.length-1,d=[0,0,0,0],e=b(a),g=0;g<4;g++)e[g]^=this._Kd[0][g];for(varh=1;h<c;h++){for(varg=0;g<4;g++)d[g]=r[e[g]>>24&255]^s[e[(g+3)%4]>>16&255]^t[e[(g+2)%4]>>8&255]^u[255&e[(g+1)%4]]^this._Kd[h][g];e=d.slice(0)}for(vari,j=f(16),g=0;g<4;g++)i=this._Kd[c][g],j[4*g]=255&(m[e[g]>>24&255]^i>>24),j[4*g+1]=255&(m[e[(g+3)%4]>>16&255]^i>>16),j[4*g+2]=255&(m[e[(g+2)%4]>>8&255]^i>>8),j[4*g+3]=255&(m[255&e[(g+1)%4]]^i);returnj};varA=function(a){this.description="Electronic Code Block",this.name="ecb",this._aes=newz(a)};A.prototype.encrypt=function(a){returnthis._aes.encrypt(a)},A.prototype.decrypt=function(a,b){returnthis._aes.decrypt(a)};varB=function(a,b){if(this.description="Cipher Block Chaining",this.name="cbc",null===b)b=f([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);elseif(16!=b.length)returnnewError("initialation vector iv must be of length 16");this._lastCipherblock=f(b),this._aes=newz(a)};B.prototype.encrypt=function(a){if(16!=a.length)returnnewError("plaintext must be a block of size 16");for(varb=f(a),c=0;c<16;c++)b[c]^=this._lastCipherblock[c];returnthis._lastCipherblock=this._aes.encrypt(b),this._lastCipherblock},B.prototype.decrypt=function(a){if(16!=a.length)returnnewError("ciphertext must be a block of size 16");for(varb=this._aes.decrypt(a),c=0;c<16;c++)b[c]^=this._lastCipherblock[c];returna.copy(this._lastCipherblock),b};varC=function(a,b,c){if(this.description="Cipher Feedback",this.name="cfb",null===b)b=f([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);elseif(16!=b.length)returnnewError("initialation vector iv must be of length 16");c||(c=1),this.segmentSize=c,this._shiftRegister=f(b),this._aes=newz(a)};C.prototype.encrypt=function(a){if(a.length%this.segmentSize!=0)returnnewError("plaintext must be a block of size module segmentSize ("+this.segmentSize+")");for(varb,c=f(a),d=0;d<c.length;d+=this.segmentSize){b=this._aes.encrypt(this._shiftRegister);for(vare=0;e<this.segmentSize;e++)c[d+e]^=b[e];this._shiftRegister.copy(this._shiftRegister,0,this.segmentSize),c.copy(this._shiftRegister,16-this.segmentSize,d,d+this.segmentSize)}returnc},C.prototype.decrypt=function(a){if(a.length%this.segmentSize!=0)returnnewError("ciphertext must be a block of size module segmentSize ("+this.segmentSize+")");for(varb,c=f(a),d=0;d<c.length;d+=this.segmentSize){b=this._aes.encrypt(this._shiftRegister);for(vare=0;e<this.segmentSize;e++)c[d+e]^=b[e];this._shiftRegister.copy(this._shiftRegister,0,this.segmentSize),a.copy(this._shiftRegister,16-this.segmentSize,d,d+this.segmentSize)}return
}functionj(a){return"[object Arguments]"==Object.prototype.toString.call(a)}functionk(a,b){if(n.isNullOrUndefined(a)||n.isNullOrUndefined(b))return!1;if(a.prototype!==b.prototype)return!1;if(n.isPrimitive(a)||n.isPrimitive(b))returna===b;varc=j(a),d=j(b);if(c&&!d||!c&&d)return!1;if(c)returna=o.call(a),b=o.call(b),i(a,b);vare,f,g=r(a),h=r(b);if(g.length!=h.length)return!1;for(g.sort(),h.sort(),f=g.length-1;f>=0;f--)if(g[f]!=h[f])return!1;for(f=g.length-1;f>=0;f--)if(e=g[f],!i(a[e],b[e]))return!1;return!0}functionl(a,b){return!(!a||!b)&&("[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):ainstanceofb||b.call({},a)===!0)}functionm(a,b,c,d){vare;n.isString(c)&&(d=c,c=null);try{b()}catch(f){e=f}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&g(e,c,"Missing expected exception"+d),!a&&l(e,c)&&g(e,c,"Got unwanted exception"+d),a&&e&&c&&!l(e,c)||!a&&e)throwe}varn=a("util/"),o=Array.prototype.slice,p=Object.prototype.hasOwnProperty,q=b.exports=h;q.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,a.message?(this.message=a.message,this.generatedMessage=!1):(this.message=f(this),this.generatedMessage=!0);varb=a.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,b);else{varc=newError;if(c.stack){vard=c.stack,e=b.name,h=d.indexOf("\n"+e);if(h>=0){vari=d.indexOf("\n",h+1);d=d.substring(i+1)}this.stack=d}}},n.inherits(q.AssertionError,Error),q.fail=g,q.ok=h,q.equal=function(a,b,c){a!=b&&g(a,b,c,"==",q.equal)},q.notEqual=function(a,b,c){a==b&&g(a,b,c,"!=",q.notEqual)},q.deepEqual=function(a,b,c){i(a,b)||g(a,b,c,"deepEqual",q.deepEqual)},q.notDeepEqual=function(a,b,c){i(a,b)&&g(a,b,c,"notDeepEqual",q.notDeepEqual)},q.strictEqual=function(a,b,c){a!==b&&g(a,b,c,"===",q.strictEqual)},q.notStrictEqual=function(a,b,c){a===b&&g(a,b,c,"!==",q.notStrictEqual)},q["throws"]=function(a,b,c){m.apply(this,[!0].concat(o.call(arguments)))},q.doesNotThrow=function(a,b){m.apply(this,[!1].concat(o.call(arguments)))},q.ifError=function(a){if(a)throwa};varr=Object.keys||function(a){varb=[];for(varcina)p.call(a,c)&&b.push(c);returnb}},{"util/":66}],39:[function(a,b,c){},{}],40:[function(a,b,c){(function(b){"use strict";functiond(){try{vara=newUint8Array(1);returna.__proto__={__proto__:Uint8Array.prototype,foo:function(){return42}},42===a.foo()&&"function"==typeofa.subarray&&0===a.subarray(1,1).byteLength}catch(b){return!1}}functione(){returng.TYPED_ARRAY_SUPPORT?2147483647:1073741823}functionf(a,b){if(e()<b)thrownewRangeError("Invalid typed array length");returng.TYPED_ARRAY_SUPPORT?(a=newUint8Array(b),a.__proto__=g.prototype):(null===a&&(a=newg(b)),a.length=b),a}functiong(a,b,c){if(!(g.TYPED_ARRAY_SUPPORT||thisinstanceofg))returnnewg(a,b,c);if("number"==typeofa){if("string"==typeofb)thrownewError("If encoding is specified then the first argument must be a string");returnk(this,a)}returnh(this,a,b,c)}functionh(a,b,c,d){if("number"==typeofb)thrownewTypeError('"value" argument must not be a number');return"undefined"!=typeofArrayBuffer&&binstanceofArrayBuffer?n(a,b,c,d):"string"==typeofb?l(a,b,c):o(a,b)}functioni(a){if("number"!=typeofa)thrownewTypeError('"size" argument must be a number')}functionj(a,b,c,d){returni(b),b<=0?f(a,b):void0!==c?"string"==typeofd?f(a,b).fill(c,d):f(a,b).fill(c):f(a,b)}functionk(a,b){if(i(b),a=f(a,b<0?0:0|p(b)),!g.TYPED_ARRAY_SUPPORT)for(varc=0;c<b;++c)a[c]=0;returna}functionl(a,b,c){if("string"==typeofc&&""!==c||(c="utf8"),!g.isEncoding(c))thrownewTypeError('"encoding" must be a valid string encoding');vard=0|r(b,c);returna=f(a,d),a.write(b,c),a}functionm(a,b){varc=0|p(b.length);a=f(a,c);for(vard=0;d<c;d+=1)a[d]=255&b[d];returna}functionn(a,b,c,d){if(b.byteLength,c<0||b.byteLength<c)thrownewRangeError("'offset' is out of bounds");if(b.byteLength<c+(d||0))thrownewRangeError("'length' is out of bounds");returnb=void0===c&&void0===d?newUint8Array(b):void0===d?newUint8Array(b,c):newUint8Array(b,c,d),g.TYPED_ARRAY_SUPPORT?(a
a|=a>>>2,a|=a>>>4,a|=a>>>8,a|=a>>>16,a++),a}functionj(a,b){return0===b.length&&b.ended?0:b.objectMode?0===a?0:1:null===a||isNaN(a)?b.flowing&&b.buffer.length?b.buffer[0].length:b.length:a<=0?0:(a>b.highWaterMark&&(b.highWaterMark=i(a)),a>b.length?b.ended?b.length:(b.needReadable=!0,0):a)}functionk(a,b){varc=null;returnF.isBuffer(b)||"string"==typeofb||null===b||void0===b||a.objectMode||(c=newTypeError("Invalid non-string/buffer chunk")),c}functionl(a,b){if(!b.ended){if(b.decoder){varc=b.decoder.end();c&&c.length&&(b.buffer.push(c),b.length+=b.objectMode?1:c.length)}b.ended=!0,m(a)}}functionm(a){varb=a._readableState;b.needReadable=!1,b.emittedReadable||(J("emitReadable",b.flowing),b.emittedReadable=!0,b.sync?A(n,a):n(a))}functionn(a){J("emit readable"),a.emit("readable"),u(a)}functiono(a,b){b.readingMore||(b.readingMore=!0,A(p,a,b))}functionp(a,b){for(varc=b.length;!b.reading&&!b.flowing&&!b.ended&&b.length<b.highWaterMark&&(J("maybeReadMore read 0"),a.read(0),c!==b.length);)c=b.length;b.readingMore=!1}functionq(a){returnfunction(){varb=a._readableState;J("pipeOnDrain",b.awaitDrain),b.awaitDrain&&b.awaitDrain--,0===b.awaitDrain&&E(a,"data")&&(b.flowing=!0,u(a))}}functionr(a){J("readable nexttick read 0"),a.read(0)}functions(a,b){b.resumeScheduled||(b.resumeScheduled=!0,A(t,a,b))}functiont(a,b){b.reading||(J("resume read 0"),a.read(0)),b.resumeScheduled=!1,a.emit("resume"),u(a),b.flowing&&!b.reading&&a.read(0)}functionu(a){varb=a._readableState;if(J("flow",b.flowing),b.flowing)dovarc=a.read();while(null!==c&&b.flowing)}functionv(a,b){varc,d=b.buffer,e=b.length,f=!!b.decoder,g=!!b.objectMode;if(0===d.length)returnnull;if(0===e)c=null;elseif(g)c=d.shift();elseif(!a||a>=e)c=f?d.join(""):1===d.length?d[0]:F.concat(d,e),d.length=0;elseif(a<d[0].length){varh=d[0];c=h.slice(0,a),d[0]=h.slice(a)}elseif(a===d[0].length)c=d.shift();else{c=f?"":G.allocUnsafe(a);for(vari=0,j=0,k=d.length;j<k&&i<a;j++){varl=d[0],m=Math.min(a-i,l.length);f?c+=l.slice(0,m):l.copy(c,i,0,m),m<l.length?d[0]=l.slice(m):d.shift(),i+=m}}returnc}functionw(a){varb=a._readableState;if(b.length>0)thrownewError('"endReadable()" called on non-empty stream');b.endEmitted||(b.ended=!0,A(x,b,a))}functionx(a,b){a.endEmitted||0!==a.length||(a.endEmitted=!0,b.readable=!1,b.emit("end"))}functiony(a,b){for(varc=0,d=a.length;c<d;c++)b(a[c],c)}functionz(a,b){for(varc=0,d=a.length;c<d;c++)if(a[c]===b)returnc;return-1}b.exports=f;varA=a("process-nextick-args"),B=a("isarray");f.ReadableState=e;varC,D=a("events").EventEmitter,E=function(a,b){returna.listeners(b).length};!function(){try{C=a("stream")}catch(b){}finally{C||(C=a("events").EventEmitter)}}();varF=a("buffer").Buffer,G=a("buffer-shims"),H=a("core-util-is");H.inherits=a("inherits");varI=a("util"),J=void0;J=I&&I.debuglog?I.debuglog("stream"):function(){};varK;H.inherits(f,C);varL,L,M="function"==typeofD.prototype.prependListener;f.prototype.push=function(a,b){varc=this._readableState;returnc.objectMode||"string"!=typeofa||(b=b||c.defaultEncoding,b!==c.encoding&&(a=G.from(a,b),b="")),g(this,c,a,b,!1)},f.prototype.unshift=function(a){varb=this._readableState;returng(this,b,a,"",!0)},f.prototype.isPaused=function(){returnthis._readableState.flowing===!1},f.prototype.setEncoding=function(b){returnK||(K=a("string_decoder/").StringDecoder),this._readableState.decoder=newK(b),this._readableState.encoding=b,this};varN=8388608;f.prototype.read=function(a){J("read",a);varb=this._readableState,c=a;if(("number"!=typeofa||a>0)&&(b.emittedReadable=!1),0===a&&b.needReadable&&(b.length>=b.highWaterMark||b.ended))returnJ("read: emitReadable",b.length,b.ended),0===b.length&&b.ended?w(this):m(this),null;if(a=j(a,b),0===a&&b.ended)return0===b.length&&w(this),null;vard=b.needReadable;J("need readable",d),(0===b.length||b.length-a<b.highWaterMark)&&(d=!0,J("length less than watermark",d)),(b.ended||b.reading)&&(d=!1,J("reading or ended",d)),d&&(J("do read"),b.reading=!0,b.sync=!0,0===b.length&&(b.needReadable=!0),this._read(b.highWaterMark),b.sync=!1),d&&!b.reading&&(a=j(c,