remove mutable arg from inputs/outputs.

This commit is contained in:
Christopher Jeffrey 2016-07-01 00:47:36 -07:00
parent 0a3e61b3e6
commit 6612b7ced3
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
3 changed files with 19 additions and 25 deletions

View File

@ -184,7 +184,6 @@ Outpoint.prototype.inspect = function inspect() {
* @exports Input
* @constructor
* @param {NakedInput} options
* @param {Boolean?} mutable
* @property {Outpoint} prevout - Outpoint.
* @property {Script} script - Input script / scriptSig.
* @property {Number} sequence - nSequence.
@ -195,33 +194,30 @@ Outpoint.prototype.inspect = function inspect() {
* @property {Boolean} mutable
*/
function Input(options, mutable) {
function Input(options) {
if (!(this instanceof Input))
return new Input(options, mutable);
return new Input(options);
this.mutable = false;
this.prevout = new Outpoint();
this.script = new bcoin.script();
this.sequence = 0xffffffff;
this.witness = new bcoin.witness();
this.coin = null;
this.mutable = false;
if (options)
this.fromOptions(options, mutable);
this.fromOptions(options);
}
/**
* Inject properties from options object.
* @private
* @param {Object} options
* @param {Boolean} mutable
*/
Input.prototype.fromOptions = function fromOptions(options, mutable) {
Input.prototype.fromOptions = function fromOptions(options) {
assert(options, 'Input data is required.');
this.mutable = !!mutable;
if (options.prevout)
this.prevout.fromOptions(options.prevout);

View File

@ -69,11 +69,11 @@ function MTX(options) {
this.inputs = [];
this.outputs = [];
this.locktime = 0;
this.ts = 0;
this.block = null;
this.index = -1;
this.ps = options.ps != null ? options.ps : utils.now();
this.changeIndex = options.changeIndex != null ? options.changeIndex : -1;
this.height = -1;
this.mutable = true;
@ -91,6 +91,8 @@ function MTX(options) {
this._hashSequence = null;
this._hashOutputs = null;
this.changeIndex = options.changeIndex != null ? options.changeIndex : -1;
if (options.inputs) {
for (i = 0; i < options.inputs.length; i++)
this.addInput(options.inputs[i]);
@ -158,7 +160,8 @@ MTX.prototype.addInput = function addInput(options, index) {
assert(options.prevout);
input = new bcoin.input(options, true);
input = new bcoin.input(options);
input.mutable = true;
this.inputs.push(input);
@ -720,7 +723,8 @@ MTX.prototype.addOutput = function addOutput(address, value) {
options = address;
}
output = new bcoin.output(options, true);
output = new bcoin.output(options);
output.mutable = true;
if (options.address)
output.script = Script.fromAddress(options.address);

View File

@ -17,7 +17,6 @@ var assert = utils.assert;
* @exports Output
* @constructor
* @param {NakedOutput} options
* @param {Boolean?} mutable
* @property {Amount} value - Value in satoshis.
* @property {Script} script
* @property {String} type - Script type.
@ -25,31 +24,27 @@ var assert = utils.assert;
* @property {Boolean} mutable
*/
function Output(options, mutable) {
function Output(options) {
if (!(this instanceof Output))
return new Output(options, mutable);
return new Output(options);
this.mutable = false;
this.value = 0;
this.script = new bcoin.script();
this.mutable = false;
if (options)
this.fromOptions(options, mutable);
this.fromOptions(options);
}
/**
* Inject properties from options object.
* @private
* @param {NakedOutput} options
* @param {Boolean} mutable
*/
Output.prototype.fromOptions = function fromOptions(options, mutable) {
Output.prototype.fromOptions = function fromOptions(options) {
assert(options, 'Output data is required.');
assert(!options.value || utils.isNumber(options.value));
assert(!mutable || options.value >= 0);
this.mutable = !!mutable;
if (options.value)
this.value = options.value;
@ -63,12 +58,11 @@ Output.prototype.fromOptions = function fromOptions(options, mutable) {
/**
* Instantiate output from options object.
* @param {NakedOutput} options
* @param {Boolean} mutable
* @returns {Output}
*/
Output.fromOptions = function fromOptions(options, mutable) {
return new Output().fromOptions(options, mutable);
Output.fromOptions = function fromOptions(options) {
return new Output().fromOptions(options);
};
/**