Skip to content

Conversation

Einliterflasche
Copy link

@Einliterflasche Einliterflasche commented Jul 4, 2025

Closes #120. On every Monero lock transaction, we split the change output into multiple smaller ones. This avoids unnecessarily blocking funds for 10 minutes.

Considerations:

  • More smaller UTXOs might mean having to send multiple lock transactions. This leads to multiple transfer proofs needing to be handled. The code for that isn't good yet.
  • Curently we just reduce all outputs until they're smaller than the threshold. I'm not happy with this design, it would be better to keep a small number of large UTXOs for larger swaps. We should come up with some sort of curve for this.
  • Needs integration testing.

ToDo's:

  • integration testing.
  • improve code handling multiple transfer proofs
  • (improve output management design)

number three might be done in a future PR

Copy link

coderabbitai bot commented Jul 4, 2025

Walkthrough

This change introduces configurable change output management for Monero wallets, allowing the wallet to split change into multiple outputs based on configuration. It propagates the change management strategy through the wallet creation and transaction methods, updates related tests, and adds new accessor methods for pending transaction amounts. The configuration layer and CLI are updated to support these options.

Changes

File(s) Change Summary
monero-sys/patches/wallet2_api_expose_pending_tx_change.patch Adds a patch exposing the change amount in the Monero wallet API.
monero-sys/build.rs Applies the new patch, adds Boost serialization library, and updates include paths.
monero-sys/src/bridge.rs Adds FFI accessors for PendingTransaction: change, amount, fee, and dust; adds EnoteDetails and related FFI methods.
monero-sys/src/bridge.h Adds functions to get and destroy enote details; moves alias declaration earlier; minor whitespace changes.
monero-sys/src/lib.rs Introduces ChangeManagement enum, updates wallet constructors and transfer logic, adds pending tx accessors, changes sweep_multi/distribute signatures, adds Enote struct and methods.
monero-harness/src/lib.rs Updates wallet creation to accept change management, and changes sweep_multi signature to accept addresses directly.
monero-sys/tests/simple.rs
monero-sys/tests/sign_message.rs
monero-sys/tests/special_paths.rs
monero-sys/tests/wallet_closing.rs
Updates tests to use the new change management argument in wallet creation.
monero-sys/tests/split_change.rs Adds a new integration test for split change management.
swap/src/asb/config.rs Adds Change struct to Monero config, removes Eq derive, and updates tests and config initialization.
swap/src/bin/asb.rs Selects and passes change management strategy to wallet initialization based on config.
swap/src/cli/api.rs Passes ChangeManagement::Default to wallet initialization in CLI API.
swap/src/monero/wallet.rs Stores and propagates change_management in Wallets struct and methods.
swap/tests/harness/mod.rs Updates test wallet initialization to use split change management.
.vscode/settings.json Adds new C++ file associations for development environment.
swap/src/asb/event_loop.rs
swap/src/asb/recovery/cancel.rs
swap/src/asb/recovery/punish.rs
swap/src/asb/recovery/redeem.rs
swap/src/asb/recovery/refund.rs
swap/src/cli/api.rs
swap/src/cli/behaviour.rs
swap/src/cli/event_loop.rs
swap/src/database/alice.rs
swap/src/network/cooperative_xmr_redeem_after_punish.rs
swap/src/network/transfer_proof.rs
swap/src/protocol.rs
swap/src/protocol/alice/state.rs
swap/src/protocol/alice/swap.rs
swap/src/protocol/bob/state.rs
Refactors handling of Monero transfer proofs from single to multiple (Vec) across state enums, event loop, recovery, network messages, and protocol logic. Updates all related method signatures and state transitions accordingly.
swap/src/database/sqlite.rs Updates buffered transfer proof storage and retrieval to handle multiple proofs as JSON array.
swap/src/monero.rs Formatting improvements for Monero address helper methods.

Sequence Diagram(s)

sequenceDiagram
    participant Config
    participant CLI
    participant Wallets
    participant WalletHandle
    participant FfiWallet
    participant MoneroCore

    Config->>CLI: Provides Monero change config (extra_outputs, threshold)
    CLI->>Wallets: Passes ChangeManagement (Default/Split) during creation
    Wallets->>WalletHandle: Passes ChangeManagement to open/create wallet
    WalletHandle->>FfiWallet: Passes ChangeManagement to wallet backend
    FfiWallet->>MoneroCore: Applies change management in transfer logic
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Efficient Monero input selection and change management (#120) The PR introduces configurable change splitting for outputs, but does not address input selection logic as described in the issue (i.e., preferring the smallest sufficient input and minimizing input count).

Assessment against linked issues: Out-of-scope changes

Code Change (file_path) Explanation
Add C++ file associations for "hash_map", "hash_set", "*.ipp" (.vscode/settings.json) This is a development environment/editor configuration change unrelated to Monero wallet input or change management.
Minor whitespace-only formatting in createTransactionMultiDest (monero-sys/src/bridge.h) Non-functional formatting change not related to the objectives.

Poem

In the warren deep, we split our change,
So coins hop home, not looking strange.
With configs new and wallets wise,
Outputs multiply—what a surprise!
🥕 The rabbits cheer, the code is neat,
Monero’s change now splits so sweet!
— CodeRabbit

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/output-management

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests 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.

@Einliterflasche
Copy link
Author

bugbot run

@Einliterflasche Einliterflasche marked this pull request as ready for review July 6, 2025 14:21
@Einliterflasche
Copy link
Author

bugbot run

@Einliterflasche
Copy link
Author

Einliterflasche commented Jul 6, 2025

Todo:

  • verify in integration test that multiple outputs are actually created
  • update docs
  • update default config in the asb-docker-compose repo

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
monero-sys/src/lib.rs (1)

472-483: Breaking change: sweep_multi signature modified.

The method signature changed from Option<monero::Address> to &[monero::Address], removing the Option wrapper. While this is cleaner, it's a breaking change that will require updates to all callers.

♻️ Duplicate comments (1)
monero-sys/src/lib.rs (1)

129-141: Excellent enum design addressing past review feedback!

The ChangeManagement enum with Default and Split variants is a clean solution that addresses the previous review comments about preferring enums to bool parameters. The Split variant clearly encapsulates the configuration parameters.

🧹 Nitpick comments (2)
monero-sys/src/bridge.h (1)

163-178: LGTM: Cosmetic formatting improvements.

The changes are purely whitespace adjustments that improve code readability without affecting functionality. Consider using consistent code formatting tools to avoid manual formatting changes in the future.

swap/src/asb/config.rs (1)

259-261: Consider using a fixed-point type for the threshold.

Using f64 for a monetary threshold could lead to floating-point precision issues when comparing with monero::Amount. Consider storing the threshold as Option<String> (for serialization) and parsing it to monero::Amount when used, or using a decimal type.

Also applies to: 268-270

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 56722a5 and 70324cd.

📒 Files selected for processing (17)
  • .vscode/settings.json (1 hunks)
  • monero-harness/src/lib.rs (3 hunks)
  • monero-sys/build.rs (4 hunks)
  • monero-sys/patches/wallet2_api_expose_pending_tx_change.patch (1 hunks)
  • monero-sys/src/bridge.h (1 hunks)
  • monero-sys/src/bridge.rs (1 hunks)
  • monero-sys/src/lib.rs (19 hunks)
  • monero-sys/tests/sign_message.rs (2 hunks)
  • monero-sys/tests/simple.rs (2 hunks)
  • monero-sys/tests/special_paths.rs (2 hunks)
  • monero-sys/tests/split_change.rs (1 hunks)
  • monero-sys/tests/wallet_closing.rs (3 hunks)
  • swap/src/asb/config.rs (7 hunks)
  • swap/src/bin/asb.rs (3 hunks)
  • swap/src/cli/api.rs (2 hunks)
  • swap/src/monero/wallet.rs (5 hunks)
  • swap/tests/harness/mod.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
`monero-sys/**/*.rs`: Use Rust 2021 edition. Use `unsafe` only for FFI interacti...

monero-sys/**/*.rs: Use Rust 2021 edition.
Use unsafe only for FFI interactions with Monero C++ code.
When using .expect(), the message should be a short description of the assumed invariant in the format of .expect("the invariant to be upheld").

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/tests/special_paths.rs
  • monero-sys/tests/wallet_closing.rs
  • monero-sys/tests/simple.rs
  • monero-sys/tests/sign_message.rs
  • monero-sys/build.rs
  • monero-sys/src/bridge.rs
  • monero-sys/tests/split_change.rs
  • monero-sys/src/lib.rs
`monero-sys/**/bridge.h`: In bridge.h, provide helper functions to work around C...

monero-sys/**/bridge.h: In bridge.h, provide helper functions to work around CXX limitations, including wrappers for static methods and handling string returns with std::unique_ptr.

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/src/bridge.h
`monero-sys/**/build.rs`: In build.rs, compile the Monero C++ code with CMake ta...

monero-sys/**/build.rs: In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/build.rs
`monero-sys/src/bridge.rs`: In src/bridge.rs, mirror functions from monero/src/w...

monero-sys/src/bridge.rs: In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
In src/bridge.rs, define the FFI interface using the cxx::bridge macro, declaring C++ types and functions to be accessed from Rust.

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/src/bridge.rs
`monero-sys/{src/bridge.rs,src/lib.rs}`: When adding a new function to the bridg...

monero-sys/{src/bridge.rs,src/lib.rs}: When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Raw pointers must be wrapped in safe Rust types, and unsafe is only used at the FFI boundary.

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/src/bridge.rs
  • monero-sys/src/lib.rs
`monero-sys/src/lib.rs`: In src/lib.rs, provide idiomatic Rust interfaces to the...

monero-sys/src/lib.rs: In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Raw pointers must never be exposed to users of the library in src/lib.rs.
Implement Send and Sync for wrapper types in src/lib.rs.
Use Pin for C++ objects that require stable memory addresses in src/lib.rs.
Implement proper deref for wrapper types in src/lib.rs.
Use the OnceLock pattern to ensure WalletManager is a singleton in src/lib.rs.

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/src/lib.rs
🧠 Learnings (17)
📓 Common learnings
Learnt from: CR
PR: UnstoppableSwap/core#0
File: AGENT.md:0-0
Timestamp: 2025-06-30T08:53:49.176Z
Learning: Pull request titles must use the format `<type>(<scope>): <description>`, for example: `feat(gui): New feature`, `fix(swap): Issue fixed`, or `refactor(ci): Ci changes`.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
swap/src/cli/api.rs (13)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/common/tor.rs:16-23
Timestamp: 2025-06-15T15:49:33.308Z
Learning: On Whonix systems in swap/src/common/tor.rs, using expect() on system_from_environment() is appropriate because Whonix systems don't have clearnet capabilities - they route all traffic through Tor only. Missing Tor environment variables on Whonix represents a fundamental system misconfiguration that should abort the program rather than attempting graceful degradation.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
monero-sys/tests/special_paths.rs (11)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
monero-sys/tests/wallet_closing.rs (12)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
monero-sys/tests/simple.rs (13)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : When using `.expect()`, the message should be a short description of the assumed invariant in the format of `.expect("the invariant to be upheld")`.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
monero-sys/tests/sign_message.rs (13)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : When using `.expect()`, the message should be a short description of the assumed invariant in the format of `.expect("the invariant to be upheld")`.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
monero-sys/src/bridge.h (10)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/bridge.h : In bridge.h, provide helper functions to work around CXX limitations, including wrappers for static methods and handling string returns with std::unique_ptr.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the `unsafe extern "C++"` block in bridge.rs, 3. Create a Rust wrapper in lib.rs, 4. For functions with CXX limitations, add helpers in bridge.h.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
swap/tests/harness/mod.rs (13)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the `unsafe extern "C++"` block in bridge.rs, 3. Create a Rust wrapper in lib.rs, 4. For functions with CXX limitations, add helpers in bridge.h.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
swap/src/bin/asb.rs (13)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, the config_data_dir is guaranteed to exist, so directory creation checks are unnecessary when writing files to it.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/common/tor.rs:16-23
Timestamp: 2025-06-15T15:49:33.308Z
Learning: On Whonix systems in swap/src/common/tor.rs, using expect() on system_from_environment() is appropriate because Whonix systems don't have clearnet capabilities - they route all traffic through Tor only. Missing Tor environment variables on Whonix represents a fundamental system misconfiguration that should abort the program rather than attempting graceful degradation.
monero-sys/build.rs (15)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the `unsafe extern "C++"` block in bridge.rs, 3. Create a Rust wrapper in lib.rs, 4. For functions with CXX limitations, add helpers in bridge.h.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/bridge.h : In bridge.h, provide helper functions to work around CXX limitations, including wrappers for static methods and handling string returns with std::unique_ptr.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Raw pointers must never be exposed to users of the library in src/lib.rs.
swap/src/monero/wallet.rs (12)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
monero-sys/src/bridge.rs (10)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/bridge.h : In bridge.h, provide helper functions to work around CXX limitations, including wrappers for static methods and handling string returns with std::unique_ptr.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the `unsafe extern "C++"` block in bridge.rs, 3. Create a Rust wrapper in lib.rs, 4. For functions with CXX limitations, add helpers in bridge.h.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
monero-sys/patches/wallet2_api_expose_pending_tx_change.patch (9)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Check wallet2_api.h for the correct function names, parameters, and return types before implementing wrappers.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/bridge.h : In bridge.h, provide helper functions to work around CXX limitations, including wrappers for static methods and handling string returns with std::unique_ptr.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the `unsafe extern "C++"` block in bridge.rs, 3. Create a Rust wrapper in lib.rs, 4. For functions with CXX limitations, add helpers in bridge.h.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.
monero-harness/src/lib.rs (12)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
monero-sys/tests/split_change.rs (11)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : When using `.expect()`, the message should be a short description of the assumed invariant in the format of `.expect("the invariant to be upheld")`.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.
swap/src/asb/config.rs (14)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, the config_data_dir is guaranteed to exist, so directory creation checks are unnecessary when writing files to it.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Raw pointers must never be exposed to users of the library in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/common/tor.rs:16-23
Timestamp: 2025-06-15T15:49:33.308Z
Learning: On Whonix systems in swap/src/common/tor.rs, using expect() on system_from_environment() is appropriate because Whonix systems don't have clearnet capabilities - they route all traffic through Tor only. Missing Tor environment variables on Whonix represents a fundamental system misconfiguration that should abort the program rather than attempting graceful degradation.
monero-sys/src/lib.rs (10)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
🧬 Code Graph Analysis (2)
monero-sys/src/bridge.rs (1)
monero-sys/src/lib.rs (3)
  • change (1914-1920)
  • fee (1923-1929)
  • dust (1932-1938)
monero-harness/src/lib.rs (1)
monero-sys/src/lib.rs (2)
  • sweep_multi (471-483)
  • sweep_multi (1621-1718)
🔇 Additional comments (28)
monero-sys/tests/special_paths.rs (1)

2-2: LGTM: Correctly updated test for new API signature.

The addition of ChangeManagement import and the ChangeManagement::Default parameter appropriately updates this test to match the new wallet creation API, while maintaining focus on the original test purpose (special path handling).

Also applies to: 33-33

monero-sys/tests/wallet_closing.rs (1)

1-1: LGTM: Consistently updated test calls for new API signature.

The changes correctly update both WalletHandle::open_or_create calls to include the required ChangeManagement::Default parameter, maintaining consistency while preserving the test's focus on wallet closing behavior.

Also applies to: 24-24, 45-45

monero-sys/tests/sign_message.rs (1)

1-1: LGTM: Correctly updated test for new API signature.

The addition of ChangeManagement import and the ChangeManagement::Default parameter appropriately updates this test to match the new wallet creation API, while maintaining focus on the original test purpose (message signing functionality).

Also applies to: 27-27

monero-sys/tests/simple.rs (1)

2-2: LGTM: Correctly updated test for new API signature.

The addition of ChangeManagement import and the ChangeManagement::Default parameter appropriately updates this test to match the new wallet creation API signature for open_or_create_from_seed, while maintaining focus on the original test purpose (basic wallet operations and recovery).

Also applies to: 34-34

.vscode/settings.json (1)

77-79: LGTM: Added appropriate C++ file associations.

The additions of hash_map, hash_set, and *.ipp file associations provide proper C++ syntax highlighting and tooling support, which aligns with the C++ development work in this codebase.

swap/src/cli/api.rs (2)

18-18: LGTM: Import addition is correct.

The import of ChangeManagement is properly added and used in the wallet initialization.


624-624: LGTM: Appropriate default change management policy.

Using ChangeManagement::Default for CLI wallet initialization maintains backward compatibility while enabling the new change management feature.

swap/tests/harness/mod.rs (2)

12-12: LGTM: Import addition is correct.

The import of ChangeManagement is properly added alongside the existing Daemon import.


317-320: LGTM: Appropriate test configuration for change splitting.

Using ChangeManagement::Split with 3 extra outputs and 1 XMR threshold in the test harness ensures the new change management feature is properly exercised during integration tests.

monero-harness/src/lib.rs (2)

33-33: LGTM: Import addition is correct.

The import of ChangeManagement is properly added to support the new wallet initialization parameter.


418-418: LGTM: Appropriate default change management policy.

Using ChangeManagement::Default for test harness wallet initialization maintains consistency with production usage while enabling the new change management feature.

swap/src/bin/asb.rs (3)

18-18: LGTM: Import addition aligns with new functionality.

The import of ChangeManagement from monero_sys is correctly placed and necessary for the new change management feature.


483-494: Well-implemented configuration-based change management selection.

The logic correctly interprets the configuration to determine the appropriate change management strategy. The error handling for threshold parsing includes proper context, and the default behavior (using ChangeManagement::Default when no extra outputs are configured) is sensible.


538-538: Proper integration of change management parameter.

The change_management parameter is correctly passed to the monero::Wallets::new constructor, completing the integration of the new feature with the wallet initialization flow.

monero-sys/patches/wallet2_api_expose_pending_tx_change.patch (1)

1-49: Well-structured patch that properly exposes change amount functionality.

The patch correctly adds the change() method to the PendingTransaction interface following established C++ API patterns. The implementation safely iterates through pending transactions and sums their change amounts without introducing memory management concerns.

monero-sys/src/bridge.rs (1)

247-258: Proper FFI declarations for new PendingTransaction accessor methods.

The new method declarations correctly mirror the C++ API additions from the patch. The return types (Result<u64>) and method signatures are appropriate, and the comments clearly document each method's purpose.

monero-sys/build.rs (3)

28-34: Properly embedded new patch for pending transaction change exposure.

The new patch is correctly added to the embedded patches array with appropriate description and follows the established pattern for patch embedding.


251-251: Added boost_wserialization library linking.

The addition of boost_wserialization static linking is likely required to support the new pending transaction functionality exposed by the patch.


293-293: Added external include paths for Boost dependencies.

The inclusion of monero/external path provides access to Boost headers required for the new functionality, following the established pattern for platform-specific includes.

Also applies to: 311-311

swap/src/monero/wallet.rs (4)

12-12: Appropriate import addition for change management functionality.

The import of ChangeManagement from monero_sys is correctly placed and necessary for the new wallet configuration feature.


38-39: Well-documented field addition for change management strategy.

The new change_management field is properly documented and appropriately placed within the struct, maintaining consistency with other configuration fields.


75-75: Proper integration of change management parameter throughout wallet lifecycle.

The change_management parameter is correctly:

  • Added to the constructor signature
  • Stored in the struct
  • Passed to wallet creation calls

This ensures consistent change management behavior across all wallet operations.

Also applies to: 82-82, 100-100


143-143: Consistent propagation of change management to swap wallets.

The change management strategy is properly propagated to swap wallet creation, ensuring consistent behavior across both main and temporary wallets.

monero-sys/tests/split_change.rs (1)

1-87: Well-structured integration test!

The test comprehensively exercises the new split change management functionality, including wallet recovery, synchronization, and transfers with proper assertions.

swap/src/asb/config.rs (1)

254-271: Clean configuration structure for change management.

The Change struct provides a clear interface for configuring output splitting behavior with sensible defaults.

monero-sys/src/lib.rs (3)

1479-1526: Well-implemented change splitting logic!

The implementation correctly:

  • Handles the threshold check to determine if splitting is needed
  • Calculates change per output accurately
  • Creates a multi-destination transaction properly
  • Manages memory by swapping and disposing the old transaction

1739-1740: Good naming improvement from "percentages" to "ratios".

The rename better reflects the requirement that values must sum to 1.0, making the API clearer.

Also applies to: 1764-1764


1904-1938: FFI bridge methods exposure verified

The FFI bridge in bridge.rs declares fn amount, fn change, fn fee, and fn dust, which your safe wrappers in lib.rs correctly invoke (output_amountamount(), etc.). No further changes are needed.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
monero-sys/src/lib.rs (1)

128-141: Consider parameterizing the default split configuration.

The ChangeManagement enum is well-designed. However, consider making the default split configuration values configurable rather than hardcoded.

Based on the past review comment mentioning preference for enums over bools and configurability, this implementation aligns well with that feedback.

🧹 Nitpick comments (1)
monero-sys/src/bridge.h (1)

272-281: Address the static variable instantiation.

The _monero_sys_pair_instantiation static variable is declared to ensure linker inclusion, but this approach seems like a workaround. Consider if there's a cleaner solution or add a comment explaining why this is necessary.

+// Static variable to ensure linker includes pair destructor for template instantiation
 static std::pair<StringMap, StringVec> _monero_sys_pair_instantiation;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 70324cd and 67bbdd9.

📒 Files selected for processing (3)
  • monero-sys/src/bridge.h (3 hunks)
  • monero-sys/src/bridge.rs (5 hunks)
  • monero-sys/src/lib.rs (23 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • monero-sys/src/bridge.rs
🧰 Additional context used
📓 Path-based instructions (4)
`monero-sys/**/bridge.h`: In bridge.h, provide helper functions to work around C...

monero-sys/**/bridge.h: In bridge.h, provide helper functions to work around CXX limitations, including wrappers for static methods and handling string returns with std::unique_ptr.

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/src/bridge.h
`monero-sys/{src/bridge.rs,src/lib.rs}`: When adding a new function to the bridg...

monero-sys/{src/bridge.rs,src/lib.rs}: When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Raw pointers must be wrapped in safe Rust types, and unsafe is only used at the FFI boundary.

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/src/lib.rs
`monero-sys/**/*.rs`: Use Rust 2021 edition. Use `unsafe` only for FFI interacti...

monero-sys/**/*.rs: Use Rust 2021 edition.
Use unsafe only for FFI interactions with Monero C++ code.
When using .expect(), the message should be a short description of the assumed invariant in the format of .expect("the invariant to be upheld").

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/src/lib.rs
`monero-sys/src/lib.rs`: In src/lib.rs, provide idiomatic Rust interfaces to the...

monero-sys/src/lib.rs: In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Raw pointers must never be exposed to users of the library in src/lib.rs.
Implement Send and Sync for wrapper types in src/lib.rs.
Use Pin for C++ objects that require stable memory addresses in src/lib.rs.
Implement proper deref for wrapper types in src/lib.rs.
Use the OnceLock pattern to ensure WalletManager is a singleton in src/lib.rs.

📄 Source: CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

List of files the instruction was applied to:

  • monero-sys/src/lib.rs
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: UnstoppableSwap/core#0
File: AGENT.md:0-0
Timestamp: 2025-06-30T08:53:49.176Z
Learning: Pull request titles must use the format `<type>(<scope>): <description>`, for example: `feat(gui): New feature`, `fix(swap): Issue fixed`, or `refactor(ci): Ci changes`.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
monero-sys/src/bridge.h (15)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/bridge.h : In bridge.h, provide helper functions to work around CXX limitations, including wrappers for static methods and handling string returns with std::unique_ptr.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the `unsafe extern "C++"` block in bridge.rs, 3. Create a Rust wrapper in lib.rs, 4. For functions with CXX limitations, add helpers in bridge.h.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Check wallet2_api.h for the correct function names, parameters, and return types before implementing wrappers.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
monero-sys/src/lib.rs (12)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the `unsafe extern "C++"` block in bridge.rs, 3. Create a Rust wrapper in lib.rs, 4. For functions with CXX limitations, add helpers in bridge.h.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
🧬 Code Graph Analysis (1)
monero-sys/src/bridge.h (2)
monero-harness/src/lib.rs (1)
  • wallet (140-148)
monero-sys/src/lib.rs (2)
  • enotes (502-504)
  • enotes (1387-1409)
🔇 Additional comments (16)
monero-sys/src/bridge.h (2)

8-13: Good approach to avoid header inclusion issues.

Moving the ConnectionStatus alias declaration before including the generated header is a proper solution to ensure the type is available when the generated code needs it.


243-268: Memory management for EnoteDetails is safe

The Rust wrapper’s Drop impl for Enote correctly calls destroyEnoteDetails on each pinned EnoteDetailsWrapper, ensuring that all underlying C++ pointers are cleaned up without leaks.

monero-sys/src/lib.rs (14)

34-36: Good integration of change management configuration.

The change_management field is properly added to WalletHandle to store the configuration for later use in transaction operations.


159-159: Consistent parameter addition across wallet creation functions.

All wallet creation functions now properly accept the change_management parameter, maintaining API consistency.

Also applies to: 215-215, 303-303


193-196: Proper field initialization in constructors.

The WalletHandle constructors correctly initialize the new change_management field.

Also applies to: 276-279, 353-356


437-446: Good integration of change management in transfer method.

The transfer method properly captures and passes the change_management configuration to the underlying implementation.


501-504: Good addition of enotes accessor method.

The async enotes method properly delegates to the underlying wallet implementation.


1386-1409: Handle FFI errors gracefully in enotes method.

The enotes method implementation properly handles FFI errors by logging and returning empty vectors rather than panicking. This is good defensive programming.


1496-1562: Well-implemented change splitting logic.

The transfer method's change management implementation is comprehensive:

  • Properly handles the default case without extra logic
  • Correctly calculates change splitting based on threshold
  • Uses multi-destination transactions for splitting
  • Properly swaps and disposes of transactions

The logic is sound and follows the intended behavior.


1762-1762: Accurate parameter name in documentation.

The documentation correction from percentages to ratios improves clarity.


1775-1815: Consistent terminology update in distribute method.

The method now uses ratios terminology consistently throughout, which better reflects the mathematical meaning (values that sum to 1).


1940-1974: Good addition of transaction amount accessors.

The new accessor methods (output_amount, change, fee, dust) provide useful transaction details with proper error handling and type conversion.


2003-2181: Confirm thread-safety of EnoteDetailsImpl before landing

I wasn’t able to find any definition of EnoteDetailsImpl or uses of thread_local in the FFI C++ sources, so the safety of unsafe impl Send for Enote { … } hinges on an assumption that the underlying C++ type has no thread-local state. Please verify that:

  • The C++ declaration/implementation of EnoteDetailsImpl (e.g. in wallet2_api.h or associated .cpp files) does not use thread_local or any thread-specific data
  • Future changes to the C++ code won’t introduce thread-local accesses that could invalidate Send

150-150: PendingTransaction pointer usage is safe

  • The raw *mut ffi::PendingTransaction is fully encapsulated in a non-pub PendingTransaction wrapper.
  • All unsafe blocks are confined to FFI boundaries (pinned(), Deref, and dispose_transaction) with proper null checks.
  • Pending transactions are explicitly freed by WalletHandle::dispose_transaction, avoiding any use-after-free or undefined behavior.

No further pointer-safety issues found.


479-479: sweep_multi signature change is non-breaking

All existing callers already pass &[monero::Address] (e.g., fill_empty_addresses returns Vec<monero::Address> and tests/harness use concrete Address). There are no usages of Option<monero::Address>, so removing the Option wrapper does not break any existing code.


143-147: Enote FFI Safety Confirmed
All FFI pointer handling and memory management for Enote follow the established Rust–C++ bridge patterns; no changes are needed:

  • monero-sys/src/lib.rs:
    • pub struct Enote { inner: ffi::EnoteDetailsWrapper } wraps a UniquePtr<EnoteDetails>.
    • impl Drop for Enote invokes ffi::destroyEnoteDetails(self.pinned()).
    • fn pinned(&mut self) -> Pin<&mut ffi::EnoteDetailsWrapper> pins the wrapper for the C++ call.
    • impl Deref for Enote returns &ffi::EnoteDetails via UniquePtr’s Deref.

No pointer‐validity or memory‐management gaps detected.

@binarybaron
Copy link

This is running on our mainnet asb. Can you update the config file to the new format to get it running?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
monero-sys/tests/split_change.rs (1)

142-168: Remove unused helper function or add tests that use it.

The find_newly_spent_enotes function is defined but never used in the test. Either remove it if it's not needed, or add test cases that utilize this functionality to verify the change splitting behavior.

-// assumes old is subset of new
-fn find_newly_spent_enotes<'a>(
-    original_enotes: &'a [Enote],
-    new_enotes: &'a [Enote],
-) -> Vec<&'a Enote> {
-    let mut old = HashMap::new();
-    let mut new = HashMap::new();
-
-    for enote in original_enotes {
-        old.insert(enote.global_enote_index(), enote);
-    }
-
-    for enote in new_enotes {
-        new.insert(enote.global_enote_index(), enote);
-    }
-
-    let mut newly_spent = Vec::new();
-
-    for (index, enote) in new.iter() {
-        if let Some(old_enote) = old.get(index) {
-            if old_enote.is_spent() != enote.is_spent() {
-                newly_spent.push(*enote);
-            }
-        }
-    }
-
-    newly_spent
-}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 67bbdd9 and f1281b4.

📒 Files selected for processing (7)
  • monero-sys/build.rs (4 hunks)
  • monero-sys/src/lib.rs (23 hunks)
  • monero-sys/tests/sign_message.rs (3 hunks)
  • monero-sys/tests/split_change.rs (1 hunks)
  • swap/src/asb/config.rs (7 hunks)
  • swap/src/database/sqlite.rs (3 hunks)
  • swap/src/monero.rs (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • swap/src/database/sqlite.rs
  • swap/src/monero.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • monero-sys/tests/sign_message.rs
  • monero-sys/build.rs
  • swap/src/asb/config.rs
🧰 Additional context used
📓 Path-based instructions (3)
monero-sys/**/*.rs

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • monero-sys/CLAUDE.md
monero-sys/{src/bridge.rs,src/lib.rs}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • monero-sys/CLAUDE.md
monero-sys/src/lib.rs

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • monero-sys/CLAUDE.md
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
monero-sys/tests/split_change.rs (10)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : When using `.expect()`, the message should be a short description of the assumed invariant in the format of `.expect("the invariant to be upheld")`.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX, and link required libraries.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.
monero-sys/src/lib.rs (11)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the `unsafe extern "C++"` block in bridge.rs, 3. Create a Rust wrapper in lib.rs, 4. For functions with CXX limitations, add helpers in bridge.h.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
🧬 Code Graph Analysis (1)
monero-sys/src/lib.rs (4)
monero-sys/src/bridge.h (14)
  • address (62-66)
  • address (62-62)
  • walletGetEnoteDetails (248-259)
  • walletGetEnoteDetails (248-248)
  • createTransaction (123-129)
  • createTransaction (123-126)
  • vector_string_push_back (237-242)
  • vector_string_push_back (237-239)
  • createTransactionMultiDest (145-185)
  • createTransactionMultiDest (145-148)
  • signMessage (212-216)
  • signMessage (212-212)
  • destroyEnoteDetails (264-267)
  • destroyEnoteDetails (264-264)
monero-sys/src/bridge.rs (12)
  • address (148-152)
  • amount (266-266)
  • amount (302-302)
  • walletGetEnoteDetails (216-218)
  • createTransaction (238-242)
  • change (263-263)
  • vector_string_push_back (257-257)
  • createTransactionMultiDest (251-255)
  • signMessage (320-325)
  • fee (269-269)
  • dust (272-272)
  • destroyEnoteDetails (221-221)
swap/src/monero.rs (5)
  • address (282-284)
  • addresses (319-321)
  • new (250-267)
  • new (314-316)
  • new (459-461)
swap/src/monero/wallet.rs (1)
  • new (68-104)
🔇 Additional comments (10)
monero-sys/tests/split_change.rs (1)

1-139: Integration test looks comprehensive and well-structured.

The test effectively exercises the new change management functionality by creating a wallet with split change configuration, performing transfers, and inspecting enotes. The test structure follows good practices with proper logging and assertions.

monero-sys/src/lib.rs (9)

34-36: Good addition of change management configuration to WalletHandle.

The change_management field properly stores the configuration for use during transfers.


128-141: Well-designed ChangeManagement enum with clear documentation.

The enum provides a clean API for configuring change behavior, with sensible defaults and clear documentation of each variant's purpose.


143-147: Enote struct properly wraps FFI pointer.

The struct follows the established pattern of wrapping C++ objects with safe Rust types.


501-504: New enotes() method provides useful wallet inspection capability.

The async method properly delegates to the wallet thread and provides access to all enotes.


1518-1565: Change splitting logic is well-implemented but complex.

The implementation correctly:

  • Creates an initial transaction to determine change amount
  • Only splits change if it exceeds the threshold
  • Distributes change evenly across extra outputs
  • Properly disposes of the original transaction

The logic handles the multi-destination transaction creation correctly and includes proper memory management.


1765-1765: Good clarification in distribute method documentation.

Changing from "percentages" to "ratios" accurately reflects that the values must sum to 1.0, not 100.0. The parameter and variable names are consistently updated.

Also applies to: 1778-1779


1386-1412: Robust enotes() implementation with proper error handling.

The method:

  • Handles FFI errors gracefully by returning an empty vector
  • Properly manages the C++ vector lifecycle
  • Sorts enotes by blockchain height for consistent ordering
  • Uses appropriate error logging

1943-1977: Consistent accessor methods for PendingTransaction amounts.

All four accessor methods (output_amount, change, fee, dust) follow the same pattern and provide proper error handling with context.


2006-2202: Well-implemented Enote wrapper with proper safety considerations.

The implementation:

  • Properly wraps the FFI pointer with null checks
  • Implements all necessary traits (Debug, Display, Send, Drop)
  • Includes a thoughtful safety comment for the Send implementation
  • Properly disposes of FFI resources in Drop
  • Provides comprehensive accessor methods

The safety comment acknowledging the implementation detail dependency is particularly good practice.

@Einliterflasche
Copy link
Author

Einliterflasche commented Jul 12, 2025

This is running on our mainnet asb. Can you update the config file to the new format to get it running?

I fixed the config format such that the default is applied and no change to the config is required anymore.

It also turns out that for very large swaps (when 200 ish UTXOs are involved) wallet2_api will create multiple transactions to fit all the inputs. monero-wallet-rpc just failed if all required inputs didn't fit into a single tx.
Since this PR will split large outputs into more smaller ones, the issue will become more likely to occur.
We need to make sure to send multiple transfer proofs if a transfer requires multiple transactions, so I'll also have to make a breaking change to the protocol and migrate the database.

We could also continue to fail to lock the Monero in such cases. Though that doesn't seem to be a good alternative because automatic output management makes it much more likely for this issue to occur. We also strive to support large swaps, which this would hinder.

@binarybaron
Copy link

This is running on our mainnet asb. Can you update the config file to the new format to get it running?

I fixed the config format such that the default is applied and no change to the config is required anymore.

It also turns out that for very large swaps (when 200 ish UTXOs are involved) wallet2_api will create multiple transactions to fit all the inputs. monero-wallet-rpc just failed if all required inputs didn't fit into a single tx.

Since this PR will split large outputs into more smaller ones, the issue will become more likely to occur.

We need to make sure to send multiple transfer proofs if a transfer requires multiple transactions, so I'll also have to make a breaking change to the protocol and migrate the database.

We could also continue to fail to lock the Monero in such cases. Though that doesn't seem to be a good alternative because automatic output management makes it much more likely for this issue to occur. We also strive to support large swaps, which this would hinder.

I believe Monero enforces a maximum of 16 inputs per tx.

This'd also require a breaking network change. If we implement this without windows support we will be cutting of a large fraction of our users.

I think we have two ways to go forward from here:

  1. Merge this first with a conservative approach (max of three outputs created per tx, one for funding, two change outputs). Simply fail if multiple transaction are needed
  2. Get Windows compilation working first, then merge this with the network protocol change

I'd probably prefer 2 but I'm not entirely sure. What do you think?

@Einliterflasche
Copy link
Author

The number of inputs is limited only by the transaction weight, which comes out to at least around 100 inputs (https://monero.stackexchange.com/questions/12275/what-is-the-max-no-of-input-for-monero-tx-how-does-it-affect-the-no-of-decoys).

I agree that we shouldn't make a breaking change we can't publish to windows users.

Option 2 seems much better.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🔭 Outside diff range comments (3)
swap/src/protocol/alice/state.rs (1)

569-637: Add validation or documentation for Monero single-transaction input limit

There’s currently no check or note in the code for the maximum number of inputs Monero allows in a single transaction, yet very large swaps (~200 UTXOs) will be split into multiple transactions by wallet2_api. The Alice refund path assumes a single batch and may break silently on large swaps.

• Location: swap/src/protocol/alice/state.rs (lines 569–637)
• Observation: no existing “max inputs” or swap-size validation in Alice or common protocol code
• Risk: swaps exceeding the Monero single-transaction input limit will generate extra transactions that this refund logic doesn’t handle
• Suggestions:

  • Enforce a maximum swap amount/UTXO count ≤ Monero’s single-tx limit (e.g. call into the Monero bindings or set a constant) and error early
  • Or document this limitation in the protocol and ensure clients cap swap sizes accordingly
  • Add tests for edge cases around the Monero input limit to avoid regressions
swap/src/database/alice.rs (1)

13-89: Database migration required for backward compatibility.

Changing from transfer_proof: TransferProof to transfer_proofs: Vec<TransferProof> is a breaking change for existing swap data in the database. Existing swaps will fail to deserialize.

A database migration is needed to:

  1. Convert existing single transfer_proof fields to transfer_proofs vectors with one element
  2. Bump the database schema version
#!/bin/bash
# Check if database migrations are handled elsewhere
fd -e rs -e sql | xargs rg -l "migration|migrate|schema.*version" | head -20
swap/src/protocol/alice/swap.rs (1)

163-176: Add validation for maximum swap size to prevent transaction failures.

The PR objectives mention that large swaps (~200 UTXOs) may require multiple transactions, which isn't supported yet. Without validation, large swaps could fail unexpectedly.

Add a check before attempting the transfer:

                    let (address, amount) = state3
                        .lock_xmr_transfer_request()
                        .address_and_amount(env_config.monero_network);

+                   // Check if the swap amount might require multiple transactions
+                   // TODO: Replace with actual UTXO count check when available
+                   const MAX_SAFE_MONERO_AMOUNT: monero::Amount = monero::Amount::from_monero(50.0).expect("valid amount");
+                   if amount > MAX_SAFE_MONERO_AMOUNT {
+                       tracing::warn!("Large swap amount may require multiple transactions, which is not yet supported");
+                       // Optionally fail here or add proper multi-transaction support
+                   }

                    // Lock the Monero
                    let receipt = monero_wallet
♻️ Duplicate comments (1)
monero-sys/src/lib.rs (1)

479-479: Note: Breaking change already documented in past review.

The signature change from &[Option<monero::Address>] to &[monero::Address] removing the Option wrapper is a documented breaking change from previous reviews.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f1281b4 and 270fb28.

📒 Files selected for processing (20)
  • monero-harness/src/lib.rs (4 hunks)
  • monero-sys/src/bridge.h (3 hunks)
  • monero-sys/src/bridge.rs (5 hunks)
  • monero-sys/src/lib.rs (24 hunks)
  • swap/src/asb/event_loop.rs (4 hunks)
  • swap/src/asb/recovery/cancel.rs (2 hunks)
  • swap/src/asb/recovery/punish.rs (2 hunks)
  • swap/src/asb/recovery/redeem.rs (2 hunks)
  • swap/src/asb/recovery/refund.rs (2 hunks)
  • swap/src/cli/behaviour.rs (1 hunks)
  • swap/src/cli/event_loop.rs (7 hunks)
  • swap/src/database/alice.rs (6 hunks)
  • swap/src/database/sqlite.rs (5 hunks)
  • swap/src/monero/wallet.rs (7 hunks)
  • swap/src/network/cooperative_xmr_redeem_after_punish.rs (2 hunks)
  • swap/src/network/transfer_proof.rs (1 hunks)
  • swap/src/protocol.rs (1 hunks)
  • swap/src/protocol/alice/state.rs (3 hunks)
  • swap/src/protocol/alice/swap.rs (21 hunks)
  • swap/src/protocol/bob/state.rs (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • swap/src/asb/recovery/punish.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • swap/src/monero/wallet.rs
  • swap/src/database/sqlite.rs
  • monero-sys/src/bridge.h
  • monero-harness/src/lib.rs
  • monero-sys/src/bridge.rs
🧰 Additional context used
📓 Path-based instructions (3)
monero-sys/{src/bridge.rs,src/lib.rs}

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • monero-sys/CLAUDE.md
monero-sys/**/*.rs

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • monero-sys/CLAUDE.md
monero-sys/src/lib.rs

Instructions used from:

Sources:
📄 CodeRabbit Inference Engine

  • monero-sys/CLAUDE.md
🧠 Learnings (15)
📓 Common learnings
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
swap/src/asb/recovery/cancel.rs (1)
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, write errors for the onion private key file are intentionally non-fatal and should be ignored using `let _ =` pattern.
swap/src/asb/recovery/redeem.rs (5)
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, write errors for the onion private key file are intentionally non-fatal and should be ignored using `let _ =` pattern.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
swap/src/asb/recovery/refund.rs (6)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
swap/src/network/transfer_proof.rs (4)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
swap/src/network/cooperative_xmr_redeem_after_punish.rs (4)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, write errors for the onion private key file are intentionally non-fatal and should be ignored using `let _ =` pattern.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
swap/src/protocol.rs (5)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
swap/src/protocol/alice/state.rs (9)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, write errors for the onion private key file are intentionally non-fatal and should be ignored using `let _ =` pattern.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
swap/src/protocol/bob/state.rs (7)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, write errors for the onion private key file are intentionally non-fatal and should be ignored using `let _ =` pattern.
swap/src/protocol/alice/swap.rs (9)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, write errors for the onion private key file are intentionally non-fatal and should be ignored using `let _ =` pattern.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
swap/src/cli/behaviour.rs (4)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
swap/src/asb/event_loop.rs (8)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, write errors for the onion private key file are intentionally non-fatal and should be ignored using `let _ =` pattern.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
swap/src/database/alice.rs (4)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
swap/src/cli/event_loop.rs (4)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: swap/src/asb/network.rs:61-77
Timestamp: 2025-06-15T15:55:03.118Z
Learning: In swap/src/asb/network.rs, write errors for the onion private key file are intentionally non-fatal and should be ignored using `let _ =` pattern.
monero-sys/src/lib.rs (13)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, using wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement `Send` and `Sync` for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use the `OnceLock` pattern to ensure WalletManager is a singleton in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, mirror functions from monero/src/wallet/api/wallet2_api.h by copying their definitions and letting CXX generate the bindings.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : When adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, then add wrapping logic in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/**/*.rs : Use Rust 2021 edition.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types in src/lib.rs.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the `unsafe extern "C++"` block in bridge.rs, 3. Create a Rust wrapper in lib.rs, 4. For functions with CXX limitations, add helpers in bridge.h.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, define the FFI interface using the `cxx::bridge` macro, declaring C++ types and functions to be accessed from Rust.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/{src/bridge.rs,src/lib.rs} : Raw pointers must be wrapped in safe Rust types, and `unsafe` is only used at the FFI boundary.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.750Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
🧬 Code Graph Analysis (2)
swap/src/protocol.rs (1)
swap/src/database/sqlite.rs (1)
  • get_buffered_transfer_proof (453-478)
monero-sys/src/lib.rs (3)
monero-sys/src/bridge.h (16)
  • address (62-66)
  • address (62-62)
  • walletGetEnoteDetails (240-251)
  • walletGetEnoteDetails (240-240)
  • createTransaction (123-129)
  • createTransaction (123-126)
  • vector_string_push_back (229-234)
  • vector_string_push_back (229-231)
  • createTransactionMultiDest (145-185)
  • createTransactionMultiDest (145-148)
  • pendingTransactionTxIds (219-222)
  • pendingTransactionTxIds (219-219)
  • walletGetTxKey (195-199)
  • walletGetTxKey (195-195)
  • destroyEnoteDetails (256-259)
  • destroyEnoteDetails (256-256)
monero-sys/src/bridge.rs (13)
  • address (148-152)
  • amount (266-266)
  • amount (299-299)
  • walletGetEnoteDetails (216-218)
  • createTransaction (238-242)
  • change (263-263)
  • vector_string_push_back (257-257)
  • createTransactionMultiDest (251-255)
  • pendingTransactionTxIds (278-280)
  • walletGetTxKey (283-283)
  • fee (269-269)
  • dust (272-272)
  • destroyEnoteDetails (221-221)
swap/src/monero/wallet.rs (1)
  • new (68-104)
🔇 Additional comments (33)
monero-sys/src/lib.rs (12)

34-35: LGTM: Clean field addition with proper documentation.

The addition of the change_management field to WalletHandle is well-documented and follows the existing patterns in the struct.


128-141: LGTM: Well-designed enum with clear semantics.

The ChangeManagement enum is well-structured with:

  • Clear documentation explaining the behavior
  • Sensible default implementation
  • Appropriate field types (usize for counts, monero::Amount for thresholds)

143-147: LGTM: Proper wrapper struct for FFI safety.

The Enote struct correctly wraps the FFI type and will have proper memory management through the Drop implementation seen later in the file.


150-150: LGTM: Consistent visibility change.

Making the PendingTransaction struct field private aligns with Rust encapsulation best practices, ensuring controlled access through the wrapper methods.


159-159: LGTM: Consistent API enhancement across wallet creation methods.

All wallet creation methods now consistently accept the change_management parameter, maintaining API uniformity across different wallet initialization paths.

Also applies to: 215-215, 303-303


501-504: LGTM: Clean addition of enotes accessor method.

The new enotes method provides access to wallet UTXOs through the safe wrapper interface, maintaining consistency with other async methods in the API.


1386-1412: LGTM: Robust enotes implementation with proper error handling.

The implementation correctly:

  • Handles FFI call failures gracefully with error logging
  • Manages memory safely through RAII
  • Sorts enotes by blockchain height for consistent ordering
  • Uses proper error contexts

1525-1580: LGTM: Well-implemented change splitting logic.

The change management implementation is robust:

  • Properly handles both Default and Split variants
  • Calculates split amounts correctly with integer division
  • Creates multi-destination transactions when splitting
  • Includes proper error handling and transaction cleanup
  • Uses appropriate logging for debugging

1582-1623: LGTM: Enhanced receipt generation for multiple transactions.

The code properly:

  • Handles multiple transaction IDs from pending transactions
  • Generates receipts for each transaction with proper error handling
  • Maintains transaction cleanup through RAII

1788-1788: LGTM: Improved clarity in method documentation and parameter naming.

The rename from "percentages" to "ratios" with the clarification that they must sum to 1.0 (not 100.0) improves API clarity and reduces confusion.

Also applies to: 1801-1802, 1818-1818, 1826-1826


1966-2000: LGTM: Comprehensive transaction detail accessors.

The new accessor methods for PendingTransaction provide valuable transaction details:

  • Consistent error handling patterns
  • Proper conversion from pico units to monero::Amount
  • Clear method names and documentation

2029-2225: LGTM: Complete and safe Enote implementation.

The Enote implementation correctly:

  • Provides safe accessor methods for all enote properties
  • Implements proper trait implementations (Debug, Display, Send, Deref, Drop)
  • Handles FFI resource cleanup in Drop
  • Uses appropriate error handling with .expect() for FFI calls that shouldn't fail
  • Includes safety documentation for the Send implementation

The safety comment for Send is particularly good, noting the implementation details that make it safe.

swap/src/network/transfer_proof.rs (1)

27-27: LGTM: Clean transition to support multiple transfer proofs.

The field rename from tx_lock_proof to tx_lock_proofs and type change to Vec<monero::TransferProof> appropriately supports the PR objective of handling multiple transfer proofs. The change maintains proper serialization support through the derive macros.

swap/src/asb/recovery/redeem.rs (1)

36-36: LGTM: Consistent field renaming for multiple transfer proof support.

The variable renaming from transfer_proof to transfer_proofs in both the pattern match and state construction correctly aligns with the broader codebase changes to support multiple transfer proofs.

Also applies to: 48-48

swap/src/cli/behaviour.rs (1)

39-39: LGTM: Clean refactor to support multiple transfer proofs.

The change from singular lock_transfer_proof to plural lock_transfer_proofs with vector type is consistent with the broader refactor to support automatic output management with multiple Monero transfer proofs.

swap/src/protocol/bob/state.rs (2)

695-695: LGTM: Appropriate field type change for multiple transfer proofs.

The change from TransferProof to Vec<TransferProof> aligns with the automatic output management feature that can generate multiple lock transactions.


739-746: LGTM: Correct implementation for handling multiple transfer proofs.

The logic properly iterates through all transfer proofs to extract transaction hashes and passes them to the swap wallet. The implementation maintains existing error handling patterns while correctly adapting to the vector type.

swap/src/asb/recovery/refund.rs (1)

36-86: LGTM: Consistent variable renaming for multiple transfer proofs.

The changes consistently rename transfer_proof to transfer_proofs throughout all pattern matches and function calls. The refactor maintains existing logic while properly adapting to the vector type.

swap/src/network/cooperative_xmr_redeem_after_punish.rs (2)

44-44: LGTM: Network protocol updated for multiple transfer proofs.

The change from lock_transfer_proof to lock_transfer_proofs: Vec<TransferProof> correctly updates the cooperative redeem response to support multiple transfer proofs.


100-105: LGTM: Conversion implementation correctly updated.

The conversion from network message to CLI event properly uses the updated plural field name, maintaining consistency with the protocol change.

swap/src/protocol.rs (1)

158-166: LGTM: Database trait correctly updated for multiple transfer proofs.

The method signatures properly change from single TransferProof to Vec<TransferProof> with appropriate parameter naming (proofproofs). The return type for get_buffered_transfer_proof correctly returns Option<Vec<TransferProof>> to handle cases where no proofs exist.

swap/src/asb/event_loop.rs (2)

394-412: LGTM! Cooperative XMR redeem properly handles multiple transfer proofs.

The pattern matching and response construction correctly handle the vector of transfer proofs, ensuring Bob receives all necessary proofs for the cooperative redeem flow.


695-703: LGTM! Transfer proof request builder updated correctly.

The method signature and implementation properly handle the vector of transfer proofs.

swap/src/protocol/alice/swap.rs (1)

309-337: LGTM! Efficient concurrent confirmation waiting.

The implementation correctly uses futures::future::join_all to wait for all transfer proof confirmations concurrently, improving performance compared to sequential waiting.

swap/src/cli/event_loop.rs (6)

60-60: Type change for transfer proof channel is correct.

The change from monero::TransferProof to Vec<monero::TransferProof> aligns with supporting multiple transfer proofs for automatic output management.


195-195: Database insertion updated for multiple transfer proofs.

The database insertion correctly uses the vector of transfer proofs for buffering.


228-231: Event handling updated for multiple transfer proofs.

The CooperativeXmrRedeemFulfilled event correctly handles lock_transfer_proofs (plural) and passes the vector to the response construction.


370-370: EventLoopHandle receiver type updated consistently.

The receiver type change maintains consistency with the sender side for the transfer proof communication channel.


437-449: Method signature and implementation correctly updated.

The recv_transfer_proof method now returns Vec<monero::TransferProof> and uses appropriate plural variable naming. The acknowledgment logic remains intact.


175-175: No action needed: tx_lock_proofs field is consistent
Verified that the Request struct in swap/src/network/transfer_proof.rs defines pub tx_lock_proofs: Vec<monero::TransferProof>, matching its use in msg.tx_lock_proofs.

swap/src/asb/recovery/cancel.rs (3)

16-16: LGTM: Variable renamed to support multiple transfer proofs.

The variable name change from transfer_proof to transfer_proofs correctly reflects the transition from handling a single transfer proof to multiple proofs, aligning with the automatic output management feature.


23-32: LGTM: Pattern matching updated consistently.

All AliceState enum pattern matches have been systematically updated to use transfer_proofs instead of transfer_proof. The destructuring and variable extraction maintain the same logic flow while accommodating the new data structure.


61-61: LGTM: State construction updated correctly.

The construction of AliceState::BtcCancelled properly uses the updated transfer_proofs variable, maintaining consistency with the enum definition changes.

Comment on lines 604 to 606
if let Err(error) = result {
tracing::warn!(%error, "Failed to wait for Monero lock transaction(s) to be confirmed, attempting to refund anyway");
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider stricter error handling for transfer proof confirmations.

The current implementation logs a warning but proceeds with the refund even if confirmation checks fail. This could be risky if the failures indicate that the Monero funds are not actually locked on-chain.

Consider either:

  1. Failing the refund if any confirmation check fails
  2. Implementing retry logic for failed confirmations before proceeding
  3. At minimum, distinguish between network errors and actual confirmation failures
-        if let Err(error) = result {
-            tracing::warn!(%error, "Failed to wait for Monero lock transaction(s) to be confirmed, attempting to refund anyway");
-        }
+        match result {
+            Err(error) => {
+                // Retry confirmation checks or fail based on error type
+                return Err(error.context("Cannot proceed with refund without confirmed Monero locks"));
+            }
+            Ok(_) => {
+                tracing::info!("All Monero lock transactions confirmed");
+            }
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if let Err(error) = result {
tracing::warn!(%error, "Failed to wait for Monero lock transaction(s) to be confirmed, attempting to refund anyway");
}
match result {
Err(error) => {
// Retry confirmation checks or fail based on error type
return Err(error.context("Cannot proceed with refund without confirmed Monero locks"));
}
Ok(_) => {
tracing::info!("All Monero lock transactions confirmed");
}
}
🤖 Prompt for AI Agents
In swap/src/protocol/alice/state.rs around lines 604 to 606, the code currently
logs a warning when waiting for Monero lock transaction confirmations fails but
proceeds with the refund regardless. To improve safety, modify the logic to
either fail the refund immediately if confirmation checks fail, or implement
retry logic to reattempt confirmation checks before refunding. Alternatively,
enhance error handling to differentiate between transient network errors and
actual confirmation failures, and only proceed with refunding when it is safe to
do so.

Comment on lines +177 to +187
let transfer_proofs: Vec<TransferProof> = receipt
.into_iter()
.map(|receipt| {
TransferProof::new(
monero::TxHash(receipt.txid),
monero::PrivateKey::from_str(&receipt.tx_key)
.expect("tx key to be valid private key"),
)
})
.collect();

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace expect with proper error handling.

Using expect at line 183 could cause a panic if the tx_key is not a valid private key.

-                    let transfer_proofs: Vec<TransferProof> = receipt
-                        .into_iter()
-                        .map(|receipt| {
-                            TransferProof::new(
-                                monero::TxHash(receipt.txid),
-                                monero::PrivateKey::from_str(&receipt.tx_key)
-                                    .expect("tx key to be valid private key"),
-                            )
-                        })
-                        .collect();
+                    let transfer_proofs: Vec<TransferProof> = receipt
+                        .into_iter()
+                        .map(|receipt| {
+                            let private_key = monero::PrivateKey::from_str(&receipt.tx_key)
+                                .context("Invalid tx_key in receipt")?;
+                            Ok(TransferProof::new(
+                                monero::TxHash(receipt.txid),
+                                private_key,
+                            ))
+                        })
+                        .collect::<Result<Vec<_>>>()?;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let transfer_proofs: Vec<TransferProof> = receipt
.into_iter()
.map(|receipt| {
TransferProof::new(
monero::TxHash(receipt.txid),
monero::PrivateKey::from_str(&receipt.tx_key)
.expect("tx key to be valid private key"),
)
})
.collect();
let transfer_proofs: Vec<TransferProof> = receipt
.into_iter()
.map(|receipt| {
let private_key = monero::PrivateKey::from_str(&receipt.tx_key)
.context("Invalid tx_key in receipt")?;
Ok(TransferProof::new(
monero::TxHash(receipt.txid),
private_key,
))
})
.collect::<Result<Vec<_>>>()?;
🤖 Prompt for AI Agents
In swap/src/protocol/alice/swap.rs between lines 177 and 187, the code uses
expect to convert tx_key to a PrivateKey, which can cause a panic if the key is
invalid. Replace the expect call with proper error handling by matching or using
a Result combinator to handle the error gracefully, returning or propagating the
error instead of panicking.

@Einliterflasche Einliterflasche self-assigned this Jul 20, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
monero-sys/src/lib.rs (2)

447-464: Breaking change properly implemented.

The transfer method signature change to return Vec<TxReceipt> correctly supports multiple transactions from change splitting. The implementation properly passes the stored change_management configuration to the underlying wallet.


494-506: Breaking change already documented.

The sweep_multi signature change from &[Option<monero::Address>] to &[monero::Address] simplifies the API by removing optional addresses. This breaking change has been previously identified and documented.

🧹 Nitpick comments (6)
swap/regenerate_sqlx_cache.sh (2)

25-33: Pre-flight check for required tools prevents cryptic failures.

Before running any cargo sqlx … invocation, abort early if the Rust tool-chain or sqlx-cli plugin is missing.

 echo "🔄 Regenerating SQLx query cache..."
+
+# Verify prerequisites --------------------------------------------------
+command -v cargo >/dev/null || {
+  echo "❌ Rust tool-chain not found (missing 'cargo')." >&2; exit 1;
+}
+if ! cargo sqlx --version >/dev/null 2>&1; then
+  echo "❌ 'sqlx-cli' not installed. Install with:" >&2
+  echo "   cargo install sqlx-cli --no-default-features --features rustls,sqlite" >&2
+  exit 1
+fi
+echo "✅ Prerequisites ok."

33-41: Fail fast when the script is executed from the wrong directory.

The comments say it “must be run from the monero-rpc-pool directory”, but the script never enforces that. A simple guard avoids accidental cache pollution elsewhere.

 DATABASE_URL="sqlite:$TEMP_DB"
 
 echo "📁 Using temporary database: $TEMP_DB"
+
+# Ensure we're at the workspace root (presence of Cargo.toml & migrations/)
+if [[ ! -f Cargo.toml || ! -d migrations ]]; then
+  echo "❌ Run this script from the project root containing Cargo.toml and migrations/." >&2
+  exit 1
+fi
monero-sys/tests/split_change.rs (3)

1-139: Good integration test but consider enhancing verification.

The test setup is well-structured and comprehensively tests the split change functionality. However, consider these improvements:

  1. Verify split change behavior: The test doesn't explicitly verify that the change was actually split into multiple outputs. Consider checking the number of UTXOs created after the transfer.

  2. Network dependency: The test relies on an external Stagenet node. Consider adding error handling or fallback nodes for better reliability.

Add verification that the split change actually worked:

 let new_enotes = wallet.utxos().await;
 tracing::info!("New enotes: {:?}", &new_enotes[new_enotes.len() - 10..]);

+// Verify that change was split (should have more new UTXOs than just the transfer)
+let newly_created_utxos = new_enotes.len() - original_enotes.len();
+tracing::info!("Newly created UTXOs: {}", newly_created_utxos);
+assert!(newly_created_utxos >= 6, "Expected at least 6 new UTXOs (1 transfer + 5 split change outputs)");

142-168: Unused helper function with room for improvement.

The find_newly_spent_enotes function is well-implemented but appears unused in the test. Consider:

  1. Usage: Either use this function in the test or remove it if not needed.

  2. Documentation: The comment "assumes old is subset of new" is misleading - the function handles arbitrary overlaps between the collections.

If keeping the function, improve the documentation:

-// assumes old is subset of new
+// Finds enotes that changed from unspent to spent between two UTXO snapshots
 fn find_newly_spent_enotes<'a>(

Or if the function serves a purpose, use it in the test to verify transaction behavior.


10-11: Consider more descriptive test function name.

The function name main is not descriptive for a test. Consider renaming to better describe what the test is verifying.

-async fn main() {
+async fn test_split_change_management_on_stagenet() {
swap/src/monero/wallet.rs (1)

47-47: Update documentation to match plural field.

The field type change is correct, but the documentation should be updated to reflect that it now holds multiple proofs.

-    /// The proof of the transfer.
+    /// The proofs of the transfer(s).
     pub transfer_proof: Vec<TransferProof>,
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 270fb28 and 859c57b.

📒 Files selected for processing (29)
  • .vscode/settings.json (1 hunks)
  • monero-sys/Cargo.toml (1 hunks)
  • monero-sys/monero (1 hunks)
  • monero-sys/src/bridge.h (3 hunks)
  • monero-sys/src/bridge.rs (5 hunks)
  • monero-sys/src/lib.rs (29 hunks)
  • monero-sys/tests/split_change.rs (1 hunks)
  • swap/.sqlx/query-e36c287aa98ae80ad4b6bb6f7e4b59cced041406a9db71da827b09f0d3bacfd6.json (0 hunks)
  • swap/.sqlx/query-e825661496f114d47ec430705bd2b87113f8b218fee5373868a22afe6905b646.json (1 hunks)
  • swap/migrations/20250727143224_multiple_transfer_proofs.sql (1 hunks)
  • swap/regenerate_sqlx_cache.sh (1 hunks)
  • swap/sqlite_dev_setup.sh (0 hunks)
  • swap/src/asb/event_loop.rs (3 hunks)
  • swap/src/asb/recovery/cancel.rs (2 hunks)
  • swap/src/asb/recovery/punish.rs (2 hunks)
  • swap/src/asb/recovery/redeem.rs (2 hunks)
  • swap/src/asb/recovery/refund.rs (2 hunks)
  • swap/src/bitcoin.rs (1 hunks)
  • swap/src/cli/api/tauri_bindings.rs (2 hunks)
  • swap/src/cli/event_loop.rs (7 hunks)
  • swap/src/database/alice.rs (6 hunks)
  • swap/src/database/bob.rs (1 hunks)
  • swap/src/database/sqlite.rs (5 hunks)
  • swap/src/monero/wallet.rs (9 hunks)
  • swap/src/protocol.rs (1 hunks)
  • swap/src/protocol/alice/state.rs (6 hunks)
  • swap/src/protocol/alice/swap.rs (21 hunks)
  • swap/src/protocol/bob/state.rs (8 hunks)
  • swap/src/protocol/bob/swap.rs (7 hunks)
💤 Files with no reviewable changes (2)
  • swap/.sqlx/query-e36c287aa98ae80ad4b6bb6f7e4b59cced041406a9db71da827b09f0d3bacfd6.json
  • swap/sqlite_dev_setup.sh
✅ Files skipped from review due to trivial changes (3)
  • swap/.sqlx/query-e825661496f114d47ec430705bd2b87113f8b218fee5373868a22afe6905b646.json
  • monero-sys/monero
  • swap/migrations/20250727143224_multiple_transfer_proofs.sql
🚧 Files skipped from review as they are similar to previous changes (15)
  • swap/src/asb/recovery/refund.rs
  • swap/src/asb/recovery/cancel.rs
  • .vscode/settings.json
  • swap/src/asb/recovery/redeem.rs
  • swap/src/asb/recovery/punish.rs
  • swap/src/protocol/bob/state.rs
  • swap/src/protocol.rs
  • swap/src/database/alice.rs
  • monero-sys/src/bridge.h
  • swap/src/database/sqlite.rs
  • swap/src/protocol/alice/swap.rs
  • swap/src/asb/event_loop.rs
  • swap/src/protocol/alice/state.rs
  • monero-sys/src/bridge.rs
  • swap/src/cli/event_loop.rs
🧰 Additional context used
📓 Path-based instructions (3)
monero-sys/src/{bridge.rs,lib.rs}

📄 CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

monero-sys/src/{bridge.rs,lib.rs}: In src/bridge.rs, when adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, and add wrapping logic in src/lib.rs.
Use unsafe only for FFI interactions with Monero C++ code.
Raw pointers must be wrapped in safe Rust types, and unsafe is only used at the FFI boundary.

Files:

  • monero-sys/src/lib.rs
monero-sys/src/**/*.rs

📄 CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

When using .expect(), the message should be a short description of the assumed invariant in the format of .expect("the invariant to be upheld").

Files:

  • monero-sys/src/lib.rs
monero-sys/src/lib.rs

📄 CodeRabbit Inference Engine (monero-sys/CLAUDE.md)

monero-sys/src/lib.rs: In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).
Implement proper deref for wrapper types and use the OnceLock pattern to ensure WalletManager is a singleton.

Files:

  • monero-sys/src/lib.rs
🧠 Learnings (10)
📓 Common learnings
Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).
swap/src/bitcoin.rs (10)

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types and use the OnceLock pattern to ensure WalletManager is a singleton.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : In src/bridge.rs, when adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, and add wrapping logic in src/lib.rs.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : Use unsafe only for FFI interactions with Monero C++ code.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, use the cxx::bridge macro to define the FFI interface, declare C++ types and functions, and wrap static C++ methods as free functions.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : Raw pointers must be wrapped in safe Rust types, and unsafe is only used at the FFI boundary.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/**/*.rs : When using .expect(), the message should be a short description of the assumed invariant in the format of .expect("the invariant to be upheld").

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to swap/Cargo.toml : The swap/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.

swap/regenerate_sqlx_cache.sh (1)

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to swap/Cargo.toml : The swap/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

swap/src/cli/api/tauri_bindings.rs (8)

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types and use the OnceLock pattern to ensure WalletManager is a singleton.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : In src/bridge.rs, when adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, and add wrapping logic in src/lib.rs.

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to swap/Cargo.toml : The swap/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to src-tauri/Cargo.toml : The src-tauri/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : Raw pointers must be wrapped in safe Rust types, and unsafe is only used at the FFI boundary.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, use the cxx::bridge macro to define the FFI interface, declare C++ types and functions, and wrap static C++ methods as free functions.

monero-sys/Cargo.toml (11)

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to src-tauri/Cargo.toml : The src-tauri/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, use the cxx::bridge macro to define the FFI interface, declare C++ types and functions, and wrap static C++ methods as free functions.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : Use unsafe only for FFI interactions with Monero C++ code.

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to swap/Cargo.toml : The swap/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : In src/bridge.rs, when adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, and add wrapping logic in src/lib.rs.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX to build the bridge, and link required static and dynamic libraries.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types and use the OnceLock pattern to ensure WalletManager is a singleton.

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to Cargo.lock : The Cargo.lock file is frequently edited and should be reviewed carefully for dependency lock changes

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : Raw pointers must be wrapped in safe Rust types, and unsafe is only used at the FFI boundary.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Use Rust 2021 edition.

swap/src/monero/wallet.rs (10)

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types and use the OnceLock pattern to ensure WalletManager is a singleton.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : In src/bridge.rs, when adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, and add wrapping logic in src/lib.rs.

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to swap/Cargo.toml : The swap/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the unsafe extern "C++" block in bridge.rs, 3. Create a corresponding Rust wrapper in lib.rs, 4. For functions returning strings or with CXX limitations, add helper functions in bridge.h.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX to build the bridge, and link required static and dynamic libraries.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : Use unsafe only for FFI interactions with Monero C++ code.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, use the cxx::bridge macro to define the FFI interface, declare C++ types and functions, and wrap static C++ methods as free functions.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : Raw pointers must be wrapped in safe Rust types, and unsafe is only used at the FFI boundary.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/bridge.h : In bridge.h, provide helper functions to work around CXX limitations, including wrappers for static methods and handling string returns with std::unique_ptrstd::string.

swap/src/database/bob.rs (5)

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types and use the OnceLock pattern to ensure WalletManager is a singleton.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to swap/Cargo.toml : The swap/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : In src/bridge.rs, when adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, and add wrapping logic in src/lib.rs.

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to Cargo.lock : The Cargo.lock file is frequently edited and should be reviewed carefully for dependency lock changes

monero-sys/tests/split_change.rs (6)

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : In src/bridge.rs, when adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, and add wrapping logic in src/lib.rs.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types and use the OnceLock pattern to ensure WalletManager is a singleton.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/**/*.rs : When using .expect(), the message should be a short description of the assumed invariant in the format of .expect("the invariant to be upheld").

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the unsafe extern "C++" block in bridge.rs, 3. Create a corresponding Rust wrapper in lib.rs, 4. For functions returning strings or with CXX limitations, add helper functions in bridge.h.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.

swap/src/protocol/bob/swap.rs (4)

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types and use the OnceLock pattern to ensure WalletManager is a singleton.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : In src/bridge.rs, when adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, and add wrapping logic in src/lib.rs.

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to swap/Cargo.toml : The swap/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

monero-sys/src/lib.rs (12)

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : In src/lib.rs, provide idiomatic Rust interfaces to the C++ code, use wrapper types (WalletManager, Wallet) with safer interfaces, and handle memory management and safety concerns (never expose raw pointers, implement Send and Sync, use Pin for C++ objects requiring stable memory addresses).

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/lib.rs : Implement proper deref for wrapper types and use the OnceLock pattern to ensure WalletManager is a singleton.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : In src/bridge.rs, when adding a new function to the bridge, copy its definition from monero/src/wallet/api/wallet2_api.h into bridge.rs, and add wrapping logic in src/lib.rs.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : Use unsafe only for FFI interactions with Monero C++ code.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Check wallet2_api.h for the correct function names, parameters, and return types before implementing FFI bindings.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: When adding new functionality: 1. Find the function in wallet2_api.h, 2. Add its declaration to the unsafe extern "C++" block in bridge.rs, 3. Create a corresponding Rust wrapper in lib.rs, 4. For functions returning strings or with CXX limitations, add helper functions in bridge.h.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/bridge.rs : In src/bridge.rs, use the cxx::bridge macro to define the FFI interface, declare C++ types and functions, and wrap static C++ methods as free functions.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/src/{bridge.rs,lib.rs} : Raw pointers must be wrapped in safe Rust types, and unsafe is only used at the FFI boundary.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Applies to monero-sys/**/build.rs : In build.rs, compile the Monero C++ code with CMake targeting wallet_api, set up include paths and library linking, configure CXX to build the bridge, and link required static and dynamic libraries.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: When implementing new wrapper functions: 1. Locate the function in wallet2_api.h, 2. Copy the exact method signature to bridge.rs, 3. Implement the Rust wrapper in lib.rs, 4. Run the build to ensure everything compiles.

Learnt from: CR
PR: eigenwallet/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-07-23T20:01:33.031Z
Learning: Always verify method signatures in the Monero C++ headers before adding them to the Rust bridge.

Learnt from: CR
PR: eigenwallet/core#0
File: AGENT.md:0-0
Timestamp: 2025-07-23T20:01:42.422Z
Learning: Applies to swap/Cargo.toml : The swap/Cargo.toml file is frequently edited and should be reviewed carefully for dependency and configuration changes

🧬 Code Graph Analysis (2)
swap/src/database/bob.rs (4)
swap/src/monero.rs (1)
  • TransferProof (445-449)
swap/src/network/transfer_proof.rs (1)
  • Request (25-28)
swap/tests/concurrent_bobs_after_xmr_lock_proof_sent.rs (1)
  • concurrent_bobs_after_xmr_lock_proof_sent (11-61)
swap/tests/harness/mod.rs (1)
  • is_lock_proof_received (1110-1112)
monero-sys/src/lib.rs (1)
monero-sys/src/bridge.rs (15)
  • address (148-152)
  • amount (266-266)
  • amount (302-302)
  • walletGetEnoteDetails (216-218)
  • createTransaction (238-242)
  • change (263-263)
  • vector_string_push_back (257-257)
  • createTransactionMultiDest (251-255)
  • pendingTransactionTxIds (278-280)
  • walletGetTxKey (283-283)
  • signMessage (320-325)
  • fee (269-269)
  • dust (272-272)
  • enoteTxId (299-299)
  • destroyEnoteDetails (221-221)
🔇 Additional comments (23)
swap/src/bitcoin.rs (1)

691-694: LGTM! Test correctly adapted to new API.

The test properly adapts to the new xmr_locked method signature that now expects a vector of TransferProof instead of a single instance, consistent with the broader refactoring to support multiple Monero transfer proofs.

swap/src/database/bob.rs (1)

26-26: LGTM! Database schema correctly updated for multiple transfer proofs.

The change from TransferProof to Vec<TransferProof> is consistently applied across the enum definition and both From implementations, properly supporting the new requirement for multiple Monero transfer proofs per swap.

swap/src/cli/api/tauri_bindings.rs (2)

772-774: LGTM! API bindings correctly updated for multiple transaction IDs.

The field name and type changes from xmr_lock_txid: monero::TxHash to xmr_lock_txids: Vec<monero::TxHash> properly reflect the new data model supporting multiple Monero lock transactions. The serialization annotations are also correctly updated.


783-784: LGTM! Consistent API update for transaction IDs.

The change from singular xmr_lock_txid to plural xmr_lock_txids with vector type is consistent with the other enum variant and properly supports multiple Monero lock transactions.

swap/src/protocol/bob/swap.rs (4)

272-277: LGTM! Consistent transition to multiple transfer proofs.

The database method call and logging have been correctly updated to handle multiple transfer proofs. The logging extracts transaction IDs from all proofs in the vector, which provides better visibility into multi-transaction scenarios.


354-365: Well-implemented multi-proof handling.

The code correctly extracts transaction hashes from multiple transfer proofs and uses them consistently for logging and event emission. The iterator-based approach is idiomatic Rust and handles the vector properly.


555-568: Consistent implementation for event emission.

The transaction hash extraction pattern is consistent with other parts of the code. The event emission correctly uses the extracted transaction IDs for UI updates.


780-812: Protocol change correctly implemented.

The cooperative redeem logic has been properly updated to handle multiple transfer proofs. The response field name change from lock_transfer_proof to lock_transfer_proofs indicates a protocol message update, which aligns with the broader changes supporting multiple proofs per swap.

swap/src/monero/wallet.rs (3)

12-12: Clean integration of ChangeManagement configuration.

The addition of the change_management field and its integration in the constructor is well-implemented. The field is properly documented and passed through to the underlying wallet creation calls.

Also applies to: 38-40, 75-76, 82-83, 100-100


113-113: Correctly updated to handle multiple lock transactions.

The method properly handles multiple transaction IDs by iterating through them and importing each one. The change_management field is correctly passed through to wallet creation.

Also applies to: 143-143, 160-166


196-196: Excellent implementation of concurrent multi-proof confirmation.

The updated method efficiently handles multiple transfer proofs by:

  • Using join_all to wait for all transfers concurrently
  • Properly aggregating received amounts from all transactions
  • Validating the total against the expected amount
  • Providing clear error messages for amount mismatches

The Clone bound addition for the listener is necessary and correctly implemented.

Also applies to: 206-244

monero-sys/src/lib.rs (12)

34-35: LGTM: Clean integration of change management configuration.

The addition of the change_management field to WalletHandle properly stores the configuration strategy and is well-documented.


129-142: LGTM: Well-designed configuration enum.

The ChangeManagement enum provides a clean, type-safe API for configuring change output behavior. The Split variant's parameters are appropriately named and the documentation clearly explains the functionality.


144-161: LGTM: Well-structured UTXO representation.

The Utxo struct provides a clean snapshot representation of wallet UTXOs with appropriate field types and encapsulation. The derived traits are suitable for a data structure used in collections.


176-177: LGTM: Consistent integration of change management configuration.

The change_management parameter is properly added to all wallet creation methods and correctly stored in the WalletHandle structure, maintaining consistency across the API.

Also applies to: 210-213


518-521: LGTM: Clean async UTXO access method.

The new utxos() method follows the established pattern for wallet operations, properly delegating to the wallet thread via the call mechanism.


670-724: LGTM: Well-implemented multi-transaction confirmation.

The wait_until_multiple_confirmed method correctly handles waiting for multiple transactions concurrently using join_all, properly sums received amounts, and validates against expected totals. The error handling and logging are appropriate.


728-794: LGTM: Enhanced transaction confirmation with flexible amount checking.

The changes to wait_until_confirmed improve API flexibility by making amount checking optional and returning detailed TxStatus. The implementation correctly validates amounts when provided and maintains clear error reporting.


2058-2092: LGTM: Well-implemented transaction detail accessors.

The new PendingTransaction methods (output_amount, change, fee, dust) follow consistent patterns with proper error handling and type conversion. These provide valuable access to transaction details for the change management functionality.


2121-2161: LGTM: Clean UTXO accessor implementation.

The Utxo implementation provides proper encapsulation with private fields and public accessor methods. The new method correctly constructs from an Enote reference, and all accessors provide appropriate access to the data.


2163-2366: LGTM: Well-implemented FFI wrapper with proper resource management.

The Enote wrapper correctly manages C++ resources through Drop, implements Send with appropriate safety justifications, and provides clean access to enote data. The null pointer assertion and FFI error handling are appropriate.


1874-1933: LGTM: Improved parameter naming for clarity.

The rename from percentages to ratios better reflects the actual requirement that these values must sum to 1.0. The implementation logic remains correct while the naming is more accurate and clear.


1462-1497: Type compatibility confirmed in utxos().
CxxVector<EnoteDetailsWrapper>::pop() returns an ffi::EnoteDetailsWrapper, exactly matching the signature of fn new(inner: ffi::EnoteDetailsWrapper). No changes are required.

anyhow = "1.0.98"
backoff = { version = "0.4.0", features = ["futures", "tokio"] }
cxx = "1.0.137"
futures = "0.3.31"
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove duplicate futures dependency.

The futures crate is now listed in both [dependencies] and [dev-dependencies]. Since it's needed for main functionality and dev-dependencies inherit from dependencies, the duplicate entry in [dev-dependencies] should be removed.

Apply this diff to remove the duplicate:

[dev-dependencies]
anyhow = "1.0.98"
-futures = "0.3.31"
quickcheck = "1.0"
quickcheck_macros = "1.0"
tempfile = "3.19.1"
testcontainers = "0.15"
tokio = { version = "1.44.2", features = ["full"] }
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
uuid = { version = "1.16.0", features = ["v4"] }
🤖 Prompt for AI Agents
In monero-sys/Cargo.toml at line 10, remove the duplicate futures dependency
from the [dev-dependencies] section since it is already declared in
[dependencies]. This avoids redundancy because dev-dependencies inherit from
dependencies.

Comment on lines +1617 to +1672
match change_management {
// Default behavior: let Monero handle change
ChangeManagement::Default => {}
// If `split_change` is enabled, we split the change into multiple outputs
ChangeManagement::Split {
extra_outputs,
threshold,
} => {
let change = pending_tx
.change()
.context("Failed to get change amount: FFI call failed with exception")?;

let extra_change_outputs = if change > threshold { extra_outputs } else { 0 };
let change_per_extra_output = change / (extra_change_outputs + 1) as u64; // won't panic: always > 0

tracing::debug!(change=%change, "Splitting change into {} outputs", extra_change_outputs + 1);

// Create a multi dest tx which spends the specified amount to the destination address
// and splits the change into extra outputs.
let mut addresses = CxxVector::<CxxString>::new();

// Add the destination address
let self_address = self.main_address();
let_cxx_string!(self_address = self_address.to_string());
ffi::vector_string_push_back(addresses.pin_mut(), &self_address);

// Add the extra change outputs
for _ in 0..extra_change_outputs {
ffi::vector_string_push_back(addresses.pin_mut(), &self_address);
}

// Add the amounts
let mut amounts = CxxVector::<u64>::new();
amounts.pin_mut().push(amount);
for _ in 0..extra_change_outputs {
amounts.pin_mut().push(change_per_extra_output.as_pico());
}

let mut tx = PendingTransaction(ffi::createTransactionMultiDest(
self.inner.pinned(),
&addresses,
&amounts,
));

if raw_transaction.is_null() {
self.check_error()
.context("Failed to create transaction: ffi call returned null")?;
anyhow::bail!(
"Failed to create transaction: ffi call returned null (no reason given)"
);
}

std::mem::swap(&mut pending_tx, &mut tx); // swap the pending transaction with the new one
self.dispose_transaction(tx); // dispose the old transaction
}
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix null pointer check in change splitting logic.

The change splitting implementation is well-designed, but there's a bug on line 1661 where raw_transaction.is_null() is checked instead of the newly created multi-destination transaction pointer.

-                if raw_transaction.is_null() {
+                if tx.0.is_null() {

The logic correctly calculates change distribution and creates appropriate multi-destination transactions for splitting change outputs.

🤖 Prompt for AI Agents
In monero-sys/src/lib.rs between lines 1617 and 1672, the null pointer check
incorrectly uses raw_transaction.is_null() instead of checking the pointer of
the newly created multi-destination transaction. To fix this, replace the null
check condition to verify if the pointer inside the newly created
PendingTransaction (tx) is null. This ensures the error handling correctly
detects failure in creating the multi-destination transaction.

# The generated .sqlx directory should be committed to version control
# to enable offline compilation without requiring DATABASE_URL.

set -e # Exit on any error
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enable stricter shell-safety flags (set -euo pipefail).
Using only set -e misses common failure modes (unset vars & masked pipe errors). Tighten the guard rails:

-set -e  # Exit on any error
+set -euo pipefail  # Exit on error, undefined var, or failed pipeline
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
set -e # Exit on any error
# swap/regenerate_sqlx_cache.sh
# Exit on error, undefined var, or failed pipeline
set -euo pipefail
🤖 Prompt for AI Agents
In swap/regenerate_sqlx_cache.sh at line 24, replace the existing `set -e` with
`set -euo pipefail` to enable stricter shell safety. This change ensures the
script exits on unset variables and pipe failures, improving robustness by
catching more error conditions.

@binarybaron
Copy link

Perhaps we can make this backwards compatible for cases where we only have a single transfer proof

@binarybaron
Copy link

binarybaron commented Sep 24, 2025

Perhaps we can make this backwards compatible for cases where we only have a single transfer proof

Forget it. I say we bite the bullet and make this a breaking change. We will bump the quote and swap_setup at the same time too.

Worst case is that a few swaps have to be refunded and there is less liquidity for a few days.

Once you merge master, I'll review this again.

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.

Manage Monero inputs efficiently
3 participants