@@ -2971,8 +2971,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
2971
2971
// handling this case better and maybe fulfilling some of the HTLCs while attempting
2972
2972
// to rebalance channels.
2973
2973
match &htlc_update {
2974
- &HTLCUpdateAwaitingACK::AddHTLC {amount_msat, cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet, ..} => {
2975
- match self.send_htlc(amount_msat, *payment_hash, cltv_expiry, source.clone(), onion_routing_packet.clone(), false, logger) {
2974
+ &HTLCUpdateAwaitingACK::AddHTLC {
2975
+ amount_msat, cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet,
2976
+ skimmed_fee_msat, ..
2977
+ } => {
2978
+ match self.send_htlc(amount_msat, *payment_hash, cltv_expiry, source.clone(),
2979
+ onion_routing_packet.clone(), false, skimmed_fee_msat, logger)
2980
+ {
2976
2981
Ok(update_add_msg_option) => update_add_htlcs.push(update_add_msg_option.unwrap()),
2977
2982
Err(e) => {
2978
2983
match e {
@@ -3614,7 +3619,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3614
3619
payment_hash: htlc.payment_hash,
3615
3620
cltv_expiry: htlc.cltv_expiry,
3616
3621
onion_routing_packet: (**onion_packet).clone(),
3617
- skimmed_fee_msat: None ,
3622
+ skimmed_fee_msat: htlc.skimmed_fee_msat ,
3618
3623
});
3619
3624
}
3620
3625
}
@@ -4962,11 +4967,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4962
4967
/// commitment update.
4963
4968
///
4964
4969
/// `Err`s will only be [`ChannelError::Ignore`].
4965
- pub fn queue_add_htlc<L: Deref>(&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
4966
- onion_routing_packet: msgs::OnionPacket, logger: &L)
4967
- -> Result<(), ChannelError> where L::Target: Logger {
4970
+ pub fn queue_add_htlc<L: Deref>(
4971
+ &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
4972
+ onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>, logger: &L
4973
+ ) -> Result<(), ChannelError> where L::Target: Logger {
4968
4974
self
4969
- .send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true, logger)
4975
+ .send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true,
4976
+ skimmed_fee_msat, logger)
4970
4977
.map(|msg_opt| assert!(msg_opt.is_none(), "We forced holding cell?"))
4971
4978
.map_err(|err| {
4972
4979
if let ChannelError::Ignore(_) = err { /* fine */ }
@@ -4991,9 +4998,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
4991
4998
/// on this [`Channel`] if `force_holding_cell` is false.
4992
4999
///
4993
5000
/// `Err`s will only be [`ChannelError::Ignore`].
4994
- fn send_htlc<L: Deref>(&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
4995
- onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool, logger: &L)
4996
- -> Result<Option<msgs::UpdateAddHTLC>, ChannelError> where L::Target: Logger {
5001
+ fn send_htlc<L: Deref>(
5002
+ &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
5003
+ onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
5004
+ skimmed_fee_msat: Option<u64>, logger: &L
5005
+ ) -> Result<Option<msgs::UpdateAddHTLC>, ChannelError> where L::Target: Logger {
4997
5006
if (self.context.channel_state & (ChannelState::ChannelReady as u32 | BOTH_SIDES_SHUTDOWN_MASK)) != (ChannelState::ChannelReady as u32) {
4998
5007
return Err(ChannelError::Ignore("Cannot send HTLC until channel is fully established and we haven't started shutting down".to_owned()));
4999
5008
}
@@ -5045,7 +5054,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5045
5054
cltv_expiry,
5046
5055
source,
5047
5056
onion_routing_packet,
5048
- skimmed_fee_msat: None ,
5057
+ skimmed_fee_msat,
5049
5058
});
5050
5059
return Ok(None);
5051
5060
}
@@ -5057,7 +5066,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5057
5066
cltv_expiry,
5058
5067
state: OutboundHTLCState::LocalAnnounced(Box::new(onion_routing_packet.clone())),
5059
5068
source,
5060
- skimmed_fee_msat: None ,
5069
+ skimmed_fee_msat,
5061
5070
});
5062
5071
5063
5072
let res = msgs::UpdateAddHTLC {
@@ -5067,7 +5076,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5067
5076
payment_hash,
5068
5077
cltv_expiry,
5069
5078
onion_routing_packet,
5070
- skimmed_fee_msat: None ,
5079
+ skimmed_fee_msat,
5071
5080
};
5072
5081
self.context.next_holder_htlc_id += 1;
5073
5082
@@ -5206,8 +5215,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5206
5215
///
5207
5216
/// Shorthand for calling [`Self::send_htlc`] followed by a commitment update, see docs on
5208
5217
/// [`Self::send_htlc`] and [`Self::build_commitment_no_state_update`] for more info.
5209
- pub fn send_htlc_and_commit<L: Deref>(&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource, onion_routing_packet: msgs::OnionPacket, logger: &L) -> Result<Option<&ChannelMonitorUpdate>, ChannelError> where L::Target: Logger {
5210
- let send_res = self.send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, false, logger);
5218
+ pub fn send_htlc_and_commit<L: Deref>(
5219
+ &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
5220
+ onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>, logger: &L
5221
+ ) -> Result<Option<&ChannelMonitorUpdate>, ChannelError> where L::Target: Logger {
5222
+ let send_res = self.send_htlc(amount_msat, payment_hash, cltv_expiry, source,
5223
+ onion_routing_packet, false, skimmed_fee_msat, logger);
5211
5224
if let Err(e) = &send_res { if let ChannelError::Ignore(_) = e {} else { debug_assert!(false, "Sending cannot trigger channel failure"); } }
5212
5225
match send_res? {
5213
5226
Some(_) => {
0 commit comments