|
|
@ -5,10 +5,9 @@ var Address = require('./address'); |
|
|
|
var BufferReader = require('./encoding/bufferreader'); |
|
|
|
var BufferWriter = require('./encoding/bufferwriter'); |
|
|
|
var Hash = require('./crypto/hash'); |
|
|
|
var Hash = require('./crypto/hash'); |
|
|
|
var Opcode = require('./opcode'); |
|
|
|
var PublicKey = require('./publickey'); |
|
|
|
var PublicKey = require('./publickey'); |
|
|
|
var Signature = require('./crypto/signature'); |
|
|
|
|
|
|
|
var _ = require('lodash'); |
|
|
|
var buffer = require('buffer'); |
|
|
@ -545,18 +544,17 @@ Script.buildScriptHashOut = function(script) { |
|
|
|
* Builds a scriptSig (a script for an input) that signs a public key hash |
|
|
|
* output script. |
|
|
|
* |
|
|
|
* @param {Object} signature |
|
|
|
* @param {PublicKey} signature.publicKey |
|
|
|
* @param {Buffer} signature.signature |
|
|
|
* @param {number} signature.sigtype |
|
|
|
* @param {Buffer|string|PublicKey} publicKey |
|
|
|
* @param {Buffer} signature - the signature in DER cannonical encoding |
|
|
|
* @param {number=1} sigtype - the type of the signature (defaults to SIGHASH_ALL) |
|
|
|
*/ |
|
|
|
Script.buildPublicKeyHashIn = function(signature) { |
|
|
|
Script.buildPublicKeyHashIn = function(publicKey, signature, sigtype) { |
|
|
|
var script = new Script() |
|
|
|
.add(bufferUtil.concat([ |
|
|
|
signature.signature.toDER(), |
|
|
|
bufferUtil.integerAsSingleByteBuffer(signature.sigtype) |
|
|
|
signature, |
|
|
|
bufferUtil.integerAsSingleByteBuffer(sigtype || Signature.SIGHASH_ALL) |
|
|
|
])) |
|
|
|
.add(signature.publicKey.toBuffer()); |
|
|
|
.add(new PublicKey(publicKey).toBuffer()); |
|
|
|
return script; |
|
|
|
}; |
|
|
|
|
|
|
|