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:', () => {