Skip to content

[WIP] Add AS-aware relay selection#1514

Draft
Mshehu5 wants to merge 5 commits into
payjoin:masterfrom
Mshehu5:ASN_asmap
Draft

[WIP] Add AS-aware relay selection#1514
Mshehu5 wants to merge 5 commits into
payjoin:masterfrom
Mshehu5:ASN_asmap

Conversation

@Mshehu5
Copy link
Copy Markdown
Contributor

@Mshehu5 Mshehu5 commented May 1, 2026

This PR is a proof of concept for AS-aware, stateless relay selection in payjoin-cli and is meant to move the discussion in #919 forward. Reviewers will probably want to read #919 for the full context behind the design and tradeoffs.

The implementation adds optional ASMap-based filtering for trusted directories and OHTTP relays then demonstrates relay selection that separates POST and POLL traffic without storing a selected relay or relay index. Relay ordering is derived from the receiver key, request/message type and short time windows with polling avoiding POST-reserved AS buckets for nearby windows.

I also added comments around parts of the implementation that may be candidates for moving into the payjoin crate or possibly into a reusable external crate. These comments are suggestions not final API proposals and reviewer feedback would be very welcome. One reason for calling these pieces out is the concern raised in #919: asking every downstream wallet to reimplement this behavior could create extra work and consistency problems.

Disclosure: co-authored by Codex

Pull Request Checklist

Please confirm the following before requesting review:

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 1, 2026

Coverage Report for CI Build 26173671454

Coverage decreased (-0.9%) to 84.348%

Details

  • Coverage decreased (-0.9%) from the base build.
  • Patch coverage: 263 uncovered changes across 5 files (551 of 814 lines covered, 67.69%).
  • 7 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
payjoin-cli/src/app/v2/relay_selection.rs 499 374 74.95%
payjoin-cli/src/app/v2/ohttp.rs 76 3 3.95%
payjoin-cli/src/app/config.rs 88 55 62.5%
payjoin-cli/src/app/v2/mod.rs 142 111 78.17%
payjoin-cli/src/app/mod.rs 9 8 88.89%

Coverage Regressions

7 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
payjoin-cli/src/app/v2/ohttp.rs 6 9.2%
payjoin-cli/src/app/config.rs 1 73.41%

Coverage Stats

Coverage Status
Relevant Lines: 14330
Covered Lines: 12087
Line Coverage: 84.35%
Coverage Strength: 378.93 hits per line

💛 - Coveralls

@arminsabouri
Copy link
Copy Markdown
Collaborator

cc @nothingmuch to approach Ack/Nack

Mshehu5 added 5 commits May 20, 2026 16:44
Replace the singular v2 directory setting with a trusted
directory list while preserving the CLI override behavior.
Load ASMap settings behind an optional feature and reject ASMap
configuration when the binary was built without support.
Choose relay order from the receiver key, request kind, time
window and relay bucket
Route key fetching and protocol requests through selected relay
candidates with failover for retryable network errors.
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.

3 participants