Skip to content

Commit 4d9c2ed

Browse files
Add hold_htlc param to internal Channel APIs
As part of supporting sending payments as an often-offline sender, the sender needs to be able to set a flag in their update_add_htlc message indicating that the HTLC should be held until receipt of a release_held_htlc onion message from the often-offline payment recipient. We don't yet ever set this flag, but lay the groundwork by including a parameter for it in internal channel send_htlc APIs, including serializing the field when the parameter is set. See-also BOLTs PR 989
1 parent 94d3167 commit 4d9c2ed

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lightning/src/ln/channel.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8048,7 +8048,7 @@ where
80488048
ref onion_routing_packet,
80498049
skimmed_fee_msat,
80508050
blinding_point,
8051-
hold_htlc: _,
8051+
hold_htlc,
80528052
..
80538053
} => {
80548054
match self.send_htlc(
@@ -8060,6 +8060,7 @@ where
80608060
false,
80618061
skimmed_fee_msat,
80628062
blinding_point,
8063+
hold_htlc.is_some(),
80638064
fee_estimator,
80648065
logger,
80658066
) {
@@ -12022,6 +12023,8 @@ where
1202212023
true,
1202312024
skimmed_fee_msat,
1202412025
blinding_point,
12026+
// This method is only called for forwarded HTLCs, which are never held at the next hop
12027+
false,
1202512028
fee_estimator,
1202612029
logger,
1202712030
)
@@ -12052,7 +12055,7 @@ where
1205212055
fn send_htlc<F: Deref, L: Deref>(
1205312056
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
1205412057
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
12055-
skimmed_fee_msat: Option<u64>, blinding_point: Option<PublicKey>,
12058+
skimmed_fee_msat: Option<u64>, blinding_point: Option<PublicKey>, hold_htlc: bool,
1205612059
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1205712060
) -> Result<bool, (LocalHTLCFailureReason, String)>
1205812061
where
@@ -12134,7 +12137,7 @@ where
1213412137
onion_routing_packet,
1213512138
skimmed_fee_msat,
1213612139
blinding_point,
12137-
hold_htlc: None,
12140+
hold_htlc: hold_htlc.then(|| ()),
1213812141
});
1213912142
return Ok(false);
1214012143
}
@@ -12156,7 +12159,7 @@ where
1215612159
blinding_point,
1215712160
skimmed_fee_msat,
1215812161
send_timestamp,
12159-
hold_htlc: None,
12162+
hold_htlc: hold_htlc.then(|| ()),
1216012163
});
1216112164
self.context.next_holder_htlc_id += 1;
1216212165

@@ -12391,7 +12394,7 @@ where
1239112394
pub fn send_htlc_and_commit<F: Deref, L: Deref>(
1239212395
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
1239312396
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
12394-
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
12397+
hold_htlc: bool, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1239512398
) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
1239612399
where
1239712400
F::Target: FeeEstimator,
@@ -12406,6 +12409,7 @@ where
1240612409
false,
1240712410
skimmed_fee_msat,
1240812411
None,
12412+
hold_htlc,
1240912413
fee_estimator,
1241012414
logger,
1241112415
);

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5098,6 +5098,7 @@ where
50985098
htlc_source,
50995099
onion_packet,
51005100
None,
5101+
false,
51015102
&self.fee_estimator,
51025103
&&logger,
51035104
);

0 commit comments

Comments
 (0)