Deprecate v2 SenderBuilder::new, fix FFI v1 panic - #1884
Conversation
Coverage Report for CI Build 35198352125Coverage decreased (-0.02%) to 86.687%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
|
CI failures here led me to #1885. Really I'm seeking concept ACK @benalleng. FFI v1 send COULD be supported on top of this here, where we'd ignore receive but at least be able to send to widely deployed BTCPayServer. What do you think? |
There was a problem hiding this comment.
CACK 6e3adea
As long as we don't have access to PjParam this seems like the best way to approach this on the FFI side. Sadly there will be some doc discrepancy between the rust src and the FFI with the deprecated new() method, though I don't think our FFi overall was ever particularly well matched in the first place
I think we should leave the full v1 send as a followup. we can still release them in the same version if you want
|
I don't have plans to make further adjustments if this is ackable. Originally, I wanted to wait until #1885 went through because otherwise CI is broken. I think this is ready to go as-is and should be much easier to swallow because it only makes aesthetic changes to the core payjoin crate. |
xstoicunicornx
left a comment
There was a problem hiding this comment.
Overall this looks good to me.
One question I had is why don't we want to mark the FFI new method as deprecated as well?
We probably want to add the v1 guard to all the language bindings tests and not just javascript, though this could be taken as a follow up.
Waiting for rebase to confirm CI finishes cleanly before approving.
|
@xstoicunicornx my suggestion here is that at the FFI layer we make a breaking change because we haven't made a 1.0 commitment yet, RATHER than deprecate. we do not yet have an alternative at the FFI layer. There is no from_parts function there. |
6e3adea to
031cf66
Compare
payjoin::send::v2::SenderBuilder::new panics on a URI whose pj endpoint is BIP 78 only. Such a URI parses and passes check_pj_supported, so a QR code from any v1 receiver could crash a v2-only sender. payjoin-ffi forwarded URIs straight into that constructor, which is how Bull Bitcoin Mobile hit an opaque uniffi panic when paying a v1 receiver. Changing new to return a Result would be a semver-major change for the 1.0 crate. Instead, deprecate it and point callers at from_parts, which takes the v2 PjParam directly and so forces the caller to match on the URI's PjParam and decide what to do with a v1 endpoint. The docs now state the panic and the migration path. In-repo tests move to from_parts except for the one that exercises new itself. The FFI SenderBuilder::new keeps its signature, since bindings have no matchable PjParam, but now does the match internally and returns a new SenderInputError::UnsupportedPjVersion for v1 endpoints instead of panicking across the FFI boundary. The JavaScript integration test that relied on that panic (asserting RuntimeError) now checks the typed FeeRateOutOfRange error against a v2 URI and the new error against a v1 URI. Fixes payjoin#1849
031cf66 to
44bc40d
Compare
|
Regarding the tests, I think we can wait for #1866 and include it on top of that rather than write 5x test fixtures to clean up. I'll make a comment there to follow on with it. |
xstoicunicornx
left a comment
There was a problem hiding this comment.
utACK 44bc40d
Straightforward updates to deprecate the SenderBuilder::new method. Agree with the decision to deprecate rather than introduce breaking change to the method's signature. Also agree with the recommendation to use SenderBuilder::from_parts rather than creating a new fallible version of SenderBuilder::new, as the new version wouldn't provide much additional utility regardless of whether implementor is using only v2 or both v1 and v2.
Closes #1849. Replaces #1870.
payjoin::send::v2::SenderBuilder::newpanics on a URI whosepjendpoint is BIP 78 only. That URI parses and passescheck_pj_supported, so a QR code from any v1 receiver can crash a v2-only sender, and through payjoin-ffi that panic reached Bull Bitcoin Mobile as an opaque uniffi error.Per the discussion on #1849,
newkeeps its signature and is deprecated in favor offrom_parts, which takes the v2PjParamdirectly and so makes the caller match on the URI'sPjParamand decide what to do with a v1 endpoint. The rustdoc now states the panic and the migration path. In-repo tests move tofrom_parts, except the one that exercisesnewitself.payjoin-ffi keeps its
SenderBuilder::newconstructor, since bindings have no matchablePjParam, but it now does the match internally and returns a newSenderInputError::UnsupportedPjVersionfor v1 endpoints. The JavaScript integration test that relied on the panic (assertingRuntimeError) now checks the typedFeeRateOutOfRangeerror against a v2 URI and the new error against a v1 URI.Testing:
contrib/lint.sh, thecargo doc -D warningsgate,payjoin/contrib/test.sh(lib, integration, and the v1-only and v2-only compile checks), and the payjoin-ffi Rust unit tests all pass locally. The JavaScript binding test change was not run locally; it follows thegetInnerandinstanceOfshapes the other tests in that file use, so I am relying on CI for it.Disclosure: co-authored by Claude Code