-
Notifications
You must be signed in to change notification settings - Fork 58
feat: add psbtbumpfee
support
#632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes add PSBT (Partially Signed Bitcoin Transaction) fee bumping and signing/finalization capabilities to the Changes
Sequence Diagram(s)sequenceDiagram
participant Test as test_psbt_bump_fee
participant AliceClient as BitcoinClient (Alice)
participant Core as Bitcoin Core RPC
Test->>AliceClient: psbt_bump_fee(txid, options)
AliceClient->>Core: psbtbumpfee RPC
Core-->>AliceClient: PsbtBumpFeeResult (PSBT, origfee, fee, errors)
AliceClient-->>Test: PsbtBumpFeeResult
Test->>AliceClient: sign_and_finalize_psbt(psbt, ...)
AliceClient->>Core: wallet_process_psbt RPC
Core-->>AliceClient: processed PSBT
AliceClient->>Core: finalize_psbt RPC
Core-->>AliceClient: finalized PSBT (with hex)
AliceClient-->>Test: Transaction
Test->>Core: sendrawtransaction (broadcast)
Test->>Core: generate(100) (confirm blocks)
Test->>Core: gettransaction (for both txs)
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
crates/utils/src/bitcoin_client.rs (1)
475-506
: Replace debug println! with proper logging.The method implementation is solid and follows the established pattern, but the debug println! statement should be replaced with proper logging.
Apply this diff to improve logging:
- println!("Failed to deserialize into PsbtBumpFeeResult"); + error!("Failed to deserialize into PsbtBumpFeeResult: {}", err);crates/utils/src/bitcoin_core.rs (1)
253-327
: Comprehensive integration test for PSBT bump fee workflow.The test effectively validates the end-to-end PSBT bump fee functionality, including transaction creation, fee bumping, signing, finalization, and confirmation verification.
Consider adding an assertion to verify the PSBT is not None before unwrapping:
+ assert!(psbt_bump_fee.psbt.is_some(), "PSBT should be present in bump fee result"); let tx = bitcoin_client.sign_and_finalize_psbt( &psbt_bump_fee.psbt.unwrap(),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
crates/utils/src/bitcoin_client.rs
(4 hunks)crates/utils/src/bitcoin_core.rs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (4)
crates/utils/src/bitcoin_client.rs (4)
12-12
: LGTM! Import is necessary for PSBT functionality.The
json
import is correctly added to supportjson::SigHashType
used in the new PSBT signing method.
185-197
: Well-designed struct for PSBT bump fee results.The struct correctly omits the
txid
field (since PSBTs aren't broadcast yet) and includes all necessary fields matching Bitcoin Core'spsbtbumpfee
response format.
234-235
: Appropriate error variant for PSBT finalization.The error variant correctly handles the case where finalized PSBT doesn't return raw transaction hex, with a clear and descriptive message.
508-521
: Excellent PSBT signing and finalization implementation.The method correctly implements the two-step process of signing with
wallet_process_psbt
and finalizing withfinalize_psbt
. Error handling is robust and the optional parameters provide necessary flexibility.
Reference: https://developer.bitcoin.org/reference/rpc/psbtbumpfee.html
Summary by CodeRabbit