From eaaa35cb8e5908bb51a6e42c76c5573078e0c6ff Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Mon, 12 Dec 2016 12:31:27 -0800 Subject: [PATCH] script: minor. --- lib/script/script.js | 34 +++++++++++++++++----------------- lib/script/witness.js | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/script/script.js b/lib/script/script.js index d7e518ae..7d20a2d2 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -247,6 +247,23 @@ Script.prototype.toASM = function toASM(decode) { return Script.formatASM(this.code, decode); }; +/** + * Calculate size of code to be compiled. + * @returns {Number} + */ + +Script.prototype.getCodeSize = function getCodeSize() { + var size = 0; + var i, op; + + for (i = 0; i < this.code.length; i++) { + op = this.code[i]; + size += op.getSize(); + } + + return size; +}; + /** * Re-encode the script internally. Useful if you * changed something manually in the `code` array. @@ -1964,23 +1981,6 @@ Script.prototype.getVarSize = function getVarSize() { return enc.sizeVarBytes(this.raw); }; -/** - * Calculate size of code to be compiled. - * @returns {Number} - */ - -Script.prototype.getCodeSize = function getCodeSize() { - var size = 0; - var i, op; - - for (i = 0; i < this.code.length; i++) { - op = this.code[i]; - size += op.getSize(); - } - - return size; -}; - /** * "Guess" the address of the input script. * This method is not 100% reliable. diff --git a/lib/script/witness.js b/lib/script/witness.js index b0a85160..2f08c912 100644 --- a/lib/script/witness.js +++ b/lib/script/witness.js @@ -355,7 +355,7 @@ Witness.prototype.toWriter = function toWriter(bw) { */ Witness.prototype.toRaw = function toRaw() { - var size = this.getSize(); + var size = this.getVarSize(); return this.toWriter(new StaticWriter(size)).render(); };