Add PersistenceNotifierGuard take to offer/refund payments

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.
This commit is contained in:
Matt Corallo 2024-02-06 23:17:50 +00:00
parent 98340dc253
commit b29033659f

View file

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