script: minor.

This commit is contained in:
Christopher Jeffrey 2016-12-12 12:31:27 -08:00
parent 41a2a46403
commit eaaa35cb8e
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 18 additions and 18 deletions

View File

@ -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.

View File

@ -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();
};