Skip to content

Commit 8900c60

Browse files
Support paying blinded paths
Completes single-path sending support. MPP support will be added later.
1 parent a77d68d commit 8900c60

File tree

3 files changed

+16
-20
lines changed

3 files changed

+16
-20
lines changed

lightning/src/ln/channel.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3124,10 +3124,11 @@ impl<SP: Deref> Channel<SP> where
31243124
match &htlc_update {
31253125
&HTLCUpdateAwaitingACK::AddHTLC {
31263126
amount_msat, cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet,
3127-
skimmed_fee_msat, ..
3127+
skimmed_fee_msat, blinding_point, ..
31283128
} => {
31293129
match self.send_htlc(amount_msat, *payment_hash, cltv_expiry, source.clone(),
3130-
onion_routing_packet.clone(), false, skimmed_fee_msat, fee_estimator, logger)
3130+
onion_routing_packet.clone(), false, skimmed_fee_msat, blinding_point, fee_estimator,
3131+
logger)
31313132
{
31323133
Ok(_) => update_add_count += 1,
31333134
Err(e) => {
@@ -3804,7 +3805,7 @@ impl<SP: Deref> Channel<SP> where
38043805
cltv_expiry: htlc.cltv_expiry,
38053806
onion_routing_packet: (**onion_packet).clone(),
38063807
skimmed_fee_msat: htlc.skimmed_fee_msat,
3807-
blinding_point: None,
3808+
blinding_point: htlc.blinding_point,
38083809
});
38093810
}
38103811
}
@@ -5150,13 +5151,11 @@ impl<SP: Deref> Channel<SP> where
51505151
pub fn queue_add_htlc<F: Deref, L: Deref>(
51515152
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
51525153
onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
5153-
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
5154-
) -> Result<(), ChannelError>
5155-
where F::Target: FeeEstimator, L::Target: Logger
5156-
{
5154+
blinding_point: Option<PublicKey>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
5155+
) -> Result<(), ChannelError> where F::Target: FeeEstimator, L::Target: Logger {
51575156
self
51585157
.send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true,
5159-
skimmed_fee_msat, fee_estimator, logger)
5158+
skimmed_fee_msat, blinding_point, fee_estimator, logger)
51605159
.map(|msg_opt| assert!(msg_opt.is_none(), "We forced holding cell?"))
51615160
.map_err(|err| {
51625161
if let ChannelError::Ignore(_) = err { /* fine */ }
@@ -5184,7 +5183,8 @@ impl<SP: Deref> Channel<SP> where
51845183
fn send_htlc<F: Deref, L: Deref>(
51855184
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
51865185
onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
5187-
skimmed_fee_msat: Option<u64>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
5186+
skimmed_fee_msat: Option<u64>, blinding_point: Option<PublicKey>,
5187+
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
51885188
) -> Result<Option<msgs::UpdateAddHTLC>, ChannelError>
51895189
where F::Target: FeeEstimator, L::Target: Logger
51905190
{
@@ -5241,7 +5241,7 @@ impl<SP: Deref> Channel<SP> where
52415241
source,
52425242
onion_routing_packet,
52435243
skimmed_fee_msat,
5244-
blinding_point: None,
5244+
blinding_point,
52455245
});
52465246
return Ok(None);
52475247
}
@@ -5253,7 +5253,7 @@ impl<SP: Deref> Channel<SP> where
52535253
cltv_expiry,
52545254
state: OutboundHTLCState::LocalAnnounced(Box::new(onion_routing_packet.clone())),
52555255
source,
5256-
blinding_point: None,
5256+
blinding_point,
52575257
skimmed_fee_msat,
52585258
});
52595259

@@ -5265,7 +5265,7 @@ impl<SP: Deref> Channel<SP> where
52655265
cltv_expiry,
52665266
onion_routing_packet,
52675267
skimmed_fee_msat,
5268-
blinding_point: None,
5268+
blinding_point,
52695269
};
52705270
self.context.next_holder_htlc_id += 1;
52715271

@@ -5420,12 +5420,12 @@ impl<SP: Deref> Channel<SP> where
54205420
pub fn send_htlc_and_commit<F: Deref, L: Deref>(
54215421
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32,
54225422
source: HTLCSource, onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
5423-
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
5423+
blinding_point: Option<PublicKey>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
54245424
) -> Result<Option<ChannelMonitorUpdate>, ChannelError>
54255425
where F::Target: FeeEstimator, L::Target: Logger
54265426
{
54275427
let send_res = self.send_htlc(amount_msat, payment_hash, cltv_expiry, source,
5428-
onion_routing_packet, false, skimmed_fee_msat, fee_estimator, logger);
5428+
onion_routing_packet, false, skimmed_fee_msat, blinding_point, fee_estimator, logger);
54295429
if let Err(e) = &send_res { if let ChannelError::Ignore(_) = e {} else { debug_assert!(false, "Sending cannot trigger channel failure"); } }
54305430
match send_res? {
54315431
Some(_) => {

lightning/src/ln/channelmanager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,7 +3245,7 @@ where
32453245
session_priv: session_priv.clone(),
32463246
first_hop_htlc_msat: htlc_msat,
32473247
payment_id,
3248-
}, onion_packet, None, &self.fee_estimator, &self.logger);
3248+
}, onion_packet, None, None, &self.fee_estimator, &self.logger);
32493249
match break_chan_entry!(self, send_res, chan) {
32503250
Some(monitor_update) => {
32513251
match handle_new_monitor_update!(self, funding_txo, monitor_update, peer_state_lock, peer_state, per_peer_state, chan) {
@@ -3982,7 +3982,7 @@ where
39823982
});
39833983
if let Err(e) = chan.get_mut().queue_add_htlc(outgoing_amt_msat,
39843984
payment_hash, outgoing_cltv_value, htlc_source.clone(),
3985-
onion_packet, skimmed_fee_msat, &self.fee_estimator,
3985+
onion_packet, skimmed_fee_msat, None, &self.fee_estimator,
39863986
&self.logger)
39873987
{
39883988
if let ChannelError::Ignore(msg) = e {

lightning/src/ln/outbound_payment.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,10 +1075,6 @@ impl OutboundPayments {
10751075
path_errs.push(Err(APIError::InvalidRoute{err: "Path didn't go anywhere/had bogus size".to_owned()}));
10761076
continue 'path_check;
10771077
}
1078-
if path.blinded_tail.is_some() {
1079-
path_errs.push(Err(APIError::InvalidRoute{err: "Sending to blinded paths isn't supported yet".to_owned()}));
1080-
continue 'path_check;
1081-
}
10821078
let dest_hop_idx = if path.blinded_tail.is_some() && path.blinded_tail.as_ref().unwrap().hops.len() > 1 {
10831079
usize::max_value() } else { path.hops.len() - 1 };
10841080
for (idx, hop) in path.hops.iter().enumerate() {

0 commit comments

Comments
 (0)