clone mtx properly.
This commit is contained in:
parent
5cab304a59
commit
f7bdcfdfb2
@ -63,7 +63,14 @@ function MTX(options) {
|
||||
utils.inherits(MTX, bcoin.tx);
|
||||
|
||||
MTX.prototype.clone = function clone() {
|
||||
return new MTX(this);
|
||||
var tx = new MTX(this);
|
||||
tx.locktime = this.locktime;
|
||||
tx.ts = this.ts;
|
||||
tx.block = this.block;
|
||||
tx.index = this.index;
|
||||
tx.ps = this.ps;
|
||||
tx.height = this.height;
|
||||
return tx;
|
||||
};
|
||||
|
||||
MTX.prototype.hash = function hash(enc) {
|
||||
@ -118,6 +125,8 @@ MTX.prototype.getVirtualSize = function getVirtualSize() {
|
||||
MTX.prototype.addInput = function addInput(options, index) {
|
||||
var input;
|
||||
|
||||
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
||||
|
||||
if (options instanceof MTX)
|
||||
options = bcoin.coin(options, index);
|
||||
|
||||
@ -146,6 +155,8 @@ MTX.prototype.addInput = function addInput(options, index) {
|
||||
MTX.prototype.scriptInput = function scriptInput(index, addr) {
|
||||
var input, prev, n, i, redeemScript, witnessScript, vector, dummy;
|
||||
|
||||
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
||||
|
||||
if (typeof index !== 'number')
|
||||
index = this.inputs.indexOf(index);
|
||||
|
||||
@ -338,6 +349,8 @@ MTX.prototype.signInput = function signInput(index, addr, type) {
|
||||
var input, prev, signature, ki, signatures, i;
|
||||
var len, m, n, keys, vector, dummy, version;
|
||||
|
||||
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
||||
|
||||
if (typeof index !== 'number')
|
||||
index = this.inputs.indexOf(index);
|
||||
|
||||
@ -626,6 +639,8 @@ MTX.prototype.sign = function sign(index, addr, type) {
|
||||
MTX.prototype.addOutput = function addOutput(obj, value) {
|
||||
var options, output;
|
||||
|
||||
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
||||
|
||||
if ((obj instanceof bcoin.wallet) || (obj instanceof bcoin.address))
|
||||
obj = obj.getAddress();
|
||||
|
||||
@ -650,6 +665,8 @@ MTX.prototype.addOutput = function addOutput(obj, value) {
|
||||
MTX.prototype.scriptOutput = function scriptOutput(index, options) {
|
||||
var output;
|
||||
|
||||
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
||||
|
||||
if (options instanceof bcoin.output)
|
||||
return;
|
||||
|
||||
@ -939,6 +956,8 @@ MTX.prototype.fill = function fill(coins, options) {
|
||||
var self = this;
|
||||
var result, err;
|
||||
|
||||
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
||||
|
||||
if (!options || typeof options !== 'object') {
|
||||
options = {
|
||||
changeAddress: arguments[1],
|
||||
@ -980,6 +999,8 @@ MTX.prototype.fill = function fill(coins, options) {
|
||||
MTX.prototype.sortMembers = function sortMembers() {
|
||||
var changeOutput;
|
||||
|
||||
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
||||
|
||||
if (this.changeIndex !== -1) {
|
||||
changeOutput = this.outputs[this.changeIndex];
|
||||
assert(changeOutput);
|
||||
@ -1023,6 +1044,8 @@ MTX.prototype.avoidFeeSniping = function avoidFeeSniping(height) {
|
||||
MTX.prototype.setLocktime = function setLocktime(locktime) {
|
||||
var i, input;
|
||||
|
||||
assert(this.ts === 0, 'Cannot modify a confirmed tx.');
|
||||
|
||||
for (i = 0; i < this.inputs.length; i++) {
|
||||
input = this.inputs[i];
|
||||
if (input.sequence === 0xffffffff)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user