Browse Source

Add `uncheckedAddInput` function

* For internal usage: for example, testing Script.Interpreter
patch-2
Esteban Ordano 10 years ago
parent
commit
99db72ba90
  1. 16
      lib/transaction/transaction.js
  2. 4
      test/script/interpreter.js

16
lib/transaction/transaction.js

@ -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;
};

4
test/script/interpreter.js

@ -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…
Cancel
Save