Skip to content

Add and Revise Receiver Interface Comments - #1710

Merged
spacebear21 merged 5 commits into
payjoin:masterfrom
xstoicunicornx:update-comments
Jul 30, 2026
Merged

Add and Revise Receiver Interface Comments#1710
spacebear21 merged 5 commits into
payjoin:masterfrom
xstoicunicornx:update-comments

Conversation

@xstoicunicornx

Copy link
Copy Markdown
Collaborator

Summary

This PR builds off of #1653 which added clear and consistent comments to the FFI receiver interface where they were missing before. This PR expands that work to revise the v1 and v2 comments to align closely with the patterns established in the FFI interface and add consistency to the doc strings between all the different typestates and interfaces. The goal of this PR was to make the documentation on how to use these receiver interfaces more clear and concise, and if deemed a strict improvement might be good to include in PDK v1.0 release.

Claude Opus 4.8 was used to collaboratively create and revise these doc strings.

Pull Request Checklist

Please confirm the following before requesting review:

@xstoicunicornx xstoicunicornx mentioned this pull request Jul 3, 2026
2 tasks
@coveralls

coveralls commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 30574097238

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.3%) to 86.494%

Details

  • Coverage increased (+0.3%) from the base build.
  • Patch coverage: 8 uncovered changes across 1 file (110 of 118 lines covered, 93.22%).
  • 329 coverage regressions across 9 files.

Uncovered Changes

File Changed Covered %
payjoin/src/core/receive/v2/mod.rs 118 110 93.22%

Coverage Regressions

329 previously-covered lines in 9 files lost coverage.

File Lines Losing Coverage Coverage
payjoin-cli/src/app/v2/mod.rs 112 57.73%
payjoin/src/core/receive/v2/mod.rs 93 92.58%
payjoin-mailroom/src/lib.rs 55 68.3%
payjoin/src/core/send/v2/mod.rs 29 88.64%
payjoin/src/core/uri/error.rs 22 46.51%
payjoin/src/core/uri/mod.rs 7 96.09%
payjoin-mailroom/src/main.rs 5 0.0%
payjoin/src/core/receive/v2/session.rs 3 99.01%
payjoin/src/core/uri/v1.rs 3 94.07%

Coverage Stats

Coverage Status
Relevant Lines: 16200
Covered Lines: 14012
Line Coverage: 86.49%
Coverage Strength: 340.64 hits per line

💛 - Coveralls

@caarloshenriq caarloshenriq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Concept ACK

/// the increased transaction size. If a sender specifies a receiver output for this purpose, this
/// function sets that parameter to None so that it is ignored in subsequent steps of the
/// receiver flow. This protects the receiver from accidentally subtracting fees from their own
/// outputs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This paragraph about additional_fee_contribution being cleared when it points at a receiver-owned output got dropped in the rewrite. That protection is still implemented, just moved to OriginalContext::new in common/mod.rs:35-40

Worth keeping this detail, it's not obvious from the new "ensure at least one output pays the receiver" wording, and it's a real guarantee callers should know about.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks better IMO, thank you!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

thank you for your review!

Comment on lines -962 to -971
/// Validates whether the original PSBT contains outputs which pay to the receiver and only
/// then proceeds to the next typestate.
/// Identify which outputs in the original transaction belong to the receiver
/// and ensure at least one output pays the receiver.
///
/// Additionally, this function also protects the receiver from accidentally subtracting fees
/// from their own outputs: when a sender is sending a proposal,
/// they can select an output which they want the receiver to subtract fees from to account for
/// the increased transaction size. If a sender specifies a receiver output for this purpose, this
/// function sets that parameter to None so that it is ignored in subsequent steps of the
/// receiver flow. This protects the receiver from accidentally subtracting fees from their own
/// outputs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as the note on v1/mod.rs, this paragraph about additional_fee_contribution sanitization was dropped here too

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Also updated.

Rework the doc comments in the v2 receive module so the state-level
comments are concise and point to the method that advances to the next
typestate, while the per-method comments align with the wording added to
the FFI interface. Method docs now name their explicit transition return
type and describe the state each transition yields once successfully
persisted.
Apply the same doc comment rework to the v1 receive module: state-level
comments are concise and point to the method that advances to the next
typestate, while per-method comments align with the wording used in the
FFI interface. Unlike v2, v1 methods return the next state directly, so
the docs describe the returned state without transition or persistence
framing.

@caarloshenriq caarloshenriq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK

@benalleng benalleng added the documentation Improvements or additions to documentation label Jul 16, 2026
@xstoicunicornx xstoicunicornx mentioned this pull request Jul 30, 2026
18 tasks

@spacebear21 spacebear21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

concept ACK but I think all the docstrings on the impl blocks need to be moved to the struct declaration like you did for UncheckedOriginalPayload, for both v1 and v2 modules (and maybe also the Sender, I haven't checked how they are written there).

correction: let's move the UncheckedOriginalPayload struct docstring to its impl block for consistency with the other typestates.

Comment thread payjoin/src/core/receive/v2/mod.rs
Add a short doc comment to each v2 receiver typestate struct so the type
appears with a one-line summary in rustdoc, with a pointer to the
Receiver<State> impl block where the detailed documentation lives.
@xstoicunicornx

Copy link
Copy Markdown
Collaborator Author

@spacebear21 feedback addressed. I also went ahead and added some super simple doc strings to all the structs to state their purpose and point to the more in depth documentation on the Receiver<typestate> impl blocks.

@spacebear21 spacebear21 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

tACK docs build successfully locally and everything looks clean.

Image

@spacebear21
spacebear21 merged commit 02954d6 into payjoin:master Jul 30, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants