Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions lightning/src/chain/channelmonitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use crate::ln::channel_keys::{
DelayedPaymentBasepoint, DelayedPaymentKey, HtlcBasepoint, HtlcKey, RevocationBasepoint,
RevocationKey,
};
use crate::ln::channelmanager::{HTLCSource, PaymentClaimDetails, SentHTLCId};
use crate::ln::channelmanager::{HTLCSource, PaymentClaimDetails, PaymentId, SentHTLCId};
use crate::ln::msgs::DecodeError;
use crate::ln::types::ChannelId;
use crate::sign::{
Expand Down Expand Up @@ -926,6 +926,9 @@ pub enum Balance {
claimable_height: u32,
/// The payment hash whose preimage our counterparty needs to claim this HTLC.
payment_hash: PaymentHash,
/// The payment ID for outbound HTLCs, enabling grouping of MPPs.
/// `None` for forwarded HTLCs or if the channel monitor was created before this feature.
payment_id: Option<PaymentId>,
/// Whether this HTLC represents a payment which was sent outbound from us. Otherwise it
/// represents an HTLC which was forwarded (and should, thus, have a corresponding inbound
/// edge on another channel).
Expand Down Expand Up @@ -2865,15 +2868,16 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
source: BalanceSource::Htlc,
});
} else {
let outbound_payment = match source {
let (outbound_payment, payment_id) = match source {
None => panic!("Outbound HTLCs should have a source"),
Some(&HTLCSource::PreviousHopData(_)) => false,
Some(&HTLCSource::OutboundRoute { .. }) => true,
Some(&HTLCSource::PreviousHopData(_)) => (false, None),
Some(&HTLCSource::OutboundRoute { payment_id, .. }) => (true, Some(payment_id)),
};
return Some(Balance::MaybeTimeoutClaimableHTLC {
amount_satoshis: htlc.amount_msat / 1000,
claimable_height: htlc.cltv_expiry,
payment_hash: htlc.payment_hash,
payment_id,
outbound_payment,
});
}
Expand Down Expand Up @@ -3077,10 +3081,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
htlc.amount_msat
} else { htlc.amount_msat % 1000 };
if htlc.offered {
let outbound_payment = match source {
let (outbound_payment, payment_id) = match source {
None => panic!("Outbound HTLCs should have a source"),
Some(HTLCSource::PreviousHopData(_)) => false,
Some(HTLCSource::OutboundRoute { .. }) => true,
Some(HTLCSource::PreviousHopData(_)) => (false, None),
Some(HTLCSource::OutboundRoute { payment_id, .. }) => (true, Some(*payment_id)),
};
if outbound_payment {
outbound_payment_htlc_rounded_msat += rounded_value_msat;
Expand All @@ -3092,6 +3096,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
amount_satoshis: htlc.amount_msat / 1000,
claimable_height: htlc.cltv_expiry,
payment_hash: htlc.payment_hash,
payment_id,
outbound_payment,
});
}
Expand Down
Loading
Loading