Skip to content

Commit 2f029a9

Browse files
committed
Move currency check to OffersMessageHandler
Add and move the check for unsupported currencies from the parsing code to `handle_message` in `ChannelManager`. This change ensures that we don't fail when parsing an `InvoiceRequest` for an Offer with a currency.
1 parent e7edc86 commit 2f029a9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use crate::offers::invoice::{Bolt12Invoice, DEFAULT_RELATIVE_EXPIRY, DerivedSign
6767
use crate::offers::invoice_error::InvoiceError;
6868
use crate::offers::invoice_request::{DerivedPayerSigningPubkey, InvoiceRequest, InvoiceRequestBuilder};
6969
use crate::offers::nonce::Nonce;
70-
use crate::offers::offer::{Offer, OfferBuilder};
70+
use crate::offers::offer::{Amount, Offer, OfferBuilder};
7171
use crate::offers::parse::Bolt12SemanticError;
7272
use crate::offers::refund::{Refund, RefundBuilder};
7373
use crate::offers::signer;
@@ -11135,6 +11135,13 @@ where
1113511135
None => return None,
1113611136
};
1113711137

11138+
if let Some(amount) = invoice_request.amount() {
11139+
if let Amount::Currency { .. } = amount {
11140+
let error = Bolt12SemanticError::UnsupportedCurrency;
11141+
return Some((OffersMessage::InvoiceError(error.into()), responder.respond()));
11142+
}
11143+
}
11144+
1113811145
let nonce = match context {
1113911146
None if invoice_request.metadata().is_some() => None,
1114011147
Some(OffersContext::InvoiceRequest { nonce }) => Some(nonce),

0 commit comments

Comments
 (0)