fix(sdk-coin-flrp): subtract minImportToPFee from ExportInC outputAmount#9120
Merged
Merged
Conversation
For C→P imports, the wallet platform shows the ExportInC transaction as the pending import amount on the FLRP (P-chain) wallet before the ImportInP is confirmed. The ExportInC exportedOutputs hold the gross P-chain UTXO amount (which includes the import fee premium), causing the pending display to show a higher amount than the actual P-chain credit delivered by the ImportInP. Fix: in `Flrp.explainTransaction`, when the transaction is a C-chain export (ExportInC), subtract the network's `minImportToPFee` from the `outputAmount` and each output's amount. This yields the minimum expected net P-chain receipt, aligning the pending display with the confirmed P-chain balance and resolving the amount discrepancy reported in CECHO-1450. The `verifyTransaction` path continues to use the gross UTXO amount for validation (via `tx.explainTransaction()` directly), so existing export validation logic is unaffected. Ticket: CECHO-1450 Session-Id: 53bbdb3d-3f67-4bc4-b5cd-a8be1b2d8857 Task-Id: 99e7fafb-287d-487c-b5fb-9c7f4c2f28f7
87f9f68 to
d9434aa
Compare
Contributor
|
@claude review as grug. Analyse if this PR solves the import amount discrepancy |
Contributor
|
Claude finished @ArunBala-Bitgo's task —— View job Grug Review of FLRP Import Amount FixGrug analyze if PR fix import amount discrepancy. Grug make todo:
Grug Understand ProblemGrug read code. Problem is:
Grug Look at FixGrug see fix in
Grug see test confirm fix work for both unsigned and signed ExportInC transactions. Grug Check Fix Logic✅ Fix solve problem correctly:
✅ Fix target right scenario:
✅ Test coverage good:
Grug Spot Concerns🟡 Grug see potential edge cases but acceptable:
✅ Good separation of concerns: Grug Final Verdict🟢 GRUG APPROVE THIS FIX Why grug think fix good:
What fix accomplish:
Grug recommend: Ship this fix. It solve real user problem with minimal risk. |
mohd-kashif
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Flrp.explainTransaction, when the transaction is a C-chain export (ExportInC), subtract the network'sminImportToPFeefromoutputAmountand each output'samountbefore returning.Why
Flrp.explainTransactionon the ExportInC transaction to display the pending import amount on the FLRP P-chain wallet (before the ImportInP is confirmed). The ExportInCexportedOutputshold the gross P-chain UTXO amount — which includes the import fee premium — so the pending display showed a higher-than-actual amount. After the ImportInP confirmed, the blockchain showed the true net P-chain credit, causing the discrepancy between pending and confirmed amounts reported in CECHO-1450.minImportToPFeefrom the displayed amount yields the expected minimum net P-chain receipt, aligning the pending display with the confirmed balance.verifyTransactionpath continues to use the rawtx.explainTransaction()output (gross UTXO amount) for validation, so existing export amount-range checks are unaffected.Test plan
yarn unit-testinmodules/sdk-coin-flrp— 362 tests passing, including the new test for adjusted ExportInCoutputAmount.yarn lintinmodules/sdk-coin-flrp— clean.Ticket: CECHO-1450