Skip to content

Expose PSBT input error index in FFI#17

Draft
DanGould wants to merge 1 commit intomasterfrom
session4/issue-1276
Draft

Expose PSBT input error index in FFI#17
DanGould wants to merge 1 commit intomasterfrom
session4/issue-1276

Conversation

@DanGould
Copy link
Copy Markdown
Owner

@DanGould DanGould commented Mar 2, 2026

Summary

When a PSBT input fails validation, FFI consumers currently get an error message but no way to programmatically identify which input caused the failure. Without the index, callers must parse error strings or guess, making robust error handling impossible in language bindings (Swift, Kotlin, Python).

Closes payjoin#1276

Approach

Add an index() getter to the core PsbtInputsError and an input_index() getter to BuildSenderError, then thread the index through the FFI layer as input_index: Option<u64> on BuildSenderError, populated during the From<send::BuildSenderError> conversion. The receive-side PsbtInputError (singular, not plural) already represents a single input and has no index to propagate, so it is left unchanged. Six tests verify index propagation at the core psbt, core send, and FFI layers.

Open questions

None

Disclosure: co-authored by Claude

Add an `index()` getter to `PsbtInputsError` and an
`input_index()` method on the core `BuildSenderError` so
the FFI layer can extract the zero-based position of the
offending PSBT input.

The FFI `BuildSenderError` now carries an `input_index`
field (exposed via uniffi) that is populated from the core
error during conversion. This lets Swift, Kotlin, Python,
and other FFI consumers surface precise diagnostics about
which input failed validation.

Six new tests verify propagation at the core psbt, core
send, and FFI layers.

Closes payjoin#1276
@coveralls
Copy link
Copy Markdown

coveralls commented Mar 2, 2026

Pull Request Test Coverage Report for Build 22572328646

Details

  • 27 of 27 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 82.552%

Totals Coverage Status
Change from base Build 22572195695: 0.07%
Covered Lines: 10655
Relevant Lines: 12907

💛 - Coveralls

@DanGould DanGould force-pushed the session4/issue-1276 branch from 2aa6067 to f687458 Compare March 2, 2026 10:40
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 2, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch session4/issue-1276

Comment @coderabbitai help to get the list of available commands and usage tips.

@DanGould DanGould force-pushed the session4/issue-1276 branch 2 times, most recently from 297a467 to de5c122 Compare March 2, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose PSBT input error index in FFI error types

2 participants