Skip to content

feat: Return feerate from transaction builder#380

Open
gyanranjanpanda wants to merge 2 commits intobitcoindevkit:masterfrom
gyanranjanpanda:feat/return-feerate-from-builder
Open

feat: Return feerate from transaction builder#380
gyanranjanpanda wants to merge 2 commits intobitcoindevkit:masterfrom
gyanranjanpanda:feat/return-feerate-from-builder

Conversation

@gyanranjanpanda
Copy link

@gyanranjanpanda gyanranjanpanda commented Feb 8, 2026

Implements functionality to return feerate from transaction builder finish() methods.

Fixes #187.

Changes:

  • Modified create_tx to return BuilderResult struct containing psbt and fee_rate
  • Updated TxBuilder::finish() and TxBuilder::finish_with_aux_rand() to return BuilderResult
  • Updated tests and examples to use the new API

This allows callers to know the exact feerate used for the constructed transaction, which is useful for fee estimation and user display.

Implements issue bitcoindevkit#187 by introducing BuilderResult struct that wraps
both the PSBT and the FeeRate used during transaction construction.

Changes:
- Add BuilderResult struct with psbt and fee_rate fields
- Update finish() and finish_with_aux_rand() to return BuilderResult
- Modify create_tx() to capture and return the feerate
- Update tests and examples to use new API (WIP)

The core implementation is complete. Some test files still need
manual updates to properly access the .psbt field from BuilderResult.

Fixes bitcoindevkit#187

Signed-off-by: Gyan Ranjan Panda <gyanranjanpanda@gmail.com>
@gyanranjanpanda gyanranjanpanda marked this pull request as draft February 8, 2026 10:40
@gyanranjanpanda gyanranjanpanda marked this pull request as ready for review February 8, 2026 11:03
@ValuedMammal ValuedMammal added the discussion Discussion label Feb 9, 2026
@notmandatory
Copy link
Member

notmandatory commented Feb 19, 2026

@gyanranjanpanda are you planning to fix the compile errors on this PR? if so please change it to Draft status until you're done. If not we'll close it.

@gyanranjanpanda
Copy link
Author

gyanranjanpanda commented Feb 20, 2026

Thanks for the feedback — I’ll fix the compile errors and update the PR shortly.

@gyanranjanpanda gyanranjanpanda force-pushed the feat/return-feerate-from-builder branch from 725510d to 9deb2d5 Compare February 20, 2026 02:36
@gyanranjanpanda
Copy link
Author

hi @notmandatory , could u review this wating for your feedback

@ValuedMammal
Copy link
Collaborator

Just want to point out that the TxBuilder API is largely stabilized, and that new features should be directed to bdk_tx and the ongoing integration with bdk_wallet.

In terms of this issue, the FeeRate is a trivially copyable type so I don't see what's preventing you from keeping it in a variable alongside your TxBuilder instance. It's not that you lose access to the value after specifying the fee_rate option.

@gyanranjanpanda
Copy link
Author

Ah got it thanks for pointing that out. I see what you mean.
My thinking earlier was to return the FeeRate from the builder so it would be easier for callers to access it after setting fee_rate, but you’re right since the API is already stabilized and FeeRate is cheap to copy, changing the builder doesn’t really add much value here.
I didn’t realize that keeping it alongside the TxBuilder instance would already solve the problem cleanly without touching the public API. I’ll rework the PR to follow that approach and keep the changes minimal.
Really appreciate the feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

discussion Discussion

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Feerate should be returned from Transaction construction

3 participants