Skip to content

Commit 77e2737

Browse files
committed
chore(mbe): add dev docs for generate wallet req
Also adds walletVersion to the list of params. Ticket: WP-5335
1 parent 205bfca commit 77e2737

3 files changed

Lines changed: 96 additions & 4 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { EnclavedExpressClient } from '../../../api/master/clients/enclavedExpre
1616
import { handleEddsaSigning } from '../../../api/master/handlers/eddsa';
1717
import { readKey } from 'openpgp';
1818

19-
// TODO: Re-enable once using EDDSA Custom signing fns
2019
describe('Eddsa Signing Handler', () => {
2120
let bitgo: BitGoBase;
2221
let wallet: Wallet;

src/api/master/handlers/generateWallet.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ async function handleGenerateOnPremOnChainWallet(
4848

4949
// Create wallet parameters with type assertion to allow 'onprem' subtype
5050
const walletParams = {
51+
...req.decoded,
5152
label: label,
5253
m: 2,
5354
n: 3,
@@ -157,6 +158,7 @@ async function handleGenerateOnPremMpcWallet(
157158
const { label, enterprise } = req.decoded;
158159

159160
const walletParams: SupplementGenerateWalletOptions = {
161+
...req.decoded,
160162
label: label,
161163
m: 2,
162164
n: 3,

src/api/master/routers/masterApiSpec.ts

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,58 @@ const GenerateWalletResponse: HttpResponse = {
104104

105105
// Request type for /generate endpoint
106106
const GenerateWalletRequest = {
107+
/**
108+
* A human-readable label for the wallet
109+
* This will be displayed in the BitGo dashboard and API responses
110+
* @example "My Wallet"
111+
*/
107112
label: t.string,
113+
114+
/**
115+
* The type of multisig wallet to create
116+
* - onchain: Traditional multisig wallets using on-chain scripts
117+
* - tss: Threshold Signature Scheme wallets using MPC protocols
118+
* If absent, BitGo uses the default wallet type for the asset
119+
* @example "tss"
120+
*/
108121
multisigType: t.union([t.literal('onchain'), t.literal('tss')]),
122+
123+
/**
124+
* Enterprise ID - Required for Ethereum wallets
125+
* Ethereum wallets can only be created under an enterprise
126+
* Each enterprise has a fee address which will be used to pay for transaction fees
127+
* Your enterprise ID can be seen by clicking on the "Manage Organization" link on the enterprise dropdown
128+
* @example "59cd72485007a239fb00282ed480da1f"
129+
* @pattern ^[0-9a-f]{32}$
130+
*/
109131
enterprise: t.string,
110-
disableTransactionNotifications: t.union([t.undefined, t.boolean]),
111-
isDistributedCustody: t.union([t.undefined, t.boolean]),
132+
133+
/**
134+
* Flag for disabling wallet transaction notifications
135+
* When true, BitGo will not send email/SMS notifications for wallet transactions
136+
* @example false
137+
*/
138+
disableTransactionNotifications: optional(t.boolean),
139+
140+
/**
141+
* True, if the wallet type is a distributed-custodial
142+
* If passed, you must also pass the 'enterprise' parameter
143+
* Distributed custody allows multiple parties to share control of the wallet
144+
* @example false
145+
*/
146+
isDistributedCustody: optional(t.boolean),
147+
148+
/**
149+
* Specify the wallet creation contract version used when creating an Ethereum wallet contract
150+
* - 0: Old wallet creation (legacy)
151+
* - 1: New wallet creation, only deployed upon receiving funds
152+
* - 2: Same functionality as v1 but with NFT support
153+
* - 3: MPC wallets
154+
* @example 1
155+
* @minimum 0
156+
* @maximum 3
157+
*/
158+
walletVersion: optional(t.number),
112159
};
113160

114161
export const SendManyRequest = {
@@ -306,12 +353,56 @@ export const MasterApiSpec = apiSpec({
306353
path: '/api/{coin}/wallet/generate',
307354
request: httpRequest({
308355
params: {
356+
/**
357+
* A cryptocurrency or token ticker symbol
358+
* This determines the blockchain and wallet type that will be created
359+
* @example "btc"
360+
* @example "eth"
361+
* @example "ltc"
362+
*/
309363
coin: t.string,
310364
},
311365
body: GenerateWalletRequest,
312366
}),
313367
response: GenerateWalletResponse,
314-
description: 'Generate a new wallet',
368+
description: `
369+
# Generate a New Wallet
370+
371+
This endpoint creates a new cryptocurrency wallet with the specified configuration. The wallet creation process involves several steps that happen automatically:
372+
373+
## Wallet Creation Process
374+
375+
1. **User Keychain Creation**: Creates the user keychain locally on the machine and encrypts it with the provided passphrase (skipped if userKey is provided)
376+
2. **Backup Keychain Creation**: Creates the backup keychain locally on the machine
377+
3. **Keychain Upload**: Uploads the encrypted user keychain and public backup keychain to BitGo
378+
4. **BitGo Key Creation**: Creates the BitGo key (and backup key if backupXpubProvider is set) on the service
379+
5. **Wallet Creation**: Creates the wallet on BitGo with the 3 public keys above
380+
381+
## Important Notes
382+
383+
### Ethereum Wallets
384+
- Ethereum wallets can only be created under an enterprise
385+
- Pass in the ID of the enterprise to associate the wallet with
386+
- Your enterprise ID can be seen by clicking on the "Manage Organization" link on the enterprise dropdown
387+
- Each enterprise has a fee address which will be used to pay for transaction fees on all Ethereum wallets in that enterprise
388+
- The fee address is displayed in the dashboard of the website - please fund it before creating a wallet
389+
390+
### Subtokens
391+
- You cannot generate a wallet by passing in a subtoken as the coin
392+
- Subtokens share wallets with their parent coin and it is not possible to create a wallet specific to one token
393+
394+
### Usage
395+
- This endpoint should be called through BitGo Express if used without the SDK, such as when using cURL
396+
- For SDK usage, the wallet creation process is handled automatically by the SDK
397+
398+
## Query Parameters
399+
400+
- **includeKeychains** (boolean, default: false): Include user, backup and bitgo keychains along with generated wallet
401+
402+
## Response
403+
404+
Returns a wallet object containing the wallet ID, label, coin type, and other configuration details. If includeKeychains is true, the response will also include the keychain information.
405+
`,
315406
}),
316407
},
317408
'v1.wallet.sendMany': {

0 commit comments

Comments
 (0)