feat(payments): negotiate CEP-8 payment interaction on the client transport - #108
Open
harsh04044 wants to merge 1 commit into
Open
feat(payments): negotiate CEP-8 payment interaction on the client transport#108harsh04044 wants to merge 1 commit into
harsh04044 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #100
Fifth piece of CEP-8, after the server negotiation in #107. Client half of the same handshake, so both sides can now be driven against each other in one process.
The client advertises its payment methods (
pmi) and its requested interaction mode (payment_interaction) on outbound requests, and records the effective mode the server discloses back. No payment flow yet: nothing reacts topayment_required, retries, or ships a handler. That'swith_client_payments. A client with no payments config publishes the same tags it did before, asserted on a published event rather than argued.What's here
ClientNegotiationStatebehind onestd::sync::Mutex, seeded from two new config fieldsget_pending_negotiation_tags, wired in as the third argument ofcompose_outbound_tags, gated onis_requestlike the discovery tagsset_payment_interaction/set_client_pmis/get_effective_payment_interactionlearn_server_discovery, recording the disclosed mode only when this client asked forexplicit_gatingtests/payments_negotiation_e2e.rs, 4 unit testsOne
Cargo.tomlline for the new test file'srequired-features. No new dependency, no FFI change.Notes
pmirides every request and never latches;payment_interactiongoes out only when the requested mode differs from the one last published; neither configured means nothing at all. A requestedtransparentis emitted explicitly, so a downgrade stays distinguishable from "no preference".set_payment_interactionlanding mid-publish can't latch a mode that never went out.src/proxy/mod.rsin the diff? Two lines, test-only. It buildsNostrClientTransportConfigas a full struct literal in a unit test, where#[non_exhaustive]doesn't protect it.Heads up
Three deliberate differences from ts, each documented on the item. The latch stores the last published mode instead of a bool, so setting a mode and setting it back with no publish in between emits nothing where ts sends a redundant upsert. The observed mode isn't cleared on
close(), matching what we already do for the CEP-35 state and unreachable anyway since the client transport can't be restarted. And a client that downgrades itself freezes its observed mode, which is exact ts parity: resetting it unilaterally would put the two SDKs' getters out of step on the same wire trace.