]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add `PersistenceNotifierGuard` take to offer/refund payments
authorMatt Corallo <git@bluematt.me>
Tue, 6 Feb 2024 23:17:50 +0000 (23:17 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 13 Mar 2024 14:18:44 +0000 (14:18 +0000)
This resolves an issue where offer and refund payments get delayed
while we wait for the `invoice_request`/`invoice` onion messages to
get sent. It further ensures we're likely to have the
`ChannelManager` persisted with the new payment info after
initiating the send/receive.

lightning/src/ln/channelmanager.rs

index 7bd395f999aa30da89dbdd1521dfbf8a864d7c3f..16ca44c34282f3b3ec68a7b4a153d605d8684e37 100644 (file)
@@ -7755,6 +7755,8 @@ macro_rules! create_refund_builder { ($self: ident, $builder: ty) => {
                        .absolute_expiry(absolute_expiry)
                        .path(path);
 
+               let _persistence_guard = PersistenceNotifierGuard::notify_on_drop($self);
+
                let expiration = StaleExpiration::AbsoluteTimeout(absolute_expiry);
                $self.pending_outbound_payments
                        .add_new_awaiting_invoice(
@@ -7870,6 +7872,8 @@ where
                let invoice_request = builder.build_and_sign()?;
                let reply_path = self.create_blinded_path().map_err(|_| Bolt12SemanticError::MissingPaths)?;
 
+               let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
+
                let expiration = StaleExpiration::TimerTicks(1);
                self.pending_outbound_payments
                        .add_new_awaiting_invoice(
@@ -7937,6 +7941,8 @@ where
                        return Err(Bolt12SemanticError::UnsupportedChain);
                }
 
+               let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
+
                match self.create_inbound_payment(Some(amount_msats), relative_expiry, None) {
                        Ok((payment_hash, payment_secret)) => {
                                let payment_paths = self.create_blinded_payment_paths(amount_msats, payment_secret)