Skip to content

Commit f761051

Browse files
Add EventCompletionAction::InboundPaymentClaimedChannelMonitorUpdate
When an Event::PaymentClaimed is processed by the user, we need to track that so we don't keep regenerating the event redundantly on startup. Here we add an event completion action for that. Note that this action will only be generated for closed channels -- if the channel is open, the inbound payment is pruned automatically when the HTLC is no longer present in any unrevoked commitment transaction, which stops the redundant event regeneration. Similar to EventCompletionAction::ReleasePaymentCompleteChannelMonitorUpdate, but for inbound payments. Actual generation and handling of this completion action is added in an upcoming commit.
1 parent e744298 commit f761051

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

lightning/src/ln/channelmanager.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,21 @@ impl_writeable_tlv_based!(PaymentCompleteUpdate, {
14751475
(7, htlc_id, required),
14761476
});
14771477

1478+
#[derive(Clone, Debug, PartialEq, Eq)]
1479+
pub(crate) struct InboundPaymentClaimedUpdate {
1480+
pub counterparty_node_id: PublicKey,
1481+
pub channel_funding_outpoint: OutPoint,
1482+
pub channel_id: ChannelId,
1483+
pub payment_hash: PaymentHash,
1484+
}
1485+
1486+
impl_writeable_tlv_based!(InboundPaymentClaimedUpdate, {
1487+
(1, counterparty_node_id, required),
1488+
(3, channel_funding_outpoint, required),
1489+
(5, channel_id, required),
1490+
(7, payment_hash, required),
1491+
});
1492+
14781493
#[derive(Clone, Debug, PartialEq, Eq)]
14791494
pub(crate) enum EventCompletionAction {
14801495
ReleaseRAAChannelMonitorUpdate {
@@ -1489,6 +1504,12 @@ pub(crate) enum EventCompletionAction {
14891504
/// fully-resolved in the [`ChannelMonitor`], which we do via this action.
14901505
/// Note that this action will be dropped on downgrade to LDK prior to 0.2!
14911506
ReleasePaymentCompleteChannelMonitorUpdate(PaymentCompleteUpdate),
1507+
1508+
/// When a payment's resolution is communicated to the downstream logic via
1509+
/// [`Event::PaymentClaimed`], we may want to mark the payment as fully-resolved in the
1510+
/// [`ChannelMonitor`], which we do via this action.
1511+
/// Note that this action will be dropped on downgrade to LDK prior to 0.3!
1512+
InboundPaymentClaimedChannelMonitorUpdate(InboundPaymentClaimedUpdate),
14921513
}
14931514
impl_writeable_tlv_based_enum!(EventCompletionAction,
14941515
(0, ReleaseRAAChannelMonitorUpdate) => {
@@ -1500,8 +1521,9 @@ impl_writeable_tlv_based_enum!(EventCompletionAction,
15001521
}
15011522
ChannelId::v1_from_funding_outpoint(channel_funding_outpoint.unwrap())
15021523
})),
1503-
}
1524+
},
15041525
{1, ReleasePaymentCompleteChannelMonitorUpdate} => (),
1526+
{3, InboundPaymentClaimedChannelMonitorUpdate} => (),
15051527
);
15061528

15071529
/// The source argument which is passed to [`ChannelManager::claim_mpp_part`].
@@ -14818,6 +14840,7 @@ impl<
1481814840
update_step,
1481914841
);
1482014842
},
14843+
EventCompletionAction::InboundPaymentClaimedChannelMonitorUpdate(_) => {},
1482114844
}
1482214845
}
1482314846
}

0 commit comments

Comments
 (0)