shuffle outputs
This commit is contained in:
parent
e06a788e05
commit
4a53da8690
|
@ -32,6 +32,7 @@ TxProposal.create = function(opts) {
|
||||||
x.requiredRejections = opts.requiredRejections;
|
x.requiredRejections = opts.requiredRejections;
|
||||||
x.status = 'pending';
|
x.status = 'pending';
|
||||||
x.actions = [];
|
x.actions = [];
|
||||||
|
x.outputOrder = _.shuffle(_.range(2));
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
@ -58,6 +59,7 @@ TxProposal.fromObj = function(obj) {
|
||||||
x.actions = _.map(obj.actions, function(action) {
|
x.actions = _.map(obj.actions, function(action) {
|
||||||
return TxProposalAction.fromObj(action);
|
return TxProposalAction.fromObj(action);
|
||||||
});
|
});
|
||||||
|
x.outputOrder = obj.outputOrder;
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,6 +22,17 @@ describe('TXProposal', function() {
|
||||||
var t = txp.getBitcoreTx();
|
var t = txp.getBitcoreTx();
|
||||||
should.exist(t);
|
should.exist(t);
|
||||||
});
|
});
|
||||||
|
it('should order ouputs as specified by outputOrder', function() {
|
||||||
|
var txp = TXP.fromObj(aTXP());
|
||||||
|
|
||||||
|
txp.outputOrder = [0, 1];
|
||||||
|
var t = txp._getBitcoreTx();
|
||||||
|
t.getChangeOutput().should.deep.equal(t.outputs[1]);
|
||||||
|
|
||||||
|
txp.outputOrder = [1, 0];
|
||||||
|
var t = txp._getBitcoreTx();
|
||||||
|
t.getChangeOutput().should.deep.equal(t.outputs[0]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,6 +119,7 @@ var aTXP = function() {
|
||||||
"requiredSignatures": 2,
|
"requiredSignatures": 2,
|
||||||
"requiredRejections": 1,
|
"requiredRejections": 1,
|
||||||
"status": "pending",
|
"status": "pending",
|
||||||
"actions": []
|
"actions": [],
|
||||||
|
"outputOrder": [0, 1],
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue