Skip to content

Commit 6c97938

Browse files
authored
Merge pull request #7574 from BitGo/WP-6950-fanout-unspents
docs(express): fanoutUnspentsV1 API definition
2 parents e28a53c + 9d6cada commit 6c97938

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

modules/express/src/typedRoutes/api/v1/fanoutUnspents.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const FanoutUnspentsRequestBody = {
2020
xprv: optional(t.string),
2121
/** Whether to validate addresses (defaults to true) */
2222
validate: optional(t.boolean),
23-
/** Target number of unspents to create (must be at least 2 and less than 300) - REQUIRED */
23+
/** Target number of unspents to create (must be integer, at least 2, at most 300) */
2424
target: t.number,
2525
/** Minimum number of confirmations needed for an unspent to be included (defaults to 1) */
2626
minConfirms: optional(t.number),
@@ -62,7 +62,7 @@ export const FanoutUnspentsRequestBody = {
6262
* Response for fanning out unspents in a wallet
6363
*/
6464
export const FanoutUnspentsResponse = t.type({
65-
/** The status of the transaction ('accepted', 'pendingApproval', or 'otp') */
65+
/** The status of the transaction: 'accepted' (broadcasted), 'pendingApproval' (needs approval), or 'otp' (needs 2FA) */
6666
status: t.string,
6767
/** The transaction hex */
6868
tx: t.string,
@@ -87,9 +87,26 @@ export const FanoutUnspentsResponse = t.type({
8787
/**
8888
* Fan out unspents in a wallet
8989
*
90-
* This endpoint fans out unspents in a wallet by creating a transaction that spends from
91-
* multiple inputs to multiple outputs. This is useful for increasing the number of UTXOs
92-
* in a wallet, which can improve transaction parallelization.
90+
* Creates a transaction that distributes all existing unspents into a larger number of
91+
* approximately equal-sized unspents. This is the opposite of consolidateUnspents and is
92+
* useful for increasing the UTXO count to enable parallel transactions.
93+
*
94+
* **How It Works:**
95+
* 1. Fetches all unspents with at least minConfirms confirmations
96+
* 2. Calculates total value of all unspents
97+
* 3. Creates target number of new addresses on the change chain
98+
* 4. Distributes total value almost equally (±1 satoshi) across new addresses
99+
* 5. Adjusts distribution to account for transaction fees
100+
* 6. Creates and broadcasts the transaction
101+
*
102+
* **Requirements:**
103+
* - Current unspent count must be less than target (otherwise use consolidateUnspents)
104+
* - Wallet must have at most 80 unspents (transaction input limit)
105+
* - Target must be 2-300 (transaction output limit)
106+
* - Requires walletPassphrase or xprv for signing
107+
*
108+
* **Note:** This operation uses ALL wallet unspents and distributes the entire balance
109+
* (minus fees) across the target number of new outputs. All original addresses will be emptied.
93110
*
94111
* @operationId express.v1.wallet.fanoutunspents
95112
* @tag express

0 commit comments

Comments
 (0)