diff --git a/binding.gyp b/binding.gyp
index 461a047..046a345 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -3,12 +3,6 @@
'node_shared_openssl%': 'true'
},
'targets': [
- {
- 'target_name': 'cryptox',
- 'sources': [
- 'src/pbkdf2_sha512.cc'
- ],
- },
{
'target_name': 'KeyModule',
'sources': [
diff --git a/browser/build.js b/browser/build.js
index 364a986..92268f6 100644
--- a/browser/build.js
+++ b/browser/build.js
@@ -29,7 +29,6 @@ var modules = [
'lib/HierarchicalKey',
'lib/BIP39',
'lib/BIP39WordlistEn',
- 'lib/cryptox',
'lib/Block',
'lib/Bloom',
'lib/Connection',
@@ -81,11 +80,21 @@ var createBitcore = function(opts) {
exec('sh concat.sh', puts);
process.chdir(cwd);
- if (!opts.includeall && (!opts.submodules || opts.submodules.length === 0)) {
- if (!opts.stdout) console.log('Must use either -s or -a option. For more info use the --help option');
+ if (!opts.includeall && !opts.includemain && (!opts.submodules || opts.submodules.length === 0)) {
+ if (!opts.stdout) console.log('Must use either -s or -a or -m option. For more info use the --help option');
process.exit(1);
}
+ var submodules = opts.submodules;
+
+ if (opts.includemain) {
+ submodules = JSON.parse(JSON.stringify(modules));
+ submodules.splice(submodules.indexOf('lib/BIP39'), 1);
+ submodules.splice(submodules.indexOf('lib/BIP39WordlistEn'), 1);
+ var assert = require('assert');
+ assert(submodules.length == modules.length - 2);
+ }
+
if (opts.submodules) {
for (var i = 0; i < opts.submodules.length; i++) {
var sm = opts.submodules[i];
@@ -114,7 +123,7 @@ var createBitcore = function(opts) {
expose: 'bitcore'
});
modules.forEach(function(m) {
- if (opts.includeall || opts.submodules.indexOf(m) > -1) {
+ if (opts.includeall || submodules.indexOf(m) > -1) {
if (!opts.stdout) console.log('Including ' + m + ' in the browser bundle');
b.require('./' + opts.dir + m + '.js', {
expose: './' + m
@@ -158,6 +167,7 @@ if (require.main === module) {
program
.version('0.0.1')
.option('-a, --includeall', 'Include all submodules.')
+ .option('-m, --includemain', 'Include main submodules.')
.option('-d, --dontminify', 'Don\'t minify the code.')
.option('-o, --stdout', 'Specify output as stdout')
.option('-D, --dir
', 'Specify a base directory')
diff --git a/browser/bundle.js b/browser/bundle.js
index 7b89a88..8ef3ec0 100644
--- a/browser/bundle.js
+++ b/browser/bundle.js
@@ -51,11 +51,11 @@ require=
// Override the current require with this new one
return newRequire;
})
-({"tmvhGl":[function(require,module,exports){
-(function(e){var i=function(e,i){Object.defineProperty(module.exports,e,{get:function(){return require(i)}})};i("Bignum","bignum"),Object.defineProperty(module.exports,"bignum",{get:function(){return console.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(){return console.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(){return console.log("BIP32 is deprecated. Use bitcore.HierarchicalKey instead."),require("./lib/HierarchicalKey")}}),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(){return console.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);
-},{"./lib/Base58":"6VqyzY","./lib/HierarchicalKey":"x1O6JW","bignum":58,"bindings":78,"buffer":85}],"bitcore":[function(require,module,exports){
+({"bitcore":[function(require,module,exports){
module.exports=require('tmvhGl');
-},{}],3:[function(require,module,exports){
+},{}],"tmvhGl":[function(require,module,exports){
+(function(e){var i=function(e,i){Object.defineProperty(module.exports,e,{get:function(){return require(i)}})};i("Bignum","bignum"),Object.defineProperty(module.exports,"bignum",{get:function(){return console.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(){return console.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(){return console.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(){return console.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);
+},{"./lib/Base58":"6VqyzY","./lib/HierarchicalKey":"x1O6JW","bignum":58,"bindings":78,"buffer":85}],3:[function(require,module,exports){
function BigInteger(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function nbi(){return new BigInteger(null)}function am1(t,e,r,i,n,o){for(;--o>=0;){var s=e*this[t++]+r[i]+n;n=Math.floor(s/67108864),r[i++]=67108863&s}return n}function am2(t,e,r,i,n,o){for(var s=32767&e,u=e>>15;--o>=0;){var p=32767&this[t],h=this[t++]>>15,a=u*p+h*s;p=s*p+((32767&a)<<15)+r[i]+(1073741823&n),n=(p>>>30)+(a>>>15)+u*h+(n>>>30),r[i++]=1073741823&p}return n}function am3(t,e,r,i,n,o){for(var s=16383&e,u=e>>14;--o>=0;){var p=16383&this[t],h=this[t++]>>14,a=u*p+h*s;p=s*p+((16383&a)<<14)+r[i]+n,n=(p>>28)+(a>>14)+u*h,r[i++]=268435455&p}return n}function int2char(t){return BI_RM.charAt(t)}function intAt(t,e){var r=BI_RC[t.charCodeAt(e)];return null==r?-1:r}function bnpCopyTo(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s}function bnpFromInt(t){this.t=1,this.s=0>t?-1:0,t>0?this[0]=t:-1>t?this[0]=t+DV:this.t=0}function nbv(t){var e=nbi();return e.fromInt(t),e}function bnpFromString(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,n=!1,o=0;--i>=0;){var s=8==r?255&t[i]:intAt(t,i);0>s?"-"==t.charAt(i)&&(n=!0):(n=!1,0==o?this[this.t++]=s:o+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-o):this[this.t-1]|=s<=this.DB&&(o-=this.DB))}8==r&&0!=(128&t[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==t;)--this.t}function bnToString(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<0)for(u>u)>0&&(n=!0,o=int2char(r));s>=0;)e>u?(r=(this[s]&(1<>(u+=this.DB-e)):(r=this[s]>>(u-=e)&i,0>=u&&(u+=this.DB,--s)),r>0&&(n=!0),n&&(o+=int2char(r));return n?o:"0"}function bnNegate(){var t=nbi();return BigInteger.ZERO.subTo(this,t),t}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(e=r-t.t,0!=e)return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0}function nbits(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s}function bnpDRShiftTo(t,e){for(var r=t;r=0;--r)e[r+s+1]=this[r]>>n|u,u=(this[r]&o)<=0;--r)e[r]=0;e[s]=u,e.t=this.t+s+1,e.s=this.s,e.clamp()}function bnpRShiftTo(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)return void(e.t=0);var i=t%this.DB,n=this.DB-i,o=(1<>i;for(var s=r+1;s>i;i>0&&(e[this.t-r-1]|=(this.s&o)<r;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i-=t.s}e.s=0>i?-1:0,-1>i?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()}function bnpMultiplyTo(t,e){var r=this.abs(),i=t.abs(),n=r.t;for(e.t=n+i.t;--n>=0;)e[n]=0;for(n=0;n=0;)t[r]=0;for(r=0;r=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()}function bnpDivRemTo(t,e,r){var i=t.abs();if(!(i.t<=0)){var n=this.abs();if(n.t0?(i.lShiftTo(p,o),n.lShiftTo(p,r)):(i.copyTo(o),n.copyTo(r));var h=o.t,a=o[h-1];if(0!=a){var F=a*(1<1?o[h-2]>>this.F2:0),g=this.FV/F,f=(1<=0&&(r[r.t++]=1,r.subTo(m,r)),BigInteger.ONE.dlShiftTo(h,m),m.subTo(o,o);o.t=0;){var y=r[--l]==a?this.DM:Math.floor(r[l]*g+(r[l-1]+c)*f);if((r[l]+=o.am(0,y,r,B,0,h))0&&r.rShiftTo(p,r),0>s&&BigInteger.ZERO.subTo(r,r)}}}function bnMod(t){var e=nbi();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(BigInteger.ZERO)>0&&t.subTo(e,e),e}function Classic(t){this.m=t}function cConvert(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function cRevert(t){return t}function cReduce(t){t.divRemTo(this.m,null,t)}function cMulTo(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function cSqrTo(t,e){t.squareTo(e),this.reduce(e)}function bnpInvDigit(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return e=e*(2-(15&t)*e)&15,e=e*(2-(255&t)*e)&255,e=e*(2-((65535&t)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function Montgomery(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(e,e),e}function montRevert(t){var e=nbi();return t.copyTo(e),this.reduce(e),e}function montReduce(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t[r]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function montSqrTo(t,e){t.squareTo(e),this.reduce(e)}function montMulTo(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)}function bnpExp(t,e){if(t>4294967295||1>t)return BigInteger.ONE;var r=nbi(),i=nbi(),n=e.convert(this),o=nbits(t)-1;for(n.copyTo(r);--o>=0;)if(e.sqrTo(r,i),(t&1<0)e.mulTo(i,n,r);else{var s=r;r=i,i=s}return e.revert(r)}function bnModPowInt(t,e){var r;return r=256>t||e.isEven()?new Classic(e):new Montgomery(e),this.exp(t,r)}function bnClone(){var t=nbi();return this.copyTo(t),t}function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1}function bnpToRadix(t){if(null==t&&(t=10),0==this.signum()||2>t||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=nbv(r),n=nbi(),o=nbi(),s="";for(this.divRemTo(i,n,o);n.signum()>0;)s=(r+o.intValue()).toString(t).substr(1)+s,n.divRemTo(i,n,o);return o.intValue().toString(t)+s}function bnpFromRadix(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),n=!1,o=0,s=0,u=0;up?"-"==t.charAt(u)&&0==this.signum()&&(n=!0):(s=e*s+p,++o>=r&&(this.dMultiply(i),this.dAddOffset(s,0),o=0,s=0))}o>0&&(this.dMultiply(Math.pow(e,o)),this.dAddOffset(s,0)),n&&BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(t,e,r){if("number"==typeof e)if(2>t)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(t-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(BigInteger.ONE.shiftLeft(t-1),this);else{var i=new Array,n=7&t;i.length=(t>>3)+1,e.nextBytes(i),n>0?i[0]&=(1<0)for(i>i)!=(this.s&this.DM)>>i&&(e[n++]=r|this.s<=0;)8>i?(r=(this[t]&(1<>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,0>=i&&(i+=this.DB,--t)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=r);return e}function bnEquals(t){return 0==this.compareTo(t)}function bnMin(t){return this.compareTo(t)<0?this:t}function bnMax(t){return this.compareTo(t)>0?this:t}function bnpBitwiseTo(t,e,r){var i,n,o=Math.min(t.t,this.t);for(i=0;o>i;++i)r[i]=e(this[i],t[i]);if(t.tt?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function bnShiftRight(t){var e=nbi();return 0>t?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function lbit(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function bnGetLowestSetBit(){for(var t=0;t=this.t?0!=this.s:0!=(this[e]&1<r;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t>=this.DB;i+=this.s}else{for(i+=this.s;r>=this.DB;i+=t.s}e.s=0>i?-1:0,i>0?e[r++]=i:-1>i&&(e[r++]=this.DV+i),e.t=r,e.clamp()}function bnAdd(t){var e=nbi();return this.addTo(t,e),e}function bnSubtract(t){var e=nbi();return this.subTo(t,e),e}function bnMultiply(t){var e=nbi();return this.multiplyTo(t,e),e}function bnSquare(){var t=nbi();return this.squareTo(t),t}function bnDivide(t){var e=nbi();return this.divRemTo(t,e,null),e}function bnRemainder(t){var e=nbi();return this.divRemTo(t,null,e),e}function bnDivideAndRemainder(t){var e=nbi(),r=nbi();return this.divRemTo(t,e,r),new Array(e,r)}function bnpDMultiply(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function bnpDAddOffset(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}}function NullExp(){}function nNop(t){return t}function nMulTo(t,e,r){t.multiplyTo(e,r)}function nSqrTo(t,e){t.squareTo(e)}function bnPow(t){return this.exp(t,new NullExp)}function bnpMultiplyLowerTo(t,e,r){var i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;var n;for(n=r.t-this.t;n>i;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(n=Math.min(t.t,e);n>i;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()}function bnpMultiplyUpperTo(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=nbi();return t.copyTo(e),this.reduce(e),e}function barrettRevert(t){return t}function barrettReduce(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function barrettSqrTo(t,e){t.squareTo(e),this.reduce(e)}function barrettMulTo(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function bnModPow(t,e){var r,i,n=t.bitLength(),o=nbv(1);if(0>=n)return o;r=18>n?1:48>n?3:144>n?4:768>n?5:6,i=8>n?new Classic(e):e.isEven()?new Barrett(e):new Montgomery(e);var s=new Array,u=3,p=r-1,h=(1<1){var a=nbi();for(i.sqrTo(s[1],a);h>=u;)s[u]=nbi(),i.mulTo(a,s[u-2],s[u]),u+=2}var F,g,f=t.t-1,c=!0,l=nbi();for(n=nbits(t[f])-1;f>=0;){for(n>=p?F=t[f]>>n-p&h:(F=(t[f]&(1<0&&(F|=t[f-1]>>this.DB+n-p)),u=r;0==(1&F);)F>>=1,--u;if((n-=u)<0&&(n+=this.DB,--f),c)s[F].copyTo(o),c=!1;else{for(;u>1;)i.sqrTo(o,l),i.sqrTo(l,o),u-=2;u>0?i.sqrTo(o,l):(g=o,o=l,l=g),i.mulTo(l,s[F],o)}for(;f>=0&&0==(t[f]&1<o)return e;for(o>n&&(o=n),o>0&&(e.rShiftTo(o,e),r.rShiftTo(o,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r}function bnpModInt(t){if(0>=t)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r}function bnModInverse(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return BigInteger.ZERO;for(var r=t.clone(),i=this.clone(),n=nbv(1),o=nbv(0),s=nbv(0),u=nbv(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(n.isEven()&&o.isEven()||(n.addTo(this,n),o.subTo(t,o)),n.rShiftTo(1,n)):o.isEven()||o.subTo(t,o),o.rShiftTo(1,o);for(;i.isEven();)i.rShiftTo(1,i),e?(s.isEven()&&u.isEven()||(s.addTo(this,s),u.subTo(t,u)),s.rShiftTo(1,s)):u.isEven()||u.subTo(t,u),u.rShiftTo(1,u);r.compareTo(i)>=0?(r.subTo(i,r),e&&n.subTo(s,n),o.subTo(u,o)):(i.subTo(r,i),e&&s.subTo(n,s),u.subTo(o,u))}return 0!=i.compareTo(BigInteger.ONE)?BigInteger.ZERO:u.compareTo(t)>=0?u.subtract(t):u.signum()<0?(u.addTo(t,u),u.signum()<0?u.add(t):u):u}function bnIsProbablePrime(t){var e,r=this.abs();if(1==r.t&&r[0]<=lowprimes[lowprimes.length-1]){for(e=0;ei;)i*=lowprimes[n++];for(i=r.modInt(i);n>e;)if(i%lowprimes[e++]==0)return!1}return r.millerRabin(t)}function bnpMillerRabin(t){var e=this.subtract(BigInteger.ONE),r=e.getLowestSetBit();if(0>=r)return!1;var i=e.shiftRight(r);t=t+1>>1,t>lowprimes.length&&(t=lowprimes.length);for(var n=nbi(),o=0;t>o;++o){n.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);var s=n.modPow(i,this);if(0!=s.compareTo(BigInteger.ONE)&&0!=s.compareTo(e)){for(var u=1;u++e;++e)this.S[e]=e;for(r=0,e=0;256>e;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0}function ARC4next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]}function prng_newstate(){return new Arcfour}function rng_seed_int(t){rng_pool[rng_pptr++]^=255&t,rng_pool[rng_pptr++]^=t>>8&255,rng_pool[rng_pptr++]^=t>>16&255,rng_pool[rng_pptr++]^=t>>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(null==rng_state){for(rng_seed_time(),rng_state=prng_newstate(),rng_state.init(rng_pool),rng_pptr=0;rng_pptr0;--e){o=o.twice();var s=i.testBit(e),u=r.testBit(e);s!=u&&(o=o.add(s?this:n))}return o}function pointFpMultiplyTwo(t,e,r){var i;i=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var n=this.curve.getInfinity(),o=this.add(e);i>=0;)n=n.twice(),t.testBit(i)?n=n.add(r.testBit(i)?o:this):r.testBit(i)&&(n=n.add(e)),--i;return n}function ECCurveFp(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new ECPointFp(this,null,null)}function curveFpGetQ(){return this.q}function curveFpGetA(){return this.a}function curveFpGetB(){return this.b}function curveFpEquals(t){return t==this?!0:this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)}function curveFpGetInfinity(){return this.infinity}function curveFpFromBigInteger(t){return new ECFieldElementFp(this.q,t)}function curveFpDecodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:return null;case 4:case 6:case 7:var e=(t.length-2)/2,r=t.substr(2,e),i=t.substr(e+2,e);return new ECPointFp(this,this.fromBigInteger(new BigInteger(r,16)),this.fromBigInteger(new BigInteger(i,16)));default:return null}}function X9ECParameters(t,e,r,i){this.curve=t,this.g=e,this.n=r,this.h=i}function x9getCurve(){return this.curve}function x9getG(){return this.g}function x9getN(){return this.n}function x9getH(){return this.h}function fromHex(t){return new BigInteger(t,16)}function secp128r1(){var t=fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF"),e=fromHex("FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC"),r=fromHex("E87579C11079F43DD824993C2CEE5ED3"),i=fromHex("FFFFFFFE0000000075A30D1B9038A115"),n=BigInteger.ONE,o=new ECCurveFp(t,e,r),s=o.decodePointHex("04161FF7528B899B2D0C28607CA52C5B86CF5AC8395BAFEB13C02DA292DDED7A83");return new X9ECParameters(o,s,i,n)}function secp160k1(){var t=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73"),e=BigInteger.ZERO,r=fromHex("7"),i=fromHex("0100000000000000000001B8FA16DFAB9ACA16B6B3"),n=BigInteger.ONE,o=new ECCurveFp(t,e,r),s=o.decodePointHex("043B4C382CE37AA192A4019E763036F4F5DD4D7EBB938CF935318FDCED6BC28286531733C3F03C4FEE");return new X9ECParameters(o,s,i,n)}function secp160r1(){var t=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF"),e=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC"),r=fromHex("1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45"),i=fromHex("0100000000000000000001F4C8F927AED3CA752257"),n=BigInteger.ONE,o=new ECCurveFp(t,e,r),s=o.decodePointHex("044A96B5688EF573284664698968C38BB913CBFC8223A628553168947D59DCC912042351377AC5FB32");return new X9ECParameters(o,s,i,n)}function secp192k1(){var t=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37"),e=BigInteger.ZERO,r=fromHex("3"),i=fromHex("FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D"),n=BigInteger.ONE,o=new ECCurveFp(t,e,r),s=o.decodePointHex("04DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D");return new X9ECParameters(o,s,i,n)}function secp192r1(){var t=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"),e=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC"),r=fromHex("64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1"),i=fromHex("FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831"),n=BigInteger.ONE,o=new ECCurveFp(t,e,r),s=o.decodePointHex("04188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF101207192B95FFC8DA78631011ED6B24CDD573F977A11E794811");return new X9ECParameters(o,s,i,n)}function secp224r1(){var t=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001"),e=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE"),r=fromHex("B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4"),i=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D"),n=BigInteger.ONE,o=new ECCurveFp(t,e,r),s=o.decodePointHex("04B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34");return new X9ECParameters(o,s,i,n)}function secp256k1(){var t=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"),e=BigInteger.ZERO,r=fromHex("7"),i=fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"),n=BigInteger.ONE,o=new ECCurveFp(t,e,r),s=o.decodePointHex("0479BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8");return new X9ECParameters(o,s,i,n)}function secp256r1(){var t=fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF"),e=fromHex("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC"),r=fromHex("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B"),i=fromHex("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551"),n=BigInteger.ONE,o=new ECCurveFp(t,e,r),s=o.decodePointHex("046B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C2964FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5");return new X9ECParameters(o,s,i,n)}function getSECCurveByName(t){return"secp128r1"==t?secp128r1():"secp160k1"==t?secp160k1():"secp160r1"==t?secp160r1():"secp192k1"==t?secp192k1():"secp192r1"==t?secp192r1():"secp224r1"==t?secp224r1():"secp256k1"==t?secp256k1():"secp256r1"==t?secp256r1():null}function integerToBytes(t,e){var r=t.toByteArrayUnsigned();if(er.length;)r.unshift(0);return r}function dmp(t){return t instanceof BigInteger||(t=t.toBigInteger()),Crypto.util.bytesToHex(t.toByteArrayUnsigned())}if("undefined"==typeof window&&(window=this),Bitcoin={},"undefined"==typeof navigator){var navigator={};navigator.appName="NodeJS"}var base64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Crypto=window.Crypto={},util=Crypto.util={rotl:function(t,e){return t<>>32-e},rotr:function(t,e){return t<<32-e|t>>>e},endian:function(t){if(t.constructor==Number)return 16711935&util.rotl(t,8)|4278255360&util.rotl(t,24);for(var e=0;e0;t--)e.push(Math.floor(256*Math.random()));return e},bytesToWords:function(t){for(var e=[],r=0,i=0;r>>5]|=t[r]<<24-i%32;return e},wordsToBytes:function(t){for(var e=[],r=0;r<32*t.length;r+=8)e.push(t[r>>>5]>>>24-r%32&255);return e},bytesToHex:function(t){for(var e=[],r=0;r>>4).toString(16)),e.push((15&t[r]).toString(16));return e.join("")},hexToBytes:function(t){for(var e=[],r=0;rn;n++)e.push(8*r+6*n<=8*t.length?base64map.charAt(i>>>6*(3-n)&63):"=");return e.join("")},base64ToBytes:function(t){if("function"==typeof atob)return Binary.stringToBytes(atob(t));t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var e=[],r=0,i=0;r>>6-2*i);return e}};Crypto.mode={};var charenc=Crypto.charenc={},UTF8=charenc.UTF8={stringToBytes:function(t){return Binary.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(Binary.bytesToString(t)))}},Binary=charenc.Binary={stringToBytes:function(t){for(var e=[],r=0;rn;n++)e[i+n>>>2]|=(r[n>>>2]>>>24-8*(n%4)&255)<<24-8*((i+n)%4);else if(65535n;n+=4)e[i+n>>>2]=r[n>>>2];else e.push.apply(e,r);return this.sigBytes+=t,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-8*(r%4),e.length=t.ceil(r/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r=[],i=0;e>i;i+=4)r.push(4294967296*t.random()|0);return new s.init(r,e)}}),u=r.enc={},p=u.Hex={stringify:function(t){var e=t.words;t=t.sigBytes;for(var r=[],i=0;t>i;i++){var n=e[i>>>2]>>>24-8*(i%4)&255;r.push((n>>>4).toString(16)),r.push((15&n).toString(16))}return r.join("")},parse:function(t){for(var e=t.length,r=[],i=0;e>i;i+=2)r[i>>>3]|=parseInt(t.substr(i,2),16)<<24-4*(i%8);return new s.init(r,e/2)}},h=u.Latin1={stringify:function(t){var e=t.words;t=t.sigBytes;for(var r=[],i=0;t>i;i++)r.push(String.fromCharCode(e[i>>>2]>>>24-8*(i%4)&255));return r.join("")},parse:function(t){for(var e=t.length,r=[],i=0;e>i;i++)r[i>>>2]|=(255&t.charCodeAt(i))<<24-8*(i%4);return new s.init(r,e)}},a=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(h.stringify(t)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(t){return h.parse(unescape(encodeURIComponent(t)))}},F=i.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=a.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,i=r.words,n=r.sigBytes,o=this.blockSize,u=n/(4*o),u=e?t.ceil(u):t.max((0|u)-this._minBufferSize,0);if(e=u*o,n=t.min(4*e,n),e){for(var p=0;e>p;p+=o)this._doProcessBlock(i,p);p=i.splice(0,e),r.sigBytes-=n}return new s.init(p,n)},clone:function(){var t=o.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});i.Hasher=F.extend({cfg:o.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){F.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new g.HMAC.init(t,r).finalize(e)}}});var g=r.algo={};return r}(Math);!function(){var t=CryptoJS,e=t.lib,r=e.WordArray,i=e.Hasher,e=t.algo,n=r.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),o=r.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),s=r.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),u=r.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),p=r.create([0,1518500249,1859775393,2400959708,2840853838]),h=r.create([1352829926,1548603684,1836072691,2053994217,0]),e=e.RIPEMD160=i.extend({_doReset:function(){this._hash=r.create([1732584193,4023233417,2562383102,271733878,3285377520])
},_doProcessBlock:function(t,e){for(var r=0;16>r;r++){var i=e+r,a=t[i];t[i]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var F,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(var w,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<>>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<>>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(){var t=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);return t},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=i._createHelper(e),t.HmacRIPEMD160=i._createHmacHelper(e)}(Math),module.exports.crypto31=CryptoJS;var dbits,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<=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;var lowprimes=[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,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=(1<<26)/lowprimes[lowprimes.length-1];BigInteger.prototype.chunkSize=bnpChunkSize,BigInteger.prototype.toRadix=bnpToRadix,BigInteger.prototype.fromRadix=bnpFromRadix,BigInteger.prototype.fromNumber=bnpFromNumber,BigInteger.prototype.bitwiseTo=bnpBitwiseTo,BigInteger.prototype.changeBit=bnpChangeBit,BigInteger.prototype.addTo=bnpAddTo,BigInteger.prototype.dMultiply=bnpDMultiply,BigInteger.prototype.dAddOffset=bnpDAddOffset,BigInteger.prototype.multiplyLowerTo=bnpMultiplyLowerTo,BigInteger.prototype.multiplyUpperTo=bnpMultiplyUpperTo,BigInteger.prototype.modInt=bnpModInt,BigInteger.prototype.millerRabin=bnpMillerRabin,BigInteger.prototype.clone=bnClone,BigInteger.prototype.intValue=bnIntValue,BigInteger.prototype.byteValue=bnByteValue,BigInteger.prototype.shortValue=bnShortValue,BigInteger.prototype.signum=bnSigNum,BigInteger.prototype.toByteArray=bnToByteArray,BigInteger.prototype.equals=bnEquals,BigInteger.prototype.min=bnMin,BigInteger.prototype.max=bnMax,BigInteger.prototype.and=bnAnd,BigInteger.prototype.or=bnOr,BigInteger.prototype.xor=bnXor,BigInteger.prototype.andNot=bnAndNot,BigInteger.prototype.not=bnNot,BigInteger.prototype.shiftLeft=bnShiftLeft,BigInteger.prototype.shiftRight=bnShiftRight,BigInteger.prototype.getLowestSetBit=bnGetLowestSetBit,BigInteger.prototype.bitCount=bnBitCount,BigInteger.prototype.testBit=bnTestBit,BigInteger.prototype.setBit=bnSetBit,BigInteger.prototype.clearBit=bnClearBit,BigInteger.prototype.flipBit=bnFlipBit,BigInteger.prototype.add=bnAdd,BigInteger.prototype.subtract=bnSubtract,BigInteger.prototype.multiply=bnMultiply,BigInteger.prototype.divide=bnDivide,BigInteger.prototype.remainder=bnRemainder,BigInteger.prototype.divideAndRemainder=bnDivideAndRemainder,BigInteger.prototype.modPow=bnModPow,BigInteger.prototype.modInverse=bnModInverse,BigInteger.prototype.pow=bnPow,BigInteger.prototype.gcd=bnGCD,BigInteger.prototype.isProbablePrime=bnIsProbablePrime,BigInteger.prototype.square=bnSquare,module.exports.BigInteger=BigInteger,Arcfour.prototype.init=ARC4init,Arcfour.prototype.next=ARC4next;var rng_psize=256;BigInteger.valueOf=nbv,BigInteger.prototype.toByteArrayUnsigned=function(){var t=this.abs().toByteArray();return t.length?(0==t[0]&&(t=t.slice(1)),t.map(function(t){return 0>t?t+256:t})):t},BigInteger.fromByteArrayUnsigned=function(t){return t.length?new BigInteger(128&t[0]?[0].concat(t):t):t.valueOf(0)},BigInteger.prototype.toByteArraySigned=function(){var t=this.abs().toByteArrayUnsigned(),e=this.compareTo(BigInteger.ZERO)<0;return e?128&t[0]?t.unshift(128):t[0]|=128:128&t[0]&&t.unshift(0),t},BigInteger.fromByteArraySigned=function(t){return 128&t[0]?(t[0]&=127,BigInteger.fromByteArrayUnsigned(t).negate()):BigInteger.fromByteArrayUnsigned(t)};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;ii;)r[i++]=e;return r},numToVarInt:function(t){if(253>t)return[t];if(65536>t)return[253,255&t,t>>>8];if(4294967296>t)return[254].concat(Crypto.util.wordsToBytes([t]).reverse());throw"quadword not implemented"},valueToBigInt:function(t){return t instanceof BigInteger?t:BigInteger.fromByteArrayUnsigned(t)},formatValue:function(t){for(var e=this.valueToBigInt(t).toString(),r=e.length>8?e.substr(0,e.length-8):"0",i=e.length>8?e.substr(e.length-8):e;i.length<8;)i="0"+i;for(i=i.replace(/0*$/,"");i.length<2;)i+="0";return r+"."+i},parseValue:function(t){for(var e=t.split("."),r=e[0],i=e[1]||"0";i.length<8;)i+="0";i=i.replace(/^0+/g,"");var n=BigInteger.valueOf(parseInt(r));return n=n.multiply(BigInteger.valueOf(1e8)),n=n.add(BigInteger.valueOf(parseInt(i)))},sha256ripe160:function(t){return Crypto.RIPEMD160(Crypto.SHA256(t,{asBytes:!0}),{asBytes:!0})}};for(var i in Crypto.util)Crypto.util.hasOwnProperty(i)&&(Bitcoin.Util[i]=Crypto.util[i]);var rng_state,rng_pool,rng_pptr;if(null==rng_pool){rng_pool=new Array,rng_pptr=0;var t;if("Netscape"==navigator.appName&&navigator.appVersion<"5"&&window.crypto){var z=window.crypto.random(32);for(t=0;trng_pptr;)t=Math.floor(65536*Math.random()),rng_pool[rng_pptr++]=t>>>8,rng_pool[rng_pptr++]=255&t;rng_pptr=0,rng_seed_time()}SecureRandom.prototype.nextBytes=function(){throw new Error("Should not use old RNG")},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,module.exports.ECPointFp=ECPointFp,module.exports.ECFieldElementFp=ECFieldElementFp,X9ECParameters.prototype.getCurve=x9getCurve,X9ECParameters.prototype.getG=x9getG,X9ECParameters.prototype.getN=x9getN,X9ECParameters.prototype.getH=x9getH,module.exports.getSECCurveByName=getSECCurveByName,ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},ECPointFp.prototype.getEncoded=function(t){var e=this.getX().toBigInteger(),r=this.getY().toBigInteger(),i=integerToBytes(e,32);return t?i.unshift(r.isEven()?2:3):(i.unshift(4),i=i.concat(integerToBytes(r,32))),i},ECPointFp.decodeFrom=function(t,e){var r=e[0],i=e.length-1;if(4===r)var n=e.slice(1,1+i/2),o=e.slice(1+i/2,1+i),s=BigInteger.fromByteArrayUnsigned(n),u=BigInteger.fromByteArrayUnsigned(o);else{var n=e.slice(1),s=BigInteger.fromByteArrayUnsigned(n),p=t.getQ(),h=s.multiply(s).multiply(s).add(new BigInteger("7")).mod(p),a=p.add(new BigInteger("1")).divide(new BigInteger("4")),u=h.modPow(a,p);u.mod(new BigInteger("2")).toString()!=""+r%2&&(u=p.subtract(u))}return new ECPointFp(t,t.fromBigInteger(s),t.fromBigInteger(u))},ECPointFp.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),r=t.y.subtract(this.y),i=r.divide(e),n=i.square().subtract(this.x).subtract(t.x),o=i.multiply(this.x.subtract(n)).subtract(this.y);return new ECPointFp(this.curve,n,o)},ECPointFp.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(BigInteger.valueOf(2)),e=this.curve.fromBigInteger(BigInteger.valueOf(3)),r=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),i=r.square().subtract(this.x.multiply(t)),n=r.multiply(this.x.subtract(i)).subtract(this.y);return new ECPointFp(this.curve,i,n)},ECPointFp.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new BigInteger("3")),n=this.negate(),o=this;for(e=i.bitLength()-2;e>0;--e){o=o.twice();var s=i.testBit(e),u=r.testBit(e);s!=u&&(o=o.add2D(s?this:n))}return o},ECPointFp.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),i=this.curve.getB().toBigInteger(),n=this.curve.getQ(),o=e.multiply(e).mod(n),s=t.multiply(t).multiply(t).add(r.multiply(t)).add(i).mod(n);return o.equals(s)},ECPointFp.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},ECPointFp.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(BigInteger.ONE)<0||e.compareTo(t.subtract(BigInteger.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(BigInteger.ONE)<0||r.compareTo(t.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(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0},Bitcoin.ECDSA=function(){function t(t,e,r,i){for(var n=Math.max(e.bitLength(),i.bitLength()),o=t.add2D(r),s=t.curve.getInfinity(),u=n-1;u>=0;--u)s=s.twice2D(),s.z=BigInteger.ONE,e.testBit(u)?s=s.add2D(i.testBit(u)?o:t):i.testBit(u)&&(s=s.add2D(r));return s}var e=getSECCurveByName("secp256k1"),r=new SecureRandom,i=null,n={getBigRandom:function(t){return new BigInteger(t.bitLength(),r).mod(t.subtract(BigInteger.ONE)).add(BigInteger.ONE)},sign:function(t,r){var i=r,o=e.getN(),s=BigInteger.fromByteArrayUnsigned(t);do var u=n.getBigRandom(o),p=e.getG(),h=p.multiply(u),a=h.getX().toBigInteger().mod(o);while(a.compareTo(BigInteger.ZERO)<=0);var F=u.modInverse(o).multiply(s.add(i.multiply(a))).mod(o);return n.serializeSig(a,F)},verify:function(t,r,i){var o,s;if(Bitcoin.Util.isArray(r)){var u=n.parseSig(r);o=u.r,s=u.s}else{if("object"!=typeof r||!r.r||!r.s)throw"Invalid value for signature";o=r.r,s=r.s}var p;if(i instanceof ECPointFp)p=i;else{if(!Bitcoin.Util.isArray(i))throw"Invalid format for pubkey value, must be byte array or ECPointFp";p=ECPointFp.decodeFrom(e.getCurve(),i)}var h=BigInteger.fromByteArrayUnsigned(t);return n.verifyRaw(h,o,s,p)},verifyRaw:function(t,r,i,n){var o=e.getN(),s=e.getG();if(r.compareTo(BigInteger.ONE)<0||r.compareTo(o)>=0)return!1;if(i.compareTo(BigInteger.ONE)<0||i.compareTo(o)>=0)return!1;var u=i.modInverse(o),p=t.multiply(u).mod(o),h=r.multiply(u).mod(o),a=s.multiply(p).add(n.multiply(h)),F=a.getX().toBigInteger().mod(o);return F.equals(r)},serializeSig:function(t,e){var r=t.toByteArraySigned(),i=e.toByteArraySigned(),n=[];return n.push(2),n.push(r.length),n=n.concat(r),n.push(2),n.push(i.length),n=n.concat(i),n.unshift(n.length),n.unshift(48),n},parseSig:function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(e=2,2!=t[e])throw new Error("First element in signature must be a DERInteger");var r=t.slice(e+2,e+2+t[e+1]);if(e+=2+t[e+1],2!=t[e])throw new Error("Second element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);e+=2+t[e+1];var n=BigInteger.fromByteArrayUnsigned(r),o=BigInteger.fromByteArrayUnsigned(i);return{r:n,s:o}},parseSigCompact:function(t){if(65!==t.length)throw"Signature has the wrong length";var r=t[0]-27;if(0>r||r>7)throw"Invalid signature type";var i=e.getN(),n=BigInteger.fromByteArrayUnsigned(t.slice(1,33)).mod(i),o=BigInteger.fromByteArrayUnsigned(t.slice(33,65)).mod(i);return{r:n,s:o,i:r}},recoverPubKey:function(r,o,s,u){u=3&u;var p=1&u,h=u>>1,a=e.getN(),F=e.getG(),g=e.getCurve(),f=g.getQ(),c=g.getA().toBigInteger(),l=g.getB().toBigInteger();i||(i=f.add(BigInteger.ONE).divide(BigInteger.valueOf(4)));var B=h?r.add(a):r,m=B.multiply(B).multiply(B).add(c.multiply(B)).add(l).mod(f),y=m.modPow(i,f),d=(y.isEven()?u%2:(u+1)%2,(y.isEven()?!p:p)?y:f.subtract(y)),v=new ECPointFp(g,g.fromBigInteger(B),g.fromBigInteger(d));v.validate();var b=BigInteger.fromByteArrayUnsigned(s),I=BigInteger.ZERO.subtract(b).mod(a),E=r.modInverse(a),C=t(v,o,F,I).multiply(E);if(C.validate(),!n.verifyRaw(b,r,o,C))throw"Pubkey recovery unsuccessful";var T=new Bitcoin.ECKey;return T.pub=C,T},calcPubkeyRecoveryParam:function(t,e,r,i){for(var n=0;4>n;n++)try{var o=Bitcoin.ECDSA.recoverPubKey(e,r,i,n);if(o.getBitcoinAddress().toString()==t)return n}catch(s){}throw"Unable to find valid recovery factor"}};return n}(),Bitcoin.ECKey=function(){var t=Bitcoin.ECDSA,e=getSECCurveByName("secp256k1"),r=(new SecureRandom,function(t){if(t)t instanceof BigInteger?this.priv=t:Bitcoin.Util.isArray(t)?this.priv=BigInteger.fromByteArrayUnsigned(t):"string"==typeof t&&(this.priv=BigInteger.fromByteArrayUnsigned(51==t.length&&"5"==t[0]?r.decodeString(t):Crypto.util.hexToBytes(t)));else{e.getN()}this.compressed=!!r.compressByDefault});return r.compressByDefault=!1,r.prototype.setCompressed=function(t){this.compressed=!!t},r.prototype.getPub=function(){return this.getPubPoint().getEncoded(this.compressed)},r.prototype.getPubPoint=function(){return this.pub||(this.pub=e.getG().multiply(this.priv)),this.pub},r.prototype.getPubKeyHash=function(){return this.pubKeyHash?this.pubKeyHash:this.pubKeyHash=Bitcoin.Util.sha256ripe160(this.getPub())},r.prototype.getBitcoinAddress=function(){var t=this.getPubKeyHash(),e=new Bitcoin.Address(t);return e},r.prototype.getExportedPrivateKey=function(){for(var t=this.priv.toByteArrayUnsigned();t.length<32;)t.unshift(0);t.unshift(128);var e=Crypto.SHA256(Crypto.SHA256(t,{asBytes:!0}),{asBytes:!0}),r=t.concat(e.slice(0,4));return Bitcoin.Base58.encode(r)},r.prototype.setPub=function(t){this.pub=ECPointFp.decodeFrom(e.getCurve(),t)},r.prototype.toString=function(t){return"base64"===t?Crypto.util.bytesToBase64(this.priv.toByteArrayUnsigned()):Crypto.util.bytesToHex(this.priv.toByteArrayUnsigned())},r.prototype.sign=function(e){return t.sign(e,this.priv)},r.prototype.verify=function(e,r){return t.verify(e,r,this.getPub())},r.decodeString=function(t){var e=Bitcoin.Base58.decode(t),r=e.slice(0,33),i=Crypto.SHA256(Crypto.SHA256(r,{asBytes:!0}),{asBytes:!0});if(i[0]!=e[33]||i[1]!=e[34]||i[2]!=e[35]||i[3]!=e[36])throw"Checksum validation failed!";var n=r.shift();if(128!=n)throw"Version "+n+" not supported!";return r},r}(),module.exports.ECKey=Bitcoin.ECKey;
},{}],"4itQ50":[function(require,module,exports){
@@ -66,11 +66,11 @@ module.exports=require('4itQ50');
module.exports=require('f08cvL');
},{}],"f08cvL":[function(require,module,exports){
MSG={TX:1,BLOCK:2,FILTERED_BLOCK:3},MSG.to_str=function(t){switch(t){case MSG.TX:return"transaction";case MSG.BLOCK:return"block";case MSG.FILTERED_BLOCK:return"filtered block";default:return"unknown"}},exports.MSG=MSG;
-},{}],"./lib/Address":[function(require,module,exports){
-module.exports=require('G+CcXD');
},{}],"G+CcXD":[function(require,module,exports){
-(function(r){"use strict";function e(r,i){if(i&&i.length&&20!=i.length)throw new Error("Hash must be 20 bytes");e.super(this,arguments)}var i=require("soop").imports(),t=i.coinUtil||require("../util"),n=i.parent||require("../util/VersionedData"),s=i.networks||require("../networks"),o=i.Script||require("./Script");e.parent=n,n.applyEncodingsTo(e),e.fromPubKey=function(r,i){if(i||(i="livenet"),33!==r.length&&65!==r.length)throw new Error("Invalid public key");var n=s[i].addressVersion,o=t.sha256ripe160(r);return new e(n,o)},e.fromKey=function(r,i){return e.fromPubKey(r.public,i)},e.fromPubKeys=function(r,i,t,n){t||(t="livenet");for(var s in i){var a=i[s];if(33!=a.length&&65!=a.length)throw new Error("Invalid public key")}var u=o.createMultisig(r,i,n);return e.fromScript(u,t)},e.fromScript=function(i,n){n||(n="livenet"),"string"==typeof i&&(i=new o(new r(i,"hex")));var a=s[n].P2SHVersion,u=i.getBuffer(),f=t.sha256ripe160(u);return new e(a,f)},e.fromScriptPubKey=function(i,n){"string"==typeof i&&(i=new o(new r(i,"hex"))),n||(n="livenet");var a,u=[],f=i.capture();if(f){var p=i.classify();switch(p){case o.TX_PUBKEY:f[0]=t.sha256ripe160(f[0]),a=s[n].addressVersion;break;case o.TX_PUBKEYHASH:a=s[n].addressVersion;break;case o.TX_MULTISIG:a=s[n].addressVersion;for(var l in f)f[l]=t.sha256ripe160(f[l]);break;case o.TX_SCRIPTHASH:a=s[n].P2SHVersion}for(var l in f)u.push(new e(a,f[l]))}return u},e.prototype.validate=function(){if(this.doAsBinary(function(){if(e.super(this,"validate",arguments),21!==this.data.length)throw new Error("invalid data length")}),"undefined"==typeof this.network())throw new Error("invalid network")},e.prototype.isValid=function(){var r=e.super(this,"isValid",arguments);return r},e.prototype.network=function(){var r,e=this.version(),i=s.livenet,t=s.testnet;return e===i.addressVersion||e===i.P2SHVersion?r=i:(e===t.addressVersion||e===t.P2SHVersion)&&(r=t),r},e.prototype.isScript=function(){return this.isValid()&&this.version()===this.network().P2SHVersion},module.exports=require("soop")(e)}).call(this,require("buffer").Buffer);
-},{"../networks":"ULNIu2","../util":143,"../util/VersionedData":"QLzNQg","./Script":"hQ0t76","buffer":85,"soop":129}],"./lib/Armory":[function(require,module,exports){
+(function(e){"use strict";function r(e,t){if(t&&t.length&&20!=t.length)throw new Error("Hash must be 20 bytes");r.super(this,arguments)}var t=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)throw new Error("Invalid public key");var n=s[t].addressVersion,o=i.sha256ripe160(e);return new r(n,o)},r.fromKey=function(e,t){return r.fromPubKey(e.public,t)},r.fromPubKeys=function(e,t,i,n){i||(i="livenet");for(var s in t){var a=t[s];if(33!=a.length&&65!=a.length)throw new Error("Invalid public key")}var u=o.createMultisig(e,t,n);return r.fromScript(u,i)},r.fromScript=function(t,n){n||(n="livenet"),"string"==typeof t&&(t=new o(new e(t,"hex")));var a=s[n].P2SHVersion,u=t.getBuffer(),f=i.sha256ripe160(u);return new r(a,f)},r.fromScriptPubKey=function(t,n){"string"==typeof t&&(t=new o(new e(t,"hex"))),n||(n="livenet");var a,u=[],f=t.capture();if(f){var p=t.classify();switch(p){case o.TX_PUBKEY:f[0]=i.sha256ripe160(f[0]),a=s[n].addressVersion;break;case o.TX_PUBKEYHASH:a=s[n].addressVersion;break;case o.TX_MULTISIG:a=s[n].addressVersion;for(var l in f)f[l]=i.sha256ripe160(f[l]);break;case o.TX_SCRIPTHASH:a=s[n].P2SHVersion}for(var l in f)u.push(new r(a,f[l]))}return u},r.prototype.validate=function(){if(this.doAsBinary(function(){if(r.super(this,"validate",arguments),21!==this.data.length)throw new Error("invalid data length")}),"undefined"==typeof this.network())throw new Error("invalid network")},r.prototype.isValid=function(){var e=r.super(this,"isValid",arguments);return e},r.prototype.network=function(){var e,r=this.version(),t=s.livenet,i=s.testnet;return r===t.addressVersion||r===t.P2SHVersion?e=t:(r===i.addressVersion||r===i.P2SHVersion)&&(e=i),e},r.prototype.isScript=function(){return this.isValid()&&this.version()===this.network().P2SHVersion},r.prototype.getScriptPubKey=function(){var e,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)throw new Error("invalid address - unknown version");e=o.createP2SH(this.payload())}return e},module.exports=require("soop")(r)}).call(this,require("buffer").Buffer);
+},{"../networks":"ULNIu2","../util":143,"../util/VersionedData":"QLzNQg","./Script":"hQ0t76","buffer":85,"soop":129}],"./lib/Address":[function(require,module,exports){
+module.exports=require('G+CcXD');
+},{}],"./lib/Armory":[function(require,module,exports){
module.exports=require('YL/05i');
},{}],"YL/05i":[function(require,module,exports){
(function(e){function r(r,n){this.chaincode=new e(r,"hex"),this.pubkey=new e(n,"hex")}function n(e){for(var r="0123456789abcdef",n="asdfghjkwertuion",t="",i=0;ii;i++)n[i]^=r[i];var o=t.fromUncompressedPubKey(e);o=t.multiply(o,n);var u=o.toUncompressedPubKey();return u},r.prototype.next=function(){var e=this.generatePubKey();return new r(this.chaincode,e)},r.fromMasterPublicKey=function(e){var n=e.substr(0,130),t=e.substr(130,e.length);return new r(t,n)},r.decodeSeed=function(t){for(var i=t.trim().split("\n"),o=[],c=0;cs;s++)i.push(new t(e.pubkeys[s],"hex"));return n.createMultisig(e.nreq,i)},e._scriptForOut=function(t){var e;if(t.address)e=this.scriptForAddress(t.address);else{if(!(t.pubkeys||t.nreq||t.nreq>1))throw new Error("unknown out type");e=this._scriptForPubkeys(t)}return e},e.infoForP2sh=function(t,e){var r=this._scriptForOut(t),n=s.sha256ripe160(r.getBuffer()),a="testnet"===e?o.testnet.P2SHVersion:o.livenet.P2SHVersion,u=new i(a,n),h=u.as("base58");return{script:r,scriptBufHex:r.getBuffer().toString("hex"),hash:n,address:h}},e.prototype.setUnspent=function(t){return this.utxos=t,this},e.prototype._setInputMap=function(){for(var e=[],r=this.selectedUtxos.length,i=0;r>i;i++){var s=this.selectedUtxos[i],a=new t(s.scriptPubKey,"hex"),u=new n(a),o=u.classify();if(o===n.TX_UNKNOWN)throw new Error("unkown output type at:"+i+" Type:"+u.getRawOutType());e.push({address:s.address,scriptPubKey:u,scriptType:o,i:i})}return this.inputMap=e,this},e.prototype.getSelectedUnspent=function(){return this.selectedUtxos},e.prototype._selectUnspent=function(t){if(!this.utxos||!this.utxos.length)throw new Error("unspent not set");var e=[6,1];this.spendUnconfirmed&&e.push(0);var r=[],i=a(0),n=!1,u=null,o=this.utxos.length;do{for(var h=e.shift(),p=0;o>p;p++){var c=this.utxos[p],f=c.confirmations||0;if(!(h>f||u&&f>=u)){var d=c.amountSat||s.parseValue(c.amount);if(i=i.add(d),r.push(c),i.cmp(t)>=0){n=!0;break}}}u=h}while(!n&&e.length);if(!n)throw new Error("no enough unspent to fulfill totalNeededAmount [SAT]:"+t);return this.selectedUtxos=r,this._setInputMap(),this},e.prototype._setInputs=function(e){var r=this.selectedUtxos,i=r.length,n=a(0);e.ins=[];for(var o=0;i>o;o++){n=n.add(s.parseValue(r[o].amount));var h={};h.s=s.EMPTY_BUFFER,h.q=4294967295;var p=new t(r[o].txid,"hex"),c=u.reverse(p),f=parseInt(r[o].vout),d=new t(4);d.writeUInt32LE(f,0),h.o=t.concat([c,d]),e.ins.push(h)}return this.valueInSat=n,this},e.prototype._setFee=function(t){if("undefined"==typeof this.valueOutSat)throw new Error("valueOutSat undefined");var e=this.valueOutSat.add(t);if(this.valueInSat.cmp(e)<0){var r=this.valueInSat.toString(),i=e.toString();throw new Error("transaction input amount is less than outputs: "+r+" < "+i+" [SAT]")}return this.feeSat=t,this},e.prototype._setRemainder=function(t,r){if("undefined"==typeof this.valueInSat||"undefined"==typeof this.valueOutSat)throw new Error("valueInSat / valueOutSat undefined");var i=this.valueInSat.sub(this.valueOutSat).sub(this.feeSat),n=t.outs.length;if(this.remainderSat=a(0),n>r&&t.outs.pop(),i.cmp(0)>0){var u=this.remainderOut||this.selectedUtxos[0],o=s.bigIntToValue(i),h=e._scriptForOut(u),p={v:o,s:h.getBuffer()};t.outs.push(p),this.remainderSat=i}return this},e.prototype._setFeeAndRemainder=function(t){var e,r=500,i=t.outs.length;do{e=parseInt(r/1e3)+1;var n=this.givenFeeSat?this.givenFeeSat:e*g,s=this.valueOutSat.add(n);this._selectUnspent(s)._setInputs(t)._setFee(n)._setRemainder(t,i),r=new d(t).getSize()}while(r>1e3*(e+1));return this},e.prototype.setOutputs=function(t){var r=a(0),i={};i.version=1,i.lock_time=this.lockTime||0,i.ins=[],i.outs=[];for(var n=t.length,u=0;n>u;u++){var o=t[u].amountSat||s.parseValue(t[u].amount),h=s.bigIntToValue(o),p=e._scriptForOut(t[u]),c={v:h,s:p.getBuffer()};i.outs.push(c);var f=t[u].amountSat||s.parseValue(t[u].amount);r=r.add(f)}return this.valueOutSat=r,this._setFeeAndRemainder(i),this.tx=new d(i),this},e._mapKeys=function(t){for(var e,r={},i=t.length,n=0;i>n;n++){var s=t[n];if("string"==typeof s){var a=new p(s);e=new h({network:a.network()}),e.fromObj({priv:s})}else{if(!(s instanceof h))throw new Error("argument must be an array of strings (WIF format) or WalletKey objects");e=s}r[e.storeObj().addr]=e}return r},e._signHashAndVerify=function(t,e){var r,i=10;do r=t.privKey.signSync(e);while(t.privKey.verifySignatureSync(e,r)===!1&&i--);if(0>i)throw new Error("could not sign input: verification failed");return r},e.prototype._checkTx=function(){if(!this.tx||!this.tx.ins.length||!this.tx.outs.length)throw new Error("tx is not defined")},e.prototype._multiFindKey=function(t,e){var r;return[o.livenet,o.testnet].forEach(function(n){[n.addressVersion,n.P2SHVersion].forEach(function(n){var s=new i(n,e);!r&&t[s]&&(r=t[s])})}),r},e.prototype._findWalletKey=function(t,e){var r;if(e.address)r=t[e.address];else if(e.pubKeyHash)r=this._multiFindKey(t,e.pubKeyHash);else{if(!e.pubKeyBuf)throw new Error("no infomation at input to find keys");var i=s.sha256ripe160(e.pubKeyBuf);r=this._multiFindKey(t,i)}return r},e.prototype._signPubKey=function(r,i,s){if(this.tx.ins[i.i].s.length>0)return{};var a=this._findWalletKey(r,i);if(a){var u=e._signHashAndVerify(a,s),o=new t(1);o[0]=this.signhash;var h=t.concat([u,o]),p=new n;return p.chunks.push(h),p.updateBuffer(),{inputFullySigned:!0,signaturesAdded:1,script:p.getBuffer()}}},e.prototype._signPubKeyHash=function(r,i,s){if(this.tx.ins[i.i].s.length>0)return{};var a=this._findWalletKey(r,i);if(a){var u=e._signHashAndVerify(a,s),o=new t(1);o[0]=this.signhash;var h=t.concat([u,o]),p=new n;return p.chunks.push(h),p.chunks.push(a.privKey.public),p.updateBuffer(),{inputFullySigned:!0,signaturesAdded:1,script:p.getBuffer()}}},e.prototype._chunkSignedWithKey=function(e,r,i){var n,s=new c;s.public=i;for(var a=1;a<=e.countSignatures();a++){var u=e.chunks[a],o=new t(u.slice(0,u.length-1));s.verifySignatureSync(r,o)&&(n=u)}return n},e.prototype._getSignatureOrder=function(e,r,i,n){for(var s=n.length,a=0;s>a;a++){var u=new c;if(u.public=new t(n[a],"hex"),u.verifySignatureSync(i,r))break}return a},e.prototype._getNewSignatureOrder=function(e,r,i,n){for(var s,a=1;a<=r.countSignatures();a++){var u=r.chunks[a],o=new t(u.slice(0,u.length-1));if(s=this._getSignatureOrder(e,o,i,n),s>=e)break}return e===s?-1:a-1},e.prototype._chunkIsEmpty=function(t){return 0===t||0===u.compare(t,s.EMPTY_BUFFER)},e.prototype._initMultiSig=function(t){var e=!1;return 0!==t.chunks[0]&&(t.prependOp0(),e=!0),e},e.prototype._updateMultiSig=function(r,i,n,s,a){var u=this._initMultiSig(n);if(this._chunkSignedWithKey(n,s,i.privKey.public))return null;var o=e._signHashAndVerify(i,s),h=new t(1);h[0]=this.signhash;var p=t.concat([o,h]),c=this._getNewSignatureOrder(r,n,s,a);return n.chunks.splice(c+1,0,p),n.updateBuffer(),u=!0,u?n:null},e.prototype._signMultiSig=function(t,e,r){for(var i=e.scriptPubKey.capture(),s=e.scriptPubKey.chunks[0]-80,a=i.length,u=this.tx.ins[e.i].s,o=new n(u),h=0,p=0;a>p&&o.countSignatures()a;a++){var u=this.inputMap[a],o=this.tx.hashForSignature(u.scriptPubKey,a,this.signhash),h=l[u.scriptType].call(this,s,u,o);h&&h.script&&(r.ins[a].s=h.script,h.inputFullySigned&&this.inputsSigned++,h.signaturesAdded&&(this.signaturesAdded+=h.signaturesAdded))}return this},e.prototype.setHashToScriptMap=function(t){return this.hashToScriptMap=t,this},e.prototype.isFullySigned=function(){return this.inputsSigned===this.tx.ins.length},e.prototype.build=function(){return this._checkTx(),this.tx},e.prototype.toObj=function(){var t={valueInSat:this.valueInSat.toString(),valueOutSat:this.valueOutSat.toString(),feeSat:this.feeSat.toString(),remainderSat:this.remainderSat.toString(),hashToScriptMap:this.hashToScriptMap,selectedUtxos:this.selectedUtxos,inputsSigned:this.inputsSigned,signaturesAdded:this.signaturesAdded,signhash:this.signhash,spendUnconfirmed:this.spendUnconfirmed};return this.tx&&(t.tx=this.tx.serialize().toString("hex")),t},e.fromObj=function(r){var i=new e;if(i.valueInSat=r.valueInSat.toString(),i.valueOutSat=r.valueOutSat.toString(),i.feeSat=r.feeSat.toString(),i.remainderSat=r.remainderSat.toString(),i.hashToScriptMap=r.hashToScriptMap,i.selectedUtxos=r.selectedUtxos,i.inputsSigned=r.inputsSigned,i.signaturesAdded=r.signaturesAdded,i.signhash=r.signhash,i.spendUnconfirmed=r.spendUnconfirmed,i._setInputMap(),r.tx){var n=new d;n.parse(new t(r.tx,"hex")),i.tx=n}return i},e.prototype._checkMergeability=function(t){var e=this;if(["valueInSat","valueOutSat","feeSat","remainderSat","signhash","spendUnconfirmed"].forEach(function(r){if(e[r].toString()!==t[r].toString())throw new Error("mismatch at TransactionBuilder match: "+r+": "+e[r]+" vs. "+t[r])}),e.hashToScriptMap){var r=0;if(t.hashToScriptMap||(r=1),Object.keys(e.hashToScriptMap).forEach(function(i){t.hashToScriptMap[i]||(r=1),e.hashToScriptMap[i]!==t.hashToScriptMap[i]&&(r=1)}),r)throw new Error("mismatch at TransactionBuilder hashToScriptMap")}var r=0,i=0;if(e.selectedUtxos.forEach(function(e){if(!r){var n=t.selectedUtxos[i++];n||(r=1),["address","hash","scriptPubKey","vout","amount"].forEach(function(t){e[t]!==n[t]&&(r=t)})}}),r)throw new Error("mismatch at TransactionBuilder selectedUtxos #"+i-1+" Key:"+r);if(r=0,i=0,e.inputMap.forEach(function(e){if(!r){var n=t.inputMap[i++];n||(r=1),["address","scriptType","scriptPubKey","i"].forEach(function(t){e[t].toString()!==n[t].toString()&&(r=t)})}}),r)throw new Error("mismatch at TransactionBuilder inputMap #"+i-1+" Key:"+r)},e.prototype._mergeInputSigP2sh=function(t,e,r){for(var i=this._p2shInput(t),s=new n(i.scriptBuf),a=s.capture(),u={},o=a.length,h=0;o>h;h++)this._chunkSignedWithKey(e,i.txSigHash,a[h])&&(u[a[h].toString("hex")]=1);for(var p=[],h=0;o>h;h++){var c=this._chunkSignedWithKey(r,i.txSigHash,a[h]),f=a[h].toString("hex");c&&!u[f]&&p.push({prio:h,chunk:c,pubHex:f})}for(var h in p){var d=p[h],g=this._getNewSignatureOrder(d.prio,e,i.txSigHash,a);e.chunks.splice(g+1,0,d.chunk),this.signaturesAdded++}return e.updateBuffer(),e.getBuffer()},e.prototype._mergeInputSig=function(t,e,r){if(0===u.compare(e,r))return e;var i=new n(e),s=new n(r),a=i.chunks.length,o=s.chunks.length;if(a&&o&&(2>a&&o>2||2>o&&a>2))throw new Error("TX sig types mismatch in merge");if(!a&&!o||a&&!o||!a&&o)return r;var h=this.inputMap[t],p=h.scriptPubKey.classify();if(p===n.TX_PUBKEYHASH||p===n.TX_PUBKEY)return f.debug("Merging two signed inputs type:"+h.scriptPubKey.getRawOutType()+". Signatures differs. Using the first version."),e;if(p!==n.TX_SCRIPTHASH)throw new Error("Script type:"+h.scriptPubKey.getRawOutType()+"not supported at #merge");return this._mergeInputSigP2sh(h,i,s)},e.prototype._mergeTx=function(t){var e=this.tx,r=t,i=e.ins.length;if(i!==r.ins.length)throw new Error("TX in length mismatch in merge");this.inputsSigned=0;for(var n=0;i>n;n++){var s=e.ins[n],a=r.ins[n];if(s.q!==a.q)throw new Error("TX sequence ins mismatch in merge. Input:",n);if(0!==u.compare(s.o,a.o))throw new Error("TX .o in mismatch in merge. Input:",n);s.s=this._mergeInputSig(n,s.s,a.s),e.isInputComplete(n)&&this.inputsSigned++}},e.prototype.merge=function(t){if(this._checkMergeability(t),this.tx||t.tx){if(this.tx.getNormalizedHash().toString("hex")!==t.tx.getNormalizedHash().toString("hex"))throw new Error("mismatch at TransactionBuilder NTXID");this._mergeTx(t.tx)}},module.exports=require("soop")(e)}).call(this,require("buffer").Buffer);
+(function(t){"use strict";function e(t){return t=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}var r=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(var r=e.pubkeys.length,i=[],s=0;r>s;s++)i.push(new t(e.pubkeys[s],"hex"));return n.createMultisig(e.nreq,i)},e._scriptForOut=function(t){var e;if(t.address)e=new i(t.address).getScriptPubKey();else{if(!(t.pubkeys||t.nreq||t.nreq>1))throw new Error("unknown out type");e=this._scriptForPubkeys(t)}return e},e.infoForP2sh=function(t,e){var r=this._scriptForOut(t),n=s.sha256ripe160(r.getBuffer()),u="testnet"===e?o.testnet.P2SHVersion:o.livenet.P2SHVersion,a=new i(u,n),h=a.as("base58");return{script:r,scriptBufHex:r.getBuffer().toString("hex"),hash:n,address:h}},e.prototype.setUnspent=function(t){return this.utxos=t,this},e.prototype._setInputMap=function(){for(var e=[],r=this.selectedUtxos.length,i=0;r>i;i++){var s=this.selectedUtxos[i],u=new t(s.scriptPubKey,"hex"),a=new n(u),o=a.classify();if(o===n.TX_UNKNOWN)throw new Error("unkown output type at:"+i+" Type:"+a.getRawOutType());e.push({address:s.address,scriptPubKey:a,scriptType:o,i:i})}return this.inputMap=e,this},e.prototype.getSelectedUnspent=function(){return this.selectedUtxos},e.prototype._selectUnspent=function(t){if(!this.utxos||!this.utxos.length)throw new Error("unspent not set");var e=[6,1];this.spendUnconfirmed&&e.push(0);var r=[],i=u(0),n=!1,a=null,o=this.utxos.length;do{for(var h=e.shift(),p=0;o>p;p++){var c=this.utxos[p],f=c.confirmations||0;if(!(h>f||a&&f>=a)){var d=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)throw new Error("not enough unspent tx outputs to fulfill totalNeededAmount [SAT]:"+t);return this.selectedUtxos=r,this._setInputMap(),this},e.prototype._setInputs=function(e){var r=this.selectedUtxos,i=r.length,n=u(0);e.ins=[];for(var o=0;i>o;o++){n=n.add(s.parseValue(r[o].amount));var h={};h.s=s.EMPTY_BUFFER,h.q=4294967295;var p=new t(r[o].txid,"hex"),c=a.reverse(p),f=parseInt(r[o].vout),d=new t(4);d.writeUInt32LE(f,0),h.o=t.concat([c,d]),e.ins.push(h)}return this.valueInSat=n,this},e.prototype._setFee=function(t){if("undefined"==typeof this.valueOutSat)throw new Error("valueOutSat undefined");var e=this.valueOutSat.add(t);if(this.valueInSat.cmp(e)<0){var r=this.valueInSat.toString(),i=e.toString();throw new Error("transaction input amount is less than outputs: "+r+" < "+i+" [SAT]")}return this.feeSat=t,this},e.prototype._setRemainder=function(t,r){if("undefined"==typeof this.valueInSat||"undefined"==typeof this.valueOutSat)throw new Error("valueInSat / valueOutSat undefined");var i=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){var a=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}return this},e.prototype._setFeeAndRemainder=function(t){var e,r=500,i=t.outs.length;do{e=parseInt(r/1e3)+1;var n=this.givenFeeSat?this.givenFeeSat:e*g,s=this.valueOutSat.add(n);this._selectUnspent(s)._setInputs(t)._setFee(n)._setRemainder(t,i),r=new d(t).getSize()}while(r>1e3*(e+1));return this},e.prototype.setOutputs=function(t){var r=u(0),i={};i.version=1,i.lock_time=this.lockTime||0,i.ins=[],i.outs=[];for(var n=t.length,a=0;n>a;a++){var o=t[a].amountSat||s.parseValue(t[a].amount),h=s.bigIntToValue(o),p=e._scriptForOut(t[a]),c={v:h,s:p.getBuffer()};i.outs.push(c);var f=t[a].amountSat||s.parseValue(t[a].amount);r=r.add(f)}return this.valueOutSat=r,this._setFeeAndRemainder(i),this.tx=new d(i),this},e._mapKeys=function(t){for(var e,r={},i=t.length,n=0;i>n;n++){var s=t[n];if("string"==typeof s){var u=new p(s);e=new h({network:u.network()}),e.fromObj({priv:s})}else{if(!(s instanceof h))throw new Error("argument must be an array of strings (WIF format) or WalletKey objects");e=s}r[e.storeObj().addr]=e}return r},e._signHashAndVerify=function(t,e){var r,i=10;do r=t.privKey.signSync(e);while(t.privKey.verifySignatureSync(e,r)===!1&&i--);if(0>i)throw new Error("could not sign input: verification failed");return r},e.prototype._checkTx=function(){if(!this.tx||!this.tx.ins.length||!this.tx.outs.length)throw new Error("tx is not defined")},e.prototype._multiFindKey=function(t,e){var r;return[o.livenet,o.testnet].forEach(function(n){[n.addressVersion,n.P2SHVersion].forEach(function(n){var s=new i(n,e);!r&&t[s]&&(r=t[s])})}),r},e.prototype._findWalletKey=function(t,e){var r;if(e.address)r=t[e.address];else if(e.pubKeyHash)r=this._multiFindKey(t,e.pubKeyHash);else{if(!e.pubKeyBuf)throw new Error("no infomation at input to find keys");var i=s.sha256ripe160(e.pubKeyBuf);r=this._multiFindKey(t,i)}return r},e.prototype._signPubKey=function(r,i,s){if(this.tx.ins[i.i].s.length>0)return{};var u=this._findWalletKey(r,i);if(u){var a=e._signHashAndVerify(u,s),o=new t(1);o[0]=this.signhash;var h=t.concat([a,o]),p=new n;return p.chunks.push(h),p.updateBuffer(),{inputFullySigned:!0,signaturesAdded:1,script:p.getBuffer()}}},e.prototype._signPubKeyHash=function(r,i,s){if(this.tx.ins[i.i].s.length>0)return{};var u=this._findWalletKey(r,i);if(u){var a=e._signHashAndVerify(u,s),o=new t(1);o[0]=this.signhash;var h=t.concat([a,o]),p=new n;return p.chunks.push(h),p.chunks.push(u.privKey.public),p.updateBuffer(),{inputFullySigned:!0,signaturesAdded:1,script:p.getBuffer()}}},e.prototype._chunkSignedWithKey=function(e,r,i){var n,s=new c;s.public=i;for(var u=1;u<=e.countSignatures();u++){var a=e.chunks[u],o=new t(a.slice(0,a.length-1));s.verifySignatureSync(r,o)&&(n=a)}return n},e.prototype._getSignatureOrder=function(e,r,i,n){for(var s=n.length,u=0;s>u;u++){var a=new c;if(a.public=new t(n[u],"hex"),a.verifySignatureSync(i,r))break}return u},e.prototype._getNewSignatureOrder=function(e,r,i,n){for(var s,u=1;u<=r.countSignatures();u++){var a=r.chunks[u],o=new t(a.slice(0,a.length-1));if(s=this._getSignatureOrder(e,o,i,n),s>=e)break}return e===s?-1:u-1},e.prototype._chunkIsEmpty=function(t){return 0===t||0===a.compare(t,s.EMPTY_BUFFER)},e.prototype._initMultiSig=function(t){var e=!1;return 0!==t.chunks[0]&&(t.prependOp0(),e=!0),e},e.prototype._updateMultiSig=function(r,i,n,s,u){var a=this._initMultiSig(n);if(this._chunkSignedWithKey(n,s,i.privKey.public))return null;var o=e._signHashAndVerify(i,s),h=new t(1);h[0]=this.signhash;var p=t.concat([o,h]),c=this._getNewSignatureOrder(r,n,s,u);return n.chunks.splice(c+1,0,p),n.updateBuffer(),a=!0,a?n:null},e.prototype._signMultiSig=function(t,e,r){for(var i=e.scriptPubKey.capture(),s=e.scriptPubKey.chunks[0]-80,u=i.length,a=this.tx.ins[e.i].s,o=new n(a),h=0,p=0;u>p&&o.countSignatures()u;u++){var a=this.inputMap[u],o=this.tx.hashForSignature(a.scriptPubKey,u,this.signhash),h=l[a.scriptType].call(this,s,a,o);h&&h.script&&(r.ins[u].s=h.script,h.inputFullySigned&&this.inputsSigned++,h.signaturesAdded&&(this.signaturesAdded+=h.signaturesAdded))}return this},e.prototype.setHashToScriptMap=function(t){return this.hashToScriptMap=t,this},e.prototype.isFullySigned=function(){return this.inputsSigned===this.tx.ins.length},e.prototype.build=function(){return this._checkTx(),this.tx},e.prototype.toObj=function(){var t={valueInSat:this.valueInSat.toString(),valueOutSat:this.valueOutSat.toString(),feeSat:this.feeSat.toString(),remainderSat:this.remainderSat.toString(),hashToScriptMap:this.hashToScriptMap,selectedUtxos:this.selectedUtxos,inputsSigned:this.inputsSigned,signaturesAdded:this.signaturesAdded,signhash:this.signhash,spendUnconfirmed:this.spendUnconfirmed};return this.tx&&(t.tx=this.tx.serialize().toString("hex")),t},e.fromObj=function(r){var i=new e;if(i.valueInSat=r.valueInSat.toString(),i.valueOutSat=r.valueOutSat.toString(),i.feeSat=r.feeSat.toString(),i.remainderSat=r.remainderSat.toString(),i.hashToScriptMap=r.hashToScriptMap,i.selectedUtxos=r.selectedUtxos,i.inputsSigned=r.inputsSigned,i.signaturesAdded=r.signaturesAdded,i.signhash=r.signhash,i.spendUnconfirmed=r.spendUnconfirmed,i._setInputMap(),r.tx){var n=new d;n.parse(new t(r.tx,"hex")),i.tx=n}return i},e.prototype._checkMergeability=function(t){var e=this;if(["valueInSat","valueOutSat","feeSat","remainderSat","signhash","spendUnconfirmed"].forEach(function(r){if(e[r].toString()!==t[r].toString())throw new Error("mismatch at TransactionBuilder match: "+r+": "+e[r]+" vs. "+t[r])}),e.hashToScriptMap){var r=0;if(t.hashToScriptMap||(r=1),Object.keys(e.hashToScriptMap).forEach(function(i){t.hashToScriptMap[i]||(r=1),e.hashToScriptMap[i]!==t.hashToScriptMap[i]&&(r=1)}),r)throw new Error("mismatch at TransactionBuilder hashToScriptMap")}var r=0,i=0;if(e.selectedUtxos.forEach(function(e){if(!r){var n=t.selectedUtxos[i++];n||(r=1),["address","hash","scriptPubKey","vout","amount"].forEach(function(t){e[t]!==n[t]&&(r=t)})}}),r)throw new Error("mismatch at TransactionBuilder selectedUtxos #"+i-1+" Key:"+r);if(r=0,i=0,e.inputMap.forEach(function(e){if(!r){var n=t.inputMap[i++];n||(r=1),["address","scriptType","scriptPubKey","i"].forEach(function(t){e[t].toString()!==n[t].toString()&&(r=t)})}}),r)throw new Error("mismatch at TransactionBuilder inputMap #"+i-1+" Key:"+r)},e.prototype._mergeInputSigP2sh=function(t,e,r){for(var i=this._p2shInput(t),s=new n(i.scriptBuf),u=s.capture(),a={},o=u.length,h=0;o>h;h++)this._chunkSignedWithKey(e,i.txSigHash,u[h])&&(a[u[h].toString("hex")]=1);for(var p=[],h=0;o>h;h++){var c=this._chunkSignedWithKey(r,i.txSigHash,u[h]),f=u[h].toString("hex");c&&!a[f]&&p.push({prio:h,chunk:c,pubHex:f})}for(var h in p){var d=p[h],g=this._getNewSignatureOrder(d.prio,e,i.txSigHash,u);e.chunks.splice(g+1,0,d.chunk),this.signaturesAdded++}return e.updateBuffer(),e.getBuffer()},e.prototype._mergeInputSig=function(t,e,r){if(0===a.compare(e,r))return e;var i=new n(e),s=new n(r),u=i.chunks.length,o=s.chunks.length;if(u&&o&&(2>u&&o>2||2>o&&u>2))throw new Error("TX sig types mismatch in merge");if(!u&&!o||u&&!o||!u&&o)return r;var h=this.inputMap[t],p=h.scriptPubKey.classify();if(p===n.TX_PUBKEYHASH||p===n.TX_PUBKEY)return f.debug("Merging two signed inputs type:"+h.scriptPubKey.getRawOutType()+". Signatures differs. Using the first version."),e;if(p!==n.TX_SCRIPTHASH)throw new Error("Script type:"+h.scriptPubKey.getRawOutType()+"not supported at #merge");return this._mergeInputSigP2sh(h,i,s)},e.prototype._mergeTx=function(t){var e=this.tx,r=t,i=e.ins.length;if(i!==r.ins.length)throw new Error("TX in length mismatch in merge");this.inputsSigned=0;for(var n=0;i>n;n++){var s=e.ins[n],u=r.ins[n];if(s.q!==u.q)throw new Error("TX sequence ins mismatch in merge. Input:",n);if(0!==a.compare(s.o,u.o))throw new Error("TX .o in mismatch in merge. Input:",n);s.s=this._mergeInputSig(n,s.s,u.s),e.isInputComplete(n)&&this.inputsSigned++}},e.prototype.merge=function(t){if(this._checkMergeability(t),this.tx||t.tx){if(this.tx.getNormalizedHash().toString("hex")!==t.tx.getNormalizedHash().toString("hex"))throw new Error("mismatch at TransactionBuilder NTXID");this._mergeTx(t.tx)}},module.exports=require("soop")(e)}).call(this,require("buffer").Buffer);
},{"../networks":"ULNIu2","../util":143,"../util/log":"AdF7pF","./Address":"G+CcXD","./Key":"ALJ4PS","./PrivateKey":"izTl9z","./Script":"hQ0t76","./Transaction":"LJhYtm","./WalletKey":"wWje7g","bignum":58,"buffer":85,"buffertools":"fugeBw","soop":129}],"yUY4WV":[function(require,module,exports){
(function(t){function e(t){"object"!=typeof t&&(t={}),this.datastore=JSON.parse(t.datastore?JSON.stringify(t.datastore):JSON.stringify(p)),this.network=void 0,this.dirty=t.dirty||!0}var r=require("soop").imports(),i=function(e){return new t(e,"hex")},n=require("fs"),s=require("../util/EncFile"),o=require("./Address"),a=require("../networks"),d=r.util||require("../util"),h="aes-256-cbc",p={client:"libcoin",client_version:"0.0.1",network:"testnet",version:1,best_hash:null,best_height:-1,keys:[],sin:{},scripts:{}};e.prototype.readSync=function(t,e){this.datastore=s.readJFileSync(h,e,t),this.dirty=!1},e.prototype.writeSync=function(t,e){var r=t+".tmp";s.writeJFileSync(h,e,r,this.datastore),n.renameSync(r,t),this.dirty=!1},e.prototype.setNetwork=function(t){switch(t||(t=this.datastore.network),t){case"mainnet":case"livenet":this.network=a.livenet;break;case"testnet":this.network=a.testnet;break;default:throw new Error("Unsupported network")}this.datastore.network=this.network.name,this.dirty=!0},e.prototype.addKey=function(t){this.datastore.keys.push(t),this.dirty=!0},e.prototype.addSIN=function(t){this.datastore.sin[t.sin]=t,this.dirty=!0},e.prototype.findKeyHash=function(t){for(var e=t.toString(),r=0;r
-#ifdef _MSC_VER
-#define strcasecmp _stricmp
-#endif
-
-#include
-#include
-
-#if OPENSSL_VERSION_NUMBER >= 0x10000000L
-# define OPENSSL_CONST const
-#else
-# define OPENSSL_CONST
-#endif
-
-#define ASSERT_IS_STRING_OR_BUFFER(val) \
- if (!Buffer::HasInstance(val) && !val->IsString()) { \
- return ThrowException(Exception::TypeError(String::New( \
- "Not a string or buffer"))); \
- }
-
-#define ASSERT_IS_BUFFER(val) \
- if (!Buffer::HasInstance(val)) { \
- return ThrowException(Exception::TypeError(String::New("Not a buffer"))); \
- }
-
-namespace node {
-namespace cryptox {
-
-using namespace v8;
-
-struct pbkdf2_req {
- uv_work_t work_req;
- int err;
- char* pass;
- size_t passlen;
- char* salt;
- size_t saltlen;
- size_t iter;
- char* key;
- size_t keylen;
- Persistent