Skip to content

Commit bacab50

Browse files
authored
docs(express): accelerateTxV2 api definition
2 parents 4170649 + fd7c605 commit bacab50

File tree

3 files changed

+28
-38
lines changed

3 files changed

+28
-38
lines changed

modules/express/src/clientRoutes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ async function handleV2Sweep(req: ExpressApiRouteRequest<'express.v2.wallet.swee
854854
* handle CPFP accelerate transaction creation
855855
* @param req
856856
*/
857-
async function handleV2AccelerateTransaction(req: ExpressApiRouteRequest<'express.v2.wallet.accelerateTx', 'post'>) {
857+
async function handleV2AccelerateTransaction(req: ExpressApiRouteRequest<'express.wallet.acceleratetx', 'post'>) {
858858
const bitgo = req.bitgo;
859859
const coin = bitgo.coin(req.decoded.coin);
860860
const wallet = await coin.wallets().get({ id: req.decoded.id });
@@ -1692,7 +1692,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
16921692
router.post('express.v2.wallet.sweep', [prepareBitGo(config), typedPromiseWrapper(handleV2Sweep)]);
16931693

16941694
// CPFP
1695-
router.post('express.v2.wallet.accelerateTx', [
1695+
router.post('express.wallet.acceleratetx', [
16961696
prepareBitGo(config),
16971697
typedPromiseWrapper(handleV2AccelerateTransaction),
16981698
]);

modules/express/src/typedRoutes/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export const ExpressV2WalletSweepApiSpec = apiSpec({
313313
});
314314

315315
export const ExpressV2WalletAccelerateTxApiSpec = apiSpec({
316-
'express.v2.wallet.accelerateTx': {
316+
'express.wallet.acceleratetx': {
317317
post: PostWalletAccelerateTx,
318318
},
319319
});

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

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,36 @@ export const MemoParams = t.type({
5353
* 2. Additional fields from PrebuildAndSignTransactionOptions (transaction building and signing fields)
5454
*/
5555
export const AccelerateTxRequestBody = {
56-
/** Transaction IDs to accelerate using CPFP (Child-Pays-For-Parent). Must be array of length 1. */
56+
/**
57+
* Txids of the transactions to bump
58+
*
59+
* **Notes:** Each target unconfirmed transaction must be sending funds to the calling wallet. Accepts only a single txid at this stage.
60+
*/
5761
cpfpTxIds: optional(t.array(t.string)),
5862

59-
/** Transaction IDs to accelerate using RBF (Replace-By-Fee). Must be array of length 1. */
63+
/** The list of transactions to accelerate using Replace-By-Fee (RBF) for UTXO coins (currently accelerating only one tx is supported). */
6064
rbfTxIds: optional(t.array(t.string)),
6165

62-
/** Fee rate for the CPFP transaction (in satoshis/kB). Required for CPFP unless noCpfpFeeRate=true. */
66+
/** Desired effective feerate of the bumped transactions and the CPFP transaction in satoshi per kilobyte */
6367
cpfpFeeRate: optional(t.number),
6468

6569
/** If true, allows skipping cpfpFeeRate requirement for CPFP */
6670
noCpfpFeeRate: optional(t.boolean),
6771

68-
/** Maximum fee willing to pay (in satoshis). Required for CPFP unless noMaxFee=true. */
72+
/**
73+
* Maximum allowed fee for the CPFP transaction in satoshi
74+
*
75+
* **Notes:** A CPFP transaction accelerates the target transactions and all of the unconfirmed transactions the target transactions depends on. As it can be difficult to discern the complete transaction ancestry at times, we recommend limiting the total fee for each CPFP attempt as a safety net to prevent CPFP transactions that exceed your cost expectations.
76+
*/
6977
maxFee: optional(t.number),
7078

7179
/** If true, allows skipping maxFee requirement for CPFP */
7280
noMaxFee: optional(t.boolean),
7381

74-
/** Fee multiplier for RBF (must be > 1). Required when using rbfTxIds. */
82+
/** (UTXO only) Custom multiplier to the feeRate. The resulting fee rate is limited by the maxFeeRate. For replace-by-fee (RBF) transactions (that include rbfTxIds), the feeMultiplier must be greater than 1, since it's an absolute fee multiplier to the transaction being replaced.
83+
*
84+
* **Note:** The maxFeeRate limits the fee rate generated by feeMultiplier.
85+
*/
7586
feeMultiplier: optional(t.number),
7687

7788
/** Recipients array (will be set to empty array by SDK for acceleration) */
@@ -84,7 +95,7 @@ export const AccelerateTxRequestBody = {
8495
)
8596
),
8697

87-
/** The wallet passphrase to decrypt the user key */
98+
/** (Hot wallet only) Passphrase to decrypt the user key on the wallet to sign the transaction. */
8899
walletPassphrase: optional(t.string),
89100

90101
/** The private key (prv) in string form */
@@ -380,39 +391,18 @@ export const AccelerateTxRequestBody = {
380391
export const AccelerateTxResponse = t.unknown;
381392

382393
/**
383-
* Accelerate Transaction Confirmation (CPFP/RBF)
394+
* Send a new transaction to accelerate the targeted unconfirmed transaction either by using Child-Pays-For-Parent (CPFP) or Replace-By-Fee (RBF).
384395
*
385-
* This endpoint accelerates a stuck or slow transaction using either:
386-
* - **CPFP (Child-Pays-For-Parent)**: Creates a new transaction that spends the output
387-
* of the stuck transaction with a higher fee, incentivizing miners to confirm both.
388-
* - **RBF (Replace-By-Fee)**: Replaces the original transaction with a new one that
389-
* has a higher fee (only works if original transaction was marked as RBF-enabled).
396+
* **Background:**
397+
* 1. In Bitcoin, a transaction can only be included in a block when all its inputs are confirmed. This requirement can be used to increase the effective fee rate of a stuck low-fee transaction. One of the stuck transaction's outputs is spent in a child transaction with a much higher fee. Miners include the transactions with the highest fees first to maximize their revenue, but the high-fee child transaction can only be included once the parent transaction is confirmed. The miners are therefore incentivized to include both the parent and the child transaction together in a block. A Child-Pays-For-Parent transaction can be created by a recipient of the transaction or by the sender if the target transaction has a change output.
398+
* 2. In Bitcoin, a transaction can be replaced by a new transaction with a higher fee as long as the new transaction spends few or all of the same inputs used by the original transaction that's being replaced. Unlike CPFP, only the sender of the transaction can create a Replace-By-Fee transaction, and only either of the transactions can be confirmed. More often than not, the replacement transaction with the higher fee will be accepted by the miners.
390399
*
391-
* Supported coins: Primarily UTXO-based coins like Bitcoin (btc, tbtc), Litecoin (ltc), etc.
400+
* **Notes:**
401+
* 1. As other coins do not have a blockspace market, this route is only available for Bitcoin at this time.
402+
* 2. Using CPFP, if a target transaction depends on other unconfirmed transactions, this route also adds sufficient fees to elevate the entire transaction ancestry's effective fee rate to the cpfpFeeRate.
392403
*
393-
* **CPFP Requirements:**
394-
* - cpfpTxIds: Array with exactly one transaction ID
395-
* - cpfpFeeRate: Fee rate in satoshis/kB (required unless noCpfpFeeRate=true)
396-
* - maxFee: Maximum fee in satoshis (required unless noMaxFee=true)
397-
* - walletPassphrase, xprv, or prv: For signing the CPFP transaction
398404
*
399-
* **RBF Requirements:**
400-
* - rbfTxIds: Array with exactly one transaction ID
401-
* - feeMultiplier: Multiplier for the fee (must be > 1, e.g., 1.5 for 50% increase)
402-
* - walletPassphrase, xprv, or prv: For signing the replacement transaction
403-
*
404-
* **Important:**
405-
* - Must specify EITHER cpfpTxIds OR rbfTxIds (not both)
406-
* - Original transaction must be unconfirmed
407-
* - For RBF, original transaction must have been created with RBF enabled
408-
*
409-
* **Behavior:**
410-
* 1. Validates acceleration parameters (CPFP or RBF)
411-
* 2. Builds and signs the acceleration transaction
412-
* 3. Submits the transaction to the blockchain
413-
* 4. Returns transaction details
414-
*
415-
* @operationId express.v2.wallet.accelerateTx
405+
* @operationId express.wallet.acceleratetx
416406
* @tag Express
417407
*/
418408
export const PostWalletAccelerateTx = httpRoute({

0 commit comments

Comments
 (0)