-
Notifications
You must be signed in to change notification settings - Fork 0
Review: Add currency conversion support for BOLT 12 offers #10
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?
Changes from all commits
790b89b
726587c
2ccfcd3
bd653a1
b2f3abf
2f5228c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,10 @@ use bitcoin::secp256k1::Secp256k1; | |
| use core::convert::TryFrom; | ||
| use lightning::ln::channelmanager::PaymentId; | ||
| use lightning::ln::inbound_payment::ExpandedKey; | ||
| use lightning::offers::currency::DefaultCurrencyConversion; | ||
| use lightning::offers::invoice_request::InvoiceRequest; | ||
| use lightning::offers::nonce::Nonce; | ||
| use lightning::offers::offer::{Amount, Offer, Quantity}; | ||
| use lightning::offers::offer::{Offer, Quantity}; | ||
| use lightning::offers::parse::Bolt12SemanticError; | ||
| use lightning::sign::EntropySource; | ||
| use lightning::util::ser::Writeable; | ||
|
|
@@ -48,13 +49,13 @@ fn build_request(offer: &Offer) -> Result<InvoiceRequest, Bolt12SemanticError> { | |
| let nonce = Nonce::from_entropy_source(&entropy); | ||
| let secp_ctx = Secp256k1::new(); | ||
| let payment_id = PaymentId([1; 32]); | ||
| let conversion = DefaultCurrencyConversion; | ||
|
|
||
| let mut builder = offer.request_invoice(&expanded_key, nonce, &secp_ctx, payment_id)?; | ||
|
|
||
| builder = match offer.amount() { | ||
| None => builder.amount_msats(1000).unwrap(), | ||
| Some(Amount::Bitcoin { amount_msats }) => builder.amount_msats(amount_msats + 1)?, | ||
| Some(Amount::Currency { .. }) => return Err(Bolt12SemanticError::UnsupportedCurrency), | ||
| Some(amount) => builder.amount_msats(amount.into_msats(&conversion)?)?, | ||
|
Comment on lines
+52
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a conversion that can actually resolve fiat amounts in this fuzzer.
🤖 Prompt for AI Agents |
||
| }; | ||
|
|
||
| builder = match offer.supported_quantity() { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.