Script: use PubKey objects not prebuilt Buffers

This commit is contained in:
Daniel Cousens 2014-05-08 13:55:57 +10:00
parent 54cc123d31
commit 55681e7e5d
4 changed files with 13 additions and 13 deletions

View file

@ -295,12 +295,15 @@ Script.createP2SHScriptPubKey = function(hash) {
// m [pubKeys ...] n OP_CHECKMULTISIG
Script.createMultisigScriptPubKey = function(m, pubKeys) {
var script = new Script()
var n = pubKeys.length
script.writeOp(opcodes.OP_1 + m - 1)
for (var i = 0; i < pubKeys.length; ++i) {
script.writeBytes(pubKeys[i])
}
script.writeOp(opcodes.OP_1 + pubKeys.length - 1)
script.writeOp((opcodes.OP_1 - 1) + m)
pubKeys.forEach(function(pubKey) {
script.writeBytes(pubKey.toBuffer())
})
script.writeOp((opcodes.OP_1 - 1) + n)
script.writeOp(opcodes.OP_CHECKMULTISIG)
return script