Skip to content

Validate FFI primitive inputs + refresh bindings/tests#1263

Open
chavic wants to merge 4 commits intopayjoin:masterfrom
chavic:chavic/primitives-validation
Open

Validate FFI primitive inputs + refresh bindings/tests#1263
chavic wants to merge 4 commits intopayjoin:masterfrom
chavic:chavic/primitives-validation

Conversation

@chavic
Copy link
Collaborator

@chavic chavic commented Jan 10, 2026

This PR addresses #1262 and hardens the FFI boundary by validating primitive inputs and surfacing explicit errors. Updates integration tests/bindings to match the new error shapes and removes silent acceptance of invalid fee rates/amounts.

Follow-ups

Decide final script/witness size caps and document rationale.
Add Dart integration fix for large fee rate parsing (separate PR).

@coveralls
Copy link
Collaborator

coveralls commented Jan 10, 2026

Pull Request Test Coverage Report for Build 21952519211

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.263%

Totals Coverage Status
Change from base Build 21922394027: 0.0%
Covered Lines: 10238
Relevant Lines: 12296

💛 - Coveralls

@benalleng benalleng mentioned this pull request Jan 13, 2026
9 tasks
@chavic chavic force-pushed the chavic/primitives-validation branch 2 times, most recently from cd3391a to a44a282 Compare January 19, 2026 17:40
@chavic chavic force-pushed the chavic/primitives-validation branch 2 times, most recently from 59affc6 to 93bc4e8 Compare January 27, 2026 11:10
@chavic chavic force-pushed the chavic/primitives-validation branch 5 times, most recently from 055a2bb to 53db1cb Compare February 3, 2026 17:13
@chavic chavic marked this pull request as ready for review February 4, 2026 09:52
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.

Instead of updating the msrv for dart I think we can simply use cargo install --locked wasm-bindgen-cli on the js workflow to prevent the install step from trying to update the deps

@chavic
Copy link
Collaborator Author

chavic commented Feb 4, 2026

Instead of updating the msrv for dart I think we can simply use cargo install --locked wasm-bindgen-cli on the js workflow to prevent the install step from trying to update the

Thanks... applying that now

@chavic chavic force-pushed the chavic/primitives-validation branch from 759be1b to 10ee724 Compare February 4, 2026 14:35
@chavic chavic requested a review from benalleng February 4, 2026 14:38
@chavic chavic force-pushed the chavic/primitives-validation branch 8 times, most recently from 732c40a to f331ef3 Compare February 4, 2026 17:21
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.

CACK f331ef3 got the commits nicely reviewable again thanks for that.

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 f331ef3 I have just a few nits and a broader question but overall I think it looks good! Thanks again for getting these commits easier to read 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

A question for a followup perhaps but should we consider making a primitives module to keep this kind of file in case we end up needing more like it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@benalleng Not bad actually, can move the shared validation helpers into a primitives module, only question is should this be in this PR or is it better to make that a separate PR

Copy link
Collaborator

Choose a reason for hiding this comment

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

this should be separate, and only probably once we have a lot more primitives to work with

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.

Jumped the gun, I think I would like this changed moved and explained into a new commit. I totally didn't realise it was a readme change..

@chavic chavic force-pushed the chavic/primitives-validation branch from f331ef3 to 7851959 Compare February 10, 2026 13:34
@benalleng
Copy link
Collaborator

we sneaked 12d2d33 in #1301 so we can safely remove 050bd88 from this PR

@chavic chavic force-pushed the chavic/primitives-validation branch 4 times, most recently from 8b3625e to 20d3670 Compare February 11, 2026 08:30
@chavic chavic removed the request for review from spacebear21 February 11, 2026 11:11
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.

I think you may have misunderstood my comments on the review, the psbt consts can be simply imported and not set as strings in the tests. I appreciate seeing the test_utils.dart but it was not really my intention to need to add this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

you've kind of reversed what you did here that you did in the dart file

Copy link
Collaborator Author

@chavic chavic Feb 12, 2026

Choose a reason for hiding this comment

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

This fell back during the rebase; I had a backup branch, so I'll bring it back. Side note, I've noticed only the Python test fails if the poll approach isn't used... will try to find out why (not the top task)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sidenote, should we consider asserting a failure when attempts exceed 3, unless the intent is explicitly “smoke test only”

Copy link
Collaborator

@benalleng benalleng Feb 11, 2026

Choose a reason for hiding this comment

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

The can actually just be

final psbt = test_utils.originalPsbt();

you will need to add it to the test_utils.dart import though

Copy link
Collaborator

Choose a reason for hiding this comment

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

Related note (but not a blocker for this PR), we should really not expose test utils in the main payjoin namespace for language bindings. This test_utils approach is a nice helper but the test utils are still exposed in the main namespace. I tried my hand at this briefly and couldn't find a good approach #1199 (comment)

@chavic chavic force-pushed the chavic/primitives-validation branch from 20d3670 to 432195d Compare February 12, 2026 07:17
@chavic chavic force-pushed the chavic/primitives-validation branch 2 times, most recently from 2c4ac28 to 5771b7a Compare February 12, 2026 15:12
@chavic chavic force-pushed the chavic/primitives-validation branch from 5771b7a to c1c3600 Compare February 12, 2026 15:18
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.

4 participants