Address: no need to check other script types

This commit is contained in:
Daniel Cousens 2014-11-28 13:53:43 +11:00
parent 254974d999
commit 4fe0b34f27
2 changed files with 6 additions and 8 deletions

View file

@ -35,12 +35,10 @@ Address.fromBase58Check = function(string) {
Address.fromOutputScript = function(script, network) {
network = network || networks.bitcoin
var type = scripts.classifyOutput(script)
if (scripts.isPubKeyHashOutput(script)) return new Address(script.chunks[2], network.pubKeyHash)
if (scripts.isScriptHashOutput(script)) return new Address(script.chunks[1], network.scriptHash)
if (type === 'pubkeyhash') return new Address(script.chunks[2], network.pubKeyHash)
if (type === 'scripthash') return new Address(script.chunks[1], network.scriptHash)
assert(false, type + ' has no matching Address')
assert(false, script.toASM() + ' has no matching Address')
}
// Export functions