@@ -3055,8 +3055,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
30553055 // handling this case better and maybe fulfilling some of the HTLCs while attempting
30563056 // to rebalance channels.
30573057 match &htlc_update {
3058- &HTLCUpdateAwaitingACK::AddHTLC {amount_msat, cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet, ..} => {
3059- match self.send_htlc(amount_msat, *payment_hash, cltv_expiry, source.clone(), onion_routing_packet.clone(), false, logger) {
3058+ &HTLCUpdateAwaitingACK::AddHTLC {
3059+ amount_msat, cltv_expiry, ref payment_hash, ref source, ref onion_routing_packet,
3060+ skimmed_fee_msat, ..
3061+ } => {
3062+ match self.send_htlc(amount_msat, *payment_hash, cltv_expiry, source.clone(),
3063+ onion_routing_packet.clone(), false, skimmed_fee_msat, logger)
3064+ {
30603065 Ok(update_add_msg_option) => update_add_htlcs.push(update_add_msg_option.unwrap()),
30613066 Err(e) => {
30623067 match e {
@@ -3698,7 +3703,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
36983703 payment_hash: htlc.payment_hash,
36993704 cltv_expiry: htlc.cltv_expiry,
37003705 onion_routing_packet: (**onion_packet).clone(),
3701- skimmed_fee_msat: None ,
3706+ skimmed_fee_msat: htlc.skimmed_fee_msat ,
37023707 });
37033708 }
37043709 }
@@ -5046,11 +5051,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
50465051 /// commitment update.
50475052 ///
50485053 /// `Err`s will only be [`ChannelError::Ignore`].
5049- pub fn queue_add_htlc<L: Deref>(&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
5050- onion_routing_packet: msgs::OnionPacket, logger: &L)
5051- -> Result<(), ChannelError> where L::Target: Logger {
5054+ pub fn queue_add_htlc<L: Deref>(
5055+ &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
5056+ onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>, logger: &L
5057+ ) -> Result<(), ChannelError> where L::Target: Logger {
50525058 self
5053- .send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true, logger)
5059+ .send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, true,
5060+ skimmed_fee_msat, logger)
50545061 .map(|msg_opt| assert!(msg_opt.is_none(), "We forced holding cell?"))
50555062 .map_err(|err| {
50565063 if let ChannelError::Ignore(_) = err { /* fine */ }
@@ -5075,9 +5082,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
50755082 /// on this [`Channel`] if `force_holding_cell` is false.
50765083 ///
50775084 /// `Err`s will only be [`ChannelError::Ignore`].
5078- fn send_htlc<L: Deref>(&mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
5079- onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool, logger: &L)
5080- -> Result<Option<msgs::UpdateAddHTLC>, ChannelError> where L::Target: Logger {
5085+ fn send_htlc<L: Deref>(
5086+ &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
5087+ onion_routing_packet: msgs::OnionPacket, mut force_holding_cell: bool,
5088+ skimmed_fee_msat: Option<u64>, logger: &L
5089+ ) -> Result<Option<msgs::UpdateAddHTLC>, ChannelError> where L::Target: Logger {
50815090 if (self.context.channel_state & (ChannelState::ChannelReady as u32 | BOTH_SIDES_SHUTDOWN_MASK)) != (ChannelState::ChannelReady as u32) {
50825091 return Err(ChannelError::Ignore("Cannot send HTLC until channel is fully established and we haven't started shutting down".to_owned()));
50835092 }
@@ -5129,7 +5138,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
51295138 cltv_expiry,
51305139 source,
51315140 onion_routing_packet,
5132- skimmed_fee_msat: None ,
5141+ skimmed_fee_msat,
51335142 });
51345143 return Ok(None);
51355144 }
@@ -5141,7 +5150,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
51415150 cltv_expiry,
51425151 state: OutboundHTLCState::LocalAnnounced(Box::new(onion_routing_packet.clone())),
51435152 source,
5144- skimmed_fee_msat: None ,
5153+ skimmed_fee_msat,
51455154 });
51465155
51475156 let res = msgs::UpdateAddHTLC {
@@ -5151,7 +5160,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
51515160 payment_hash,
51525161 cltv_expiry,
51535162 onion_routing_packet,
5154- skimmed_fee_msat: None ,
5163+ skimmed_fee_msat,
51555164 };
51565165 self.context.next_holder_htlc_id += 1;
51575166
@@ -5290,8 +5299,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
52905299 ///
52915300 /// Shorthand for calling [`Self::send_htlc`] followed by a commitment update, see docs on
52925301 /// [`Self::send_htlc`] and [`Self::build_commitment_no_state_update`] for more info.
5293- 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 {
5294- let send_res = self.send_htlc(amount_msat, payment_hash, cltv_expiry, source, onion_routing_packet, false, logger);
5302+ pub fn send_htlc_and_commit<L: Deref>(
5303+ &mut self, amount_msat: u64, payment_hash: PaymentHash, cltv_expiry: u32, source: HTLCSource,
5304+ onion_routing_packet: msgs::OnionPacket, skimmed_fee_msat: Option<u64>, logger: &L
5305+ ) -> Result<Option<&ChannelMonitorUpdate>, ChannelError> where L::Target: Logger {
5306+ let send_res = self.send_htlc(amount_msat, payment_hash, cltv_expiry, source,
5307+ onion_routing_packet, false, skimmed_fee_msat, logger);
52955308 if let Err(e) = &send_res { if let ChannelError::Ignore(_) = e {} else { debug_assert!(false, "Sending cannot trigger channel failure"); } }
52965309 match send_res? {
52975310 Some(_) => {
0 commit comments