File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -8816,8 +8816,15 @@ where
8816
8816
None => builder,
8817
8817
Some(payer_note) => builder.payer_note(payer_note),
8818
8818
};
8819
+
8819
8820
let invoice_request = builder.build_and_sign()?;
8820
8821
8822
+ let total_liquidity: u64 = self.list_usable_channels().iter().map(|channel| channel.next_outbound_htlc_limit_msat).sum();
8823
+ if invoice_request.amount_msats() > Some(total_liquidity) {
8824
+ log_error!(self.logger, "Insufficient liquidity for payment with payment id: {}", payment_id);
8825
+ return Err(Bolt12SemanticError::InsufficientLiquidity);
8826
+ }
8827
+
8821
8828
let context = OffersContext::OutboundPayment { payment_id };
8822
8829
let reply_path = self.create_blinded_path(context).map_err(|_| Bolt12SemanticError::MissingPaths)?;
8823
8830
Original file line number Diff line number Diff line change @@ -193,6 +193,8 @@ pub enum Bolt12SemanticError {
193
193
UnexpectedPaymentHash ,
194
194
/// A signature was expected but was missing.
195
195
MissingSignature ,
196
+ /// There is insufficient liquidity to complete the payment.
197
+ InsufficientLiquidity ,
196
198
}
197
199
198
200
impl From < bech32:: Error > for Bolt12ParseError {
You can’t perform that action at this time.
0 commit comments