Skip to content

feat: expose Wallet::get_psbt_input#1032

Open
reez wants to merge 2 commits into
bitcoindevkit:masterfrom
reez:get-psbt-input
Open

feat: expose Wallet::get_psbt_input#1032
reez wants to merge 2 commits into
bitcoindevkit:masterfrom
reez:get-psbt-input

Conversation

@reez

@reez reez commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Description

Exposes Wallet::get_psbt_input so users can derive PSBT input metadata for a wallet owned LocalOutput

Notes to the reviewers

Tests can be minimized/removed before merge if needed.

Documentation

Changelog

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing
  • I've added exactly one changelog:* label
  • I've linked the relevant upstream docs or specs above

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@reez reez marked this pull request as ready for review June 17, 2026 17:59
@reez reez force-pushed the get-psbt-input branch from c515c37 to 08689d2 Compare June 25, 2026 18:20
@reez

reez commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator Author

rebased, open for review

@reez reez requested review from ItoroD and thunderbiscuit June 25, 2026 18:22
Comment thread bdk-ffi/src/types.rs
transitively: transitively.map(|txid| txid.0),
},
ChainPosition::Unconfirmed { timestamp } => BdkChainPosition::Unconfirmed {
first_seen: timestamp,

@ItoroD ItoroD Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we leave out first_seen in our ChainPosition type definition but now we have to use same timestamp when passing back.

Maybe not related to this PR; Asking in general... Do we really not need first seen?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, cuz we had already exposed first_seen on TxGraphChangeSet, but ChainPosition was still using the older single timestamp field which maps to upstream last_seen. I opened a followup PR to expose both first_seen and last_seen there too: #1039

Comment thread bdk-ffi/src/wallet.rs
utxo: LocalOutput,
sighash_type: Option<String>,
only_witness_utxo: bool,
) -> Result<Input, GetPsbtInputError> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Took me a while to see why we are returning GetPsbtInputError here when we have CreateTxError. This is good as we need to handle for string parsing, the 2 possible errors from bdk-wallet (miniscript and unknown), and all others.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yup exactly

Comment thread bdk-ffi/src/error.rs Outdated
impl From<CreateTxError> for GetPsbtInputError {
fn from(error: CreateTxError) -> Self {
match error {
CreateTxError::UnknownUtxo { outpoint } => GetPsbtInputError::UnknownUtxo { outpoint },

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there ever be a match on CreateTxError::UnknownUtxo here since we always call from_bdk_create_tx_error which handles the UnknownUtxo?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, cuz in the current path no, so I simplified this so get_psbt_input maps the upstream errors directly now d9a61d5

@ItoroD

ItoroD commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks for making all the updates! No more comments from me, looks all good.

Do you want to merge #1039 and update first_seen last seen here or vice versa. Either way is fine with me. I could approve this now

@reez

reez commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for making all the updates! No more comments from me, looks all good.

Do you want to merge #1039 and update first_seen last seen here or vice versa. Either way is fine with me. I could approve this now

I think we gotta wait on 1039 because it's a breaking change.

And thanks for the good review comments.

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

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants