Skip to content
Merged
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
47 changes: 33 additions & 14 deletions modules/express/src/typedRoutes/api/v1/signTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ export const signTransactionRequestParams = {
};

export const signTransactionRequestBody = {
/** Serialized form of the transaction in hex */
/** Serialized unsigned transaction in hex format (required for regular signing, not used with psbt) */
transactionHex: t.string,
/** array of unspent information, where each unspent is a chainPath
and redeemScript with the same index as the inputs in the
transactionHex */
/** Array of unspent information matching transaction inputs - each contains chainPath and redeemScript (required for regular signing, not used with psbt) */
unspents: t.array(t.any),
/** Keychain containing the xprv to sign with (either this or signingKey required) */
/** Keychain containing xprv for signing (required for PSBT signing, or for regular signing if signingKey not provided) */
keychain: optional(
t.intersection([
t.type({
Expand All @@ -23,23 +21,44 @@ export const signTransactionRequestBody = {
t.record(t.string, t.any),
])
),
/** For legacy safe wallets, the private key string (either this or keychain required) */
/** For legacy safe wallets, WIF private key (alternative to keychain for regular signing only, not used with psbt) */
signingKey: optional(t.string),
/** extra verification of signatures (which are always verified server-side) (defaults to global config) */
/** Extra signature verification (defaults to global BitGo config, always verified server-side) */
validate: optional(t.boolean),
/** PSBT (Partially Signed Bitcoin Transaction) in hex format for PSBT signing flow */
/** PSBT (Partially Signed Bitcoin Transaction) in hex format - when provided, uses PSBT signing flow instead of regular signing */
psbt: optional(t.string),
/** Private key in WIF format for single-key fee address */
/** WIF private key for signing single-key fee address inputs (used when transaction has fee inputs from single-key addresses) */
feeSingleKeyWIF: optional(t.string),
/** Enable Bitcoin Cash signing mode */
/** Enable Bitcoin Cash signing mode for BCH transactions */
forceBCH: optional(t.boolean),
/** Require at least two valid signatures for full local signing */
fullLocalSigning: optional(t.boolean),
};

/**
* signTransaction
* Sign a previously created transaction with a keychain
* Sign a transaction with wallet's user key
*
* Signs a previously created unsigned transaction with the wallet's user key. This endpoint
* supports two signing flows: regular transaction signing and PSBT (Partially Signed Bitcoin
* Transaction) signing.
*
* **Regular Transaction Signing:**
* Required parameters:
* - transactionHex: The unsigned transaction in hex format
* - unspents: Array of unspent information (chainPath, redeemScript) matching transaction inputs
* - keychain.xprv OR signingKey: Private key for signing
*
* **PSBT Signing:**
* Required parameters:
* - psbt: The PSBT in hex format
* - keychain.xprv: Extended private key for HD signing
*
* **Response:**
* - Regular signing: Returns { tx: string } - signed transaction hex
* - PSBT signing: Returns { psbt: string } - signed PSBT hex
*
* **Note:** The validate parameter controls signature verification. If omitted, uses the
* global BitGo validation setting. Signature verification is always performed server-side.
*
* @operationId express.v1.wallet.signTransaction
* @tag express
Expand All @@ -52,9 +71,9 @@ export const PostSignTransaction = httpRoute({
body: signTransactionRequestBody,
}),
response: {
/** Successfully accepted wallet share */
/** Successfully signed transaction. Returns { tx: string } for regular signing or { psbt: string } for PSBT signing. */
200: t.UnknownRecord,
/** Error response */
/** Error response (e.g., missing required parameters, invalid transaction hex, invalid keychain, signature verification failure) */
400: BitgoExpressError,
},
});