(function(r){"use strict";functione(){e.super(this,arguments)}vari=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)thrownewError("Invalid public key");varn=s[i].addressVersion,o=t.sha256ripe160(r);returnnewe(n,o)},e.fromKey=function(r,i){returne.fromPubKey(r.public,i)},e.fromPubKeys=function(r,i,t,n){t||(t="livenet");for(varsini){vara=i[s];if(33!=a.length&&65!=a.length)thrownewError("Invalid public key")}varu=o.createMultisig(r,i,n);returne.fromScript(u,t)},e.fromScript=function(i,n){n||(n="livenet"),"string"==typeofi&&(i=newo(newr(i,"hex")));vara=s[n].P2SHVersion,u=i.getBuffer(),f=t.sha256ripe160(u);returnnewe(a,f)},e.fromScriptPubKey=function(i,n){"string"==typeofi&&(i=newo(newr(i,"hex"))),n||(n="livenet");vara,u=[],f=i.capture();if(f){varp=i.classify();switch(p){caseo.TX_PUBKEY:f[0]=t.sha256ripe160(f[0]),a=s[n].addressVersion;break;caseo.TX_PUBKEYHASH:a=s[n].addressVersion;break;caseo.TX_MULTISIG:a=s[n].addressVersion;for(varcinf)f[c]=t.sha256ripe160(f[c]);break;caseo.TX_SCRIPTHASH:a=s[n].P2SHVersion}for(varcinf)u.push(newe(a,f[c]))}returnu},e.prototype.validate=function(){if(this.doAsBinary(function(){if(e.super(this,"validate",arguments),21!==this.data.length)thrownewError("invalid data length")}),"undefined"==typeofthis.network())thrownewError("invalid network")},e.prototype.isValid=function(){varr=e.super(this,"isValid",arguments);returnr},e.prototype.network=function(){varr,e=this.version(),i=s.livenet,t=s.testnet;returne===i.addressVersion||e===i.P2SHVersion?r=i:(e===t.addressVersion||e===t.P2SHVersion)&&(r=t),r},e.prototype.isScript=function(){returnthis.isValid()&&this.version()===this.network().P2SHVersion},module.exports=require("soop")(e)}).call(this,require("buffer").Buffer);
(function(r){"use strict";functione(r,i){if(i&&i.length&&20!=i.length)thrownewError("Hash must be 20 bytes");e.super(this,arguments)}vari=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)thrownewError("Invalid public key");varn=s[i].addressVersion,o=t.sha256ripe160(r);returnnewe(n,o)},e.fromKey=function(r,i){returne.fromPubKey(r.public,i)},e.fromPubKeys=function(r,i,t,n){t||(t="livenet");for(varsini){vara=i[s];if(33!=a.length&&65!=a.length)thrownewError("Invalid public key")}varu=o.createMultisig(r,i,n);returne.fromScript(u,t)},e.fromScript=function(i,n){n||(n="livenet"),"string"==typeofi&&(i=newo(newr(i,"hex")));vara=s[n].P2SHVersion,u=i.getBuffer(),f=t.sha256ripe160(u);returnnewe(a,f)},e.fromScriptPubKey=function(i,n){"string"==typeofi&&(i=newo(newr(i,"hex"))),n||(n="livenet");vara,u=[],f=i.capture();if(f){varp=i.classify();switch(p){caseo.TX_PUBKEY:f[0]=t.sha256ripe160(f[0]),a=s[n].addressVersion;break;caseo.TX_PUBKEYHASH:a=s[n].addressVersion;break;caseo.TX_MULTISIG:a=s[n].addressVersion;for(varlinf)f[l]=t.sha256ripe160(f[l]);break;caseo.TX_SCRIPTHASH:a=s[n].P2SHVersion}for(varlinf)u.push(newe(a,f[l]))}returnu},e.prototype.validate=function(){if(this.doAsBinary(function(){if(e.super(this,"validate",arguments),21!==this.data.length)thrownewError("invalid data length")}),"undefined"==typeofthis.network())thrownewError("invalid network")},e.prototype.isValid=function(){varr=e.super(this,"isValid",arguments);returnr},e.prototype.network=function(){varr,e=this.version(),i=s.livenet,t=s.testnet;returne===i.addressVersion||e===i.P2SHVersion?r=i:(e===t.addressVersion||e===t.P2SHVersion)&&(r=t),r},e.prototype.isScript=function(){returnthis.isValid()&&this.version()===this.network().P2SHVersion},module.exports=require("soop")(e)}).call(this,require("buffer").Buffer);