Parameterize Channel's htlc forward method by outbound blinding point

Used in the next commit to set the update_add blinding point on HTLC forward.
This commit is contained in:
Valentine Wallace 2023-10-26 14:18:18 -04:00
parent 21ae9fdd69
commit a2b2fb0ceb
No known key found for this signature in database
GPG key ID: FD3E106A2CE099B4
2 changed files with 15 additions and 13 deletions

View file

@ -3358,11 +3358,12 @@ impl<SP: Deref> Channel<SP> where
match &htlc_update {
&HTLCUpdateAwaitingACK::AddHTLC {
amount_msat, cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet,
skimmed_fee_msat, ..
skimmed_fee_msat, blinding_point, ..
} => {
match self.send_htlc(amount_msat, *payment_hash, cltv_expiry, source.clone(),
onion_routing_packet.clone(), false, skimmed_fee_msat, fee_estimator, logger)
{
match self.send_htlc(
amount_msat, *payment_hash, cltv_expiry, source.clone(), onion_routing_packet.clone(),
false, skimmed_fee_msat, blinding_point, fee_estimator, logger
) {
Ok(_) => update_add_count += 1,
Err(e) => {
match e {
@ -4078,7 +4079,7 @@ impl<SP: Deref> Channel<SP> where
cltv_expiry: htlc.cltv_expiry,
onion_routing_packet: (**onion_packet).clone(),
skimmed_fee_msat: htlc.skimmed_fee_msat,
blinding_point: None,
blinding_point: htlc.blinding_point,
});
}
}
@ -5507,13 +5508,13 @@ impl<SP: Deref> Channel<SP> where
pub fn queue_add_htlc<F: Deref, L: Deref>(
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>,
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
blinding_point: Option<PublicKey>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
) -> Result<(), ChannelError>
where F::Target: FeeEstimator, L::Target: Logger
{
self
.send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true,
skimmed_fee_msat, fee_estimator, logger)
skimmed_fee_msat, blinding_point, fee_estimator, logger)
.map(|msg_opt| assert!(msg_opt.is_none(), "We forced holding cell?"))
.map_err(|err| {
if let ChannelError::Ignore(_) = err { /* fine */ }
@ -5541,7 +5542,8 @@ impl<SP: Deref> Channel<SP> where
fn send_htlc<F: Deref, L: Deref>(
&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
skimmed_fee_msat: Option<u64>, fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
skimmed_fee_msat: Option<u64>, blinding_point: Option<PublicKey>,
fee_estimator: &LowerBoundedFeeEstimator<F>, logger: &L
) -> Result<Option<msgs::UpdateAddHTLC>, ChannelError>
where F::Target: FeeEstimator, L::Target: Logger
{
@ -5598,7 +5600,7 @@ impl<SP: Deref> Channel<SP> where
source,
onion_routing_packet,
skimmed_fee_msat,
blinding_point: None,
blinding_point,
});
return Ok(None);
}
@ -5610,7 +5612,7 @@ impl<SP: Deref> Channel<SP> where
cltv_expiry,
state: OutboundHTLCState::LocalAnnounced(Box::new(onion_routing_packet.clone())),
source,
blinding_point: None,
blinding_point,
skimmed_fee_msat,
});
@ -5622,7 +5624,7 @@ impl<SP: Deref> Channel<SP> where
cltv_expiry,
onion_routing_packet,
skimmed_fee_msat,
blinding_point: None,
blinding_point,
};
self.context.next_holder_htlc_id += 1;
@ -5785,7 +5787,7 @@ impl<SP: Deref> Channel<SP> where
where F::Target: FeeEstimator, L::Target: Logger
{
let send_res = self.send_htlc(amount_msat, payment_hash, cltv_expiry, source,
onion_routing_packet, false, skimmed_fee_msat, fee_estimator, logger);
onion_routing_packet, false, skimmed_fee_msat, None, fee_estimator, logger);
if let Err(e) = &send_res { if let ChannelError::Ignore(_) = e {} else { debug_assert!(false, "Sending cannot trigger channel failure"); } }
match send_res? {
Some(_) => {

View file

@ -4264,7 +4264,7 @@ where
});
if let Err(e) = chan.queue_add_htlc(outgoing_amt_msat,
payment_hash, outgoing_cltv_value, htlc_source.clone(),
onion_packet, skimmed_fee_msat, &self.fee_estimator,
onion_packet, skimmed_fee_msat, None, &self.fee_estimator,
&self.logger)
{
if let ChannelError::Ignore(msg) = e {