Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/sdk-coin-ada/src/ada.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
80 changes: 80 additions & 0 deletions modules/sdk-coin-ada/test/unit/ada.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:', () => {
Expand Down