fix(sdk-coin-flrp): update address index computation and signing logic in txn builders#7990
Merged
mohd-kashif merged 1 commit intomasterfrom Jan 29, 2026
Merged
fix(sdk-coin-flrp): update address index computation and signing logic in txn builders#7990mohd-kashif merged 1 commit intomasterfrom
mohd-kashif merged 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug in FLRP (Flare P-chain) atomic transactions where import/export transactions were failing on-chain with "wrong signature" errors. The root cause was that FlareJS's matchOwners() function was selecting different signature indices than intended when all 3 wallet addresses were passed to the transaction builders.
Changes:
- Added
getSigningAddresses()method to pass only 2 signing addresses (user+BitGo or backup+BitGo) to FlareJS instead of all 3 wallet addresses - Fixed change output creation in ExportInPTxBuilder to ensure all 3 addresses are included for proper multisig
- Updated test data with new transaction hashes reflecting the corrected sigIndices
- Added on-chain verified test cases for Import P, Import C, and Export P transactions
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/sdk-coin-flrp/src/lib/atomicTransactionBuilder.ts | Added getSigningAddresses() method and simplified credential/addressMap creation logic |
| modules/sdk-coin-flrp/src/lib/ImportInPTxBuilder.ts | Updated to use getSigningAddresses() and pass only 2 addresses to FlareJS |
| modules/sdk-coin-flrp/src/lib/ImportInCTxBuilder.ts | Updated to use getSigningAddresses() and pass only 2 addresses to FlareJS |
| modules/sdk-coin-flrp/src/lib/ExportInPTxBuilder.ts | Updated to use getSigningAddresses() for signing but all 3 addresses for change outputs |
| modules/sdk-coin-flrp/test/unit/lib/signatureIndex.ts | Deleted comprehensive 1377-line test file with extensive signature index coverage |
| modules/sdk-coin-flrp/test/unit/lib/importInPTxBuilder.ts | Added on-chain verified test case, removed extensive address ordering tests |
| modules/sdk-coin-flrp/test/unit/lib/importInCTxBuilder.ts | Added on-chain verified test case, removed extensive address ordering tests |
| modules/sdk-coin-flrp/test/unit/lib/exportInPTxBuilder.ts | Added on-chain verified test case with change output verification, removed address ordering tests |
| modules/sdk-coin-flrp/test/unit/flrp.ts | Updated change amount assertions to match new transaction data |
| modules/sdk-coin-flrp/test/resources/transactionData/*.ts | Updated test data with new transaction hashes and hex values |
| modules/sdk-coin-flrp/test/resources/account.ts | Added ON_CHAIN_TEST_WALLET with verified test keys |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…c in txn builders Ticket: WIN-8746
prithvishet2503
approved these changes
Jan 29, 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.
Summary: FLRP Signature Index Bug Fix
The Bug
Problem: P-chain import/export transactions for FLRP were failing on-chain with "wrong signature" errors, while identical AVAXP transactions succeeded.
Root Cause: The FlareJS library's
pvm.e.newImportTx/pvm.e.newExportTxmethods usematchOwners()internally to determinesigIndices(signature positions). When all 3 wallet addresses were passed to FlareJS,matchOwners()would select different signature indices than intended, causing a mismatch between:Example of the mismatch:
The Fix
Solution: Pass only the 2 intended signing addresses to FlareJS builders, not all 3 wallet addresses.
Key Changes:
getSigningAddresses()method - Added toatomicTransactionBuilder.tsto determine the correct 2 signers:Updated transaction builders (
ImportInPTxBuilder.ts,ExportInPTxBuilder.ts,ImportInCTxBuilder.ts):newImportTx/newExportTxmatchOwners()now correctly selects the 2 signers from the UTXO's address listChange output fix (
ExportInPTxBuilder.ts):C-chain import fee (
ImportInCTxBuilder.ts):baseTxFeeis correctly applied for EVM gas costsHow It Works in Production
Signing Flow (User signs first, BitGo signs second):
On-Chain Verified Transactions
These transactions were built with the fix and accepted on Flare Coston2 testnet:
bgHnEJ64td8u31aZrGDaWcDqxZ8vDV5qGd7bmSifgvUnUW8v2nSBwNcgfLbk5S425b1qaYaqTTCiMCV75KU4Fbnq8SPUUqLq22t4gxEAdPLiiy9HsbjaQun1mVFewMoixNS64eZ56C38L4mpP1jsigIndices [0, 2] meaning:
3094db9d...sorts first)c20336a9...sorts third)This matches the expected signing pair (User + BitGo) for normal transactions.