Skip to content

Correct full privacy mode check when orders arrives#454

Merged
grunch merged 3 commits into
developfrom
feature-full-privacy-mode-checks
Feb 28, 2025
Merged

Correct full privacy mode check when orders arrives#454
grunch merged 3 commits into
developfrom
feature-full-privacy-mode-checks

Conversation

@arkanoider

@arkanoider arkanoider commented Feb 28, 2025

Copy link
Copy Markdown
Collaborator

@grunch @Catrya

fix for full privacy order coming in mostrod, now events are published also if order is in full privacy.

Removed an useless map_err call which was creating not precise error message remapping again a MostroError coming from below.

Summary by CodeRabbit

  • New Features

    • Introduced a new function to streamline the generation of tags for orders based on user privacy status, enhancing the order processing experience.
  • Refactor

    • Simplified error management during order publication for more consistent and reliable processing.

@coderabbitai

coderabbitai Bot commented Feb 28, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request modifies the error handling in the order_action function by replacing explicit error mapping with the ? operator. Additionally, it introduces a new asynchronous function get_tags_for_new_order in src/util.rs, which encapsulates the logic for checking user presence and transforming order fields into tags. The publish_order function is updated to utilize this new function, thereby streamlining the process and reducing code duplication.

Changes

File(s) Summary
src/app/order.rs Simplified error handling in order_action by replacing explicit error mapping with the ? operator.
src/util.rs Added asynchronous function get_tags_for_new_order to handle user presence checks and tag transformations. Replaced old logic in publish_order with a call to this new function.

Possibly related PRs

  • Fix on some full privacy cases #446: The changes in the main PR are related to modifications in the order handling, particularly regarding the management of the trade_index variable.
  • Feat: issue #437 implementation #445: The modifications to the publish_order function's error handling are related to updates in the order_to_tags function, as both involve handling user data and error propagation in order processing.
  • Refactoring code removing unwraps() #449: The simplification of error handling in the order_action function by using the ? operator is related to modifications that also replace unwrap() with the ? operator for consistent error management across the codebase.

Poem

Oh, I’m a hopping rabbit in the code meadow,
Skipping through changes where logic flows.
Error maps now vanish with a gentle “?” sway,
And privacy checks keep bugs at bay.
With tags transformed, our code shines so bright,
Hoppy cheers to a codebase taking flight!
(_/)_/


📜 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 566f73c and d1c1961.

📒 Files selected for processing (1)
  • src/util.rs (2 hunks)
🔇 Additional comments (2)
src/util.rs (2)

166-192: Well-designed function for tag generation with privacy handling!

This new function effectively encapsulates the logic for determining tags based on whether an order is in full privacy mode or not. The function properly checks for user presence and handles the case where identity_pubkey matches trade_pubkey as a full privacy scenario, addressing the issue mentioned in the PR objectives.


229-231: Good refactoring to simplify the code flow

The code now uses the new get_tags_for_new_order function to handle tag generation, including the proper checking for full privacy mode. This change ensures events are published correctly even when an order is received in full privacy mode, fulfilling the PR objective.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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.

coderabbitai Bot added a commit that referenced this pull request Feb 28, 2025
Docstrings generation was requested by @arkanoider.

* #454 (comment)

The following files were modified:

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

coderabbitai Bot commented Feb 28, 2025

Copy link
Copy Markdown
Contributor

Note

Generated docstrings for this pull request at #455

Comment thread src/util.rs Outdated

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

tACK

@grunch grunch merged commit 014c6dd into develop Feb 28, 2025
@grunch grunch deleted the feature-full-privacy-mode-checks branch February 28, 2025 13:24
@arkanoider arkanoider restored the feature-full-privacy-mode-checks branch February 28, 2025 13:47
@grunch grunch deleted the feature-full-privacy-mode-checks branch February 28, 2025 20:27
grunch pushed a commit that referenced this pull request Feb 28, 2025
* 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>
@coderabbitai coderabbitai Bot mentioned this pull request Mar 3, 2025
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>
arkanoider added a commit that referenced this pull request May 18, 2025
* 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>
grunch added a commit that referenced this pull request May 29, 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>

* 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>

* 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>

* 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

* 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

* first commit for database encryption

* Moving on with encryption work

* Implemented base64 on cipher

* Takebuy and takesell pending orders check now working with encryption

* Removed unwraps

* Finishing code: changed password management and completing checks

* Finishing code: used hashset for search

* added unit test for evaluate timings

* first order cycle completed - to be fixed empty password case

* Added logic for testing a caching idea using hashmap to speed up search of identity keys when encrypted

* ready to start review process

* Cleaned test

* removed patch from cargo.toml

* Rabbit fixes

* some improvements to have also rating working with encryption

* Removed useless call in db.rs

* fix for tests

* Cosmetics on release.rs - improved a bit a function in more ribust way

* fix: wrong check on full privacy orders in disputes

* fix: more meaningful variable name in dispute setup

* fix: wrong commented lines reactivated

* fix: some fixes in privacy orders with encryption

* fix: some fixes following coderabbit advices

Introduced a random delay on password entering to avoid timing attacks.

Removed awaiting from store_encrypted function that does not require async.

* refactor: removed many useless connection opening to database with direct use of borrowed pool variable

* chore: more meaningful text for user in db.rs

* chore: improved encryption unit test

now fix salt for testing works - fix salt and password are used to test timings with decryption using key caching, to test it do:

cargo test test_fetch_string_column_scalar -- --nocapture

* refactor: some improvements in db.rs

improved password error management

reduce code duplication for pending orders checks

* chore(rebase-on-main): commit cargo.lock for rebasing on top of main encrytpion

* feat: completing refactor and rebase of encryption pr

* refactor: introduced new refactoring of encryption-decryption function

- cargo compiles now, we will have to create the new mostro-core after some testings.

- bumped nostr-sdk to 0.41 release, no breaking changes

* chore: temporary added git branch of mostro-core to compile

* chore(test): fix tests

* chore: bumped mostro-core version in cargo.toml

* fix: wrong database path string creation

* chore: fix tests in db.rs

* fix: child order after a trade with a full privacy user have wrong master keys

* fix: typo on check password hash function

* fix: child order event after a complete order does not send user information also if order is normal (not full privacy)

* fix: if a child order come from a privacy order user rating are sent in the event wit all zeroes

* fix: fixed bug found by Catrya

- when I recreate the child order master keys were saved without encryption
  so when a takesell or takebuy comes in the search for pending user orders generate a decrytpion error.

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>
gdonhftinascott added a commit to gdonhftinascott/mostro that referenced this pull request Oct 9, 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.

* MostroP2P/mostro#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>
gdonhftinascott added a commit to gdonhftinascott/mostro that referenced this pull request Oct 9, 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.

* MostroP2P/mostro#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>

* 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>

* 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>

* 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

* 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

* first commit for database encryption

* Moving on with encryption work

* Implemented base64 on cipher

* Takebuy and takesell pending orders check now working with encryption

* Removed unwraps

* Finishing code: changed password management and completing checks

* Finishing code: used hashset for search

* added unit test for evaluate timings

* first order cycle completed - to be fixed empty password case

* Added logic for testing a caching idea using hashmap to speed up search of identity keys when encrypted

* ready to start review process

* Cleaned test

* removed patch from cargo.toml

* Rabbit fixes

* some improvements to have also rating working with encryption

* Removed useless call in db.rs

* fix for tests

* Cosmetics on release.rs - improved a bit a function in more ribust way

* fix: wrong check on full privacy orders in disputes

* fix: more meaningful variable name in dispute setup

* fix: wrong commented lines reactivated

* fix: some fixes in privacy orders with encryption

* fix: some fixes following coderabbit advices

Introduced a random delay on password entering to avoid timing attacks.

Removed awaiting from store_encrypted function that does not require async.

* refactor: removed many useless connection opening to database with direct use of borrowed pool variable

* chore: more meaningful text for user in db.rs

* chore: improved encryption unit test

now fix salt for testing works - fix salt and password are used to test timings with decryption using key caching, to test it do:

cargo test test_fetch_string_column_scalar -- --nocapture

* refactor: some improvements in db.rs

improved password error management

reduce code duplication for pending orders checks

* chore(rebase-on-main): commit cargo.lock for rebasing on top of main encrytpion

* feat: completing refactor and rebase of encryption pr

* refactor: introduced new refactoring of encryption-decryption function

- cargo compiles now, we will have to create the new mostro-core after some testings.

- bumped nostr-sdk to 0.41 release, no breaking changes

* chore: temporary added git branch of mostro-core to compile

* chore(test): fix tests

* chore: bumped mostro-core version in cargo.toml

* fix: wrong database path string creation

* chore: fix tests in db.rs

* fix: child order after a trade with a full privacy user have wrong master keys

* fix: typo on check password hash function

* fix: child order event after a complete order does not send user information also if order is normal (not full privacy)

* fix: if a child order come from a privacy order user rating are sent in the event wit all zeroes

* fix: fixed bug found by Catrya

- when I recreate the child order master keys were saved without encryption
  so when a takesell or takebuy comes in the search for pending user orders generate a decrytpion error.

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Francisco Calderón <fjcalderon@gmail.com>
meta-forgen8io added a commit to meta-forgen8io/mostro that referenced this pull request Nov 14, 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.

* MostroP2P/mostro#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>
meta-forgen8io added a commit to meta-forgen8io/mostro that referenced this pull request Nov 14, 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.

* MostroP2P/mostro#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>

* 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>

* 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>

* 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

* 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

* first commit for database encryption

* Moving on with encryption work

* Implemented base64 on cipher

* Takebuy and takesell pending orders check now working with encryption

* Removed unwraps

* Finishing code: changed password management and completing checks

* Finishing code: used hashset for search

* added unit test for evaluate timings

* first order cycle completed - to be fixed empty password case

* Added logic for testing a caching idea using hashmap to speed up search of identity keys when encrypted

* ready to start review process

* Cleaned test

* removed patch from cargo.toml

* Rabbit fixes

* some improvements to have also rating working with encryption

* Removed useless call in db.rs

* fix for tests

* Cosmetics on release.rs - improved a bit a function in more ribust way

* fix: wrong check on full privacy orders in disputes

* fix: more meaningful variable name in dispute setup

* fix: wrong commented lines reactivated

* fix: some fixes in privacy orders with encryption

* fix: some fixes following coderabbit advices

Introduced a random delay on password entering to avoid timing attacks.

Removed awaiting from store_encrypted function that does not require async.

* refactor: removed many useless connection opening to database with direct use of borrowed pool variable

* chore: more meaningful text for user in db.rs

* chore: improved encryption unit test

now fix salt for testing works - fix salt and password are used to test timings with decryption using key caching, to test it do:

cargo test test_fetch_string_column_scalar -- --nocapture

* refactor: some improvements in db.rs

improved password error management

reduce code duplication for pending orders checks

* chore(rebase-on-main): commit cargo.lock for rebasing on top of main encrytpion

* feat: completing refactor and rebase of encryption pr

* refactor: introduced new refactoring of encryption-decryption function

- cargo compiles now, we will have to create the new mostro-core after some testings.

- bumped nostr-sdk to 0.41 release, no breaking changes

* chore: temporary added git branch of mostro-core to compile

* chore(test): fix tests

* chore: bumped mostro-core version in cargo.toml

* fix: wrong database path string creation

* chore: fix tests in db.rs

* fix: child order after a trade with a full privacy user have wrong master keys

* fix: typo on check password hash function

* fix: child order event after a complete order does not send user information also if order is normal (not full privacy)

* fix: if a child order come from a privacy order user rating are sent in the event wit all zeroes

* fix: fixed bug found by Catrya

- when I recreate the child order master keys were saved without encryption
  so when a takesell or takebuy comes in the search for pending user orders generate a decrytpion error.

---------

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

2 participants