-
Notifications
You must be signed in to change notification settings - Fork 103
feat: add onchain address validation for network-specific addresses #519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: add onchain address validation for network-specific addresses #519
Conversation
👋 Thanks for assigning @tnull as a reviewer! |
🔔 1st Reminder Hey @jkczyz! This PR has been waiting for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Camillarhi,
Thanks for picking this. I reviewed this over the weekend and from my understanding of the issue, the expectation is to expose functionality for the bindings targets, so that they can validate addresses against the network.
We use UniFFI to generate the bindings targeting ldk-node
, defining interfaces in here. Your approach uses an already exposed interface OnchainPayment
. You can update the interface to add parse_and_validate_address
.
@tnull is this enough of a middle ground or do you have other ideas? Would it be preferable to adapt rust-bitcoin's Address
and implement the validation on the wrapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this!
Yeah, honestly, I'm a bit on the fence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, seems CI is also unhappy due to formatting issues. Please make sure to run cargo fmt
before committing.
Thanks for clarifying this. |
src/payment/onchain.rs
Outdated
pub fn parse_and_validate_address( | ||
&self, network: Network, address: &Address, | ||
) -> Result<Address, Error> { | ||
Address::<NetworkUnchecked>::from_str(address.to_string().as_str()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of annoying, but I guess there is no other way to do this if we don't want to take an UncheckedAddress
type ourselves, so fine to leave as is I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright , do I go ahead and expose this functionality for the binding targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please go ahead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems CI is still failing, please let me know when this is ready for another round of review.
Hello @tnull , this is ready for another review, though the CI is still failing |
…n `sending all to address`
…llet::send_to_address`
63a6895
to
8273f07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excuse the delay here. Basically looks good, just a few minor comments.
Addresses need to be validated against the target network before use to ensure correctness
and prevent potential loss of funds.
This commit introduces a function to validate addresses based on the target network:
This change enhances the robustness of address handling and mitigates risks associated with invalid or mismatched addresses.
Fixes #386