Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visibility modifiers #713

Merged
merged 5 commits into from
Mar 27, 2025

Conversation

thunderbiscuit
Copy link
Member

This PR fixes our incorrect use of visibility modifiers on some of our types. Note that when exporting to uniffi, visibility modifiers were not respected anyway? Not sure how that works or if it's my understanding of Rust that is lacking here, but a private or crate-private struct should not be available to outside users, yet definitely was.

In any case this PR makes public the types and methods we want to expose to users of the bindings explicit.

Changelog notice

No changelog.

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing

@thunderbiscuit thunderbiscuit force-pushed the fix/visibility branch 3 times, most recently from 91c613c to 33b64f4 Compare March 26, 2025 18:23
@thunderbiscuit thunderbiscuit requested a review from reez March 27, 2025 18:46
@@ -289,13 +289,13 @@ impl TxBuilder {
/// This will be used to:
///
/// 1. Set the `nLockTime` for preventing fee sniping. Note: This will be ignored if you manually specify a
/// `nlocktime` using `TxBuilder::nlocktime`.
/// `nlocktime` using `TxBuilder::nlocktime`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the extra spacing here and in a couple other spots in the diff for any specific reason?

Copy link
Member Author

@thunderbiscuit thunderbiscuit Mar 27, 2025

Choose a reason for hiding this comment

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

Yeah those were warnings from cargo's linter (the fmt tool). I can't find the commit right now but do you remember when we had to turn off the "fail" on the fmt CI workflow when warnings were issued, and only fail on fmt's failures? Some of the warnings were not in our power to fix (they were coming from uniffi's side), and so the CI was failing even though they were just warnings and we couldn't do anything about them.

This had the downside of now letting us merge stuff even if there is a warning by cargo's linter. In particular you probably won't know there is a warning if you don't run cargo fmt locally (or just check), which I sometimes forget to do. Not a big deal, but in this case I just thought I'd deal with the warning. The commit that did that is 78f38cf.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ahhhh ok!

Copy link
Collaborator

@reez reez left a comment

Choose a reason for hiding this comment

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

ACK 03c7535

Thanks for this PR, for one I always love this sorts of changes that just tighten up the codebase in some really nice way.

It also helped me discover a bit more about "when exporting to uniffi, visibility modifiers were not respected anyway", so I think I understand now that while pub(crate) was technically correct from a Rust perspective, it could be misleading because uniffi was exposing these functions regardless.

So this PR makes the code more honest/explicit about its actual visibility in the bindings 👍

@thunderbiscuit
Copy link
Member Author

Yeah love it too. It sort of bothered me at first that it appeared inconsistent but I put it out of my mind for a while. The macros just brought me more into the Rust side of things lately and I'm finding little snags like that.

@thunderbiscuit thunderbiscuit merged commit 03c7535 into bitcoindevkit:master Mar 27, 2025
53 checks passed
@thunderbiscuit thunderbiscuit deleted the fix/visibility branch March 27, 2025 23:28
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.

2 participants