Skip to content

Privacy range order fix#468

Merged
grunch merged 4 commits into
developfrom
feature-privacy-range-order
Mar 31, 2025
Merged

Privacy range order fix#468
grunch merged 4 commits into
developfrom
feature-privacy-range-order

Conversation

@arkanoider

@arkanoider arkanoider commented Mar 31, 2025

Copy link
Copy Markdown
Collaborator

@Catrya @grunch ,

this pull request is related to this pull request of mostro-core.

I have improved dispute message for solver adding a specific field for full privacy orders and optional fields for the users.

I fixed also #466 , need to be tested a bit more because I introduced this morning an improvement on mostro-core to check full privacy orders.

@Catrya when you can do a round of test, as usal use mostro-core locally with pull request linked above.

Summary by CodeRabbit

  • Refactor

    • Improved invoice processing for a more reliable transaction experience.
    • Enhanced dispute resolution workflows to further protect sensitive user information.
    • Streamlined order event handling to provide more consistent error feedback.
  • Chores

    • Updated the version of the mostro-core dependency for enhanced performance and stability.

@coderabbitai

coderabbitai Bot commented Mar 31, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes update several components. In the Cargo.toml, the version of the mostro-core dependency is updated from 0.6.34 to 0.6.35. The control flow in the add_invoice_action function is simplified by adjusting the match statement. The privacy handling in admin_take_dispute.rs is refactored by removing the standalone function and integrating a method into the Order struct, while user data handling is adjusted. Finally, the order event creation process in release.rs now conditionally retrieves user information based on privacy mode and updates error messaging.

Changes

File(s) Change Summary
Cargo.toml Updated mostro-core dependency version from 0.6.34 to 0.6.35 with features ["sqlx"].
src/app/add_invoice.rs Modified the control flow in add_invoice_action by replacing a trailing comma with a closing brace in the match statement, streamlining the update handling.
src/app/admin_take_dispute.rs
src/app/order.rs
Removed check_full_privacy_order function; added is_full_privacy_order method to Order. Updated user presence check to return None for full privacy mode and removed operating days calculation.
src/app/release.rs Introduced new logic flow in create_order_event to check for full privacy orders and updated error handling for tag generation. New imports added for new_event and order_to_tags.

Possibly related PRs

  • Bumps mostro core version #405: The changes in the main PR, which update the version of the mostro-core dependency in Cargo.toml, are related to the changes in the retrieved PR that also involve an update to the mostro-core dependency version in the same file.

Suggested reviewers

  • Catrya
  • grunch

Poem

I’m a rabbit, hopping in the code,
Patches and functions lighten my mode.
Local paths and logic refined with care,
Privacy checks ensure we’re all aware.
In every commit, I joyfully roam,
Celebrating clean code in my digital home!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55df7d8 and 7e4102f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • Cargo.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Cargo.toml

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@arkanoider arkanoider requested review from Catrya and grunch March 31, 2025 06:54

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8022076 and 55df7d8.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • Cargo.toml (1 hunks)
  • src/app/add_invoice.rs (1 hunks)
  • src/app/admin_take_dispute.rs (3 hunks)
  • src/app/release.rs (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/app/release.rs (2)
src/nip33.rs (2)
  • new_event (26-40)
  • order_to_tags (104-179)
src/db.rs (1)
  • is_user_present (404-419)
🔇 Additional comments (7)
src/app/add_invoice.rs (1)

82-82: Improved code structure by properly closing the match arm.

This change fixes the control flow structure in the function by properly closing the match arm for the Ok(updated_order) case with a brace, making the code cleaner and more maintainable.

src/app/release.rs (3)

5-5: Added required imports for new functionality.

Added imports for new_event and order_to_tags from crate::nip33 to support the refactored privacy handling in the create_order_event function.


406-419: Enhanced privacy handling for order events.

The code now respects user privacy settings when generating order events by checking if either buyer or seller has requested full privacy. This ensures that user data is only included in tags when appropriate.

The implementation correctly:

  1. Checks privacy status for both parties using the new is_full_privacy_order() method
  2. Only retrieves and includes user data when neither party is in full privacy mode
  3. Creates tags without user data when either party has full privacy enabled

This aligns with the PR objective of enhancing privacy handling for orders.


425-427: Improved error message for order event creation failures.

The error message has been updated to be more generic when tags cannot be created, using "Error creating order event" instead of a more specific message about invalid public keys. This is appropriate since there could be multiple reasons why tags might not be created.

src/app/admin_take_dispute.rs (3)

26-26: Refactored privacy check to use the new method on Order struct.

The standalone check_full_privacy_order function has been replaced with a direct call to order.is_full_privacy_order(), which simplifies the code and centralizes privacy-checking logic in the Order struct.


37-96: Improved handling of user privacy in dispute resolution.

The code now properly handles full privacy orders by:

  1. Using Option<User> to explicitly represent the presence or absence of user data
  2. Only fetching user data from the database when users are not in full privacy mode
  3. Passing None instead of a default User object when privacy is enabled

This change improves both the data handling and the clarity of the code by making it explicit when user data is available vs. when it's being withheld for privacy reasons.


99-105:

Details

❓ Verification inconclusive

Updated dispute info creation to handle optional user data.

The SolverDisputeInfo::new function now correctly receives optional user data, passing counterpart and initiator based on privacy settings. This ensures the dispute solver only receives user information that respects privacy preferences.

Let's verify that the SolverDisputeInfo struct in mostro-core has been updated to handle optional user data:


🏁 Script executed:

#!/bin/bash
# Check the SolverDisputeInfo struct definition in mostro-core
cd ../mostro-core
rg -A 20 "pub struct SolverDisputeInfo" src/

Length of output: 183


I'm having trouble locating the SolverDisputeInfo definition using the provided path. The earlier shell script failed because the relative directory ../mostro-core wasn’t found in this repository. To help us verify that the changes correctly handle optional user details, please run the following search from the repository root:

Once we get output from that search, we can confirm that the struct’s definition has been updated as expected. Please verify that the updated struct correctly handles optional user data based on privacy settings.

Action Required: Please verify the location and update status of the SolverDisputeInfo struct.


🏁 Script executed:

#!/bin/bash
rg -A 20 "pub struct SolverDisputeInfo" .

Length of output: 43


Action Required: Verify the updated SolverDisputeInfo in mostro-core

The dispute info creation in src/app/admin_take_dispute.rs now passes counterpart and initiator based on privacy settings so that only permitted user data is provided. However, our automated search did not locate the SolverDisputeInfo struct in the codebase. Please manually verify that:

  • The SolverDisputeInfo::new function in mostro-core is updated to accept optional user data.
  • The struct’s definition properly handles the optional fields based on privacy preferences (omitting or setting them as None when required).

Once you confirm these points, the change can be approved.

Comment thread Cargo.toml Outdated

@Catrya Catrya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tACK great job @arkanoider

@grunch grunch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK

@grunch grunch merged commit a6b119b into develop Mar 31, 2025
@grunch grunch deleted the feature-privacy-range-order branch March 31, 2025 21:12
arkanoider added a commit that referenced this pull request Apr 30, 2025
* 📝 Add docstrings to `feature-full-privacy-mode-checks` (#455)

* add feature to check correctly if order is full privacy or normal

* 📝 Add docstrings to `feature-full-privacy-mode-checks`

Docstrings generation was requested by @arkanoider.

* #454 (comment)

The following files were modified:

* `src/app/order.rs`
* `src/util.rs`

---------

Co-authored-by: arkanoider <github.913zc@simplelogin.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: arkanoider <113362043+arkanoider@users.noreply.github.com>

* Fix network in order event (#452)

Now in orers event 38383 the network that comes out is the correct one

* Feature anyhow removal (#459)

* remove of anyhow dependency start

* removed anyhow dependecy

* remove patch from cargo.toml

* Update mostro-core version

---------

Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>

* Feature disputes (#463)

* Feature: dispute fix for new logic

* fix for coop cancel case

* Add logic for info message about dispute for solver

* first working dispute info message for admin after taking disputes

* added fields to dispute info message for solver

* removed some probably useless and refactored a bit admin-take-dispute function

* clippy suggestion

* other cosmetics to admin take file

* some other cosmetics on admin-take-dispute file

* fix on admin-take

* Update admin_take_dispute.rs

* fixed a wrong search of order id in admin take file@

* Fix: added correct check to add solver from admin cli

* fix: wrong check on admin cancel

* Fix initiator pubkey: now is the trade key of initiator not identity

* quick fix for full privacy orders

* new logic with mixed full privacy - regular reputation mode

* Update cargo toml to compile with version 0.6.32 of mostro-core - this is in preparation for migrating to nostr-sdk 0.40

* rollback sdk to 0.38 version to merge disputes - we will come back to 0.40 when we will fix signature issue

* Update mostro-core dependency

---------

Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>

* added correction for the case of buyer adding back a new invoice after payment failure (#462)

* Fix for nostr sdk 40 issue on incoming message (#465)

* testing sdk 40

* fix for sdk 40

* cleaned cargo.toml

* Bump mostro core version

---------

Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>

* fix: sends order with an updated 'status' field as the reply to add-invoice when there is a preimage (#464)

* Feature-nip69-order-status (#467)

* feature: align to nip69 order status in nostr event

* Improved in progress nip69 logic

* refined event states of the order with nip69 request

* add another check to avoid multiple events with in-progress state

* Privacy range order fix (#468)

* add optional field for users in full privacy inside solver message

* To be tested - privacy range child order fix

* fix cargo.toml

* bumped mostro-core version to 6.35

* New user or privacy order send same user info with zeros (#471)

* new user or privacy order send same user info with zeros

* fix days field and removed some println! macro with nicer tracing messages

* bumped mostro-core version to 6.36 and added requested fix to compile

* Add previous order state in database for solver message (#472)

* add previous state in database for solver message

* bumped mostro-core version to 6.36

* Taker info message to maker.

I think that could be modifies in a more generic UserInfo.
 (#473)

* added logic to send infos to maker when an order is taken

* Add takers info message for maker

* fix cargo.toml

* set peer pubkey to empty string when notifying taker reputation to maker

* moved user info message to the right point of the order flow

* fix cargo.toml

* changed message struct from UserDisputeInfo to UserInfo

* fix: get master keys for user infos

* Bumped mostro-core to version 6.38

* fix for buy order flow with message to maker (#479)

* Rabbit fixes

---------

Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Catrya <140891948+Catrya@users.noreply.github.com>
Co-authored-by: Bilthon <bilthon@gmail.com>
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