Browse Source

Address: no need to check other script types

hk-custom-address
Daniel Cousens 10 years ago
parent
commit
4fe0b34f27
  1. 8
      src/address.js
  2. 6
      test/fixtures/address.json

8
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

6
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"
}
],

Loading…
Cancel
Save