feat(gui): Redeem to internal Monero wallet#448
Conversation
WalkthroughThis set of changes introduces support for optional Monero receive addresses throughout the codebase. Database schemas, Rust backend logic, and TypeScript/React frontend components are updated to allow swaps to specify either an explicit Monero address or use an internal wallet address. Related constructors, methods, and validation logic are refactored to handle this optionality, and the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant Backend
participant Database
participant Wallet
User->>Frontend: Start swap, choose redeem address (internal/external)
Frontend->>Backend: Submit swap request (redeemAddress: Option<monero::Address>)
Backend->>Database: Store address (nullable)
Backend->>Wallet: sweep_multi([Option<monero::Address>])
Wallet->>Wallet: Replace None with main address
Wallet->>Backend: Return TxReceipts
Backend->>Frontend: Respond with swap status
Frontend->>User: Show swap progress/outcome
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Clippy (1.86.0)error: failed to load source for dependency Caused by: Caused by: Caused by: 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧠 Learnings (2)📓 Common learningsmonero-harness/src/lib.rs (10)⏰ Context from checks skipped due to timeout of 90000ms (6)
🔇 Additional comments (4)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (2)
swap/src/monero.rs (2)
376-384: Fix compilation error in From implementation.The
From<::monero::Address>implementation still calls the now-privatenewconstructor, which will cause a compilation error.Apply this fix:
impl From<::monero::Address> for MoneroAddressPool { fn from(address: ::monero::Address) -> Self { - Self(vec![LabeledMoneroAddress::new( + Self(vec![LabeledMoneroAddress::with_address( address, Decimal::from(1), "user address".to_string(), ) .expect("Percentage 1 is always valid")]) } }
935-937: Fix compilation error in test.The test still calls the now-private
newconstructor, which will cause a compilation error.Apply this fix:
- assert!(LabeledMoneroAddress::new(address, Decimal::ZERO, "test".to_string()).is_ok()); - assert!(LabeledMoneroAddress::new(address, Decimal::ONE, "test".to_string()).is_ok()); - assert!(LabeledMoneroAddress::new(address, Decimal::new(5, 1), "test".to_string()).is_ok()); // 0.5 + assert!(LabeledMoneroAddress::with_address(address, Decimal::ZERO, "test".to_string()).is_ok()); + assert!(LabeledMoneroAddress::with_address(address, Decimal::ONE, "test".to_string()).is_ok()); + assert!(LabeledMoneroAddress::with_address(address, Decimal::new(5, 1), "test".to_string()).is_ok()); // 0.5 assert!( - LabeledMoneroAddress::new(address, Decimal::new(9925, 4), "test".to_string()).is_ok() + LabeledMoneroAddress::with_address(address, Decimal::new(9925, 4), "test".to_string()).is_ok() ); // 0.9925 // Invalid percentages should fail assert!( - LabeledMoneroAddress::new(address, Decimal::new(-1, 0), "test".to_string()).is_err() + LabeledMoneroAddress::with_address(address, Decimal::new(-1, 0), "test".to_string()).is_err() ); assert!( - LabeledMoneroAddress::new(address, Decimal::new(11, 1), "test".to_string()).is_err() + LabeledMoneroAddress::with_address(address, Decimal::new(11, 1), "test".to_string()).is_err() ); // 1.1 assert!( - LabeledMoneroAddress::new(address, Decimal::new(2, 0), "test".to_string()).is_err() + LabeledMoneroAddress::with_address(address, Decimal::new(2, 0), "test".to_string()).is_err() ); // 2.0
🧹 Nitpick comments (3)
monero-rpc-pool/.sqlx/query-7bc8d637e7cf020bff58d05109ae88e56672e95e0e638af99e82df5b00595e77.json (1)
25-29: Nit: commit only semantic‐relevant metadata to reduce noisy diffs
This hunk merely reflows thenullablearray onto multiple lines without any real semantic change. If these JSON artefacts are auto-generated bysqlx prepare, consider adding an.editorconfig/CI step to normalise their formatting or excluding them entirely from the review scope to avoid PR noise.monero-rpc-pool/.sqlx/query-d32d91ca2debc4212841282533482b2ff081234c7f9f848a7223ae04234995d9.json (1)
20-23: Same formatting-only reflow as other .sqlx files
Again, no behavioural impact—just array pretty-printing. Consider tooling/ignore rules to keep the repo history clean if this churn is unintended.src-gui/src/renderer/components/other/TruncatedText.tsx (1)
7-7: Type inconsistency: Interface vs implementationThe interface declares
children: string(non-nullable), but the implementation now handles null/undefined values withchildren ?? "". Consider updating the interface to reflect the actual expected types:- children: string; + children?: string | null;This would make the type definition consistent with the defensive null handling in the implementation.
Also applies to: 12-12
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (25)
monero-rpc-pool/.sqlx/query-44ddff5bdf5b56e9c1a9848641181de4441c8974b2d1304804874cf620420ad4.json(1 hunks)monero-rpc-pool/.sqlx/query-7bc8d637e7cf020bff58d05109ae88e56672e95e0e638af99e82df5b00595e77.json(1 hunks)monero-rpc-pool/.sqlx/query-d32d91ca2debc4212841282533482b2ff081234c7f9f848a7223ae04234995d9.json(1 hunks)monero-sys/src/lib.rs(1 hunks)src-gui/src/renderer/components/other/TruncatedText.tsx(1 hunks)src-gui/src/renderer/components/pages/swap/swap/init/InitPage.tsx(4 hunks)swap/.sqlx/query-081c729a0f1ad6e4ff3e13d6702c946bc4d37d50f40670b4f51d2efcce595aa6.json(0 hunks)swap/.sqlx/query-0d465a17ebbb5761421def759c73cad023c30705d5b41a1399ef79d8d2571d7c.json(0 hunks)swap/.sqlx/query-2a356078a41b321234adf2aa385b501749f907f7c422945a8bdda2b6274f5225.json(0 hunks)swap/.sqlx/query-50ef34b4efabe650d40096a390d9240b9a7cd62878dfaa6805563cfc21284cd5.json(0 hunks)swap/.sqlx/query-5cc61dd0315571bc198401a354cd9431ee68360941f341386cbacf44ea598de8.json(0 hunks)swap/.sqlx/query-6130b6cdd184181f890964eb460741f5cf23b5237fb676faed009106627a4ca6.json(0 hunks)swap/.sqlx/query-7c37de52b3bb2ccd0868ccb861127416848d85eaebe8245c58d5beac7d537087.json(0 hunks)swap/.sqlx/query-88f761a4f7a0429cad1df0b1bebb1c0a27b2a45656549b23076d7542cfa21ecf.json(0 hunks)swap/.sqlx/query-98a8b7f4971e0eb4ab8f5aa688aa22e7fdc6b925de211f7784782f051c2dcd8c.json(0 hunks)swap/.sqlx/query-b703032b4ddc627a1124817477e7a8e5014bdc694c36a14053ef3bb2fc0c69b0.json(0 hunks)swap/.sqlx/query-d78acba5eb8563826dd190e0886aa665aae3c6f1e312ee444e65df1c95afe8b2.json(0 hunks)swap/.sqlx/query-dff8b986c3dde27b8121775e48a58564fa346b038866699210a63f8a33b03f0b.json(0 hunks)swap/.sqlx/query-e05620f420f8c1022971eeb66a803323a8cf258cbebb2834e3f7cf8f812fa646.json(0 hunks)swap/.sqlx/query-e36c287aa98ae80ad4b6bb6f7e4b59cced041406a9db71da827b09f0d3bacfd6.json(0 hunks)swap/.sqlx/query-e9d422daf774d099fcbde6c4cda35821da948bd86cc57798b4d8375baf0b51ae.json(0 hunks)swap/migrations/20250704115958_receive_xmr_to_internal_wallet.sql(1 hunks)swap/src/cli/api/request.rs(2 hunks)swap/src/database/sqlite.rs(3 hunks)swap/src/monero.rs(5 hunks)
💤 Files with no reviewable changes (15)
- swap/.sqlx/query-2a356078a41b321234adf2aa385b501749f907f7c422945a8bdda2b6274f5225.json
- swap/.sqlx/query-081c729a0f1ad6e4ff3e13d6702c946bc4d37d50f40670b4f51d2efcce595aa6.json
- swap/.sqlx/query-e36c287aa98ae80ad4b6bb6f7e4b59cced041406a9db71da827b09f0d3bacfd6.json
- swap/.sqlx/query-98a8b7f4971e0eb4ab8f5aa688aa22e7fdc6b925de211f7784782f051c2dcd8c.json
- swap/.sqlx/query-d78acba5eb8563826dd190e0886aa665aae3c6f1e312ee444e65df1c95afe8b2.json
- swap/.sqlx/query-b703032b4ddc627a1124817477e7a8e5014bdc694c36a14053ef3bb2fc0c69b0.json
- swap/.sqlx/query-5cc61dd0315571bc198401a354cd9431ee68360941f341386cbacf44ea598de8.json
- swap/.sqlx/query-6130b6cdd184181f890964eb460741f5cf23b5237fb676faed009106627a4ca6.json
- swap/.sqlx/query-e9d422daf774d099fcbde6c4cda35821da948bd86cc57798b4d8375baf0b51ae.json
- swap/.sqlx/query-50ef34b4efabe650d40096a390d9240b9a7cd62878dfaa6805563cfc21284cd5.json
- swap/.sqlx/query-e05620f420f8c1022971eeb66a803323a8cf258cbebb2834e3f7cf8f812fa646.json
- swap/.sqlx/query-0d465a17ebbb5761421def759c73cad023c30705d5b41a1399ef79d8d2571d7c.json
- swap/.sqlx/query-88f761a4f7a0429cad1df0b1bebb1c0a27b2a45656549b23076d7542cfa21ecf.json
- swap/.sqlx/query-dff8b986c3dde27b8121775e48a58564fa346b038866699210a63f8a33b03f0b.json
- swap/.sqlx/query-7c37de52b3bb2ccd0868ccb861127416848d85eaebe8245c58d5beac7d537087.json
🧰 Additional context used
📓 Path-based instructions (3)
`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, andunsafeis 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.
Useunsafeonly 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.
ImplementSendandSyncfor wrapper types in src/lib.rs.
UsePinfor C++ objects that require stable memory addresses in src/lib.rs.
Implement proper deref for wrapper types in src/lib.rs.
Use theOnceLockpattern 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 (5)
📓 Common learnings
Learnt from: CR
PR: UnstoppableSwap/core#0
File: AGENT.md:0-0
Timestamp: 2025-06-30T08:53:49.168Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
Learning: Applies to monero-sys/src/lib.rs : Use `Pin` for C++ objects that require stable memory addresses in src/lib.rs.
swap/src/database/sqlite.rs (10)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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: 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.743Z
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.
src-gui/src/renderer/components/pages/swap/swap/init/InitPage.tsx (1)
Learnt from: nabijaczleweli
PR: UnstoppableSwap/core#391
File: src-gui/src/renderer/components/pages/help/SettingsBox.tsx:54-57
Timestamp: 2025-06-15T15:52:41.735Z
Learning: In the UnstoppableSwap GUI codebase, top-level await is used as a convention for infallible RPC calls like getTorForced() and getMatches(), as seen in files like SettingsBox.tsx and config.ts. This is an intentional architectural decision by the team.
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
swap/src/monero.rs (10)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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: 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.743Z
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.743Z
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.743Z
Learning: Applies to monero-sys/**/*.rs : Use `unsafe` only for FFI interactions with Monero C++ code.
🧬 Code Graph Analysis (4)
swap/src/database/sqlite.rs (1)
swap/src/monero.rs (8)
address(278-280)percentage(283-285)label(288-290)with_address(269-271)with_internal_address(273-275)new(250-267)new(310-312)new(447-449)
src-gui/src/renderer/components/pages/swap/swap/init/InitPage.tsx (1)
src-gui/src/renderer/components/inputs/MoneroAddressTextField.tsx (1)
MoneroAddressTextField(29-97)
monero-sys/src/lib.rs (2)
swap/src/monero.rs (2)
addresses(315-317)address(278-280)monero-harness/src/lib.rs (1)
address(437-439)
swap/src/monero.rs (2)
monero-sys/src/lib.rs (1)
address(1087-1093)monero-harness/src/lib.rs (1)
address(437-439)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Cursor BugBot
- GitHub Check: test (macos-latest)
- GitHub Check: build (x86_64-pc-windows-msvc, windows-latest-l)
- GitHub Check: build (x86_64-apple-darwin, macos-13)
- GitHub Check: build (aarch64-apple-darwin, macos-latest)
🔇 Additional comments (19)
monero-rpc-pool/.sqlx/query-44ddff5bdf5b56e9c1a9848641181de4441c8974b2d1304804874cf620420ad4.json (1)
25-29: Trivial formatting change
Pure whitespace/line-split on thenullablefield. No action required, but worth checking if your formatter is stable across environments to avoid future diff clutter.swap/src/cli/api/request.rs (1)
165-165: Question: Relevance of logging level change to PR objectivesThe change from
tracing::debug!totracing::trace!for seller status logging doesn't seem directly related to the core PR objective of "redeem to internal Monero wallet" functionality. While reducing log verbosity can be beneficial, this change appears unrelated to the optional address feature being implemented.Consider whether this logging change should be in a separate commit or PR focused on logging improvements rather than being bundled with the Monero address feature.
Also applies to: 185-185
swap/migrations/20250704115958_receive_xmr_to_internal_wallet.sql (1)
7-26: Migration and code updates correctly support a nullableaddresscolumnThe schema migration and application code already handle
addressas nullable without issues:
- In
swap/src/database/sqlite.rs, theget_monero_address_poolmethod treatsrow.addressasOption<monero::Address>:let address: Option<monero::Address> = row.address.clone().map(|address| address.parse()).transpose()?;- SQLx’s
query!macro now infersaddressasOption<String>, matching the updated schema.- All insert and select statements against
monero_addressescontinue to function with the new nullable column.No further changes are required.
monero-sys/src/lib.rs (2)
441-441: LGTM! Signature change aligns with optional address feature.The parameter type change from
&[monero::Address]to&[Option<monero::Address>]correctly supports the new feature allowing optional Monero addresses.
446-450: LGTM! Correct implementation of address fallback logic.The implementation properly handles optional addresses by:
- Fetching the wallet's main address as a fallback
- Using
map()andunwrap_or()to substituteNonevalues with the primary address- Maintaining the original vector length and order
The async call to
main_address()is correctly placed before the mapping operation.src-gui/src/renderer/components/pages/swap/swap/init/InitPage.tsx (4)
15-16: LGTM! Consistent state variable declaration.The new state variable follows the same pattern as the existing
useExternalRefundAddressand is properly initialized.
26-26: LGTM! Correct conditional address passing.The logic correctly passes
redeemAddressonly whenuseExternalRedeemAddressis true, otherwise passingnullfor internal wallet redemption. This mirrors the existing refund address pattern.
40-69: LGTM! Well-implemented tabbed interface.The new tabbed interface for redeem address selection:
- Follows the same pattern as the refund address section for consistency
- Provides clear tab labels and appropriate helper text
- Correctly uses conditional rendering based on
useExternalRedeemAddress- Maintains consistent styling and structure
The implementation enhances user experience by clearly distinguishing between internal and external redemption options.
107-107: LGTM! Consistent validation logic.The updated validation correctly includes redeem address validation when external address is selected, maintaining the same pattern as the refund address validation.
swap/src/database/sqlite.rs (4)
114-114: LGTM! Correct handling of optional address insertion.The change from direct
.to_string()to.map(|address| address.to_string())properly handles the optional address type for database insertion.
166-166: LGTM! Proper optional address parsing.The use of
.map()and.transpose()correctly handles parsing optional address strings to optionalmonero::Addresstypes, maintaining type safety.
170-175: LGTM! Correct constructor selection based on address presence.The conditional logic properly:
- Uses
with_address()when an address is present- Uses
with_internal_address()when no address is provided- Maintains consistent error handling with descriptive messages
- Maps constructor errors to
anyhow::ErrorappropriatelyThis ensures type safety and proper handling of both internal and external address scenarios.
545-550: LGTM! Test code updated for new constructor API.The test code correctly updates from using
.new()to using the explicit.with_address()constructor, maintaining test functionality while adapting to the updated API that distinguishes between internal and external addresses.swap/src/monero.rs (6)
230-232: LGTM! Clean optional address implementation.The change to make the address field optional with clear documentation is well-implemented. This enables the "redeem to internal wallet" feature by allowing
Noneto indicate using the internal Monero wallet address.
250-267: Good constructor refactoring with proper validation.The private
newconstructor correctly handles the optional address conversion and maintains the existing percentage validation logic. Theimpl Into<Option<monero::Address>>parameter provides flexibility for bothSome(address)andNonecases.
269-275: Excellent API design with clear intent.The two new public constructors provide a clean, intent-revealing API:
with_addressfor explicit external addresseswith_internal_addressfor internal wallet addressesThis design makes the code more readable and prevents confusion about when to use
SomevsNone.
278-280: Address getter correctly updated for optional addresses.The getter now properly returns
Option<monero::Address>and clones the value, maintaining consistency with the new optional address design.
315-317: MoneroAddressPool correctly adapted for optional addresses.The
addresses()method correctly maps over the addresses and returns a vector of optional addresses, maintaining consistency with the new design.
347-353: Smart network validation handling for optional addresses.The
assert_networkmethod correctly handles optional addresses by only validating the network when an address is present. This prevents validation errors for internal wallet addresses while still ensuring external addresses are on the correct network.
43f5614 to
46695b1
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
swap/.sqlx/query-1f332be08a5426f3fbcadea4e755d82ff1cdc2690eb464ccc607d3a613fa76a1.json (1)
3-3: Query now filters NULLs – verify index for performance.
SELECT DISTINCT address ... WHERE address IS NOT NULLis functionally correct, but on large tablesDISTINCT + IS NOT NULLcan trigger full‐table scans unless an index onaddressexists.If
monero_addresses.addressis not already indexed, consider:CREATE INDEX IF NOT EXISTS idx_monero_addresses_address ON monero_addresses(address);This keeps the call cheap even as data grows.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (20)
monero-sys/build.rs(1 hunks)monero-sys/src/lib.rs(1 hunks)src-gui/src/renderer/components/modal/swap/SwapDialog.tsx(0 hunks)src-gui/src/renderer/components/other/TruncatedText.tsx(1 hunks)src-gui/src/renderer/components/pages/swap/swap/in_progress/XmrLockInMempoolPage.tsx(0 hunks)src-gui/src/renderer/components/pages/swap/swap/init/InitPage.tsx(4 hunks)swap/.sqlx/query-081c729a0f1ad6e4ff3e13d6702c946bc4d37d50f40670b4f51d2efcce595aa6.json(1 hunks)swap/.sqlx/query-0d465a17ebbb5761421def759c73cad023c30705d5b41a1399ef79d8d2571d7c.json(1 hunks)swap/.sqlx/query-1f332be08a5426f3fbcadea4e755d82ff1cdc2690eb464ccc607d3a613fa76a1.json(2 hunks)swap/.sqlx/query-5cc61dd0315571bc198401a354cd9431ee68360941f341386cbacf44ea598de8.json(1 hunks)swap/.sqlx/query-6130b6cdd184181f890964eb460741f5cf23b5237fb676faed009106627a4ca6.json(1 hunks)swap/.sqlx/query-88f761a4f7a0429cad1df0b1bebb1c0a27b2a45656549b23076d7542cfa21ecf.json(1 hunks)swap/.sqlx/query-d78acba5eb8563826dd190e0886aa665aae3c6f1e312ee444e65df1c95afe8b2.json(1 hunks)swap/.sqlx/query-dff8b986c3dde27b8121775e48a58564fa346b038866699210a63f8a33b03f0b.json(1 hunks)swap/.sqlx/query-e05620f420f8c1022971eeb66a803323a8cf258cbebb2834e3f7cf8f812fa646.json(1 hunks)swap/.sqlx/query-e9d422daf774d099fcbde6c4cda35821da948bd86cc57798b4d8375baf0b51ae.json(1 hunks)swap/migrations/20250704115958_receive_xmr_to_internal_wallet.sql(1 hunks)swap/src/cli/api/request.rs(2 hunks)swap/src/database/sqlite.rs(3 hunks)swap/src/monero.rs(5 hunks)
💤 Files with no reviewable changes (2)
- src-gui/src/renderer/components/pages/swap/swap/in_progress/XmrLockInMempoolPage.tsx
- src-gui/src/renderer/components/modal/swap/SwapDialog.tsx
✅ Files skipped from review due to trivial changes (5)
- swap/.sqlx/query-5cc61dd0315571bc198401a354cd9431ee68360941f341386cbacf44ea598de8.json
- swap/.sqlx/query-88f761a4f7a0429cad1df0b1bebb1c0a27b2a45656549b23076d7542cfa21ecf.json
- swap/.sqlx/query-dff8b986c3dde27b8121775e48a58564fa346b038866699210a63f8a33b03f0b.json
- swap/.sqlx/query-e05620f420f8c1022971eeb66a803323a8cf258cbebb2834e3f7cf8f812fa646.json
- swap/.sqlx/query-0d465a17ebbb5761421def759c73cad023c30705d5b41a1399ef79d8d2571d7c.json
🚧 Files skipped from review as they are similar to previous changes (11)
- swap/.sqlx/query-d78acba5eb8563826dd190e0886aa665aae3c6f1e312ee444e65df1c95afe8b2.json
- swap/.sqlx/query-e9d422daf774d099fcbde6c4cda35821da948bd86cc57798b4d8375baf0b51ae.json
- swap/.sqlx/query-6130b6cdd184181f890964eb460741f5cf23b5237fb676faed009106627a4ca6.json
- swap/src/cli/api/request.rs
- src-gui/src/renderer/components/other/TruncatedText.tsx
- swap/.sqlx/query-081c729a0f1ad6e4ff3e13d6702c946bc4d37d50f40670b4f51d2efcce595aa6.json
- swap/migrations/20250704115958_receive_xmr_to_internal_wallet.sql
- monero-sys/src/lib.rs
- src-gui/src/renderer/components/pages/swap/swap/init/InitPage.tsx
- swap/src/database/sqlite.rs
- swap/src/monero.rs
🧰 Additional context used
📓 Path-based instructions (2)
`monero-sys/**/*.rs`: Use Rust 2021 edition. Use `unsafe` only for FFI interacti...
monero-sys/**/*.rs: Use Rust 2021 edition.
Useunsafeonly 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/build.rs
`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
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: UnstoppableSwap/core#0
File: AGENT.md:0-0
Timestamp: 2025-06-30T08:53:49.168Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.
monero-sys/build.rs (7)
Learnt from: CR
PR: UnstoppableSwap/core#0
File: monero-sys/CLAUDE.md:0-0
Timestamp: 2025-06-30T08:53:46.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.743Z
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.
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Cursor BugBot
- GitHub Check: build (x86_64-pc-windows-msvc, windows-latest-l)
- GitHub Check: build (aarch64-apple-darwin, macos-latest)
- GitHub Check: build (x86_64-apple-darwin, macos-13)
- GitHub Check: test (macos-latest)
🔇 Additional comments (3)
swap/.sqlx/query-1f332be08a5426f3fbcadea4e755d82ff1cdc2690eb464ccc607d3a613fa76a1.json (2)
15-17: Nullable flag changed – ensure Rust side usesOption<String>.
"nullable": [ true ]means sqlx will now expectOption<_>for this column. Double-check any consumer code of this query was updated accordingly; otherwise it will fail at compile time.
19-19: Prepared statement hash updated – remember to runcargo sqlx prepare.The hash change implies the offline data has been regenerated locally. Make sure CI runs
cargo sqlx prepare --checkso that future PRs don’t break the compile-time metadata.monero-sys/build.rs (1)
82-82: LGTM: Reasonable parallel build configuration.The fixed
-j4provides a good balance between build performance and resource usage while maintaining predictable behavior across environments.
|
bugbot run |
There was a problem hiding this comment.
✅ BugBot reviewed your changes and found no bugs!
BugBot free trial expires on July 22, 2025
You have used $0.00 of your $0.00 spend limit so far. Manage your spend limit in the Cursor dashboard.
Was this report helpful? Give feedback by reacting with 👍 or 👎
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Chores
Revert