Skip to content

Commit e5701b1

Browse files
Merge pull request #8566 from BitGo/WCI-203
docs(express): walletSweep V2 TICKET: WCI-203
2 parents e1ef46c + 8b30e07 commit e5701b1

1 file changed

Lines changed: 12 additions & 43 deletions

File tree

modules/express/src/typedRoutes/api/v2/walletSweep.ts

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { SendManyResponse } from './sendmany';
77
* Request path parameters for sweeping a wallet
88
*/
99
export const WalletSweepParams = {
10-
/** The coin type */
10+
/** A cryptocurrency or token ticker symbol */
1111
coin: t.string,
1212
/** The wallet ID */
1313
id: t.string,
@@ -21,70 +21,39 @@ export const WalletSweepParams = {
2121
* For account-based coins, it calculates the maximum spendable amount and uses sendMany.
2222
*/
2323
export const WalletSweepBody = {
24-
/** The destination address to send all funds to - REQUIRED */
24+
/** The destination address for the sweep transaction */
2525
address: t.string,
2626

27-
/** The wallet passphrase to decrypt the user key */
27+
/** Passphrase to decrypt the user key on the wallet */
2828
walletPassphrase: optional(t.string),
2929

30-
/** The extended private key (alternative to walletPassphrase) */
30+
/** Private key in string form, if walletPassphrase is not available */
3131
xprv: optional(t.string),
3232

33-
/** One-time password for 2FA */
33+
/** Two factor auth code to enable sending the transaction */
3434
otp: optional(t.string),
3535

36-
/** The desired fee rate for the transaction in satoshis/kB (UTXO coins) */
36+
/** Custom fee rate (in base units) per kilobyte (or virtual kilobyte). For example, satoshis per kvByte */
3737
feeRate: optional(t.number),
3838

39-
/** Upper limit for fee rate in satoshis/kB (UTXO coins) */
39+
/** (BTC only) The maximum fee rate (in base units) per kilobyte (or virtual kilobyte). For example, satoshis per kvByte. The `maxFeeRate` limits the fee rate generated by both `feeMultiplier` and `numBlocks` */
4040
maxFeeRate: optional(t.number),
4141

42-
/** Estimate fees to aim for confirmation within this number of blocks (UTXO coins) */
42+
/** Number of blocks to wait to confirm the transaction */
4343
feeTxConfirmTarget: optional(t.number),
4444

45-
/** Allows sweeping 200 unspents when wallet has more than that (UTXO coins) */
45+
/** Use `allowPartialSweep: true` to sweep part of a wallet when there are too many unspents to empty the wallet in a single transaction. While the expected outcome of a single sweep call would usually be an empty wallet, using the allowPartialSweep option may leave some funds in the wallet. Making repeated calls with the allowPartialSweep option allows emptying wallets with many unspents without consolidating first */
4646
allowPartialSweep: optional(t.boolean),
4747

48-
/** Transaction format: 'legacy', 'psbt', or 'psbt-lite' (UTXO coins) */
48+
/** [UTXO only] Format of the returned transaction hex serialization. `legacy` for serialized transaction in custom bitcoinjs-lib format. `psbt` for BIP174 serialized transaction */
4949
txFormat: optional(t.union([t.literal('legacy'), t.literal('psbt'), t.literal('psbt-lite')])),
5050
} as const;
5151

5252
/**
53-
* Sweep all funds from a wallet to a specified address
53+
* The sweep call spends the full balance of the wallet to the provided address. On UTXO coins, the sweep call will fail if the wallet has any unconfirmed funds, or if there are more unspents than can be sent with a single transaction.
5454
*
55-
* This endpoint sweeps (sends) all available funds from a wallet to a single destination address.
56-
*
57-
* **Behavior by coin type:**
58-
* - **UTXO coins (BTC, LTC, etc.)**: Uses the native /sweepWallet endpoint that:
59-
* - Collects all unspents in the wallet
60-
* - Builds a transaction sending everything (minus fees) to the destination
61-
* - Signs and broadcasts the transaction
62-
* - Validates that all funds go to the specified destination address
63-
*
64-
* - **Account-based coins (ETH, etc.)**:
65-
* - Checks for unconfirmed funds (fails if any exist)
66-
* - Queries the maximumSpendable amount
67-
* - Creates a sendMany transaction with that amount to the destination
68-
*
69-
* **Implementation Note:**
70-
* Both execution paths (UTXO and account-based) ultimately call the same underlying
71-
* transaction sending mechanisms as sendMany, resulting in identical response structures.
72-
*
73-
* **Authentication:**
74-
* - Requires either `walletPassphrase` (to decrypt the encrypted user key) or `xprv` (raw private key)
75-
* - Optional `otp` for 2FA
76-
*
77-
* **Fee control (UTXO coins):**
78-
* - `feeRate`: Desired fee rate in satoshis/kB
79-
* - `maxFeeRate`: Upper limit for fee rate
80-
* - `feeTxConfirmTarget`: Target number of blocks for confirmation
81-
*
82-
* **Special options:**
83-
* - `allowPartialSweep`: For UTXO wallets with >200 unspents, allows sweeping just 200
84-
* - `txFormat`: Choose between 'legacy', 'psbt', or 'psbt-lite' format
85-
*
86-
* @tag express
8755
* @operationId express.v2.wallet.sweep
56+
* @tag Express
8857
*/
8958
export const PostWalletSweep = httpRoute({
9059
path: '/api/v2/{coin}/wallet/{id}/sweep',

0 commit comments

Comments
 (0)