Skip to content

Commit dfe3b1a

Browse files
authored
Consider the size of version in AggregateTransaction.setMaxFeeForAggregate (#694)
1 parent a74ee08 commit dfe3b1a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/model/transaction/AggregateTransaction.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,10 @@ export class AggregateTransaction extends Transaction {
409409
}
410410
// Check if current cosignature count is greater than requiredCosignatures.
411411
const calculatedCosignatures = requiredCosignatures > this.cosignatures.length ? requiredCosignatures : this.cosignatures.length;
412+
// version + public key + signature
413+
const sizePerCosignature = 8 + 32 + 64;
412414
// Remove current cosignature length and use the calculated one.
413-
const calculatedSize = this.size - this.cosignatures.length * 96 + calculatedCosignatures * 96;
415+
const calculatedSize = this.size - this.cosignatures.length * sizePerCosignature + calculatedCosignatures * sizePerCosignature;
414416
return DtoMapping.assign(this, {
415417
maxFee: UInt64.fromUint(calculatedSize * feeMultiplier),
416418
});

test/model/transaction/AggregateTransaction.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,9 @@ describe('AggregateTransaction', () => {
626626
NetworkType.PRIVATE_TEST,
627627
[],
628628
).setMaxFeeForAggregate(2, 10);
629-
expect(aggregateTransaction.maxFee.compact()).to.be.equal(560 + 960 * 2);
629+
const size = aggregateTransaction.size;
630+
expect(size).to.be.equal(280);
631+
expect(aggregateTransaction.maxFee.compact()).to.be.equal((size + 104 * 10) * 2);
630632

631633
const signedTransaction = aggregateTransaction.signWith(account, generationHash);
632634
expect(signedTransaction.hash).not.to.be.undefined;

0 commit comments

Comments
 (0)