Skip to content

[LWDM] fix(coin-tezos): reserve the reported fee in send-max (LIVE-28506) - #20292

Open
amaslakov wants to merge 2 commits into
developfrom
fix/coin-tezos-LIVE-28506-send-max-min-fees
Open

[LWDM] fix(coin-tezos): reserve the reported fee in send-max (LIVE-28506)#20292
amaslakov wants to merge 2 commits into
developfrom
fix/coin-tezos-LIVE-28506-send-max-min-fees

Conversation

@amaslakov

@amaslakov amaslakov commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📝 Description

Previous behaviour: Use max on a Tezos account fails with "Sorry, insufficient funds" when the remote minFees config is ≥ 788 mutez, regardless of balance.

Root cause: estimateFees reports mainOpFee = max(minFees, suggestedFee) but the send-max path subtracted the raw (lower) suggestedFee when computing the amount, so amount + reportedFee > spendable and validateIntent rejects it.

Fix: use mainOpFee in the send-max totalFees expression. Unit test and coin-tester scenario added to cover the regression.

🔗 Context

Copilot AI review requested due to automatic review settings July 31, 2026 15:57
@live-github-bot live-github-bot Bot changed the title fix(coin-tezos): reserve the reported fee when computing send-max (LIVE-28506) [LWDM] fix(coin-tezos): reserve the reported fee when computing send-max (LIVE-28506) Jul 31, 2026

This comment was marked as resolved.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Web Tools Build Status

Build Status Deployment
Web Tools Build ✅ Deployed https://web-tools-9g4nlxohh-ledger-hq-prd.vercel.app
Native Storybook Build ⏭️ Skipped
React Storybook Build ⏭️ Skipped

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 7 projects in monorepo, 3 projects with changes.

📊 Quick Summary
Project Total Size Change
desktop-main 2.3 MB 0
desktop-preloader 7.1 KB -
desktop-renderer 80.6 MB +147.0 B (0.0%)
desktop-webviewDappPreloader 36.9 KB ❓ 0
desktop-webviewPreloader 0 B ❓ 0
desktop-workers 36.8 KB 0
mobile 261.4 MB -
📋 Detailed Reports (Click to expand)

📁 desktop-preloader

Path: rsdoctor/desktop-preloader/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 7.1 KB - -
📄 JavaScript 5.3 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 1.8 KB - -

📁 desktop-renderer

Path: rsdoctor/desktop-renderer/rsdoctor-data.json

📌 Baseline Commit: 68b9451b54 | PR: #20253

Metric Current Baseline Change
📊 Total Size 80.6 MB 80.6 MB +147.0 B (0.0%)
📄 JavaScript 29.3 MB 29.3 MB +147.0 B (0.0%)
🎨 CSS 183.1 KB 183.1 KB 0
🌐 HTML 1.8 KB 1.8 KB 0
📁 Other Assets 51.2 MB 51.2 MB 0

📦 Download Diff Report: desktop-renderer Bundle Diff

📁 mobile

Path: rsdoctor/mobile/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 261.4 MB - -
📄 JavaScript 110.4 MB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 151.0 MB - -

Generated by Rsdoctor GitHub Action

Copilot AI review requested due to automatic review settings July 31, 2026 17:05
@amaslakov
amaslakov force-pushed the fix/coin-tezos-LIVE-28506-send-max-min-fees branch from c146f6a to 9a32a74 Compare July 31, 2026 17:05

This comment was marked as outdated.

@amaslakov amaslakov changed the title [LWDM] fix(coin-tezos): reserve the reported fee when computing send-max (LIVE-28506) fix(coin-tezos): reserve the reported fee in send-max (LIVE-28506) Jul 31, 2026
Copilot AI review requested due to automatic review settings July 31, 2026 17:49
@live-github-bot live-github-bot Bot added the shared-lib Label added for automated tagging of PRs label Jul 31, 2026
@live-github-bot live-github-bot Bot changed the title fix(coin-tezos): reserve the reported fee in send-max (LIVE-28506) [LWDM] fix(coin-tezos): reserve the reported fee in send-max (LIVE-28506) Jul 31, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (6)

libs/coin-tester-modules/coin-tester-tezos/src/scenarii/tezos.ts:291

  • Same as above: the comment mentions DUST_MARGIN_MUTEZ but the assertion hardcodes 500, which can drift from the real dust margin. Prefer a named constant (or import) to keep this resilient.
    // Send-max leaves the dust margin behind (DUST_MARGIN_MUTEZ, less the fee-per-gas/op-size
    // increment), independently of how the `minFees` floor compares to the suggested fee.
    expect(account.balance.toNumber()).toBeLessThanOrEqual(500);

.changeset/lucky-otters-wander.md:2

  • This changeset describes a bug fix (send-max validation when minFees exceeds the estimate). That should typically be a patch release for @ledgerhq/coin-tezos, consistent with other coin-tezos fixes (e.g. .changeset/tezos-baker-delegate-account-support.md).
"@ledgerhq/coin-tezos": minor

libs/coin-modules/coin-tezos/src/logic/estimateFees.test.ts:831

  • This test title uses %i for balance, but balance is a BigInt in the table. Using %s avoids implicit Number() coercion (and potential precision loss if larger balances get added later).
    "useAllAmount send reserves the reported fee (balance=%i, minFees=%i, suggested=%i, burn=%i)",

libs/coin-modules/coin-tezos/src/logic/estimateFees.ts:210

  • The new log("tezos-send-max", ...) runs on every send-max estimation (happy path) and can create noisy/high-volume logs in production. Unless this is intentionally permanent telemetry, it should be removed or gated behind a debug flag.
      log("tezos-send-max", "send-max fee inputs", {
        minFees,
        mainOpFee,
        suggestedFeeMutez: estimate.suggestedFeeMutez,
        burnFeeMutez: estimate.burnFeeMutez,
        opSize: Number(estimate.opSize),
        revealFee: Number(revealFee),
      });

libs/coin-modules/coin-tezos/src/logic/estimateFees.ts:189

  • This newly added block comment is quite detailed and risks going stale. Per repo comment guidance, prefer a concise comment that links to the ticket and let the code/tests carry the rest of the explanation.
      // Reserve `mainOpFee`, not the raw taquito suggestion: `estimatedFees` below reports the
      // `minFees` floor, so subtracting the (lower) suggestion here yields an amount whose
      // `amount + estimatedFees` exceeds the spendable balance, and validateIntent then rejects
      // the very max it was handed (LIVE-28506).

libs/coin-tester-modules/coin-tester-tezos/src/scenarii/tezos.ts:200

  • This assertion references DUST_MARGIN_MUTEZ in the comment but hardcodes 500 in code. That makes the test brittle if the dust margin changes; consider naming the constant (or importing it) so the code and comment stay aligned.

This issue also appears on line 289 of the same file.

    // Send-max leaves the dust margin behind (DUST_MARGIN_MUTEZ, less the fee-per-gas/op-size
    // increment), independently of how the `minFees` floor compares to the suggested fee.
    expect(account.balance.toNumber()).toBeLessThanOrEqual(500);

@sonarqubecloud

Copy link
Copy Markdown

@amaslakov
amaslakov marked this pull request as ready for review August 3, 2026 07:29
@amaslakov
amaslakov requested review from a team as code owners August 3, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coin-modules shared-lib Label added for automated tagging of PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants