Skip to content

Expose JSON reply accessors#1427

Open
chavic wants to merge 1 commit intopayjoin:masterfrom
chavic:chavic/json-reply-accessors-1271
Open

Expose JSON reply accessors#1427
chavic wants to merge 1 commit intopayjoin:masterfrom
chavic:chavic/json-reply-accessors-1271

Conversation

@chavic
Copy link
Copy Markdown
Collaborator

@chavic chavic commented Mar 20, 2026

Closes #1271.

This PR fixes a gap between the core library and the FFI surface around structured BIP78 reply data. The core already modeled reply fields like errorCode, message, status code, and supported versions, but bindings mostly had to treat replies as opaque JSON blobs. There was also a real compatibility bug here: receiver-side JsonReply serialized supported as a JSON string, while sender-side parsing expected an array.

The change adds typed accessors for JsonReply and WellKnownError, exposes reply data directly from HasReplyableError, and fixes receiver-side supported serialization to use the correct array shape. Sender-side parsing remains backward compatible by still accepting the older broken format, so this improves the wire behavior without making the transition brittle.

The net effect is that bindings can branch on structured receiver replies without reparsing raw JSON, and version-negotiation replies now line up correctly across sender and receiver. This also establishes the object-plus-getters pattern that the rest of the receiver-side FFI error work can follow.

Add typed accessors for receiver JsonReply and sender
WellKnownError across the core and FFI layers. This lets
bindings inspect structured error data without reparsing raw
JSON strings.

Fix the receiver-side version-unsupported reply shape at the
same time so supported versions are emitted as a JSON array,
while still accepting the legacy string form for backward
compatibility. Add focused Rust and Python tests to lock in
both the new accessors and the wire-format compatibility.
@coveralls
Copy link
Copy Markdown
Collaborator

Pull Request Test Coverage Report for Build 23355389027

Details

  • 89 of 102 (87.25%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 84.206%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/core/receive/v2/mod.rs 0 1 0.0%
payjoin/src/core/send/error.rs 22 25 88.0%
payjoin/src/core/receive/error.rs 67 76 88.16%
Totals Coverage Status
Change from base Build 23300212261: 0.08%
Covered Lines: 10732
Relevant Lines: 12745

💛 - Coveralls

@chavic chavic requested a review from spacebear21 March 22, 2026 09:11
@chavic chavic marked this pull request as ready for review March 22, 2026 09:11
@chavic chavic self-assigned this Mar 22, 2026
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 structured access to JsonReply error code and supported_versions in FFI

2 participants