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
src
test/fixtures

View file

@ -35,12 +35,10 @@ Address.fromBase58Check = function(string) {
Address.fromOutputScript = function(script, network) { Address.fromOutputScript = function(script, network) {
network = network || networks.bitcoin 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) assert(false, script.toASM() + ' has no matching Address')
if (type === 'scripthash') return new Address(script.chunks[1], network.scriptHash)
assert(false, type + ' has no matching Address')
} }
// Export functions // Export functions

View file

@ -48,15 +48,15 @@
], ],
"fromOutputScript": [ "fromOutputScript": [
{ {
"description": "pubkey has no matching Address", "description": "has no matching Address",
"hex": "21031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95ac" "hex": "21031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95ac"
}, },
{ {
"description": "multisig has no matching Address", "description": "has no matching Address",
"hex": "5121032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca330162102308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a52ae" "hex": "5121032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca330162102308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a52ae"
}, },
{ {
"description": "nulldata has no matching Address", "description": "has no matching Address",
"hex": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474" "hex": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474"
} }
], ],