Add `uncheckedAddInput` function
* For internal usage: for example, testing Script.Interpreter
This commit is contained in:
parent
9a73338c91
commit
99db72ba90
|
@ -414,9 +414,23 @@ Transaction.prototype.addInput = function(input, outputScript, satoshis) {
|
|||
satoshis: satoshis
|
||||
});
|
||||
}
|
||||
return this.uncheckedAddInput(input);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add an input to this transaction, without checking that the input has information about
|
||||
* the output that it's spending.
|
||||
*
|
||||
* @param {Input} input
|
||||
* @return Transaction this, for chaining
|
||||
*/
|
||||
Transaction.prototype.uncheckedAddInput = function(input) {
|
||||
$.checkArgumentType(input, Input, 'input');
|
||||
this._changeSetup = false;
|
||||
this.inputs.push(input);
|
||||
this._inputAmount += input.output.satoshis;
|
||||
if (input.output) {
|
||||
this._inputAmount += input.output.satoshis;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ describe('Interpreter', function() {
|
|||
var hashbuf = new Buffer(32);
|
||||
hashbuf.fill(0);
|
||||
var credtx = Transaction();
|
||||
credtx.inputs.push(new Transaction.Input({
|
||||
credtx.uncheckedAddInput(new Transaction.Input({
|
||||
prevTxId: '0000000000000000000000000000000000000000000000000000000000000000',
|
||||
outputIndex: 0xffffffff,
|
||||
sequenceNumber: 0xffffffff,
|
||||
|
@ -215,7 +215,7 @@ describe('Interpreter', function() {
|
|||
var idbuf = credtx.id;
|
||||
|
||||
var spendtx = Transaction();
|
||||
spendtx.inputs.push(new Transaction.Input({
|
||||
spendtx.uncheckedAddInput(new Transaction.Input({
|
||||
prevTxId: idbuf.toString('hex'),
|
||||
outputIndex: 0,
|
||||
sequenceNumber: 0xffffffff,
|
||||
|
|
Loading…
Reference in New Issue