-
Notifications
You must be signed in to change notification settings - Fork 113
Refactor unified_qr.rs to use bitcoin-payment-instructions #666
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?
Refactor unified_qr.rs to use bitcoin-payment-instructions #666
Conversation
|
I've assigned @tnull as a reviewer! |
|
🔔 1st Reminder Hey @tnull! This PR has been waiting for your review. |
|
🔔 2nd Reminder Hey @tnull! This PR has been waiting for your review. |
|
🔔 3rd Reminder Hey @tnull! This PR has been waiting for your review. |
|
🔔 4th Reminder Hey @tnull! This PR has been waiting for your review. |
|
🔔 5th Reminder Hey @tnull! This PR has been waiting for your review. |
|
🔔 6th Reminder Hey @tnull! This PR has been waiting for your review. |
tnull
left a comment
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 needs a rebase by now, sorry!
1e7d616 to
3e30347
Compare
|
This need a rebase now. |
This rename reflects that this module is a unified payment interface for both QR code payments and HRN payments passed in as a string without scanning a QR code
…UnifiedPaymentResult These renamings are necessary to reflect the expanded responsibilities for this module.
This commit adds a HRN Resolver to the Node struct which will be useful for resolving HRNs when making BIP 353 payments. It also passes the HRN Resolver into UnifiedPayment.
3e30347 to
a8ed274
Compare
This commit ensures that when using the unified API to send to a HRN, we use pay_for_offer_from_hrn
a8ed274 to
4abb530
Compare
tnull
left a comment
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, now that we published v0.7.0-rc.0 and branched off release/0.7 we should ready to move forward with this as soon as bitcoin-payment-instructions supporting the new LDK version is released.
To this end, please rebase this PR and clean up the commit history. In particular, please avoid line wrapping for the first line in the commit description and also clearly describe the what, how and why for each change in the commit descriptions. Please refer to https://cbea.ms/git-commit/ for guidance on how to write good commit messages.
| pub use crate::payment::QrPaymentResult; | ||
| pub use crate::payment::UnifiedPaymentResult; | ||
|
|
||
| pub use lightning::onion_message::dns_resolution::HumanReadableName as LdkHumanReadableName; |
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.
I don't think we want to expose the LdkHumanReadableName variant, this is just an internal type alias, no?
| } | ||
|
|
||
| impl HumanReadableName { | ||
| pub fn into_inner(&self) -> LdkHumanReadableName { |
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 shouldn't be pub, and I think we can simply inline this into impl From<HumanReadableName> for LdkHumanReadableName?
| self.inner.clone() | ||
| } | ||
|
|
||
| pub fn from_encoded(encoded: &str) -> Result<Self, Error> { |
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.
Please provide docs on all public methods. Feel free to copy them over from the LDK counterpart.
| pub fn send_using_amount( | ||
| &self, offer: &Offer, amount_msat: u64, quantity: Option<u64>, payer_note: Option<String>, | ||
| route_parameters: Option<RouteParametersConfig>, | ||
| route_parameters: Option<RouteParametersConfig>, hrn: Option<HumanReadableName>, |
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.
I don't think we should change the public API here. Please create a pub(crate) send_using_amount_inner method that you can use here and that is simply used with None for the hrn parameter here in send_using_amount.
| }, | ||
| }; | ||
|
|
||
| if let Some(PaymentMethod::LightningBolt12(offer)) = |
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.
Why not simply use a match instead of if let Some(..) = .. matches!`?
This PR is a continuation of #607 which was closed mistakenly when the
developbase branch was deleted.This PR introduces a
unified.rsmodule (which is a refactor of theunified_qr.rsmodule) - this refactor allows us to use this module as a single API for sending payments toBIP 21/321 URIsas well asBIP 353 HRNs, creating a simpler interface for users.https://github.com/rust-bitcoin/bitcoin-payment-instructions is used to parse
BIP 21/321 URIsas well as theBIP 353 HRNs.Changes
unified_qr.rsmodule has been renamed tounified.rs.UnifiedQrPaymentstruct has been renamed toUnifiedPayment.QRPaymentResultenum has been renamed toUnifiedPaymentResult.sendmethod inunified.rsnow supports sending to bothBIP 21/321 URIsas well asBIP 353 HRNs.This PR closes #521 and #435