From 852137d53e5813aaaccc0590379f81aafd708892 Mon Sep 17 00:00:00 2001 From: Deepak Jangid Date: Mon, 19 Jan 2026 15:29:27 +0530 Subject: [PATCH] fix(sdk-coin-ada): use derivedFromParentWithSeed in address verification Address verification was failing for wallets created with existing keys because isWalletAddress was not using the derivedFromParentWithSeed property to compute the correct derivation path. This fix extracts the seed from the keychain and passes it to getAdaAddressAndAccountId. TICKET: COIN-7254 --- modules/sdk-coin-ada/src/ada.ts | 2 + modules/sdk-coin-ada/test/unit/ada.ts | 80 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/modules/sdk-coin-ada/src/ada.ts b/modules/sdk-coin-ada/src/ada.ts index 440a6c9218..b55e8cc12c 100644 --- a/modules/sdk-coin-ada/src/ada.ts +++ b/modules/sdk-coin-ada/src/ada.ts @@ -174,9 +174,11 @@ export class Ada extends BaseCoin { } const commonKeychain = extractCommonKeychain(keychains); + const derivationSeed = (keychains[0] as { derivedFromParentWithSeed?: string })?.derivedFromParentWithSeed; const { address: derivedAddress } = await this.getAdaAddressAndAccountId({ bitgoKey: commonKeychain, index: indexNumber, + seed: derivationSeed, }); return address === derivedAddress; diff --git a/modules/sdk-coin-ada/test/unit/ada.ts b/modules/sdk-coin-ada/test/unit/ada.ts index 086e0f9b14..f5d657f39a 100644 --- a/modules/sdk-coin-ada/test/unit/ada.ts +++ b/modules/sdk-coin-ada/test/unit/ada.ts @@ -1010,6 +1010,86 @@ describe('ADA', function () { }) .should.be.rejectedWith('all keychains must have the same commonKeychain for MPC coins'); }); + + it('should verify address when derivedFromParentWithSeed is present', async function () { + const derivedFromParentWithSeed = 'testDerivationSeed123'; + + const keychains = [ + { + id: '1', + commonKeychain: commonKeychain, + derivedFromParentWithSeed: derivedFromParentWithSeed, + type: 'tss' as const, + source: 'user' as const, + }, + { + id: '2', + commonKeychain: commonKeychain, + derivedFromParentWithSeed: derivedFromParentWithSeed, + type: 'tss' as const, + source: 'backup' as const, + }, + { + id: '3', + commonKeychain: commonKeychain, + derivedFromParentWithSeed: derivedFromParentWithSeed, + type: 'tss' as const, + source: 'bitgo' as const, + }, + ]; + + const { address: expectedAddress } = await (basecoin as any).getAdaAddressAndAccountId({ + bitgoKey: commonKeychain, + index: 0, + seed: derivedFromParentWithSeed, + }); + + const isValid = await basecoin.isWalletAddress({ + address: expectedAddress, + keychains, + index: 0, + }); + + isValid.should.equal(true); + }); + + it('should fail verification when derivedFromParentWithSeed is missing but address was created with seed', async function () { + const derivedFromParentWithSeed = 'testDerivationSeed123'; + const { address: addressWithSeed } = await (basecoin as any).getAdaAddressAndAccountId({ + bitgoKey: commonKeychain, + index: 0, + seed: derivedFromParentWithSeed, + }); + + const keychainsWithoutSeed = [ + { + id: '1', + commonKeychain: commonKeychain, + type: 'tss' as const, + source: 'user' as const, + }, + { + id: '2', + commonKeychain: commonKeychain, + type: 'tss' as const, + source: 'backup' as const, + }, + { + id: '3', + commonKeychain: commonKeychain, + type: 'tss' as const, + source: 'bitgo' as const, + }, + ]; + + const isValid = await basecoin.isWalletAddress({ + address: addressWithSeed, + keychains: keychainsWithoutSeed, + index: 0, + }); + + isValid.should.equal(false); + }); }); describe('Verify token consolidation transaction:', () => {