@@ -64,20 +64,33 @@ impl UnifiedQrPayment {
6464 /// Generates a URI with an on-chain address, [BOLT 11] invoice and [BOLT 12] offer.
6565 ///
6666 /// The URI allows users to send the payment request allowing the wallet to decide
67- /// which payment method to use. This enables a fallback mechanism: older wallets
68- /// can always pay using the provided on-chain address, while newer wallets will
69- /// typically opt to use the provided BOLT11 invoice or BOLT12 offer.
67+ /// which payment method to use. This enables a fallback mechanism:
68+ /// - Older wallets can always pay using the provided on-chain address
69+ /// - Newer wallets will typically opt to use the provided BOLT11 invoice or BOLT12 offer
70+ ///
71+ /// The URI will always include an on-chain address, and will include a BOLT11 invoice and BOLT12 offer
72+ /// when they can be successfully generated. Offer generation may fail in certain conditions while still
73+ /// allowing invoice generation (see examples below).
7074 ///
7175 /// # Parameters
7276 /// - `amount_sats`: The amount to be received, specified in satoshis.
7377 /// - `description`: A description or note associated with the payment.
7478 /// This message is visible to the payer and can provide context or details about the payment.
7579 /// - `expiry_sec`: The expiration time for the payment, specified in seconds.
7680 ///
81+ /// # Examples
82+ /// ## When BOLT12 offer generation might fail
83+ /// A BOLT12 offer requires:
84+ /// - Sufficiently connected channels for pathfinding
85+ /// - Available liquidity in channels
86+ /// - Valid route hints
87+ /// If these conditions aren't met (e.g., when first setting up a node with no channels),
88+ /// the URI will still be generated but without the BOLT12 offer.
89+ ///
7790 /// Returns a payable URI that can be used to request and receive a payment of the amount
78- /// given. In case of an error, the function returns `Error::WalletOperationFailed`for on-chain
79- /// address issues, `Error::InvoiceCreationFailed` for BOLT11 invoice issues, or
80- /// `Error::OfferCreationFailed` for BOLT12 offer issues .
91+ /// given. Failure to generate the on-chain address will result in an error return
92+ /// ( `Error::WalletOperationFailed`), while failures in invoice or offer generation will
93+ /// result in those components being omitted from the URI .
8194 ///
8295 /// The generated URI can then be given to a QR code library.
8396 ///
@@ -95,7 +108,7 @@ impl UnifiedQrPayment {
95108 Ok ( offer) => Some ( offer) ,
96109 Err ( e) => {
97110 log_error ! ( self . logger, "Failed to create offer: {}" , e) ;
98- return Err ( Error :: OfferCreationFailed ) ;
111+ None
99112 } ,
100113 } ;
101114
@@ -111,7 +124,7 @@ impl UnifiedQrPayment {
111124 Ok ( invoice) => Some ( invoice) ,
112125 Err ( e) => {
113126 log_error ! ( self . logger, "Failed to create invoice {}" , e) ;
114- return Err ( Error :: InvoiceCreationFailed ) ;
127+ None
115128 } ,
116129 } ;
117130
0 commit comments