Skip to content

Commit 7478abc

Browse files
authored
fix(express): fixed fanoutunspents response codec
2 parents a9d27c7 + 7e2f112 commit 7478abc

File tree

2 files changed

+198
-238
lines changed

2 files changed

+198
-238
lines changed

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

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ export const FanoutUnspentsRequestBody = {
5454
otp: optional(t.string),
5555
/** Target address for the fanout outputs */
5656
targetAddress: optional(t.string),
57+
/** If true, enables fanout of large number of unspents by creating multiple transactions (200 unspents per tx) */
58+
bulk: optional(t.boolean),
5759
} as const;
5860

5961
/**
60-
* Response for fanning out unspents in a wallet (v2)
61-
*
62-
* Returns transaction details after the fanout operation is built, signed, and sent.
62+
* Single transaction response object
6363
*/
64-
export const FanoutUnspentsResponse = t.type({
64+
const FanoutUnspentsSingleTxResponse = t.type({
6565
/** The status of the transaction ('accepted', 'signed', 'pendingApproval', or 'otp') */
6666
status: t.string,
6767
/** The transaction hex/serialized transaction */
@@ -86,6 +86,17 @@ export const FanoutUnspentsResponse = t.type({
8686
travelResult: optional(t.unknown),
8787
});
8888

89+
/**
90+
* Response for fanning out unspents in a wallet (v2)
91+
*
92+
* Returns transaction details after the fanout operation is built, signed, and sent.
93+
* When bulk=true, an array of transaction objects is returned; otherwise, a single transaction object is returned.
94+
*/
95+
export const FanoutUnspentsResponse = t.union([
96+
FanoutUnspentsSingleTxResponse,
97+
t.array(FanoutUnspentsSingleTxResponse),
98+
]);
99+
89100
/**
90101
* Fan out unspents in a wallet (v2)
91102
*
@@ -98,7 +109,8 @@ export const FanoutUnspentsResponse = t.type({
98109
* - Requiring a coin parameter in the path
99110
* - Supporting the full set of SDK parameters for advanced UTXO management
100111
* - Using numUnspentsToMake instead of target (though both refer to output count)
101-
* - Supporting additional parameters like maxNumInputsToUse, unspents array, fee controls
112+
* - Supporting bulk fanout mode that creates multiple transactions
113+
* - Supporting additional parameters like maxNumInputsToUse, unspents array, bulk, fee controls
102114
*
103115
* @operationId express.v2.wallet.fanoutunspents
104116
* @tag express

0 commit comments

Comments
 (0)