From 78c3080537a0ed54bc3b105790b046f938379a2f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Thu, 19 May 2022 00:56:16 +0000 Subject: [PATCH] Rename HTLC `onchain_value_satoshis` to `htlc_value_satoshis` In `HTLCUpdate` and `OnchainEvent` tracking, we store the HTLC value (rounded down to whole satoshis). This is somewhat confusingly referred to as the `onchain_value_satoshis` even though it refers to the commitment transaction output value, not the value available on chain (which may have been reduced by an HTLC-Timeout/HTLC-Success transaction). --- lightning/src/chain/channelmonitor.rs | 20 ++++++++++---------- lightning/src/ln/channelmanager.rs | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 9c6030c4..7e721f63 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -166,11 +166,11 @@ pub struct HTLCUpdate { pub(crate) payment_hash: PaymentHash, pub(crate) payment_preimage: Option, pub(crate) source: HTLCSource, - pub(crate) onchain_value_satoshis: Option, + pub(crate) htlc_value_satoshis: Option, } impl_writeable_tlv_based!(HTLCUpdate, { (0, payment_hash, required), - (1, onchain_value_satoshis, option), + (1, htlc_value_satoshis, option), (2, source, required), (4, payment_preimage, option), }); @@ -357,7 +357,7 @@ enum OnchainEvent { HTLCUpdate { source: HTLCSource, payment_hash: PaymentHash, - onchain_value_satoshis: Option, + htlc_value_satoshis: Option, /// None in the second case, above, ie when there is no relevant output in the commitment /// transaction which appeared on chain. commitment_tx_output_idx: Option, @@ -423,7 +423,7 @@ impl MaybeReadable for OnchainEventEntry { impl_writeable_tlv_based_enum_upgradable!(OnchainEvent, (0, HTLCUpdate) => { (0, source, required), - (1, onchain_value_satoshis, option), + (1, htlc_value_satoshis, option), (2, payment_hash, required), (3, commitment_tx_output_idx, option), }, @@ -1689,7 +1689,7 @@ macro_rules! fail_unbroadcast_htlcs { event: OnchainEvent::HTLCUpdate { source: (**source).clone(), payment_hash: htlc.payment_hash.clone(), - onchain_value_satoshis: Some(htlc.amount_msat / 1000), + htlc_value_satoshis: Some(htlc.amount_msat / 1000), commitment_tx_output_idx: None, }, }; @@ -2523,7 +2523,7 @@ impl ChannelMonitorImpl { // Produce actionable events from on-chain events having reached their threshold. for entry in onchain_events_reaching_threshold_conf.drain(..) { match entry.event { - OnchainEvent::HTLCUpdate { ref source, payment_hash, onchain_value_satoshis, commitment_tx_output_idx } => { + OnchainEvent::HTLCUpdate { ref source, payment_hash, htlc_value_satoshis, commitment_tx_output_idx } => { // Check for duplicate HTLC resolutions. #[cfg(debug_assertions)] { @@ -2545,7 +2545,7 @@ impl ChannelMonitorImpl { payment_hash, payment_preimage: None, source: source.clone(), - onchain_value_satoshis, + htlc_value_satoshis, })); if let Some(idx) = commitment_tx_output_idx { self.htlcs_resolved_on_chain.push(IrrevocablyResolvedHTLC { commitment_tx_output_idx: idx, payment_preimage: None }); @@ -2887,7 +2887,7 @@ impl ChannelMonitorImpl { source, payment_preimage: Some(payment_preimage), payment_hash, - onchain_value_satoshis: Some(amount_msat / 1000), + htlc_value_satoshis: Some(amount_msat / 1000), })); } } else if offered_preimage_claim { @@ -2908,7 +2908,7 @@ impl ChannelMonitorImpl { source, payment_preimage: Some(payment_preimage), payment_hash, - onchain_value_satoshis: Some(amount_msat / 1000), + htlc_value_satoshis: Some(amount_msat / 1000), })); } } else { @@ -2926,7 +2926,7 @@ impl ChannelMonitorImpl { height, event: OnchainEvent::HTLCUpdate { source, payment_hash, - onchain_value_satoshis: Some(amount_msat / 1000), + htlc_value_satoshis: Some(amount_msat / 1000), commitment_tx_output_idx: Some(input.previous_output.vout), }, }; diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index cc5590f4..528447be 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -4841,7 +4841,7 @@ impl ChannelMana MonitorEvent::HTLCEvent(htlc_update) => { if let Some(preimage) = htlc_update.payment_preimage { log_trace!(self.logger, "Claiming HTLC with preimage {} from our monitor", log_bytes!(preimage.0)); - self.claim_funds_internal(self.channel_state.lock().unwrap(), htlc_update.source, preimage, htlc_update.onchain_value_satoshis.map(|v| v * 1000), true, funding_outpoint.to_channel_id()); + self.claim_funds_internal(self.channel_state.lock().unwrap(), htlc_update.source, preimage, htlc_update.htlc_value_satoshis.map(|v| v * 1000), true, funding_outpoint.to_channel_id()); } else { log_trace!(self.logger, "Failing HTLC with hash {} from our monitor", log_bytes!(htlc_update.payment_hash.0)); self.fail_htlc_backwards_internal(self.channel_state.lock().unwrap(), htlc_update.source, &htlc_update.payment_hash, HTLCFailReason::Reason { failure_code: 0x4000 | 8, data: Vec::new() }); -- 2.30.2