Skip to content

Deduplicate payjoin URI creation logic#817

Merged
spacebear21 merged 1 commit intopayjoin:masterfrom
spacebear21:refactor-uri
Jun 27, 2025
Merged

Deduplicate payjoin URI creation logic#817
spacebear21 merged 1 commit intopayjoin:masterfrom
spacebear21:refactor-uri

Conversation

@spacebear21
Copy link
Collaborator

Create a helper function create_pj_uri in the v2 module that centralizes the logic for creating Payjoin URIs from a SessionContext. This eliminates code duplication between SessionHistory::pj_uri and Receiver<WithContext>::pj_uri.

The helper function takes a SessionContext reference and an OutputSubstitution parameter, making it flexible for both use cases while maintaining the same behavior as the original implementations.

This change:

  • Improves maintainability by centralizing URI creation logic
  • Reduces code duplication
  • Preserves the existing API and behavior

Create a helper function `create_pj_uri` in the v2 module that centralizes
the logic for creating Payjoin URIs from a SessionContext. This eliminates
code duplication between `SessionHistory::pj_uri` and
`Receiver<WithContext>::pj_uri`.

The helper function takes a SessionContext reference and an OutputSubstitution
parameter, making it flexible for both use cases while maintaining the same
behavior as the original implementations.

This change:
- Improves maintainability by centralizing URI creation logic
- Reduces code duplication
- Preserves the existing API and behavior
@spacebear21
Copy link
Collaborator Author

Moved from #812 which was accidentally closed. Merging based on ACKs received there.

@spacebear21 spacebear21 merged commit d879aff into payjoin:master Jun 27, 2025
7 checks passed
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 15935262286

Details

  • 12 of 12 (100.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.005%) to 85.487%

Files with Coverage Reduction New Missed Lines %
payjoin/src/receive/v2/session.rs 1 93.77%
Totals Coverage Status
Change from base Build 15934923586: -0.005%
Covered Lines: 7251
Relevant Lines: 8482

💛 - Coveralls

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