|
| 1 | +import * as t from 'io-ts'; |
| 2 | +import { httpRoute, httpRequest, optional } from '@api-ts/io-ts-http'; |
| 3 | +import { BitgoExpressError } from '../../schemas/error'; |
| 4 | + |
| 5 | +/** |
| 6 | + * Request parameters for fanning out unspents in a wallet |
| 7 | + */ |
| 8 | +export const FanoutUnspentsRequestParams = { |
| 9 | + /** The ID of the wallet */ |
| 10 | + id: t.string, |
| 11 | +}; |
| 12 | + |
| 13 | +/** |
| 14 | + * Request body for fanning out unspents in a wallet |
| 15 | + */ |
| 16 | +export const FanoutUnspentsRequestBody = { |
| 17 | + /** The wallet passphrase to decrypt the user key */ |
| 18 | + walletPassphrase: optional(t.string), |
| 19 | + /** The extended private key (alternative to walletPassphrase) */ |
| 20 | + xprv: optional(t.string), |
| 21 | + /** Whether to validate addresses (defaults to true) */ |
| 22 | + validate: optional(t.boolean), |
| 23 | + /** Target number of unspents to create (must be at least 2 and less than 300) */ |
| 24 | + target: t.number, |
| 25 | + /** Minimum number of confirmations needed for an unspent to be included (defaults to 1) */ |
| 26 | + minConfirms: optional(t.number), |
| 27 | +}; |
| 28 | + |
| 29 | +/** |
| 30 | + * Response for fanning out unspents in a wallet |
| 31 | + */ |
| 32 | +export const FanoutUnspentsResponse = t.type({ |
| 33 | + /** The status of the transaction ('accepted', 'pendingApproval', or 'otp') */ |
| 34 | + status: t.string, |
| 35 | + /** The transaction hex */ |
| 36 | + tx: t.string, |
| 37 | + /** The transaction hash/ID */ |
| 38 | + hash: t.string, |
| 39 | + /** Whether the transaction is instant */ |
| 40 | + instant: t.boolean, |
| 41 | + /** The instant ID (if applicable) */ |
| 42 | + instantId: optional(t.string), |
| 43 | + /** The fee amount in satoshis */ |
| 44 | + fee: t.number, |
| 45 | + /** The fee rate in satoshis per kilobyte */ |
| 46 | + feeRate: t.number, |
| 47 | + /** Travel rule information */ |
| 48 | + travelInfos: t.unknown, |
| 49 | + /** BitGo fee information (if applicable) */ |
| 50 | + bitgoFee: optional(t.unknown), |
| 51 | + /** Travel rule result (if applicable) */ |
| 52 | + travelResult: optional(t.unknown), |
| 53 | +}); |
| 54 | + |
| 55 | +/** |
| 56 | + * Fan out unspents in a wallet |
| 57 | + * |
| 58 | + * This endpoint fans out unspents in a wallet by creating a transaction that spends from |
| 59 | + * multiple inputs to multiple outputs. This is useful for increasing the number of UTXOs |
| 60 | + * in a wallet, which can improve transaction parallelization. |
| 61 | + * |
| 62 | + * @operationId express.v1.wallet.fanoutunspents |
| 63 | + */ |
| 64 | +export const PutFanoutUnspents = httpRoute({ |
| 65 | + path: '/api/v1/wallet/:id/fanoutunspents', |
| 66 | + method: 'PUT', |
| 67 | + request: httpRequest({ |
| 68 | + params: FanoutUnspentsRequestParams, |
| 69 | + body: FanoutUnspentsRequestBody, |
| 70 | + }), |
| 71 | + response: { |
| 72 | + /** Successfully fanned out unspents */ |
| 73 | + 200: FanoutUnspentsResponse, |
| 74 | + /** Invalid request or fan out fails */ |
| 75 | + 400: BitgoExpressError, |
| 76 | + }, |
| 77 | +}); |
0 commit comments