@@ -3055,8 +3055,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3055
3055
// handling this case better and maybe fulfilling some of the HTLCs while attempting
3056
3056
// to rebalance channels.
3057
3057
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
+ {
3060
3065
Ok(update_add_msg_option) => update_add_htlcs.push(update_add_msg_option.unwrap()),
3061
3066
Err(e) => {
3062
3067
match e {
@@ -3698,7 +3703,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
3698
3703
payment_hash: htlc.payment_hash,
3699
3704
cltv_expiry: htlc.cltv_expiry,
3700
3705
onion_routing_packet: (**onion_packet).clone(),
3701
- skimmed_fee_msat: None ,
3706
+ skimmed_fee_msat: htlc.skimmed_fee_msat ,
3702
3707
});
3703
3708
}
3704
3709
}
@@ -5046,11 +5051,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5046
5051
/// commitment update.
5047
5052
///
5048
5053
/// `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 {
5052
5058
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)
5054
5061
.map(|msg_opt| assert!(msg_opt.is_none(), "We forced holding cell?"))
5055
5062
.map_err(|err| {
5056
5063
if let ChannelError::Ignore(_) = err { /* fine */ }
@@ -5075,9 +5082,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5075
5082
/// on this [`Channel`] if `force_holding_cell` is false.
5076
5083
///
5077
5084
/// `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 {
5081
5090
if (self.context.channel_state & (ChannelState::ChannelReady as u32 | BOTH_SIDES_SHUTDOWN_MASK)) != (ChannelState::ChannelReady as u32) {
5082
5091
return Err(ChannelError::Ignore("Cannot send HTLC until channel is fully established and we haven't started shutting down".to_owned()));
5083
5092
}
@@ -5129,7 +5138,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5129
5138
cltv_expiry,
5130
5139
source,
5131
5140
onion_routing_packet,
5132
- skimmed_fee_msat: None ,
5141
+ skimmed_fee_msat,
5133
5142
});
5134
5143
return Ok(None);
5135
5144
}
@@ -5141,7 +5150,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5141
5150
cltv_expiry,
5142
5151
state: OutboundHTLCState::LocalAnnounced(Box::new(onion_routing_packet.clone())),
5143
5152
source,
5144
- skimmed_fee_msat: None ,
5153
+ skimmed_fee_msat,
5145
5154
});
5146
5155
5147
5156
let res = msgs::UpdateAddHTLC {
@@ -5151,7 +5160,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5151
5160
payment_hash,
5152
5161
cltv_expiry,
5153
5162
onion_routing_packet,
5154
- skimmed_fee_msat: None ,
5163
+ skimmed_fee_msat,
5155
5164
};
5156
5165
self.context.next_holder_htlc_id += 1;
5157
5166
@@ -5290,8 +5299,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
5290
5299
///
5291
5300
/// Shorthand for calling [`Self::send_htlc`] followed by a commitment update, see docs on
5292
5301
/// [`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);
5295
5308
if let Err(e) = &send_res { if let ChannelError::Ignore(_) = e {} else { debug_assert!(false, "Sending cannot trigger channel failure"); } }
5296
5309
match send_res? {
5297
5310
Some(_) => {
0 commit comments