Browse Source

updated _estimateSize for bare multisig input

patch-2
Ruben de Vries 9 years ago
parent
commit
502026086c
  1. 8
      lib/transaction/input/multisig.js
  2. 2
      test/transaction/input/multisig.js

8
lib/transaction/input/multisig.js

@ -200,14 +200,12 @@ MultiSigInput.normalizeSignatures = function(transaction, input, inputIndex, sig
});
};
MultiSigInput.OPCODES_SIZE = 7; // serialized size (<=3) + 0 .. N .. M OP_CHECKMULTISIG
MultiSigInput.SIGNATURE_SIZE = 74; // size (1) + DER (<=72) + sighash (1)
MultiSigInput.PUBKEY_SIZE = 34; // size (1) + DER (<=33)
MultiSigInput.OPCODES_SIZE = 1; // 0
MultiSigInput.SIGNATURE_SIZE = 73; // size (1) + DER (<=72)
MultiSigInput.prototype._estimateSize = function() {
return MultiSigInput.OPCODES_SIZE +
this.threshold * MultiSigInput.SIGNATURE_SIZE +
this.publicKeys.length * MultiSigInput.PUBKEY_SIZE;
this.threshold * MultiSigInput.SIGNATURE_SIZE;
};
module.exports = MultiSigInput;

2
test/transaction/input/multisig.js

@ -101,7 +101,7 @@ describe('MultiSigInput', function() {
.from(output, [public1, public2, public3], 2)
.to(address, 1000000);
var input = transaction.inputs[0];
input._estimateSize().should.equal(257);
input._estimateSize().should.equal(147);
});
it('uses SIGHASH_ALL by default', function() {
var transaction = new Transaction()

Loading…
Cancel
Save