From 87a94639d4f6656b78ecbe96969ca6638b41bd8f Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Fri, 1 Jul 2016 14:48:23 -0700 Subject: [PATCH] fix parse error. misc. --- lib/bcoin/chain.js | 1 + lib/bcoin/miner.js | 3 ++- lib/bcoin/script.js | 23 ++++++++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/bcoin/chain.js b/lib/bcoin/chain.js index 4e38c1fb..87698686 100644 --- a/lib/bcoin/chain.js +++ b/lib/bcoin/chain.js @@ -155,6 +155,7 @@ Chain.prototype._init = function _init() { this.on('exists', function(block, height) { bcoin.debug('Already have block %s (%d).', block.rhash, height); + }); this.on('orphan', function(block, height) { bcoin.debug('Handled orphan %s (%d).', block.rhash, height); diff --git a/lib/bcoin/miner.js b/lib/bcoin/miner.js index cc0547a5..e408faf1 100644 --- a/lib/bcoin/miner.js +++ b/lib/bcoin/miner.js @@ -460,7 +460,8 @@ MinerBlock.prototype.updateCommitment = function updateCommitment() { hash = this.block.getCommitmentHash(); // Update commitment. - output.script = bcoin.script.fromCommitment(hash, flags); + output.script.clear(); + output.script.fromCommitment(hash, flags); }; /** diff --git a/lib/bcoin/script.js b/lib/bcoin/script.js index b2744101..955a8d5c 100644 --- a/lib/bcoin/script.js +++ b/lib/bcoin/script.js @@ -2555,6 +2555,7 @@ Script.prototype.fromMultisig = function fromMultisig(m, n, keys) { this.push(n + 0x50); this.push(opcodes.OP_CHECKMULTISIG); + this.compile(); return this; @@ -2692,14 +2693,7 @@ Script.fromAddress = function fromAddress(address) { */ Script.prototype.fromCommitment = function fromCommitment(hash, flags) { - var p; - - if (typeof flags === 'string') - flags = new Buffer(flags, 'utf8'); - - assert(!flags || Buffer.isBuffer(flags)); - - p = new BufferWriter(); + var p = new BufferWriter(); p.writeU32BE(0xaa21a9ed); p.writeHash(hash); @@ -4656,7 +4650,7 @@ Opcode.prototype.toRaw = function toRaw(writer) { }; /** - * Instantiate an opcode from a number. + * Instantiate an opcode from a number opcode. * @param {Number} op * @returns {Opcode} */ @@ -4721,6 +4715,17 @@ Opcode.fromNumber = function fromNumber(num) { return Opcode.fromData(Script.array(num)); }; +/** + * Instantiate an opcode from a small number. + * @param {Number} num + * @returns {Opcode} + */ + +Opcode.fromSmall = function fromSmall(num) { + assert(utils.isNumber(num) && num >= 0 && num <= 16); + return new Opcode(num === 0 ? 0 : num + 0x50); +}; + /** * Instantiate a pushdata opcode from a string. * @param {String} data