script: minor.
This commit is contained in:
parent
41a2a46403
commit
eaaa35cb8e
@ -247,6 +247,23 @@ Script.prototype.toASM = function toASM(decode) {
|
|||||||
return Script.formatASM(this.code, 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
|
* Re-encode the script internally. Useful if you
|
||||||
* changed something manually in the `code` array.
|
* changed something manually in the `code` array.
|
||||||
@ -1964,23 +1981,6 @@ Script.prototype.getVarSize = function getVarSize() {
|
|||||||
return enc.sizeVarBytes(this.raw);
|
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.
|
* "Guess" the address of the input script.
|
||||||
* This method is not 100% reliable.
|
* This method is not 100% reliable.
|
||||||
|
|||||||
@ -355,7 +355,7 @@ Witness.prototype.toWriter = function toWriter(bw) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
Witness.prototype.toRaw = function toRaw() {
|
Witness.prototype.toRaw = function toRaw() {
|
||||||
var size = this.getSize();
|
var size = this.getVarSize();
|
||||||
return this.toWriter(new StaticWriter(size)).render();
|
return this.toWriter(new StaticWriter(size)).render();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user