Merge pull request #2245 from TheBlueMatt/2023-04-ping-count-overflow
[rust-lightning] / lightning / src / chain / package.rs
index 5974a65d2a3e7527102c57cd8781a66d4a4b21e6..7ea61dc244976c2257087b91ade479d5aa758832 100644 (file)
@@ -460,13 +460,13 @@ impl PackageSolvingData {
                }
        }
        fn absolute_tx_timelock(&self, current_height: u32) -> u32 {
-               // We use `current_height + 1` as our default locktime to discourage fee sniping and because
+               // We use `current_height` as our default locktime to discourage fee sniping and because
                // transactions with it always propagate.
                let absolute_timelock = match self {
-                       PackageSolvingData::RevokedOutput(_) => current_height + 1,
-                       PackageSolvingData::RevokedHTLCOutput(_) => current_height + 1,
-                       PackageSolvingData::CounterpartyOfferedHTLCOutput(_) => current_height + 1,
-                       PackageSolvingData::CounterpartyReceivedHTLCOutput(ref outp) => cmp::max(outp.htlc.cltv_expiry, current_height + 1),
+                       PackageSolvingData::RevokedOutput(_) => current_height,
+                       PackageSolvingData::RevokedHTLCOutput(_) => current_height,
+                       PackageSolvingData::CounterpartyOfferedHTLCOutput(_) => current_height,
+                       PackageSolvingData::CounterpartyReceivedHTLCOutput(ref outp) => cmp::max(outp.htlc.cltv_expiry, current_height),
                        // HTLC timeout/success transactions rely on a fixed timelock due to the counterparty's
                        // signature.
                        PackageSolvingData::HolderHTLCOutput(ref outp) => {
@@ -475,7 +475,7 @@ impl PackageSolvingData {
                                }
                                outp.cltv_expiry
                        },
-                       PackageSolvingData::HolderFundingOutput(_) => current_height + 1,
+                       PackageSolvingData::HolderFundingOutput(_) => current_height,
                };
                absolute_timelock
        }
@@ -554,6 +554,9 @@ impl PackageTemplate {
        pub(crate) fn aggregable(&self) -> bool {
                self.aggregable
        }
+       pub(crate) fn previous_feerate(&self) -> u64 {
+               self.feerate_previous
+       }
        pub(crate) fn set_feerate(&mut self, new_feerate: u64) {
                self.feerate_previous = new_feerate;
        }