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
1,061 changes: 976 additions & 85 deletions masterBitgoExpress.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/__tests__/api/master/eddsa.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { AdvancedWalletManagerClient as AdvancedWalletManagerClient } from '../.
import { handleEddsaSigning } from '../../../api/master/handlers/eddsa';
import { readKey } from 'openpgp';

// TODO: Re-enable once using EDDSA Custom signing fns
describe('Eddsa Signing Handler', () => {
let bitgo: BitGoBase;
let wallet: Wallet;
Expand Down
182 changes: 140 additions & 42 deletions src/__tests__/api/master/generateWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,74 @@ describe('POST /api/:coin/wallet/generate', () => {
keyType: 'independent',
enterprise: 'test_enterprise',
})
.reply(200, { id: 'bitgo-key-id', pub: 'xpub_bitgo' });
.reply(200, {
id: 'bitgo-key-id',
pub: 'xpub_bitgo',
source: 'bitgo',
type: 'independent',
isBitGo: true,
isTrust: false,
hsmType: 'institutional',
});

const bitgoAddWalletNock = nock(bitgoApiUrl)
.post(`/api/v2/${coin}/wallet/add`, {
label: 'test_wallet',
enterprise: 'test_enterprise',
multisigType: 'onchain',
coin: coin,
m: 2,
n: 3,
keys: ['user-key-id', 'backup-key-id', 'bitgo-key-id'],
type: 'cold',
subType: 'onPrem',
multisigType: 'onchain',
enterprise: 'test_enterprise',
})
.matchHeader('any', () => true)
.reply(200, {
id: 'new-wallet-id',
users: [
{
user: 'user-id',
permissions: ['admin', 'spend', 'view'],
},
],
coin: coin,
label: 'test_wallet',
m: 2,
n: 3,
keys: ['user-key-id', 'backup-key-id', 'bitgo-key-id'],
keySignatures: {},
enterprise: 'test_enterprise',
organization: 'org-id',
bitgoOrg: 'BitGo Inc',
tags: ['new-wallet-id', 'test_enterprise'],
disableTransactionNotifications: false,
freeze: {},
deleted: false,
approvalsRequired: 1,
isCold: true,
coinSpecific: {},
admin: {},
pendingApprovals: [],
allowBackupKeySigning: false,
clientFlags: [],
recoverable: false,
startDate: '2025-01-01T00:00:00.000Z',
hasLargeNumberOfAddresses: false,
config: {},
balanceString: '0',
confirmedBalanceString: '0',
spendableBalanceString: '0',
receiveAddress: {
id: 'addr-id',
address: 'tb1qexampleaddress000000000000000000000',
chain: 20,
index: 0,
coin: coin,
wallet: 'new-wallet-id',
coinSpecific: {},
},
// optional-ish fields used in assertions
multisigType: 'onchain',
type: 'cold',
subType: 'onPrem',
Expand Down Expand Up @@ -416,31 +468,33 @@ describe('POST /api/:coin/wallet/generate', () => {
const addWalletNock = nock(bitgoApiUrl)
.post(`/api/v2/${eddsaCoin}/wallet/add`, {
label: 'test_wallet',
enterprise: 'test_enterprise',
multisigType: 'tss',
coin: eddsaCoin,
m: 2,
n: 3,
keys: ['id', 'id', 'id'],
type: 'cold',
subType: 'onPrem',
multisigType: 'tss',
enterprise: 'test_enterprise',
})
.reply(200, {
id: '685cb53debcd0bcb5ab4fe80d2b74be2',
users: [['Object']],
coin: 'tsol',
label: 'OnPrem eddsa sendMany test 2025-06-26T02:49:18.622Z',
id: 'wallet-id',
users: [
{
user: 'user-id',
permissions: ['admin', 'spend', 'view'],
},
],
coin: eddsaCoin,
label: 'test_wallet',
m: 2,
n: 3,
keys: [
'685cb5393d57687bdf0a464594ca9e36',
'685cb53a3d57687bdf0a4657b5f1f364',
'685cb536f21050339163a75dd04d41bf',
],
keys: ['id', 'id', 'id'],
keySignatures: {},
enterprise: '6750c2d327511bc4e5f83ccfcfe1b3eb',
organization: '6750c2e027511bc4e5f83d251248fc14',
bitgoOrg: 'BitGo Trust',
tags: ['685cb53debcd0bcb5ab4fe80d2b74be2', '6750c2d327511bc4e5f83ccfcfe1b3eb'],
enterprise: 'test_enterprise',
organization: 'org-id',
bitgoOrg: 'BitGo Inc',
tags: ['wallet-id', 'test_enterprise'],
disableTransactionNotifications: false,
freeze: {},
deleted: false,
Expand All @@ -454,37 +508,30 @@ describe('POST /api/:coin/wallet/generate', () => {
nonceExpiresAt: '2025-06-25T23:00:12.019Z',
trustedTokens: [],
},
admin: {
policy: ['Object'],
},
admin: {},
pendingApprovals: [],
allowBackupKeySigning: false,
clientFlags: [],
walletFlags: [],
allowBackupKeySigning: false,
recoverable: false,
startDate: '2025-06-26T02:49:33.000Z',
type: 'cold',
buildDefaults: {},
customChangeKeySignatures: {},
startDate: '2025-01-01T00:00:00.000Z',
hasLargeNumberOfAddresses: false,
multisigType: 'tss',
hasReceiveTransferPolicy: false,
creator: '63f512adc61d7100088e99bf1deece73',
subType: 'onPrem',
config: {},
pendingChainInitialization: true,
balanceString: '0',
confirmedBalanceString: '0',
spendableBalanceString: '0',
reservedBalanceString: '0',
receiveAddress: {
id: '685cb53eebcd0bcb5ab4fe8ed214d5b9',
address: '74AUHib3F6Fq5eVm2ywP5ik9iQjviwAfZXWnGM9JHhJ4',
id: 'addr-id',
address: '93AHaUAExampleRootAddress',
chain: 0,
index: 0,
coin: 'tsol',
wallet: '685cb53debcd0bcb5ab4fe80d2b74be2',
coinSpecific: ['Object'],
coin: eddsaCoin,
wallet: 'wallet-id',
coinSpecific: {},
},
multisigType: 'tss',
type: 'cold',
subType: 'onPrem',
});

const response = await agent
Expand Down Expand Up @@ -1051,7 +1098,7 @@ describe('POST /api/:coin/wallet/generate', () => {
type: 'tss',
isMPCv2: true,
})
.reply(200, { id: 'user-key-id' });
.reply(200, { id: 'user-key-id', source: 'user', type: 'tss' });

const bitgoAddBackupKeyNock = nock(bitgoApiUrl)
.post(`/api/v2/${ecdsaCoin}/key`, {
Expand All @@ -1060,7 +1107,7 @@ describe('POST /api/:coin/wallet/generate', () => {
type: 'tss',
isMPCv2: true,
})
.reply(200, { id: 'backup-key-id' });
.reply(200, { id: 'backup-key-id', source: 'backup', type: 'tss' });

const bitgoAddBitGoKeyNock = nock(bitgoApiUrl)
.post(`/api/v2/${ecdsaCoin}/key`, {
Expand All @@ -1069,21 +1116,72 @@ describe('POST /api/:coin/wallet/generate', () => {
type: 'tss',
isMPCv2: true,
})
.reply(200, { id: 'bitgo-key-id' });
.reply(200, {
id: 'bitgo-key-id',
source: 'bitgo',
type: 'tss',
commonKeychain: 'commonKeychain',
isBitGo: true,
isTrust: false,
hsmType: 'institutional',
});

const bitgoAddWalletNock = nock(bitgoApiUrl)
.post(`/api/v2/${ecdsaCoin}/wallet/add`, {
label: 'test-wallet', // ?
enterprise: 'test-enterprise',
multisigType: 'tss',
coin: ecdsaCoin,
m: 2,
n: 3,
keys: ['user-key-id', 'backup-key-id', 'bitgo-key-id'],
type: 'cold',
subType: 'onPrem',
multisigType: 'tss',
enterprise: 'test-enterprise',
})
.reply(200, {
id: 'new-wallet-id',
users: [
{
user: 'user-id',
permissions: ['admin', 'spend', 'view'],
},
],
coin: ecdsaCoin,
label: 'test-wallet',
m: 2,
n: 3,
keys: ['user-key-id', 'backup-key-id', 'bitgo-key-id'],
keySignatures: {},
enterprise: 'test-enterprise',
organization: 'org-id',
bitgoOrg: 'BitGo Inc',
tags: ['new-wallet-id', 'test-enterprise'],
disableTransactionNotifications: false,
freeze: {},
deleted: false,
approvalsRequired: 1,
isCold: true,
coinSpecific: {},
admin: {},
pendingApprovals: [],
allowBackupKeySigning: false,
clientFlags: [],
recoverable: false,
startDate: '2025-01-01T00:00:00.000Z',
hasLargeNumberOfAddresses: false,
config: {},
balanceString: '0',
confirmedBalanceString: '0',
spendableBalanceString: '0',
receiveAddress: {
id: 'addr-id',
address: '0xexample',
chain: 0,
index: 0,
coin: ecdsaCoin,
wallet: 'new-wallet-id',
coinSpecific: {},
},
multisigType: 'tss',
type: 'cold',
subType: 'onPrem',
Expand Down
Empty file.
Empty file.
2 changes: 2 additions & 0 deletions src/api/master/handlers/generateWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async function handleGenerateOnPremOnChainWallet(

// Create wallet parameters with type assertion to allow 'onprem' subtype
const walletParams = {
...req.decoded,
label: label,
m: 2,
n: 3,
Expand Down Expand Up @@ -157,6 +158,7 @@ async function handleGenerateOnPremMpcWallet(
const { label, enterprise } = req.decoded;

const walletParams: SupplementGenerateWalletOptions = {
...req.decoded,
label: label,
m: 2,
n: 3,
Expand Down
11 changes: 3 additions & 8 deletions src/api/master/handlers/recoveryWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ import {
} from '../../../shared/recoveryUtils';

import { AdvancedWalletManagerClient } from '../clients/advancedWalletManagerClient';
import {
CoinSpecificParams,
CoinSpecificParamsUnion,
MasterApiSpecRouteRequest,
ScriptType2Of3,
SolanaRecoveryOptions,
} from '../routers/masterBitGoExpressApiSpec';
import { MasterApiSpecRouteRequest, ScriptType2Of3 } from '../routers/masterBitGoExpressApiSpec';
import { CoinSpecificParams, CoinSpecificParamsUnion } from '../routers/recoveryRoute';
import { recoverEddsaWallets } from './recoverEddsaWallets';
import { EnvironmentName, MasterExpressConfig } from '../../../shared/types';
import { recoverEcdsaMpcV2Params, recoverEcdsaMPCv2Wallets } from './recoverEcdsaWallets';
Expand Down Expand Up @@ -154,7 +149,7 @@ async function handleEddsaRecovery(
};
let unsignedSweepPrebuildTx: Awaited<ReturnType<typeof recoverEddsaWallets>>;
if (sdkCoin.getFamily() === CoinFamily.SOL) {
const solanaParams = params.coinSpecificParams as SolanaRecoveryOptions;
const solanaParams = params.coinSpecificParams as SolRecoveryOptions;
const solanaRecoveryOptions: SolRecoveryOptions = { ...options };
solanaRecoveryOptions.recoveryDestinationAtaAddress =
solanaParams.recoveryDestinationAtaAddress;
Expand Down
Loading