|
|
@ -1,16 +1,15 @@ |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var _ = require('lodash'); |
|
|
|
var bu = require('./util/buffer'); |
|
|
|
|
|
|
|
var Address = require('./address'); |
|
|
|
var BufferReader = require('./encoding/bufferreader'); |
|
|
|
var BufferWriter = require('./encoding/bufferwriter'); |
|
|
|
var Errors = require('./errors'); |
|
|
|
var Hash = require('./crypto/hash'); |
|
|
|
var Opcode = require('./opcode'); |
|
|
|
var PublicKey = require('./publickey'); |
|
|
|
var PublicKey = require('./publickey'); |
|
|
|
var Hash = require('./crypto/hash'); |
|
|
|
var bu = require('./util/buffer'); |
|
|
|
var _ = require('lodash'); |
|
|
|
|
|
|
|
/** |
|
|
|
* A bitcoin transaction script. Each transaction's inputs and outputs |
|
|
@ -304,6 +303,17 @@ Script.prototype.isDataOut = function() { |
|
|
|
this.chunks[1].length === this.chunks.len))); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* @returns true if the script is only composed of data pushing |
|
|
|
* opcodes or small int opcodes (OP_0, OP_1, ..., OP_16) |
|
|
|
*/ |
|
|
|
Script.prototype.isPushOnly = function() { |
|
|
|
return _.every(this.chunks, function(chunk) { |
|
|
|
var opcodenum = chunk.opcodenum; |
|
|
|
return !_.isUndefined(opcodenum) || chunk <= Opcode.map.OP_16; |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Script.types = {}; |
|
|
|
Script.types.UNKNOWN = 'Unknown'; |
|
|
@ -453,7 +463,7 @@ Script.prototype.removeCodeseparators = function() { |
|
|
|
* @returns a new Multisig output script for given public keys, |
|
|
|
* requiring m of those public keys to spend |
|
|
|
* @param {PublicKey[]} pubkeys - list of all public keys controlling the output |
|
|
|
* @param {number} m - amount of required signatures to spend the output |
|
|
|
* @param {number} m - amount of required signatures to spend the output |
|
|
|
*/ |
|
|
|
Script.buildMultisigOut = function(pubkeys, m) { |
|
|
|
var s = new Script(); |
|
|
@ -513,7 +523,7 @@ Script.buildDataOut = function(data) { |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param {Script} script - the redeemScript for the new p2sh output |
|
|
|
* @param {Script} script - the redeemScript for the new p2sh output |
|
|
|
* @returns Script new pay to script hash script for given script |
|
|
|
*/ |
|
|
|
Script.buildScriptHashOut = function(script) { |
|
|
|