Implement RBF and CPFP with new fees package and add pending transactions view in @caravan/coordinator#116
Conversation
…ions view in @caravan/coordinator This commit introduces significant enhancements to the transaction management capabilities of caravan/coordinator, focusing on Replace-By-Fee (RBF) and Child-Pays-For-Parent (CPFP) functionalities, along with a new pending transactions view. Key changes Expected: 1. Pending Transactions View: - Add new component 'PendingTransactionsView' in src/components/Wallet/ - Implement basic layout showing transaction ID, amount, recipient, and timestamp - Integrate view into main Wallet dashboard 2. Enhanced Transaction Information: - Add 'TransactionDetails' component to display comprehensive tx info - Implement time-pending calculation and display - Add current fee rate vs market rate comparison - Include estimated blocks until confirmation based on current mempool state 3. Fee Bumping Possibility Indicators: - Add RBF status indicator to transaction details - Implement change output detection and display - Calculate and show estimated cost for potential fee bump 4. UI Support for Manual RBF: - Modify existing transaction creation flow to support RBF - Add RBF toggle in transaction creation form (OutputsForm.jsx) - Implement logic to replace existing transaction when RBF is selected 5. Fee Bumping Interfaces: - Add 'CancelTransaction' button and associated logic - Implement 'AccelerateTransaction' functionality - Create 'DownloadPSBT' option for RBF/CPFP transactions - Modify transaction authoring page to support pre-filled RBF/CPFP data 6. Integration with new fees package: - Import and utilize functions from @caravan/fees for fee calculations - Implement FeeManager class to handle fee-related operations 7. State Management Updates: - Add new reducers for managing pending transactions and fee bump operations - Implement new actions for RBF and CPFP operations - Update selectors to support new state structure
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…transactions view in @caravan/coordinator" This reverts commit 2781e95.
…ence 0xfffffffd in coordinator UI
|
Add a new 'Pending Transactions' tab to the Wallet component, enabling users to easily view and manage pending transactions. This update helps users perform fee bumping actions (RBF, CPFP) when necessary.
bucko13
left a comment
There was a problem hiding this comment.
Looking good so far! Excited to see this hooked up with the fees package.
One additional comment I wanted to add was that it would be nice if the RBF option(s) allowed for an override to fee bump even if the pending tx is not signaling. full-rbf is going to be the default in core soon and there is already a decent chance that fee bumping even without opt-in signaling will work. So maybe you can have a little chip indicating if it's signaling and then allow an option to override with a warning that it might be rejected or not propagate.
| const walletSlices = useSelector((state: RootState) => [ | ||
| ...Object.values(state.wallet.deposits.nodes), | ||
| ...Object.values(state.wallet.change.nodes), | ||
| ]); | ||
| const blockchainClient = useGetClient(); | ||
|
|
||
| useEffect(() => { | ||
| fetchPendingTransactions(); | ||
| }, [network, walletSlices, blockchainClient]); | ||
|
|
||
| const fetchPendingTransactions = async () => { | ||
| try { | ||
| const pendingTxs = walletSlices | ||
| .flatMap((slice) => slice.utxos) | ||
| .filter((utxo) => !utxo.confirmed); | ||
|
|
||
| const currentNetworkFeeRate = await getCurrentNetworkFeeRate(); | ||
|
|
||
| const analyzedTransactions = await Promise.all( | ||
| pendingTxs.map(async (utxo) => | ||
| analyzeTransaction(utxo, currentNetworkFeeRate), | ||
| ), | ||
| ); | ||
|
|
||
| setPendingTransactions(analyzedTransactions); | ||
| } catch (error) { | ||
| console.error("Error fetching pending transactions:", error); | ||
| setError("Failed to fetch pending transactions. Please try again later."); | ||
| } finally { | ||
| setIsLoading(false); | ||
| } | ||
| }; |
There was a problem hiding this comment.
I wonder if this could all be pulled out as a hook, something like useGetPendingTransactions. We'd need some way to set an error from inside the hook though.
| @@ -0,0 +1,37 @@ | |||
| import { Network } from "@caravan/bitcoin"; | |||
|
|
|||
| export interface UTXO { | |||
There was a problem hiding this comment.
these are ultimately going to come from the fees package right?
There was a problem hiding this comment.
Yes ... unless I need a custom type to handle some changes
| utxos: UTXO[]; | ||
| } | ||
|
|
||
| export interface RootState { |
There was a problem hiding this comment.
can you move this closer to the actual root store file?
| import { satoshisToBitcoins } from "@caravan/bitcoin"; | ||
|
|
||
| export const calculateTimeElapsed = (timestamp: number): string => { | ||
| const now = Date.now(); |
There was a problem hiding this comment.
the coordinator already has momentjs installed so you could probably use that to do time comparisons a little more easily.
… improvement and error fixes
| inputs: state.inputs.map(convertLegacyInput), | ||
| inputs: state.inputs.map((input) => ({ | ||
| ...convertLegacyInput(input), | ||
| sequence: rbfSequence, |
There was a problem hiding this comment.
So I can see an implementation for the sequence field has been added in the fees package which works with PSBT V2. But as this PR stands, I think the sequence is not persisting in the inputs

inputData logging is coming from packages/caravan-psbt/src/psbtv0/psbt.ts:L90
Working with testnet v4 (merged in #131)
There was a problem hiding this comment.
Thanks for the feedback .... I shall move on to resolving this issue and completing the fees package integration, once I am done with completing the last round of reviews on the fees package and getting it merged :)
| } | ||
|
|
||
| if (!parentTx) { | ||
| const parentTxDetails = await blockchainClient.getTransaction( |
Closing in Favor of PR #168As we are progressing with a new PR (#168) that addresses the transactions tab functionality and we'll be building a new PR for RBF/CPFP that will build on top of that, so this PR will be closed in favor of that. All relevant updates and discussions will continue in the new PR. |


This commit lays foundation of introduction of significant enhancements to be done to the transaction management capabilities of caravan/coordinator, focusing on Replace-By-Fee (RBF) and Child-Pays-For-Parent (CPFP) functionalities, along with a new pending transactions view.
Key changes Expected:
Pending Transactions View:
Enhanced Transaction Information:
Fee Bumping Possibility Indicators:
UI Support for Manual RBF:
Fee Bumping Interfaces:
Integration with new fees package:
State Management Updates: