always duplicate objects.

This commit is contained in:
Christopher Jeffrey 2016-07-01 02:35:04 -07:00
parent 27b88ddba9
commit f5ea3b1870
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 1 additions and 46 deletions

View File

@ -29,9 +29,6 @@ var assert = utils.assert;
*/
function Coin(options) {
if (options instanceof Coin)
return options;
if (!(this instanceof Coin))
return new Coin(options);
@ -85,8 +82,6 @@ Coin.prototype.fromOptions = function fromOptions(options) {
*/
Coin.fromOptions = function fromOptions(options) {
if (options instanceof Coin)
return options;
return new Coin().fromOptions(options);
};

View File

@ -32,9 +32,6 @@ var ScriptError = bcoin.errors.ScriptError;
*/
function Witness(options) {
if (options instanceof Witness)
return options;
if (!(this instanceof Witness))
return new Witness(options);
@ -1090,9 +1087,6 @@ Stack.isStack = function isStack(obj) {
*/
function Script(options) {
if (options instanceof Script)
return options;
if (!(this instanceof Script))
return new Script(options);
@ -1156,8 +1150,6 @@ Script.prototype.fromOptions = function fromOptions(options) {
*/
Script.fromOptions = function fromOptions(options) {
if (options instanceof Script)
return options;
return new Script().fromOptions(options);
};

View File

@ -166,39 +166,7 @@ TX.fromOptions = function fromOptions(options) {
*/
TX.prototype.clone = function clone() {
var copy = new TX();
var i, input, output;
copy.ts = this.ts;
copy.block = this.block;
copy.index = this.index;
copy.height = this.height;
copy.version = this.version;
copy.flag = this.flag;
for (i = 0; i < this.inputs.length; i++) {
input = new bcoin.input();
input.prevout = new bcoin.outpoint();
input.prevout.hash = this.inputs[i].prevout.hash;
input.prevout.index = this.inputs[i].prevout.index;
input.coin = this.inputs[i].coin;
input.script = this.inputs[i].script;
input.witness = this.inputs[i].witness;
input.sequence = this.inputs[i].sequence;
copy.inputs.push(input);
}
for (i = 0; i < this.outputs.length; i++) {
output = new bcoin.output();
output.value = this.outputs[i].value;
output.script = this.outputs[i].script;
copy.outputs.push(output);
}
copy.locktime = this.locktime;
return copy;
return new TX(this);
};
/**