Skip to content

Conversation

@chavic
Copy link
Contributor

@chavic chavic commented Nov 16, 2025

Following up on rust-payjoin#738 to make the FFI boundary primitive-first. Strong types at the edge forced downstreams to depend on bitcoin_ffi and broke whenever wrappers drifted. We now expose strings/bytes/integers with runtime validation.

Changes

  • ReceiverBuilder::new takes an address string; errors surface as ReceiverBuilderError/AddressParseError. Added PlainTxIn/TxOut/OutPoint/PsbtInput/Weight plus InputPairError for the rest of the receiver typestates (script callbacks, output substitution, input contribution, PSBT parsing).
  • Sender alignment: Mirrored the upstream FSM (ProposalReceived is gone) and added helpers on SenderSessionOutcome to expose success/failure/cancel plus base64 PSBT.
  • PSBT handoff: ProvisionalProposal::psbt_to_sign now returns base64, so wallets can consume it without wrappers. Fee-rate setters validate raw u64 and report overflow.
  • bitcoin_ffi removed: Deleted the module/exports and cleaned constants; uniffi is bumped to 0.30 with refreshed lockfiles.
  • Bindings/test harnesses updated: Dart/JS/Python harnesses use the new primitives and validation paths; regenerated bindings accordingly.

Notes

  • Runtime validation remains in the core; conversions happen at the edge to avoid version lockstep on wrappers.

@chavic chavic changed the title refactor(send): convert Psbt boundary to primitive strings Move the Default Payjoin FFI API to primitives Nov 16, 2025
@DanGould
Copy link
Contributor

Thanks for sharing your draft in public early before it's ready for review

@coveralls
Copy link
Collaborator

coveralls commented Nov 17, 2025

Pull Request Test Coverage Report for Build 20280641768

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 83.402%

Totals Coverage Status
Change from base Build 20276641686: 0.0%
Covered Lines: 9728
Relevant Lines: 11664

💛 - Coveralls

@chavic chavic force-pushed the chavic/uniform-primitive-types-at-ffi-boundary branch 4 times, most recently from 8a25f4f to ec56cdc Compare November 27, 2025 17:23
@chavic chavic marked this pull request as ready for review November 27, 2025 17:41
@chavic
Copy link
Contributor Author

chavic commented Nov 27, 2025

Ready for review @spacebear21 @DanGould

@arminsabouri
Copy link
Collaborator

Assigned @spacebear21 to this one
@chavic two things

  • This PR needs a rebase as there are conflicts
  • Please consider squashing some of your commits per the contributing.md guide

@spacebear21
Copy link
Collaborator

Thanks Armin - I agree this will be much easier to review once it's rebased and commits are organized.

@chavic
Copy link
Contributor Author

chavic commented Dec 8, 2025

will do

@chavic chavic force-pushed the chavic/uniform-primitive-types-at-ffi-boundary branch 3 times, most recently from c4baa41 to da7a4d2 Compare December 10, 2025 18:44
@chavic
Copy link
Contributor Author

chavic commented Dec 10, 2025

@arminsabouri and @spacebear21 squashed much of the git history to make things much cleaner

Copy link
Collaborator

@benalleng benalleng left a comment

Choose a reason for hiding this comment

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

Everything looks pretty good just the small nit about the uniffi-downgrade and upgrade one after the other.

I was able to test python but couldn't build dart or javascript properly to test

Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

Looking good! I also think the three "adapt harness" commits could be squashed into one since they kind of all do the same thing.

I think the last two commits may also be squashed, which would resolve @benalleng 's comment.

@chavic chavic force-pushed the chavic/uniform-primitive-types-at-ffi-boundary branch 6 times, most recently from 5ae6fef to 229a2ba Compare December 15, 2025 14:44
@chavic chavic force-pushed the chavic/uniform-primitive-types-at-ffi-boundary branch 5 times, most recently from ec32660 to f83f814 Compare December 15, 2025 17:50
@chavic chavic force-pushed the chavic/uniform-primitive-types-at-ffi-boundary branch 7 times, most recently from f6cae3c to e86ef0c Compare December 16, 2025 18:18
This introduces PlainTx* records and Weight for the primitive FFI surface, adds ReceiverBuilderError, AddressParseError, InputPairError, FeeRateError, and provides conversions without altering existing signatures.
@chavic chavic force-pushed the chavic/uniform-primitive-types-at-ffi-boundary branch from e86ef0c to 1c43f78 Compare December 16, 2025 18:51
This migrates the FFI layer to the new primitive types and serialized PSBTs as we move away from importing bitcoin_ffi.
After migrating to primitive types on the FFI layer we no longer need to import the bitcoin_ffi package. Also cleans up any API changes made during the transition.
@chavic chavic force-pushed the chavic/uniform-primitive-types-at-ffi-boundary branch from 1c43f78 to 3187533 Compare December 16, 2025 19:45
Copy link
Collaborator

@benalleng benalleng left a comment

Choose a reason for hiding this comment

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

Ack 3187533 those are some clean commit messages 👀

Copy link
Collaborator

@spacebear21 spacebear21 left a comment

Choose a reason for hiding this comment

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

ACK 3187533, great work on the rebase and commit organization!

@spacebear21 spacebear21 merged commit 96965a8 into payjoin:master Dec 16, 2025
15 checks passed
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.

Uniformly use primitive types in FFI boundary, with runtime validation

6 participants