Skip to content

Helper method for optional parameters with docstring#853

Merged
DanGould merged 2 commits intopayjoin:masterfrom
zealsham:optional-param-doc
Jul 7, 2025
Merged

Helper method for optional parameters with docstring#853
DanGould merged 2 commits intopayjoin:masterfrom
zealsham:optional-param-doc

Conversation

@zealsham
Copy link
Collaborator

@zealsham zealsham commented Jul 5, 2025

This pr addresess #685

summary

in the specs if the both parameter max_additional_fee_contribution and additional_fee_output_index isn't present then the receiver should not be able to alter sender output https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki#optional-parameters

We follow postel's law here and by implementing a helper method with docstring explaining why we proceed and don't fail in this case .

@zealsham zealsham changed the title Docstring imporovement for optional parameters Helper method for optional parameters with docstring Jul 5, 2025
@coveralls
Copy link
Collaborator

coveralls commented Jul 5, 2025

Pull Request Test Coverage Report for Build 16106375061

Details

  • 14 of 15 (93.33%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 84.914%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/core/receive/optional_parameters.rs 14 15 93.33%
Totals Coverage Status
Change from base Build 16058369464: 0.02%
Covered Lines: 7261
Relevant Lines: 8551

💛 - Coveralls

Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

Just the one question. Otherwise looking good

fn handle_additonal_fee_param(
max_additional_fee_contribution: Option<bitcoin::Amount>,
additional_fee_output_index: Option<usize>,
params: &mut Params,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you not pass mutable reference to just the params.additional_fee_contribution rather than the whole Params struct?

- Mutate &mut self rather than a params: &mut Params argument
- Minimize docstring since arguments are self-documenting
- Write warn contents on one line to avoid printing all of that whitespace
@DanGould
Copy link
Contributor

DanGould commented Jul 7, 2025

Hey @zealsham I wanted to get this one out of the way so that you can have a win and we can iterate. I hope you don't mind my suggestions going straight into a commit on top of yours. If it looks good to you I will squash and merge.

Check out my commit message, I made a few changes here.

@zealsham
Copy link
Collaborator Author

zealsham commented Jul 7, 2025

@DanGould it looks good . i see why passing the the mutable params isnt needed at all

Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

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

ACK 0d73b9b

@DanGould DanGould merged commit 25acd56 into payjoin:master Jul 7, 2025
8 checks passed
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