diff --git a/src/address.js b/src/address.js index 124c0ef..cc6264f 100644 --- a/src/address.js +++ b/src/address.js @@ -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 diff --git a/test/fixtures/address.json b/test/fixtures/address.json index cedd17d..28602bc 100644 --- a/test/fixtures/address.json +++ b/test/fixtures/address.json @@ -48,15 +48,15 @@ ], "fromOutputScript": [ { - "description": "pubkey has no matching Address", + "description": "has no matching Address", "hex": "21031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95ac" }, { - "description": "multisig has no matching Address", + "description": "has no matching Address", "hex": "5121032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca330162102308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a52ae" }, { - "description": "nulldata has no matching Address", + "description": "has no matching Address", "hex": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474" } ],