Skip to content

Commit ef8e38d

Browse files
committed
chore(mbe): move all remaining api-routes and add desc
Ticket: WP-5355
1 parent 8be9548 commit ef8e38d

File tree

8 files changed

+302
-154
lines changed

8 files changed

+302
-154
lines changed

masterBitgoExpress.json

Lines changed: 61 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@
190190
},
191191
"/api/{coin}/wallet/{walletId}/consolidate": {
192192
"post": {
193+
"summary": "Build, sign, and send a consolidation transaction for an account-based asset all in 1 call.",
194+
"description": "For account-based assets, consolidating the balances in the receive addresses to the base address maximizes the spendable balance of a wallet.",
193195
"parameters": [
194196
{
195197
"name": "walletId",
@@ -214,31 +216,36 @@
214216
"schema": {
215217
"type": "object",
216218
"properties": {
217-
"pubkey": {
218-
"type": "string"
219-
},
220219
"source": {
221220
"type": "string",
222221
"enum": [
223222
"user",
224223
"backup"
225-
]
224+
],
225+
"description": "The key to use for signing the transaction"
226+
},
227+
"pubkey": {
228+
"type": "string",
229+
"description": "Public key of the key used for signing multisig transactions"
226230
},
227231
"consolidateAddresses": {
228232
"type": "array",
229233
"items": {
230-
"type": "string"
234+
"type": "string",
235+
"description": "Optional: restrict the consolidation to the specified receive addresses. If not provided, will consolidate the funds from all receive addresses up to 500 addresses."
231236
}
232237
},
238+
"commonKeychain": {
239+
"type": "string",
240+
"description": "For TSS wallets, this is the common keychain of the wallet"
241+
},
233242
"apiVersion": {
234243
"type": "string",
235244
"enum": [
236245
"full",
237246
"lite"
238-
]
239-
},
240-
"commonKeychain": {
241-
"type": "string"
247+
],
248+
"description": "The Trasaction Request API version to use for MPC EdDSA Hot Wallets. Defaults based on the wallet type and asset curve."
242249
}
243250
},
244251
"required": [
@@ -322,6 +329,8 @@
322329
},
323330
"/api/{coin}/wallet/{walletId}/consolidateunspents": {
324331
"post": {
332+
"summary": "Build and send a transaction to consolidate unspents in a wallet.",
333+
"description": "Consolidating unspents is only for UTXO-based assets.",
325334
"parameters": [
326335
{
327336
"name": "walletId",
@@ -347,29 +356,36 @@
347356
"type": "object",
348357
"properties": {
349358
"pubkey": {
350-
"type": "string"
359+
"type": "string",
360+
"description": "Public key of the key used for signing multisig transactions"
351361
},
352362
"source": {
353363
"type": "string",
354364
"enum": [
355365
"user",
356366
"backup"
357-
]
367+
],
368+
"description": "The key to use for signing the transaction"
358369
},
359370
"feeRate": {
360-
"type": "number"
371+
"type": "number",
372+
"description": "Custom fee rate (in base units) per kilobyte"
361373
},
362374
"maxFeeRate": {
363-
"type": "number"
375+
"type": "number",
376+
"description": "Maximum fee rate (in base units) per kilobyte"
364377
},
365378
"maxFeePercentage": {
366-
"type": "number"
379+
"type": "number",
380+
"description": "Maximum fee percentage"
367381
},
368382
"feeTxConfirmTarget": {
369-
"type": "number"
383+
"type": "number",
384+
"description": "Fee transaction confirmation target"
370385
},
371386
"bulk": {
372-
"type": "boolean"
387+
"type": "boolean",
388+
"description": "Enable bulk processing"
373389
},
374390
"minValue": {
375391
"oneOf": [
@@ -379,7 +395,8 @@
379395
{
380396
"type": "number"
381397
}
382-
]
398+
],
399+
"description": "Minimum value for unspents"
383400
},
384401
"maxValue": {
385402
"oneOf": [
@@ -389,33 +406,41 @@
389406
{
390407
"type": "number"
391408
}
392-
]
409+
],
410+
"description": "Maximum value for unspents"
393411
},
394412
"minHeight": {
395-
"type": "number"
413+
"type": "number",
414+
"description": "Minimum block height"
396415
},
397416
"minConfirms": {
398-
"type": "number"
417+
"type": "number",
418+
"description": "Minimum confirmations required"
399419
},
400420
"enforceMinConfirmsForChange": {
401-
"type": "boolean"
421+
"type": "boolean",
422+
"description": "Enforce minimum confirmations for change outputs"
402423
},
403424
"limit": {
404-
"type": "number"
425+
"type": "number",
426+
"description": "Limit the number of unspents to process"
405427
},
406428
"numUnspentsToMake": {
407-
"type": "number"
429+
"type": "number",
430+
"description": "Number of unspents to make"
408431
},
409432
"targetAddress": {
410-
"type": "string"
433+
"type": "string",
434+
"description": "Target address for consolidation"
411435
},
412436
"txFormat": {
413437
"type": "string",
414438
"enum": [
415439
"legacy",
416440
"psbt",
417441
"psbt-lite"
418-
]
442+
],
443+
"description": "Transaction format"
419444
}
420445
},
421446
"required": [
@@ -556,7 +581,8 @@
556581
"enabletoken",
557582
"transfertoken",
558583
"trustline"
559-
]
584+
],
585+
"description": "Required for transactions from MPC wallets."
560586
},
561587
"recipients": {
562588
"type": "array",
@@ -726,9 +752,7 @@
726752
}
727753
},
728754
"required": [
729-
"source",
730-
"type",
731-
"recipients"
755+
"source"
732756
]
733757
}
734758
}
@@ -808,6 +832,8 @@
808832
},
809833
"/api/{coin}/wallet/{walletId}/txrequest/{txRequestId}/signAndSend": {
810834
"post": {
835+
"summary": "Sign a TxRequest and Broadcast it (MPC wallets only)",
836+
"description": "This is usually needed after resolving a pending approval for a MPC wallet",
811837
"parameters": [
812838
{
813839
"name": "walletId",
@@ -845,14 +871,17 @@
845871
"enum": [
846872
"user",
847873
"backup"
848-
]
874+
],
875+
"description": "The key to use for signing the transaction"
849876
},
850877
"commonKeychain": {
851-
"type": "string"
878+
"type": "string",
879+
"description": "Common keychain of the wallet during wallet creation"
852880
}
853881
},
854882
"required": [
855-
"source"
883+
"source",
884+
"commonKeychain"
856885
]
857886
}
858887
}

src/__tests__/api/master/generateWallet.test.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,22 @@ describe('POST /api/:coin/wallet/generate', () => {
310310
isTrust: true,
311311
hsmType: 'institutional',
312312
keyShares: [
313-
{ from: 'bitgo', to: 'user', publicShare: 'publicShare' },
314-
{ from: 'bitgo', to: 'backup', publicShare: 'publicShare' },
313+
{
314+
from: 'bitgo',
315+
to: 'user',
316+
publicShare: 'publicShare',
317+
privateShare: 'privateShare',
318+
vssProof: 'true',
319+
gpgKey: 'bitgo-key',
320+
},
321+
{
322+
from: 'bitgo',
323+
to: 'backup',
324+
publicShare: 'publicShare',
325+
privateShare: 'privateShare',
326+
vssProof: 'true',
327+
gpgKey: 'bitgo-key',
328+
},
315329
],
316330
walletHSMGPGPublicKeySigs: 'hsm-sig',
317331
});
@@ -486,11 +500,19 @@ describe('POST /api/:coin/wallet/generate', () => {
486500
deleted: false,
487501
approvalsRequired: 1,
488502
isCold: true,
489-
coinSpecific: {},
503+
coinSpecific: {
504+
rootAddress: '74AUHib3F6Fq5eVm2ywP5ik9iQjviwAfZXWnGM9JHhJ4',
505+
pendingChainInitialization: true,
506+
minimumFunding: 2447136,
507+
lastChainIndex: ['Object'],
508+
nonceExpiresAt: '2025-06-25T23:00:12.019Z',
509+
trustedTokens: [],
510+
},
490511
admin: {},
491512
pendingApprovals: [],
492513
allowBackupKeySigning: false,
493514
clientFlags: [],
515+
walletFlags: [],
494516
recoverable: false,
495517
startDate: '2025-01-01T00:00:00.000Z',
496518
hasLargeNumberOfAddresses: false,
@@ -1076,7 +1098,7 @@ describe('POST /api/:coin/wallet/generate', () => {
10761098
type: 'tss',
10771099
isMPCv2: true,
10781100
})
1079-
.reply(200, { id: 'user-key-id' });
1101+
.reply(200, { id: 'user-key-id', source: 'user', type: 'tss' });
10801102

10811103
const bitgoAddBackupKeyNock = nock(bitgoApiUrl)
10821104
.post(`/api/v2/${ecdsaCoin}/key`, {
@@ -1085,7 +1107,7 @@ describe('POST /api/:coin/wallet/generate', () => {
10851107
type: 'tss',
10861108
isMPCv2: true,
10871109
})
1088-
.reply(200, { id: 'backup-key-id' });
1110+
.reply(200, { id: 'backup-key-id', source: 'backup', type: 'tss' });
10891111

10901112
const bitgoAddBitGoKeyNock = nock(bitgoApiUrl)
10911113
.post(`/api/v2/${ecdsaCoin}/key`, {

src/api/master/handlers/generateWallet.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ async function handleGenerateOnPremOnChainWallet(
131131
responseType: 'WalletWithKeychains',
132132
};
133133

134-
const tet = result.wallet.toJSON();
135134
return { ...result, wallet: result.wallet.toJSON() };
136135
}
137136

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { httpRequest, HttpResponse, httpRoute, optional } from '@api-ts/io-ts-http';
2+
import * as t from 'io-ts';
3+
import { ErrorResponses } from '../../../shared/errors';
4+
5+
export const ConsolidateRequest = {
6+
/**
7+
* The key to use for signing the transaction
8+
*/
9+
source: t.union([t.literal('user'), t.literal('backup')]),
10+
/**
11+
* Public key of the key used for signing multisig transactions
12+
*/
13+
pubkey: t.union([t.undefined, t.string]),
14+
/**
15+
* Optional: restrict the consolidation to the specified receive addresses. If not provided, will consolidate the
16+
* funds from all receive addresses up to 500 addresses.
17+
*/
18+
consolidateAddresses: optional(t.array(t.string)),
19+
20+
/**
21+
* For TSS wallets, this is the common keychain of the wallet
22+
*/
23+
commonKeychain: t.union([t.undefined, t.string]),
24+
25+
/**
26+
* The Trasaction Request API version to use for MPC EdDSA Hot Wallets.
27+
* Defaults based on the wallet type and asset curve.
28+
*/
29+
apiVersion: t.union([t.undefined, t.literal('full'), t.literal('lite')]),
30+
};
31+
32+
export const ConsolidateResponse: HttpResponse = {
33+
200: t.any,
34+
...ErrorResponses,
35+
};
36+
37+
/**
38+
* Build, sign, and send a consolidation transaction for an account-based asset all in 1 call.
39+
* For account-based assets, consolidating the balances in the receive addresses to the base address maximizes the spendable balance of a wallet.
40+
*/
41+
export const ConsolidateRoute = httpRoute({
42+
method: 'POST',
43+
path: '/api/{coin}/wallet/{walletId}/consolidate',
44+
request: httpRequest({
45+
params: {
46+
walletId: t.string,
47+
coin: t.string,
48+
},
49+
body: ConsolidateRequest,
50+
}),
51+
response: ConsolidateResponse,
52+
description: 'Consolidate addresses',
53+
});

0 commit comments

Comments
 (0)