Skip to content
Open
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
39 changes: 36 additions & 3 deletions modules/bitgo/test/v2/unit/keychains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ describe('V2 Keychains', function () {

['tbsc'].forEach((coin) => {
it('should create ECDSA TSS Keychains', async function () {
nock(bgUrl).get('/api/v2/tss/settings').reply(200, {
nock(bgUrl).get('/api/v2/tss/settings').query(true).reply(200, {
coinSettings: {},
});
sandbox.stub(ECDSAUtils.EcdsaUtils.prototype, 'createKeychains').resolves(stubbedKeychainsTriplet);
Expand All @@ -601,6 +601,38 @@ describe('V2 Keychains', function () {
});
});

['tsol'].forEach((coin) => {
it('should forward the enterprise param on the GET /tss/settings call', async function () {
// Exact query match (not .query(true)) — this only passes if `enterprise` is actually
// forwarded on the request, proving WCI-1358's fix rather than just tolerating it.
const tssSettingsNock = nock(bgUrl)
.get('/api/v2/tss/settings')
.query({ enterprise: 'enterprise-123' })
.reply(200, { coinSettings: {} });
sandbox.stub(EDDSAUtils.default.prototype, 'createKeychains').resolves(stubbedKeychainsTriplet);
await bitgo.coin(coin).keychains().createMpc({
multisigType: 'tss',
passphrase: 'password',
enterprise: 'enterprise-123',
originalPasscodeEncryptionCode: 'originalPasscodeEncryptionCode',
});
tssSettingsNock.isDone().should.be.true();
});
});

['tsol'].forEach((coin) => {
it('should send no enterprise query param on GET /tss/settings when enterprise is not supplied', async function () {
const tssSettingsNock = nock(bgUrl).get('/api/v2/tss/settings').reply(200, { coinSettings: {} });
sandbox.stub(EDDSAUtils.default.prototype, 'createKeychains').resolves(stubbedKeychainsTriplet);
await bitgo.coin(coin).keychains().createMpc({
multisigType: 'tss',
passphrase: 'password',
originalPasscodeEncryptionCode: 'originalPasscodeEncryptionCode',
});
tssSettingsNock.isDone().should.be.true();
});
});

['tsol'].forEach((coin) => {
it('should pass webauthnInfo to createKeychains for EDDSA TSS', async function () {
const webauthnInfo = {
Expand All @@ -624,7 +656,7 @@ describe('V2 Keychains', function () {

['tbsc'].forEach((coin) => {
it('should reject safe root creation when the resolved ceremony is legacy MPCv1', async function () {
nock(bgUrl).get('/api/v2/tss/settings').reply(200, {
nock(bgUrl).get('/api/v2/tss/settings').query(true).reply(200, {
coinSettings: {},
});
const createKeychains = sandbox
Expand All @@ -646,7 +678,7 @@ describe('V2 Keychains', function () {

['tbsc'].forEach((coin) => {
it('should pass webauthnInfo to createKeychains for ECDSA TSS', async function () {
nock(bgUrl).get('/api/v2/tss/settings').reply(200, {
nock(bgUrl).get('/api/v2/tss/settings').query(true).reply(200, {
coinSettings: {},
});
const webauthnInfo = {
Expand Down Expand Up @@ -680,6 +712,7 @@ describe('V2 Keychains', function () {
beforeEach(function () {
nock(bgUrl)
.get('/api/v2/tss/settings')
.query(true)
.reply(200, {
coinSettings: {
eth: {
Expand Down
7 changes: 5 additions & 2 deletions modules/bitgo/test/v2/unit/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ describe('V2 Wallets:', function () {
beforeEach(function () {
nock('https://bitgo.fakeurl')
.get(`/api/v2/tss/settings`)
.query(true)
.times(2)
.reply(200, {
coinSettings: {
Expand Down Expand Up @@ -825,6 +826,7 @@ describe('V2 Wallets:', function () {
// FLRP is ECDSA, so generateCustodialMpcWallet fetches TSS settings
nock('https://bitgo.fakeurl')
.get('/api/v2/tss/settings')
.query(true)
.reply(200, { coinSettings: { flrp: { walletCreationSettings: {} } } });

const walletNock = nock('https://bitgo.fakeurl')
Expand Down Expand Up @@ -1052,7 +1054,7 @@ describe('V2 Wallets:', function () {
},
},
};
nock('https://bitgo.fakeurl').get(`/api/v2/tss/settings`).times(2).reply(200, tssSettings);
nock('https://bitgo.fakeurl').get(`/api/v2/tss/settings`).query(true).times(2).reply(200, tssSettings);
});

afterEach(function () {
Expand Down Expand Up @@ -1424,7 +1426,7 @@ describe('V2 Wallets:', function () {
},
},
};
nock('https://bitgo.fakeurl').get(`/api/v2/tss/settings`).times(2).reply(200, tssSettings);
nock('https://bitgo.fakeurl').get(`/api/v2/tss/settings`).query(true).times(2).reply(200, tssSettings);
});

afterEach(function () {
Expand Down Expand Up @@ -1487,6 +1489,7 @@ describe('V2 Wallets:', function () {
nock.cleanAll();
nock('https://bitgo.fakeurl')
.get('/api/v2/tss/settings')
.query(true)
.reply(200, { coinSettings: { sol: { walletCreationSettings: {} } } });

const testCoin = bitgo.coin('tsol');
Expand Down
5 changes: 4 additions & 1 deletion modules/sdk-core/src/bitgo/keychain/keychains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ export class Keychains implements IKeychains {
throw new Error('Unsupported multi-sig type');
}

const tssSettings: TssSettings = await this.bitgo.get(this.bitgo.microservicesUrl('/api/v2/tss/settings')).result();
const tssSettings: TssSettings = await this.bitgo
.get(this.bitgo.microservicesUrl('/api/v2/tss/settings'))
.query({ enterprise: params.enterprise })
.result();
const multisigTypeVersion =
tssSettings.coinSettings[this.baseCoin.getFamily()]?.walletCreationSettings?.multiSigTypeVersion;

Expand Down
9 changes: 6 additions & 3 deletions modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsaMPCv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
params.passphrase,
params.originalPasscodeEncryptionCode,
params.encryptionVersion,
params.enterprise,
params.safeId
);
const bitgoKeychainPromise = this.addBitgoKeychain(userCommonKeychain, params.safeId);
Expand Down Expand Up @@ -306,8 +307,8 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {

const keychains = this.baseCoin.keychains();
const [userKeychain, backupKeychain, bitgoKeychain] = await Promise.all([
keychains.add({ source: 'user', keyType: 'tss' as KeyType, commonKeychain, isMPCv2: true }),
keychains.add({ source: 'backup', keyType: 'tss' as KeyType, commonKeychain, isMPCv2: true }),
keychains.add({ source: 'user', keyType: 'tss' as KeyType, commonKeychain, isMPCv2: true, enterprise }),
keychains.add({ source: 'backup', keyType: 'tss' as KeyType, commonKeychain, isMPCv2: true, enterprise }),
this.addBitgoKeychain(commonKeychain),
]);

Expand Down Expand Up @@ -372,6 +373,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
originalPasscodeEncryptionCode,
isMPCv2: true,
safeId,
enterprise,
};

if (webauthnInfo && participantIndex === MPCv2PartiesEnum.USER && privateMaterialBase64) {
Expand Down Expand Up @@ -425,6 +427,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
passphrase: string,
originalPasscodeEncryptionCode?: string,
encryptionVersion?: EncryptionVersion,
enterprise?: string,
safeId?: string
): Promise<Keychain> {
return this.createParticipantKeychain(
Expand All @@ -436,7 +439,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
originalPasscodeEncryptionCode,
undefined,
encryptionVersion,
undefined,
enterprise,
safeId
);
}
Expand Down
5 changes: 5 additions & 0 deletions modules/sdk-core/src/bitgo/wallet/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export class Wallets implements IWallets {
if (params.multisigType === 'tss' && this.baseCoin.getMPCAlgorithm() === 'ecdsa' && params.walletVersion === 3) {
const tssSettings: TssSettings = await this.bitgo
.get(this.bitgo.microservicesUrl('/api/v2/tss/settings'))
.query({ enterprise: params.enterprise })
.result();
const multisigTypeVersion =
tssSettings.coinSettings[this.baseCoin.getFamily()]?.walletCreationSettings?.multiSigTypeVersion;
Expand Down Expand Up @@ -1800,6 +1801,7 @@ export class Wallets implements IWallets {
}
const tssSettings: TssSettings = await this.bitgo
.get(this.bitgo.microservicesUrl('/api/v2/tss/settings'))
.query({ enterprise })
.result();
const multisigTypeVersion =
tssSettings.coinSettings[this.baseCoin.getFamily()]?.walletCreationSettings?.multiSigTypeVersion;
Expand Down Expand Up @@ -1875,6 +1877,7 @@ export class Wallets implements IWallets {
if (multisigType === 'tss' && this.baseCoin.getMPCAlgorithm() === 'ecdsa') {
const tssSettings: TssSettings = await this.bitgo
.get(this.bitgo.microservicesUrl('/api/v2/tss/settings'))
.query({ enterprise })
.result();
const multisigTypeVersion =
tssSettings.coinSettings[this.baseCoin.getFamily()]?.walletCreationSettings?.multiSigTypeVersion;
Expand Down Expand Up @@ -1945,6 +1948,7 @@ export class Wallets implements IWallets {
if (multisigType === 'tss' && this.baseCoin.getMPCAlgorithm() === 'ecdsa') {
const tssSettings: TssSettings = await this.bitgo
.get(this.bitgo.microservicesUrl('/api/v2/tss/settings'))
.query({ enterprise })
.result();
multisigTypeVersion =
tssSettings.coinSettings[this.baseCoin.getFamily()]?.walletCreationSettings?.coldMultiSigTypeVersion;
Expand Down Expand Up @@ -2033,6 +2037,7 @@ export class Wallets implements IWallets {
if (multisigType === 'tss' && this.baseCoin.getMPCAlgorithm() === 'ecdsa') {
const tssSettings: TssSettings = await this.bitgo
.get(this.bitgo.microservicesUrl('/api/v2/tss/settings'))
.query({ enterprise })
.result();
const multisigTypeVersion =
tssSettings.coinSettings[this.baseCoin.getFamily()]?.walletCreationSettings?.custodialMultiSigTypeVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ describe('Wallets - external signer onchain wallet generation', function () {
post: sinon.stub().returns({
send: sinon.stub().returns({ result: sinon.stub().resolves({ id: 'tss-wallet-id' }) }),
}),
get: sinon.stub().returns({ result: sinon.stub().resolves({ coinSettings: {} }) }),
get: sinon
.stub()
.returns({ query: sinon.stub().returnsThis(), result: sinon.stub().resolves({ coinSettings: {} }) }),
setRequestTracer: sinon.stub(),
microservicesUrl: sinon.stub().returns('/api/v2/tss/settings'),
};
Expand Down Expand Up @@ -546,7 +548,9 @@ describe('Wallets - external signer onchain wallet generation', function () {
send = sinon.stub().returns({ result: sinon.stub().resolves({ id: 'tss-wallet-id' }) });
const integrationBitGo = {
post: sinon.stub().returns({ send }),
get: sinon.stub().returns({ result: sinon.stub().resolves({ coinSettings: {} }) }),
get: sinon
.stub()
.returns({ query: sinon.stub().returnsThis(), result: sinon.stub().resolves({ coinSettings: {} }) }),
setRequestTracer: sinon.stub(),
microservicesUrl: sinon.stub().returns('/api/v2/tss/settings'),
...bitgoOverrides,
Expand Down Expand Up @@ -593,6 +597,7 @@ describe('Wallets - external signer onchain wallet generation', function () {
{ isEVM: sinon.stub().returns(true) },
{
get: sinon.stub().returns({
query: sinon.stub().returnsThis(),
result: sinon.stub().resolves({
coinSettings: { eth: { walletCreationSettings: { multiSigTypeVersion: 'MPCv2' } } },
}),
Expand Down
Loading