|
|
@ -1,6 +1,6 @@ |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
var Address = require('../address'); |
|
|
|
var BufferReader = require('../encoding/bufferreader'); |
|
|
|
var BufferWriter = require('../encoding/bufferwriter'); |
|
|
|
var Hash = require('../crypto/hash'); |
|
|
@ -8,7 +8,6 @@ var Opcode = require('../opcode'); |
|
|
|
var PublicKey = require('../publickey'); |
|
|
|
var Signature = require('../crypto/signature'); |
|
|
|
var Networks = require('../networks'); |
|
|
|
|
|
|
|
var $ = require('../util/preconditions'); |
|
|
|
var _ = require('lodash'); |
|
|
|
var errors = require('../errors'); |
|
|
@ -29,8 +28,6 @@ var Script = function Script(from) { |
|
|
|
if (!(this instanceof Script)) { |
|
|
|
return new Script(from); |
|
|
|
} |
|
|
|
var Address = require('../address'); |
|
|
|
|
|
|
|
this.chunks = []; |
|
|
|
|
|
|
|
if (BufferUtil.isBuffer(from)) { |
|
|
@ -639,7 +636,6 @@ Script.buildP2SHMultisigIn = function(pubkeys, threshold, signatures, opts) { |
|
|
|
* @param {(Address|PublicKey)} to - destination address or public key |
|
|
|
*/ |
|
|
|
Script.buildPublicKeyHashOut = function(to) { |
|
|
|
var Address = require('../address'); |
|
|
|
$.checkArgument(!_.isUndefined(to)); |
|
|
|
$.checkArgument(to instanceof PublicKey || to instanceof Address || _.isString(to)); |
|
|
|
if (to instanceof PublicKey) { |
|
|
@ -692,7 +688,6 @@ Script.buildDataOut = function(data) { |
|
|
|
* @returns {Script} new pay to script hash script for given script |
|
|
|
*/ |
|
|
|
Script.buildScriptHashOut = function(script) { |
|
|
|
var Address = require('../address'); |
|
|
|
$.checkArgument(script instanceof Script || |
|
|
|
(script instanceof Address && script.isPayToScriptHash())); |
|
|
|
var s = new Script(); |
|
|
@ -745,7 +740,6 @@ Script.prototype.toScriptHashOut = function() { |
|
|
|
* @return {Script} an output script built from the address |
|
|
|
*/ |
|
|
|
Script.fromAddress = function(address) { |
|
|
|
var Address = require('../address'); |
|
|
|
address = Address(address); |
|
|
|
if (address.isPayToScriptHash()) { |
|
|
|
return Script.buildScriptHashOut(address); |
|
|
@ -761,7 +755,6 @@ Script.fromAddress = function(address) { |
|
|
|
* for this script if any, or false |
|
|
|
*/ |
|
|
|
Script.prototype.getAddressInfo = function() { |
|
|
|
var Address = require('../address'); |
|
|
|
var info = {}; |
|
|
|
if (this.isScriptHashOut()) { |
|
|
|
info.hashBuffer = this.getData(); |
|
|
@ -787,7 +780,6 @@ Script.prototype.getAddressInfo = function() { |
|
|
|
* @return {Address|boolean} the associated address for this script if possible, or false |
|
|
|
*/ |
|
|
|
Script.prototype.toAddress = function(network) { |
|
|
|
var Address = require('../address'); |
|
|
|
network = Networks.get(network) || this._network || Networks.defaultNetwork; |
|
|
|
var info = this.getAddressInfo(); |
|
|
|
if (!info) { |
|
|
|