Skip to content

Commit 9c4bb94

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 766bb36 commit 9c4bb94

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
@@ -8067,7 +8067,7 @@ where
80678067
ref onion_routing_packet,
80688068
skimmed_fee_msat,
80698069
blinding_point,
8070-
hold_htlc: _,
8070+
hold_htlc,
80718071
..
80728072
} => {
80738073
match self.send_htlc(
@@ -8079,6 +8079,7 @@ where
80798079
false,
80808080
skimmed_fee_msat,
80818081
blinding_point,
8082+
hold_htlc,
80828083
fee_estimator,
80838084
logger,
80848085
) {
@@ -12053,6 +12054,8 @@ where
1205312054
true,
1205412055
skimmed_fee_msat,
1205512056
blinding_point,
12057+
// This method is only called for forwarded HTLCs, which are never held at the next hop
12058+
None,
1205612059
fee_estimator,
1205712060
logger,
1205812061
)
@@ -12083,7 +12086,7 @@ where
1208312086
fn send_htlc<F: Deref, L: Deref>(
1208412087
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
1208512088
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
12086-
skimmed_fee_msat: Option<u64>, blinding_point: Option<PublicKey>,
12089+
skimmed_fee_msat: Option<u64>, blinding_point: Option<PublicKey>, hold_htlc: Option<()>,
1208712090
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1208812091
) -> Result<bool, (LocalHTLCFailureReason, String)>
1208912092
where
@@ -12165,7 +12168,7 @@ where
1216512168
onion_routing_packet,
1216612169
skimmed_fee_msat,
1216712170
blinding_point,
12168-
hold_htlc: None,
12171+
hold_htlc,
1216912172
});
1217012173
return Ok(false);
1217112174
}
@@ -12187,7 +12190,7 @@ where
1218712190
blinding_point,
1218812191
skimmed_fee_msat,
1218912192
send_timestamp,
12190-
hold_htlc: None,
12193+
hold_htlc,
1219112194
});
1219212195
self.context.next_holder_htlc_id += 1;
1219312196

@@ -12422,7 +12425,7 @@ where
1242212425
pub fn send_htlc_and_commit<F: Deref, L: Deref>(
1242312426
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
1242412427
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
12425-
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
12428+
hold_htlc: Option<()>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L,
1242612429
) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
1242712430
where
1242812431
F::Target: FeeEstimator,
@@ -12437,6 +12440,7 @@ where
1243712440
false,
1243812441
skimmed_fee_msat,
1243912442
None,
12443+
hold_htlc,
1244012444
fee_estimator,
1244112445
logger,
1244212446
);

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5040,6 +5040,7 @@ where
50405040
htlc_source,
50415041
onion_packet,
50425042
None,
5043+
None,
50435044
&self.fee_estimator,
50445045
&&logger,
50455046
);

0 commit comments

Comments
 (0)