Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 51 additions & 24 deletions modules/express/src/typedRoutes/api/v1/consolidateUnspents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,62 @@ export const ConsolidateUnspentsRequestBody = {
minConfirms: optional(t.number),
/** Custom fee rate in satoshis per kilobyte */
feeRate: optional(t.number),
/** One-time password for 2FA authentication */
otp: optional(t.string),
/** Optional message to attach to the transaction */
message: optional(t.string),
/** Whether to use instant transaction (BitGo Instant) */
instant: optional(t.boolean),
/** Sequence ID for transaction ordering */
sequenceId: optional(t.string),
/** Target number of blocks for fee estimation */
numBlocks: optional(t.number),
/** Whether minConfirms also applies to change outputs */
enforceMinConfirmsForChange: optional(t.boolean),
/** Target number of unspents for the wallet */
targetWalletUnspents: optional(t.number),
/** Minimum value of unspents to include (in satoshis) - accepts number or string */
minValue: optional(t.union([t.number, t.string])),
/** Maximum value of unspents to include (in satoshis) - accepts number or string */
maxValue: optional(t.union([t.number, t.string])),
/** Comment to attach to the transaction */
comment: optional(t.string),
};

/**
* Response for consolidating unspents in a wallet
*
* Returns an array of transaction objects when consolidation occurs,
* or an empty object {} when no consolidation is needed (target already reached).
* The empty object is how Express serializes an undefined return from the V1 SDK.
*/
export const ConsolidateUnspentsResponse = t.array(
t.type({
/** The status of the transaction ('accepted', 'pendingApproval', or 'otp') */
status: t.string,
/** The transaction hex */
tx: t.string,
/** The transaction hash/ID */
hash: t.string,
/** Whether the transaction is instant */
instant: t.boolean,
/** The instant ID (if applicable) */
instantId: optional(t.string),
/** The fee amount in satoshis */
fee: t.number,
/** The fee rate in satoshis per kilobyte */
feeRate: t.number,
/** Travel rule information */
travelInfos: t.unknown,
/** BitGo fee information (if applicable) */
bitgoFee: optional(t.unknown),
/** Travel rule result (if applicable) */
travelResult: optional(t.unknown),
})
);
export const ConsolidateUnspentsResponse = t.union([
t.array(
t.type({
/** The status of the transaction ('accepted', 'pendingApproval', or 'otp') */
status: t.union([t.literal('accepted'), t.literal('pendingApproval'), t.literal('otp')]),
/** The transaction hex */
tx: t.string,
/** The transaction hash/ID */
hash: t.string,
/** Whether the transaction is instant */
instant: t.boolean,
/** The instant ID (if applicable) */
instantId: optional(t.string),
/** The fee amount in satoshis */
fee: t.number,
/** The fee rate in satoshis per kilobyte */
feeRate: t.number,
/** Travel rule information */
travelInfos: t.unknown,
/** BitGo fee information (if applicable) */
bitgoFee: optional(t.unknown),
/** Travel rule result (if applicable) */
travelResult: optional(t.unknown),
})
),
t.type({}), // Empty object when SDK returns undefined
]);

/**
* Consolidate unspents in a wallet
Expand Down
Loading