lisk-sdk icon indicating copy to clipboard operation
lisk-sdk copied to clipboard

API Client: transaction minimum fee miscalculation

Open MichalTuleja opened this issue 3 years ago • 1 comments

Expected behavior

Multisignature transaction with optional members returns the result equal to all optional signatures collected.

The function apiClient.transaction.computeMinFee(txn) assumes all signatures having 64 bytes of length while some of them can equal to 0.

Refer to the https://github.com/LiskHQ/lisk-service/issues/971 for more information.

Actual behavior

Multisignature transaction with optional members returns minimum fees incorrectly.

Steps to reproduce

Use the apiClient.transaction.computeMinFee(txn) on a transaction with a minimum required number of optional signatures.

Additional Information

Current implementation is here https://github.com/LiskHQ/lisk-sdk/blob/development/elements/lisk-transactions/src/fee.ts#L28-L50

Which version(s) does this affect? (Environment, OS, etc...)

latest

MichalTuleja avatar Feb 16 '22 16:02 MichalTuleja

Using apiClient.transaction.computeMinFee(txn) for the following mainnet transaction returns 281000 beddows instead of the expected value of 217000 beddows. And, using computeMinFee directly from the Lisk elements (@liskhq/lisk-transactions, as implemented here) returns a value of 283000 beddows instead.

Dependency versions as resolved in https://github.com/LiskHQ/lisk-service/blob/4591de5eff40368aca9785d4f31ea2cd292d6fdf/services/core/package-lock.json:

@liskhq/lisk-api-client: 5.1.5,
@liskhq/lisk-transactions: 5.2.1

Transaction:

{
  "data": {
    "moduleID": 2,
    "assetID": 0,
    "nonce": "13",
    "fee": "217000",
    "senderPublicKey": "0cff7751b07124a79d985b376204eebf92d98c9e84639e5f7b7d88e19067f925",
    "asset": {
      "amount": "500000000",
      "recipientAddress": "57ea25402b703ab7104f3e7fae13a894b6db887c",
      "data": "Testing"
    },
    "signatures": [
      "e57822cd326a6430c48775103935c638ce06001510759549bf46a4a388393a285ee3d9d63cdf32553d6915878eb61afea3a533ca1f4f05947f1671567f952e0d",
      "64bb009d5ce9d8c6fe8e5838fa26453a2ca561253b325ccb92ae12ce0a5b69da9d20b749c71825b1342505a645fd4e4382a81eb00d4adb725b7d9bb93f21350f",
      ""
    ],
    "id": "62e5b0a9a87561e902a6f6147a34318deec517f0be2b1696b5f1fca489047c71"
  },
  "meta": {}
}

sameersubudhi avatar Feb 21 '22 10:02 sameersubudhi