refactor: add strong typing to Send UI message#270
Merged
benthecarman merged 1 commit intoHarborWallet:masterfrom Sep 6, 2025
Merged
refactor: add strong typing to Send UI message#270benthecarman merged 1 commit intoHarborWallet:masterfrom
benthecarman merged 1 commit intoHarborWallet:masterfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the Send UI message to use strong typing by replacing the String parameter with a new SendDestination enum. This moves input validation from message processing to message creation, improving error handling and UX.
- Introduces
SendDestinationenum with variants forBolt11Invoice,LnUrl, andbitcoin::Address - Moves destination parsing from message handler to UI layer with
parse_send_destinationfunction - Changes Send button to use
.on_press_maybe()to disable the button when input is invalid
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| harbor-ui/src/routes/send.rs | Adds parsing function and updates Send button to use conditional enabling |
| harbor-ui/src/main.rs | Defines SendDestination enum and refactors message handler to use typed destinations |
| harbor-ui/Cargo.toml | Adds lnurl-rs dependency for LnUrl parsing |
Comments suppressed due to low confidence (1)
harbor-ui/src/main.rs:1
- This amount parsing logic is duplicated between the LnUrl and Address cases. Consider extracting it into a helper function to reduce code duplication.
#![warn(clippy::nursery, clippy::pedantic)]
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
benthecarman
reviewed
Sep 6, 2025
61acbc7 to
00616fd
Compare
benthecarman
approved these changes
Sep 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change the type within
Message::SendfromStringto a newSendDestinationtype, which is an enum containing either aBolt11Invoice,LnUrl, orbitcoin::Address. This forces the parsing of connection strings to be moved from the message processing code to the message creation code. This has two positive effects:.on_press_maybe(), which disables the button unless a validSendDestinationcan be parsedEssentially, rather than allowing for the "Send" button to be pressed at any time, but presenting error toasts if pressed with an unparseable value, we now disable this button from even being pressed unless a parseable value is entered