Address: add Address.*ScriptPubKey and tests
The introduction of these two functions allow for the all the network related code to be eventually removed from Transaction and Script. Previously the result for non-standard transactions was undefined behaviour. This change mandates that an exception is thrown if a non-standard transaction is input.
This commit is contained in:
parent
0822def7e0
commit
5e0d38ba54
4 changed files with 129 additions and 30 deletions
src
|
@ -205,13 +205,7 @@ Script.prototype.toScriptHash = function() {
|
|||
Script.prototype.getToAddress = function(network) {
|
||||
network = network || networks.bitcoin
|
||||
|
||||
if(isPubkeyhash.call(this)) {
|
||||
return new Address(new Buffer(this.chunks[2]), network.pubKeyHash)
|
||||
}
|
||||
|
||||
assert(isScripthash.call(this))
|
||||
|
||||
return new Address(new Buffer(this.chunks[1]), network.scriptHash)
|
||||
return Address.fromScriptPubKey(this, network)
|
||||
}
|
||||
|
||||
Script.prototype.getFromAddress = function(version) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue