/** * BitcoinJS-lib v0.1.0-default * Copyright (c) 2011 BitcoinJS Project * * This program is free software; you can redistribute it and/or modify * it under the terms of the MIT license. */ (function(){var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=window.Crypto={},c=b.util={rotl:function(a,b){return a<>>32-b},rotr:function(a,b){return a<<32-b|a>>>b},endian:function(a){if(a.constructor==Number)return c.rotl(a,8)&16711935|c.rotl(a,24)&4278255360;for(var b=0;b0;a--)b.push(Math.floor(Math.random()*256));return b},bytesToWords:function(a){for(var b=[],c=0,d=0;c>>5]|=a[c]<<24-d%32;return b},wordsToBytes:function(a){for(var b=[],c=0;c>>5]>>>24-c%32&255);return b},bytesToHex:function(a){for(var b=[],c=0;c>>4).toString(16)),b.push((a[c]&15).toString(16));return b.join("")},hexToBytes:function(a){for(var b=[],c=0;cb.length*8?c.push("="):c.push(a.charAt(e>>>6*(3-g)&63))}return c.join("")},base64ToBytes:function(b){if(typeof atob=="function")return f.stringToBytes(atob(b));b=b.replace(/[^A-Z0-9+\/]/ig,"");for(var c=[],d=0,e=0;d>>6-e*2)}return c}};b.mode={};var d=b.charenc={},e=d.UTF8={stringToBytes:function(a){return f.stringToBytes(unescape(encodeURIComponent(a)))},bytesToString:function(a){return decodeURIComponent(escape(f.bytesToString(a)))}},f=d.Binary={stringToBytes:function(a){for(var b=[],c=0;c>5]|=128<<24-e%32,c[(e+64>>9<<4)+15]=e;for(var q=0;q>>7)^(u<<14|u>>>18)^u>>>3,x=(v<<15|v>>>17)^(v<<13|v>>>19)^v>>>10;h[r]=w+(h[r-7]>>>0)+x+(h[r-16]>>>0)}var y=m&n^~m&o,z=i&j^i&k^j&k,A=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),B=(m<<26|m>>>6)^(m<<21|m>>>11)^(m<<7|m>>>25);s=(p>>>0)+B+y+f[r]+(h[r]>>>0),t=A+z,p=o,o=n,n=m,m=l+s,l=k,k=j,j=i,i=s+t}g[0]+=i,g[1]+=j,g[2]+=k,g[3]+=l,g[4]+=m,g[5]+=n,g[6]+=o,g[7]+=p}return g},g._blocksize=16})() (function(){function g(a,b,c,d){return 0>a||a>15?16>a||a>31?32>a||a>47?48>a||a>63?64>a||a>79?"rmd160_f: j out of range":b^(c|~d):b&d|c&~d:(b|~c)^d:b&c|~b&d:b^c^d}function h(a){return 0>a||a>15?16>a||a>31?32>a||a>47?48>a||a>63?64>a||a>79?"rmd160_K1: j out of range":2840853838:2400959708:1859775393:1518500249:0}function i(a){return 0>a||a>15?16>a||a>31?32>a||a>47?48>a||a>63?64>a||a>79?"rmd160_K2: j out of range":0:2053994217:1836072691:1548603684:1352829926}function n(a,b){var c=(a&65535)+(b&65535),d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535}function o(a,b){return a<>>32-b}var a=Crypto,b=a.util,c=a.charenc,d=c.UTF8,e=c.Binary;b.bytesToLWords=function(a){var b=Array(a.length>>2);for(var c=0;c>5]|=(a[c/8]&255)<>5]>>>c%32&255);return b};var f=a.RIPEMD160=function(a,c){var d=b.lWordsToBytes(f._rmd160(a));return c&&c.asBytes?d:c&&c.asString?e.bytesToString(d):b.bytesToHex(d)};f._rmd160=function(a){a.constructor==String&&(a=d.stringToBytes(a));var c=b.bytesToLWords(a),e=a.length*8;c[e>>5]|=128<>>9<<4)+14]=e;var f=1732584193,p=4023233417,q=2562383102,r=271733878,s=3285377520;for(var t=0;t>8&255,rng_pool[rng_pptr++]^=a>>16&255,rng_pool[rng_pptr++]^=a>>24&255,rng_pptr>=rng_psize&&(rng_pptr-=rng_psize)}function rng_seed_time(){rng_seed_int((new Date).getTime())}function rng_get_byte(){if(rng_state==null){rng_seed_time(),rng_state=prng_newstate(),rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr>>8,rng_pool[rng_pptr++]=t&255;rng_pptr=0,rng_seed_time()}SecureRandom.prototype.nextBytes=rng_get_bytes function BigInteger(a,b,c){a!=null&&("number"==typeof a?this.fromNumber(a,b,c):b==null&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function nbi(){return new BigInteger(null)}function am1(a,b,c,d,e,f){while(--f>=0){var g=b*this[a++]+c[d]+e;e=Math.floor(g/67108864),c[d++]=g&67108863}return e}function am2(a,b,c,d,e,f){var g=b&32767,h=b>>15;while(--f>=0){var i=this[a]&32767,j=this[a++]>>15,k=h*i+j*g;i=g*i+((k&32767)<<15)+c[d]+(e&1073741823),e=(i>>>30)+(k>>>15)+h*j+(e>>>30),c[d++]=i&1073741823}return e}function am3(a,b,c,d,e,f){var g=b&16383,h=b>>14;while(--f>=0){var i=this[a]&16383,j=this[a++]>>14,k=h*i+j*g;i=g*i+((k&16383)<<14)+c[d]+e,e=(i>>28)+(k>>14)+h*j,c[d++]=i&268435455}return e}function int2char(a){return BI_RM.charAt(a)}function intAt(a,b){var c=BI_RC[a.charCodeAt(b)];return c==null?-1:c}function bnpCopyTo(a){for(var b=this.t-1;b>=0;--b)a[b]=this[b];a.t=this.t,a.s=this.s}function bnpFromInt(a){this.t=1,this.s=a<0?-1:0,a>0?this[0]=a:a<-1?this[0]=a+DV:this.t=0}function nbv(a){var b=nbi();return b.fromInt(a),b}function bnpFromString(a,b){var c;if(b==16)c=4;else if(b==8)c=3;else if(b==256)c=8;else if(b==2)c=1;else if(b==32)c=5;else if(b==4)c=2;else{this.fromRadix(a,b);return}this.t=0,this.s=0;var d=a.length,e=!1,f=0;while(--d>=0){var g=c==8?a[d]&255:intAt(a,d);if(g<0){a.charAt(d)=="-"&&(e=!0);continue}e=!1,f==0?this[this.t++]=g:f+c>this.DB?(this[this.t-1]|=(g&(1<>this.DB-f):this[this.t-1]|=g<=this.DB&&(f-=this.DB)}c==8&&(a[0]&128)!=0&&(this.s=-1,f>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==a)--this.t}function bnToString(a){if(this.s<0)return"-"+this.negate().toString(a);var b;if(a==16)b=4;else if(a==8)b=3;else if(a==2)b=1;else if(a==32)b=5;else if(a==4)b=2;else return this.toRadix(a);var c=(1<0){h>h)>0&&(e=!0,f=int2char(d));while(g>=0)h>(h+=this.DB-b)):(d=this[g]>>(h-=b)&c,h<=0&&(h+=this.DB,--g)),d>0&&(e=!0),e&&(f+=int2char(d))}return e?f:"0"}function bnNegate(){var a=nbi();return BigInteger.ZERO.subTo(this,a),a}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(a){var b=this.s-a.s;if(b!=0)return b;var c=this.t;b=c-a.t;if(b!=0)return b;while(--c>=0)if((b=this[c]-a[c])!=0)return b;return 0}function nbits(a){var b=1,c;return(c=a>>>16)!=0&&(a=c,b+=16),(c=a>>8)!=0&&(a=c,b+=8),(c=a>>4)!=0&&(a=c,b+=4),(c=a>>2)!=0&&(a=c,b+=2),(c=a>>1)!=0&&(a=c,b+=1),b}function bnBitLength(){return this.t>0?this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM):0}function bnpDLShiftTo(a,b){var c;for(c=this.t-1;c>=0;--c)b[c+a]=this[c];for(c=a-1;c>=0;--c)b[c]=0;b.t=this.t+a,b.s=this.s}function bnpDRShiftTo(a,b){for(var c=a;c=0;--h)b[h+f+1]=this[h]>>d|g,g=(this[h]&e)<=0;--h)b[h]=0;b[f]=g,b.t=this.t+f+1,b.s=this.s,b.clamp()}function bnpRShiftTo(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t){b.t=0;return}var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;d>0&&(b[this.t-c-1]|=(this.s&f)<>=this.DB;if(a.t>=this.DB;d+=this.s}else{d+=this.s;while(c>=this.DB;d-=a.s}b.s=d<0?-1:0,d<-1?b[c++]=this.DV+d:d>0&&(b[c++]=d),b.t=c,b.clamp()}function bnpMultiplyTo(a,b){var c=this.abs(),d=a.abs(),e=c.t;b.t=e+d.t;while(--e>=0)b[e]=0;for(e=0;e=0)a[c]=0;for(c=0;c=b.DV&&(a[c+b.t]-=b.DV,a[c+b.t+1]=1)}a.t>0&&(a[a.t-1]+=b.am(c,b[c],a,2*c,0,1)),a.s=0,a.clamp()}function bnpDivRemTo(a,b,c){var d=a.abs();if(d.t<=0)return;var e=this.abs();if(e.t0?(d.lShiftTo(i,f),e.lShiftTo(i,c)):(d.copyTo(f),e.copyTo(c));var j=f.t,k=f[j-1];if(k==0)return;var l=k*(1<1?f[j-2]>>this.F2:0),m=this.FV/l,n=(1<=0&&(c[c.t++]=1,c.subTo(r,c)),BigInteger.ONE.dlShiftTo(j,r),r.subTo(f,f);while(f.t=0){var s=c[--p]==k?this.DM:Math.floor(c[p]*m+(c[p-1]+o)*n);if((c[p]+=f.am(0,s,c,q,0,j))0&&c.rShiftTo(i,c),g<0&&BigInteger.ZERO.subTo(c,c)}function bnMod(a){var b=nbi();return this.abs().divRemTo(a,null,b),this.s<0&&b.compareTo(BigInteger.ZERO)>0&&a.subTo(b,b),b}function Classic(a){this.m=a}function cConvert(a){return a.s<0||a.compareTo(this.m)>=0?a.mod(this.m):a}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function cSqrTo(a,b){a.squareTo(b),this.reduce(b)}function bnpInvDigit(){if(this.t<1)return 0;var a=this[0];if((a&1)==0)return 0;var b=a&3;return b=b*(2-(a&15)*b)&15,b=b*(2-(a&255)*b)&255,b=b*(2-((a&65535)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV,b>0?this.DV-b:-b}function Montgomery(a){this.m=a,this.mp=a.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(b,b),b}function montRevert(a){var b=nbi();return a.copyTo(b),this.reduce(b),b}function montReduce(a){while(a.t<=this.mt2)a[a.t++]=0;for(var b=0;b>15)*this.mpl&this.um)<<15)&a.DM;c=b+this.m.t,a[c]+=this.m.am(0,d,a,b,0,this.m.t);while(a[c]>=a.DV)a[c]-=a.DV,a[++c]++}a.clamp(),a.drShiftTo(this.m.t,a),a.compareTo(this.m)>=0&&a.subTo(this.m,a)}function montSqrTo(a,b){a.squareTo(b),this.reduce(b)}function montMulTo(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function bnpIsEven(){return(this.t>0?this[0]&1:this.s)==0}function bnpExp(a,b){if(a>4294967295||a<1)return BigInteger.ONE;var c=nbi(),d=nbi(),e=b.convert(this),f=nbits(a)-1;e.copyTo(c);while(--f>=0){b.sqrTo(c,d);if((a&1<0)b.mulTo(d,e,c);else{var g=c;c=d,d=g}}return b.revert(c)}function bnModPowInt(a,b){var c;return a<256||b.isEven()?c=new Classic(b):c=new Montgomery(b),this.exp(a,c)}var dbits,canary=0xdeadbeefcafe,j_lm=(canary&16777215)==15715070;j_lm&&navigator.appName=="Microsoft Internet Explorer"?(BigInteger.prototype.am=am2,dbits=30):j_lm&&navigator.appName!="Netscape"?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<>24}function bnShortValue(){return this.t==0?this.s:this[0]<<16>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function bnpToRadix(a){a==null&&(a=10);if(this.signum()==0||a<2||a>36)return"0";var b=this.chunkSize(a),c=Math.pow(a,b),d=nbv(c),e=nbi(),f=nbi(),g="";this.divRemTo(d,e,f);while(e.signum()>0)g=(c+f.intValue()).toString(a).substr(1)+g,e.divRemTo(d,e,f);return f.intValue().toString(a)+g}function bnpFromRadix(a,b){this.fromInt(0),b==null&&(b=10);var c=this.chunkSize(b),d=Math.pow(b,c),e=!1,f=0,g=0;for(var h=0;h=c&&(this.dMultiply(d),this.dAddOffset(g,0),f=0,g=0)}f>0&&(this.dMultiply(Math.pow(b,f)),this.dAddOffset(g,0)),e&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(a,b,c){if("number"==typeof b)if(a<2)this.fromInt(1);else{this.fromNumber(a,c),this.testBit(a-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);while(!this.isProbablePrime(b))this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(BigInteger.ONE.shiftLeft(a-1),this)}else{var d=new Array,e=a&7;d.length=(a>>3)+1,b.nextBytes(d),e>0?d[0]&=(1<0){c>c)!=(this.s&this.DM)>>c&&(b[e++]=d|this.s<=0){c<8?(d=(this[a]&(1<>(c+=this.DB-8)):(d=this[a]>>(c-=8)&255,c<=0&&(c+=this.DB,--a)),(d&128)!=0&&(d|=-256),e==0&&(this.s&128)!=(d&128)&&++e;if(e>0||d!=this.s)b[e++]=d}}return b}function bnEquals(a){return this.compareTo(a)==0}function bnMin(a){return this.compareTo(a)<0?this:a}function bnMax(a){return this.compareTo(a)>0?this:a}function bnpBitwiseTo(a,b,c){var d,e,f=Math.min(a.t,this.t);for(d=0;d>=16,b+=16),(a&255)==0&&(a>>=8,b+=8),(a&15)==0&&(a>>=4,b+=4),(a&3)==0&&(a>>=2,b+=2),(a&1)==0&&++b,b}function bnGetLowestSetBit(){for(var a=0;a>=this.DB;if(a.t>=this.DB;d+=this.s}else{d+=this.s;while(c>=this.DB;d+=a.s}b.s=d<0?-1:0,d>0?b[c++]=d:d<-1&&(b[c++]=this.DV+d),b.t=c,b.clamp()}function bnAdd(a){var b=nbi();return this.addTo(a,b),b}function bnSubtract(a){var b=nbi();return this.subTo(a,b),b}function bnMultiply(a){var b=nbi();return this.multiplyTo(a,b),b}function bnSquare(){var a=nbi();return this.squareTo(a),a}function bnDivide(a){var b=nbi();return this.divRemTo(a,b,null),b}function bnRemainder(a){var b=nbi();return this.divRemTo(a,null,b),b}function bnDivideAndRemainder(a){var b=nbi(),c=nbi();return this.divRemTo(a,b,c),new Array(b,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(a,b){if(a==0)return;while(this.t<=b)this[this.t++]=0;this[b]+=a;while(this[b]>=this.DV)this[b]-=this.DV,++b>=this.t&&(this[this.t++]=0),++this[b]}function NullExp(){}function nNop(a){return a}function nMulTo(a,b,c){a.multiplyTo(b,c)}function nSqrTo(a,b){a.squareTo(b)}function bnPow(a){return this.exp(a,new NullExp)}function bnpMultiplyLowerTo(a,b,c){var d=Math.min(this.t+a.t,b);c.s=0,c.t=d;while(d>0)c[--d]=0;var e;for(e=c.t-this.t;d=0)c[d]=0;for(d=Math.max(b-this.t,0);d2*this.m.t)return a.mod(this.m);if(a.compareTo(this.m)<0)return a;var b=nbi();return a.copyTo(b),this.reduce(b),b}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2),a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0)a.dAddOffset(1,this.m.t+1);a.subTo(this.r2,a);while(a.compareTo(this.m)>=0)a.subTo(this.m,a)}function barrettSqrTo(a,b){a.squareTo(b),this.reduce(b)}function barrettMulTo(a,b,c){a.multiplyTo(b,c),this.reduce(c)}function bnModPow(a,b){var c=a.bitLength(),d,e=nbv(1),f;if(c>0)c<18?d=1:c<48?d=3:c<144?d=4:c<768?d=5:d=6;else return e;c<8?f=new Classic(b):b.isEven()?f=new Barrett(b):f=new Montgomery(b);var g=new Array,h=3,i=d-1,j=(1<1){var k=nbi();f.sqrTo(g[1],k);while(h<=j)g[h]=nbi(),f.mulTo(k,g[h-2],g[h]),h+=2}var l=a.t-1,m,n=!0,o=nbi(),p;c=nbits(a[l])-1;while(l>=0){c0&&(m|=a[l-1]>>this.DB+c-i)):m=a[l]>>c-i&j,h=d;while((m&1)==0)m>>=1,--h;(c-=h)<0&&(c+=this.DB,--l);if(n)g[m].copyTo(e),n=!1;else{while(h>1)f.sqrTo(e,o),f.sqrTo(o,e),h-=2;h>0?f.sqrTo(e,o):(p=e,e=o,o=p),f.mulTo(o,g[m],e)}while(l>=0&&(a[l]&1<0&&(b.rShiftTo(f,b),c.rShiftTo(f,c));while(b.signum()>0)(e=b.getLowestSetBit())>0&&b.rShiftTo(e,b),(e=c.getLowestSetBit())>0&&c.rShiftTo(e,c),b.compareTo(c)<0?(c.subTo(b,c),c.rShiftTo(1,c)):(b.subTo(c,b),b.rShiftTo(1,b));return f>0&&c.lShiftTo(f,c),c}function bnpModInt(a){if(a>0){var b=this.DV%a,c=this.s<0?a-1:0;if(this.t>0)if(b==0)c=this[0]%a;else for(var d=this.t-1;d>=0;--d)c=(b*c+this[d])%a;return c}return 0}function bnModInverse(a){var b=a.isEven();if(this.isEven()&&b||a.signum()==0)return BigInteger.ZERO;var c=a.clone(),d=this.clone(),e=nbv(1),f=nbv(0),g=nbv(0),h=nbv(1);while(c.signum()!=0){while(c.isEven()){c.rShiftTo(1,c);if(b){if(!e.isEven()||!f.isEven())e.addTo(this,e),f.subTo(a,f);e.rShiftTo(1,e)}else f.isEven()||f.subTo(a,f);f.rShiftTo(1,f)}while(d.isEven()){d.rShiftTo(1,d);if(b){if(!g.isEven()||!h.isEven())g.addTo(this,g),h.subTo(a,h);g.rShiftTo(1,g)}else h.isEven()||h.subTo(a,h);h.rShiftTo(1,h)}c.compareTo(d)<0?(d.subTo(c,d),b&&g.subTo(e,g),h.subTo(f,h)):(c.subTo(d,c),b&&e.subTo(g,e),f.subTo(h,f))}if(d.compareTo(BigInteger.ONE)!=0)return BigInteger.ZERO;if(h.compareTo(a)<0){if(h.signum()<0)h.addTo(a,h);else return h;return h.signum()<0?h.add(a):h}return h.subtract(a)}function bnIsProbablePrime(a){var b,c=this.abs();if(c.t!=1||c[0]>lowprimes[lowprimes.length-1]){if(c.isEven())return!1;b=1;while(b0){var d=b.shiftRight(c);a=a+1>>1,a>lowprimes.length&&(a=lowprimes.length);var e=nbi();for(var f=0;f0;--f){e=e.twice();var g=c.testBit(f),h=b.testBit(f);g!=h&&(e=e.add(g?this:d))}return e}function pointFpMultiplyTwo(a,b,c){var d;a.bitLength()>c.bitLength()?d=a.bitLength()-1:d=c.bitLength()-1;var e=this.curve.getInfinity(),f=this.add(b);while(d>=0)e=e.twice(),a.testBit(d)?c.testBit(d)?e=e.add(f):e=e.add(this):c.testBit(d)&&(e=e.add(b)),--d;return e}function ECCurveFp(a,b,c){this.q=a,this.a=this.fromBigInteger(b),this.b=this.fromBigInteger(c),this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(a){return a==this?!0:this.q.equals(a.q)&&this.a.equals(a.a)&&this.b.equals(a.b)}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(a){return new ECFieldElementFp(this.q,a)}function curveFpDecodePointHex(a){switch(parseInt(a.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var b=(a.length-2)/2,c=a.substr(2,b),d=a.substr(b+2,b);return new ECPointFp(this,this.fromBigInteger(new BigInteger(c,16)),this.fromBigInteger(new BigInteger(d,16)));default:return null}}ECFieldElementFp.prototype.equals=feFpEquals,ECFieldElementFp.prototype.toBigInteger=feFpToBigInteger,ECFieldElementFp.prototype.negate=feFpNegate,ECFieldElementFp.prototype.add=feFpAdd,ECFieldElementFp.prototype.subtract=feFpSubtract,ECFieldElementFp.prototype.multiply=feFpMultiply,ECFieldElementFp.prototype.square=feFpSquare,ECFieldElementFp.prototype.divide=feFpDivide,ECPointFp.prototype.getX=pointFpGetX,ECPointFp.prototype.getY=pointFpGetY,ECPointFp.prototype.equals=pointFpEquals,ECPointFp.prototype.isInfinity=pointFpIsInfinity,ECPointFp.prototype.negate=pointFpNegate,ECPointFp.prototype.add=pointFpAdd,ECPointFp.prototype.twice=pointFpTwice,ECPointFp.prototype.multiply=pointFpMultiply,ECPointFp.prototype.multiplyTwo=pointFpMultiplyTwo,ECCurveFp.prototype.getQ=curveFpGetQ,ECCurveFp.prototype.getA=curveFpGetA,ECCurveFp.prototype.getB=curveFpGetB,ECCurveFp.prototype.equals=curveFpEquals,ECCurveFp.prototype.getInfinity=curveFpGetInfinity,ECCurveFp.prototype.fromBigInteger=curveFpFromBigInteger,ECCurveFp.prototype.decodePointHex=curveFpDecodePointHex function X9ECParameters(a,b,c,d){this.curve=a,this.g=b,this.n=c,this.h=d}function x9getCurve(){return this.curve}function x9getG(){return this.g}function x9getN(){return this.n}function x9getH(){return this.h}function fromHex(a){return new BigInteger(a,16)}function secp128r1(){var a=fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF"),b=fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC"),c=fromHex("E87579C11079F43DD824993C2CEE5ED3"),d=fromHex("FFFFFFFE0000000075A30D1B9038A115"),e=BigInteger.ONE,f=new ECCurveFp(a,b,c),g=f.decodePointHex("04161FF7528B899B2D0C28607CA52C5B86CF5AC8395BAFEB13C02DA292DDED7A83");return new X9ECParameters(f,g,d,e)}function secp160k1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73"),b=BigInteger.ZERO,c=fromHex("7"),d=fromHex("0100000000000000000001B8FA16DFAB9ACA16B6B3"),e=BigInteger.ONE,f=new ECCurveFp(a,b,c),g=f.decodePointHex("043B4C382CE37AA192A4019E763036F4F5DD4D7EBB938CF935318FDCED6BC28286531733C3F03C4FEE");return new X9ECParameters(f,g,d,e)}function secp160r1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF"),b=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC"),c=fromHex("1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45"),d=fromHex("0100000000000000000001F4C8F927AED3CA752257"),e=BigInteger.ONE,f=new ECCurveFp(a,b,c),g=f.decodePointHex("044A96B5688EF573284664698968C38BB913CBFC8223A628553168947D59DCC912042351377AC5FB32");return new X9ECParameters(f,g,d,e)}function secp192k1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37"),b=BigInteger.ZERO,c=fromHex("3"),d=fromHex("FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D"),e=BigInteger.ONE,f=new ECCurveFp(a,b,c),g=f.decodePointHex("04DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D");return new X9ECParameters(f,g,d,e)}function secp192r1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"),b=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC"),c=fromHex("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1"),d=fromHex("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831"),e=BigInteger.ONE,f=new ECCurveFp(a,b,c),g=f.decodePointHex("04188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF101207192B95FFC8DA78631011ED6B24CDD573F977A11E794811");return new X9ECParameters(f,g,d,e)}function secp224r1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001"),b=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE"),c=fromHex("B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4"),d=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D"),e=BigInteger.ONE,f=new ECCurveFp(a,b,c),g=f.decodePointHex("04B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34");return new X9ECParameters(f,g,d,e)}function secp256k1(){var a=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"),b=BigInteger.ZERO,c=fromHex("7"),d=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"),e=BigInteger.ONE,f=new ECCurveFp(a,b,c),g=f.decodePointHex("0479BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8");return new X9ECParameters(f,g,d,e)}function secp256r1(){var a=fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF"),b=fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC"),c=fromHex("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B"),d=fromHex("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551"),e=BigInteger.ONE,f=new ECCurveFp(a,b,c),g=f.decodePointHex("046B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C2964FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5");return new X9ECParameters(f,g,d,e)}function getSECCurveByName(a){return a=="secp128r1"?secp128r1():a=="secp160k1"?secp160k1():a=="secp160r1"?secp160r1():a=="secp192k1"?secp192k1():a=="secp192r1"?secp192r1():a=="secp224r1"?secp224r1():a=="secp256k1"?secp256k1():a=="secp256r1"?secp256r1():null}X9ECParameters.prototype.getCurve=x9getCurve,X9ECParameters.prototype.getG=x9getG,X9ECParameters.prototype.getN=x9getN,X9ECParameters.prototype.getH=x9getH var EventEmitter=function(){};EventEmitter.prototype.on=function(a,b,c){c||(c=this),this._listeners||(this._listeners={}),this._listeners[a]||(this._listeners[a]=[]),this._unbinders||(this._unbinders={}),this._unbinders[a]||(this._unbinders[a]=[]);var d=function(a){b.apply(c,[a])};this._unbinders[a].push(b),this._listeners[a].push(d)},EventEmitter.prototype.trigger=function(a,b){b===undefined&&(b={}),this._listeners||(this._listeners={});if(!this._listeners[a])return;var c=this._listeners[a].length;while(c--)this._listeners[a][c](b)},EventEmitter.prototype.removeListener=function(a,b){this._unbinders||(this._unbinders={});if(!this._unbinders[a])return;var c=this._unbinders[a].length;while(c--)this._unbinders[a][c]===b&&(this._unbinders[a].splice(c,1),this._listeners[a].splice(c,1))},EventEmitter.augment=function(a){for(var b in EventEmitter.prototype)a[b]||(a[b]=EventEmitter.prototype[b])} function makeKeypair(){var a=ecparams.getN(),b=a.subtract(BigInteger.ONE),c=new BigInteger(a.bitLength(),rng),d=c.mod(b).add(BigInteger.ONE),e=ecparams.getG(),f=e.multiply(d);return{priv:d,pubkey:f}}function serializeTransaction(a){var b=[];b=b.concat(Crypto.util.wordsToBytes([parseInt(a.version)])),b=b.concat(numToVarInt(a.ins.length));for(var c=0;c65536?a>1?[255].concat(Crypto.util.wordsToBytes([a>>>32,a])):[254].concat(Crypto.util.wordsToBytes([a])):[253,a>>>8,a&255]}var Bitcoin={},OP_CODESEPARATOR=171,SIGHASH_ALL=1,SIGHASH_NONE=2,SIGHASH_SINGLE=3,SIGHASH_ANYONECANPAY=80,testTx={version:"1",lock_time:"0",block:{hash:"N/A",height:115806},index:6,hash:"WUFzjKubG1kqfJWMb4qZdlhU2F3l5NGXN7AUg8Jwl14=",ins:[{outpoint:{hash:"nqcbMM1oRhfLdZga11q7x0CpUMujm+vtxHXO9V0gnwE=",index:0},script:"RzBEAiB2XXkx1pca9SlfCmCGNUVf+h2sAFBttcxG1VnypIcvEgIgXrOp7LSdYBYp3nPsQAz8BOLD3K4pAlXfZImP1rkzk2EBQQRi7NcODzNfnVqLtG79Axp5UF6EhFIhCmzqKqssfKpfCIOmzCuXEeDFUFvFzeGLJx5N+wp2qRS1TqYezGD3yERk",sequence:4294967295}],outs:[{value:"3000000000",script:"dqkUBLZwqhAPRVgZvwI8MN5gLHbU8NOIrA=="},{value:"25937000000",script:"dqkUQ82gJ0O5vOBg6yK5/yorLLV5zLKIrA=="}]} BigInteger.valueOf=nbv,BigInteger.prototype.toByteArrayUnsigned=function(){var a=this.toByteArray();return a.length?(a[0]==0&&(a=a.slice(1)),a.map(function(a){return a<0?a+256:a})):a},BigInteger.fromByteArrayUnsigned=function(a){return a.length?a[0]&128?new BigInteger([0].concat(a)):new BigInteger(a):a.valueOf(0)};var names=["log","debug","info","warn","error","assert","dir","dirxml","group","groupEnd","time","timeEnd","count","trace","profile","profileEnd"];"undefined"==typeof window.console&&(window.console={});for(var i=0;i65536?a>1?[255].concat(Crypto.util.wordsToBytes([a>>>32,a])):[254].concat(Crypto.util.wordsToBytes([a])):[253,a>>>8,a&255]},valueToBigInt:function(a){return a instanceof BigInteger?a:BigInteger.fromByteArrayUnsigned(a)},formatValue:function(a){var b=this.valueToBigInt(a).toString(),c=b.length>8?b.substr(0,b.length-8):"0",d=b.length>8?b.substr(b.length-8):b;while(d.length<8)d="0"+d;d=d.replace(/0*$/,"");while(d.length<2)d+="0";return c+"."+d},parseValue:function(a){var b=a.split("."),c=b[0],d=b[1]||"0";while(d.length<8)d+="0";d=d.replace(/^0+/g,"");var e=BigInteger.valueOf(parseInt(c));return e=e.multiply(BigInteger.valueOf(1e8)),e=e.add(BigInteger.valueOf(parseInt(d))),e},sha256ripe160:function(a){return Crypto.RIPEMD160(Crypto.SHA256(a,{asBytes:!0}),{asBytes:!0})}} (function(){var a=Bitcoin.Base58={alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",base:BigInteger.valueOf(58),encode:function(b){var c=BigInteger.fromByteArrayUnsigned(b),d=[];while(c.compareTo(a.base)>=0){var e=c.mod(a.base);d.unshift(a.alphabet[e.intValue()]),c=c.subtract(e).divide(a.base)}d.unshift(a.alphabet[c.intValue()]);for(var f=0;f=0;d--){var e=a.alphabet.indexOf(b[d]);bi=bi.add(BigInteger.valueOf(e).multiply(a.base.pow(b.length-1-d))),b[d]=="1"?c++:c=0}var f=bi.toByteArrayUnsigned();while(c-->0)f.unshift(0);return f}}})() Bitcoin.Address=function(a){"string"==typeof a&&(a=Bitcoin.Address.decodeString(a)),this.hash=a,this.version=0},Bitcoin.Address.prototype.toString=function(){var a=this.hash.slice(0);a.unshift(this.version);var b=Crypto.SHA256(Crypto.SHA256(a,{asBytes:!0}),{asBytes:!0}),c=a.concat(b.slice(0,4));return Bitcoin.Base58.encode(c)},Bitcoin.Address.prototype.getHashBase64=function(){return Crypto.util.bytesToBase64(this.hash)},Bitcoin.Address.decodeString=function(a){var b=Bitcoin.Base58.decode(a),c=b.slice(0,21),d=Crypto.SHA256(Crypto.SHA256(c,{asBytes:!0}),{asBytes:!0});if(d[0]!=b[21]||d[1]!=b[22]||d[2]!=b[23]||d[3]!=b[24])throw"Checksum validation failed!";var e=c.shift();if(e!=0)throw"Version "+e+" not supported!";return c} function integerToBytes(a,b){var c=a.toByteArrayUnsigned();if(bc.length)c.unshift(0);return c}function dmp(a){return a instanceof BigInteger||(a=a.toBigInteger()),Crypto.util.bytesToHex(a.toByteArrayUnsigned())}ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ECPointFp.prototype.getEncoded=function(a){var b=this.getX().toBigInteger(),c=this.getY().toBigInteger();if(a)var d;var e=this.getX().getByteLength(),f=integerToBytes(b,e);return a?c.testBit(0)?f.unshift(2):f.unshift(3):(f.unshift(4),f=f.concat(integerToBytes(c,e))),f},ECPointFp.decodeFrom=function(a,b){var c=b[0],d=b.length-1,e=b.slice(1,1+d/2),f=b.slice(1+d/2,1+d);e.unshift(0),f.unshift(0);var g=new BigInteger(e),h=new BigInteger(f);return new ECPointFp(a,a.fromBigInteger(g),a.fromBigInteger(h))},ECPointFp.prototype.add2D=function(a){if(this.isInfinity())return a;if(a.isInfinity())return this;if(this.x.equals(a.x))return this.y.equals(a.y)?this.twice():this.curve.getInfinity();var b=a.x.subtract(this.x),c=a.y.subtract(this.y),d=c.divide(b),e=d.square().subtract(this.x).subtract(a.x),f=d.multiply(this.x.subtract(e)).subtract(this.y);return new ECPointFp(this.curve,e,f)},ECPointFp.prototype.twice2D=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var a=this.curve.fromBigInteger(BigInteger.valueOf(2)),b=this.curve.fromBigInteger(BigInteger.valueOf(3)),c=this.x.square().multiply(b).add(this.curve.a).divide(this.y.multiply(a)),d=c.square().subtract(this.x.multiply(a)),e=c.multiply(this.x.subtract(d)).subtract(this.y);return new ECPointFp(this.curve,d,e)},ECPointFp.prototype.multiply2D=function(a){if(this.isInfinity())return this;if(a.signum()==0)return this.curve.getInfinity();var b=a,c=b.multiply(new BigInteger("3")),d=this.negate(),e=this,f;for(f=c.bitLength()-2;f>0;--f){e=e.twice();var g=c.testBit(f),h=b.testBit(f);g!=h&&(e=e.add2D(g?this:d))}return e},ECPointFp.prototype.isOnCurve=function(){var a=this.getX().toBigInteger(),b=this.getY().toBigInteger(),c=this.curve.getA().toBigInteger(),d=this.curve.getB().toBigInteger(),e=this.curve.getQ(),f=b.multiply(b).mod(e),g=a.multiply(a).multiply(a).add(c.multiply(a)).add(d).mod(e);return f.equals(g)},ECPointFp.prototype.validate=function(){var a=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var b=this.getX().toBigInteger(),c=this.getY().toBigInteger();if(b.compareTo(BigInteger.ONE)<0||b.compareTo(a.subtract(BigInteger.ONE))>0)throw new Error("x coordinate out of bounds");if(c.compareTo(BigInteger.ONE)<0||c.compareTo(a.subtract(BigInteger.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(a).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0},Bitcoin.ECDSA=function(){function c(a,b,c,d){var e=Math.max(b.bitLength(),d.bitLength()),f=a.add2D(c),g=a.curve.getInfinity();for(var h=e-1;h>=0;--h)g=g.twice2D(),g.z=BigInteger.ONE,b.testBit(h)?d.testBit(h)?g=g.add2D(f):g=g.add2D(a):d.testBit(h)&&(g=g.add2D(c));return g}var a=getSECCurveByName("secp256k1"),b=new SecureRandom,d={getBigRandom:function(a){return(new BigInteger(a.bitLength(),b)).mod(a.subtract(BigInteger.ONE)).add(BigInteger.ONE)},sign:function(b,c){var e=c,f=a.getN(),g=BigInteger.fromByteArrayUnsigned(b);do var h=d.getBigRandom(f),i=a.getG(),j=i.multiply(h),k=j.getX().toBigInteger().mod(f);while(k.compareTo(BigInteger.ZERO)<=0);var l=h.modInverse(f).multiply(g.add(e.multiply(k))).mod(f);return d.serializeSig(k,l)},serializeSig:function(a,b){var c=a.toByteArrayUnsigned(),d=b.toByteArrayUnsigned(),e=[];return e.push(2),e.push(c.length),e=e.concat(c),e.push(2),e.push(d.length),e=e.concat(d),e.unshift(e.length),e.unshift(48),e},verify:function(b,e,f){var g=d.parseSig(e),h=g.r,i=g.s,j=a.getN(),k=BigInteger.fromByteArrayUnsigned(b);if(h.compareTo(BigInteger.ONE)<0||h.compareTo(j)>=0)return!1;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(j)>=0)return!1;var l=i.modInverse(j),m=k.multiply(l).mod(j),n=h.multiply(l).mod(j),o=a.getG(),p=ECPointFp.decodeFrom(a.getCurve(),f),q=c(o,m,p,n),r=q.x.toBigInteger().mod(j);return r.equals(h)},parseSig:function(a){var b;if(a[0]!=48)throw new Error("Signature not a valid DERSequence");b=2;if(a[b]!=2)throw new Error("First element in signature must be a DERInteger");var c=a.slice(b+2,b+2+a[b+1]);b+=2+a[b+1];if(a[b]!=2)throw new Error("Second element in signature must be a DERInteger");var d=a.slice(b+2,b+2+a[b+1]);b+=2+a[b+1];var e=BigInteger.fromByteArrayUnsigned(c),f=BigInteger.fromByteArrayUnsigned(d);return{r:e,s:f}}};return d}() Bitcoin.ECKey=function(){var a=Bitcoin.ECDSA,b=getSECCurveByName("secp256k1"),c=new SecureRandom,d=function(c){if(!c){var d=b.getN();this.priv=a.getBigRandom(d)}else c instanceof BigInteger?this.priv=c:Bitcoin.Util.isArray(c)?this.priv=BigInteger.fromByteArrayUnsigned(c):"string"==typeof c&&(this.priv=BigInteger.fromByteArrayUnsigned(Crypto.util.base64ToBytes(c)))};return d.prototype.getPub=function(){return this.pub?this.pub:this.pub=b.getG().multiply(this.priv).getEncoded()},d.prototype.getPubKeyHash=function(){return this.pubKeyHash?this.pubKeyHash:this.pubKeyHash=Bitcoin.Util.sha256ripe160(this.getPub())},d.prototype.getBitcoinAddress=function(){var a=this.getPubKeyHash(),b=new Bitcoin.Address(a);return b},d.prototype.setPub=function(a){this.pub=a},d.prototype.toString=function(a){return a==="base64"?Crypto.util.bytesToBase64(this.priv.toByteArrayUnsigned()):Crypto.util.bytesToHex(this.priv.toByteArrayUnsigned())},d.prototype.sign=function(b){return a.sign(b,this.priv)},d.prototype.verify=function(b,c){return a.verify(b,c,this.getPub())},d}() (function(){var a=Bitcoin.Opcode=function(a){this.code=a};a.prototype.toString=function(){return a.reverseMap[this.code]},a.map={OP_0:0,OP_FALSE:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_1:81,OP_TRUE:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_NOP3:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255},a.reverseMap=[];for(var b in a.map)a.reverseMap[a.map[b]]=b})() (function(){var Opcode=Bitcoin.Opcode;for(var i in Opcode.map)eval("var "+i+" = "+Opcode.map[i]+";");var Script=Bitcoin.Script=function(a){if(!a)this.buffer=[];else if("string"==typeof a)this.buffer=Crypto.util.base64ToBytes(a);else if(Bitcoin.Util.isArray(a))this.buffer=a;else if(a instanceof Script)this.buffer=a.buffer;else throw new Error("Invalid script");this.parse()};Script.prototype.parse=function(){function c(c){a.chunks.push(a.buffer.slice(b,b+c)),b+=c}var a=this;this.chunks=[];var b=0;while(b=240&&(d=d<<8|this.buffer[b++]);var e;d>0&&d255?a.length>65535?(this.buffer.push(OP_PUSHDATA4),this.buffer.push(a.length&255),this.buffer.push(a.length>>>8&255),this.buffer.push(a.length>>>16&255),this.buffer.push(a.length>>>24&255)):(this.buffer.push(OP_PUSHDATA2),this.buffer.push(a.length&255),this.buffer.push(a.length>>>8&255)):(this.buffer.push(OP_PUSHDATA1),this.buffer.push(a.length)),this.buffer=this.buffer.concat(a),this.chunks.push(a)},Script.createOutputScript=function(a){var b=new Script;return b.writeOp(OP_DUP),b.writeOp(OP_HASH160),b.writeBytes(a.hash),b.writeOp(OP_EQUALVERIFY),b.writeOp(OP_CHECKSIG),b},Script.createInputScript=function(a,b){var c=new Script;return c.writeBytes(a),c.writeBytes(b),c},Script.prototype.clone=function(){return new Script(this.buffer)}})() (function(){var a=Bitcoin.Script,b=Bitcoin.Transaction=function(a){this.version=1,this.lock_time=0,this.ins=[],this.outs=[],this.timestamp=null,this.block=null;if(a){a.hash&&(this.hash=a.hash),a.version&&(this.version=a.version),a.lock_time&&(this.lock_time=a.lock_time);if(a.ins&&a.ins.length)for(var b=0;b=0;g--){var h=this.outs[g],i=h.script.simpleOutPubKeyHash();a.hasHash(i)?e=i:c=!1,d=i}for(var g=this.ins.length-1;g>=0;g--){var j=this.ins[g];f=j.script.simpleInPubKeyHash();if(!a.hasHash(f)){b=!1;break}}var k=this.calcImpact(a),l={};return l.impact=k,k.sign>0&&k.value.compareTo(BigInteger.ZERO)>0?(l.type="recv",l.addr=new Bitcoin.Address(e)):b&&c?l.type="self":b?(l.type="sent",l.addr=new Bitcoin.Address(d)):l.type="other",l}return null},b.prototype.getDescription=function(a){var b=this.analyze(a);if(!b)return"";switch(b.type){case"recv":return"Received with "+b.addr;case"sent":return"Payment to "+b.addr;case"self":return"Payment to yourself";case"other":default:return""}},b.prototype.getTotalValue=function(){var a=BigInteger.ZERO;for(var b=0;b=0)break}if(g.compareTo(f)<0)throw new Error("Insufficient funds.");console.log(e);var i=g.subtract(f),j=new Bitcoin.Transaction;for(var h=0;h0&&j.addOutput(this.getNextAddress(),i);var k=1;for(var h=0;h