Rename HTLC `onchain_value_satoshis` to `htlc_value_satoshis`
authorMatt Corallo <git@bluematt.me>
Thu, 19 May 2022 00:56:16 +0000 (00:56 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 26 May 2022 00:50:30 +0000 (00:50 +0000)
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
lightning/src/ln/channelmanager.rs

index 9c6030c4131baca56d530efd7537184a6cc24545..7e721f6307160b8a9d7db20d552932b0789e6875 100644 (file)
@@ -166,11 +166,11 @@ pub struct HTLCUpdate {
        pub(crate) payment_hash: PaymentHash,
        pub(crate) payment_preimage: Option<PaymentPreimage>,
        pub(crate) source: HTLCSource,
-       pub(crate) onchain_value_satoshis: Option<u64>,
+       pub(crate) htlc_value_satoshis: Option<u64>,
 }
 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<u64>,
+               htlc_value_satoshis: Option<u64>,
                /// 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<u32>,
@@ -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<Signer: Sign> ChannelMonitorImpl<Signer> {
                // 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<Signer: Sign> ChannelMonitorImpl<Signer> {
                                                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<Signer: Sign> ChannelMonitorImpl<Signer> {
                                                        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<Signer: Sign> ChannelMonitorImpl<Signer> {
                                                        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<Signer: Sign> ChannelMonitorImpl<Signer> {
                                                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),
                                                },
                                        };
index cc5590f41f040c2dad067e91d60ba9b77b41f53f..528447be364b39fa692727d0a327856715855322 100644 (file)
@@ -4841,7 +4841,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> 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() });