Skip to content

Commit 461fef6

Browse files
author
Antoine Riard
committed
-f Drop BumpStrategy
1 parent 4d565a9 commit 461fef6

File tree

3 files changed

+12
-53
lines changed

3 files changed

+12
-53
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use chain::chaininterface::{BroadcasterInterface, FeeEstimator};
4343
use chain::transaction::{OutPoint, TransactionData};
4444
use chain::keysinterface::{SpendableOutputDescriptor, StaticPaymentOutputDescriptor, DelayedPaymentOutputDescriptor, Sign, KeysInterface};
4545
use chain::onchaintx::OnchainTxHandler;
46-
use chain::onchain_utils::{BumpStrategy, CounterpartyHTLCOutput, HolderFundingOutput, HolderHTLCOutput, InputDescriptors, OnchainRequest, PackageMalleability, PackageSolvingData, PackageTemplate, RevokedOutput};
46+
use chain::onchain_utils::{CounterpartyHTLCOutput, HolderFundingOutput, HolderHTLCOutput, InputDescriptors, OnchainRequest, PackageMalleability, PackageSolvingData, PackageTemplate, RevokedOutput};
4747
use chain::Filter;
4848
use util::logger::Logger;
4949
use util::ser::{Readable, ReadableArgs, MaybeReadable, Writer, Writeable, U48};
@@ -1463,7 +1463,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
14631463
if outp.script_pubkey == revokeable_p2wsh {
14641464
let revk_outp = RevokedOutput::build(per_commitment_point, per_commitment_key, self.counterparty_tx_cache.counterparty_delayed_payment_base_key, self.counterparty_tx_cache.counterparty_htlc_base_key, InputDescriptors::RevokedOutput, outp.value, None, self.counterparty_tx_cache.on_counterparty_tx_csv);
14651465
let justice_package = PackageTemplate::build_package(commitment_txid, idx as u32, PackageSolvingData::RevokedOutput(revk_outp), PackageMalleability::Malleable);
1466-
claimable_outpoints.push(OnchainRequest { aggregation: true, bump_strategy: BumpStrategy::RBF, feerate_previous: 0, height_timer: None, absolute_timelock: height + self.counterparty_tx_cache.on_counterparty_tx_csv as u32, height_original: height, content: justice_package});
1466+
claimable_outpoints.push(OnchainRequest { aggregation: true, feerate_previous: 0, height_timer: None, absolute_timelock: height + self.counterparty_tx_cache.on_counterparty_tx_csv as u32, height_original: height, content: justice_package});
14671467
}
14681468
}
14691469

@@ -1477,7 +1477,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
14771477
}
14781478
let revk_outp = RevokedOutput::build(per_commitment_point, per_commitment_key, self.counterparty_tx_cache.counterparty_delayed_payment_base_key, self.counterparty_tx_cache.counterparty_htlc_base_key, if htlc.offered { InputDescriptors::RevokedOfferedHTLC } else { InputDescriptors::RevokedReceivedHTLC }, htlc.amount_msat / 1000, Some(htlc.clone()), self.counterparty_tx_cache.on_counterparty_tx_csv);
14791479
let justice_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, PackageSolvingData::RevokedOutput(revk_outp), PackageMalleability::Malleable);
1480-
claimable_outpoints.push(OnchainRequest { aggregation: true, bump_strategy: BumpStrategy::RBF, feerate_previous: 0, height_timer: None, absolute_timelock: htlc.cltv_expiry, height_original: height, content: justice_package});
1480+
claimable_outpoints.push(OnchainRequest { aggregation: true, feerate_previous: 0, height_timer: None, absolute_timelock: htlc.cltv_expiry, height_original: height, content: justice_package});
14811481
}
14821482
}
14831483
}
@@ -1627,7 +1627,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
16271627
if preimage.is_some() || !htlc.offered {
16281628
let counterparty_htlc_outp = CounterpartyHTLCOutput::build(*revocation_point, self.counterparty_tx_cache.counterparty_delayed_payment_base_key, self.counterparty_tx_cache.counterparty_htlc_base_key, preimage, htlc.clone());
16291629
let counterparty_package = PackageTemplate::build_package(commitment_txid, transaction_output_index, PackageSolvingData::CounterpartyHTLCOutput(counterparty_htlc_outp), PackageMalleability::Malleable);
1630-
claimable_outpoints.push(OnchainRequest { aggregation: if !htlc.offered { false } else { true }, bump_strategy: BumpStrategy::RBF, feerate_previous: 0, height_timer: None, absolute_timelock: htlc.cltv_expiry, height_original: /*XXX(ariard) Option<height> */ 0, content: counterparty_package });
1630+
claimable_outpoints.push(OnchainRequest { aggregation: if !htlc.offered { false } else { true }, feerate_previous: 0, height_timer: None, absolute_timelock: htlc.cltv_expiry, height_original: /*XXX(ariard) Option<height> */ 0, content: counterparty_package });
16311631
}
16321632
}
16331633
}
@@ -1660,7 +1660,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
16601660
log_trace!(logger, "Counterparty HTLC broadcast {}:{}", htlc_txid, 0);
16611661
let revk_outp = RevokedOutput::build(per_commitment_point, per_commitment_key, self.counterparty_tx_cache.counterparty_delayed_payment_base_key, self.counterparty_tx_cache.counterparty_htlc_base_key, InputDescriptors::RevokedOutput, tx.output[0].value, None, self.counterparty_tx_cache.on_counterparty_tx_csv);
16621662
let justice_package = PackageTemplate::build_package(htlc_txid, 0, PackageSolvingData::RevokedOutput(revk_outp), PackageMalleability::Malleable);
1663-
let claimable_outpoints = vec!(OnchainRequest { aggregation: true, bump_strategy: BumpStrategy::RBF, feerate_previous: 0, height_timer: None, absolute_timelock: height + self.counterparty_tx_cache.on_counterparty_tx_csv as u32, height_original: height, content: justice_package });
1663+
let claimable_outpoints = vec!(OnchainRequest { aggregation: true, feerate_previous: 0, height_timer: None, absolute_timelock: height + self.counterparty_tx_cache.on_counterparty_tx_csv as u32, height_original: height, content: justice_package });
16641664
let outputs = vec![(0, tx.output[0].clone())];
16651665
(claimable_outpoints, Some((htlc_txid, outputs)))
16661666
}
@@ -1685,7 +1685,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
16851685
}
16861686
} else { None }, htlc.amount_msat);
16871687
let htlc_package = PackageTemplate::build_package(holder_tx.txid, transaction_output_index, PackageSolvingData::HolderHTLCOutput(htlc_output), PackageMalleability::Untractable);
1688-
claim_requests.push(OnchainRequest { aggregation: false, bump_strategy: BumpStrategy::CPFP, feerate_previous: 0, height_timer: None, absolute_timelock: height, height_original: height, content: htlc_package });
1688+
claim_requests.push(OnchainRequest { aggregation: false, feerate_previous: 0, height_timer: None, absolute_timelock: height, height_original: height, content: htlc_package });
16891689
}
16901690
}
16911691

@@ -1894,7 +1894,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
18941894
if should_broadcast {
18951895
let funding_outp = HolderFundingOutput::build(self.funding_redeemscript.clone());
18961896
let commitment_package = PackageTemplate::build_package(self.funding_info.0.txid.clone(), self.funding_info.0.index as u32, PackageSolvingData::HolderFundingOutput(funding_outp), PackageMalleability::Untractable);
1897-
claimable_outpoints.push(OnchainRequest { aggregation: false, bump_strategy: BumpStrategy::CPFP, feerate_previous: 0, height_timer: None, absolute_timelock: height, height_original: height, content: commitment_package });
1897+
claimable_outpoints.push(OnchainRequest { aggregation: false, feerate_previous: 0, height_timer: None, absolute_timelock: height, height_original: height, content: commitment_package });
18981898
}
18991899
if should_broadcast {
19001900
self.pending_monitor_events.push(MonitorEvent::CommitmentTxBroadcasted(self.funding_info.0));

lightning/src/chain/onchain_utils.rs

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ pub(crate) struct PackageTemplate {
482482
}
483483

484484
impl PackageTemplate {
485+
pub(crate) fn is_malleable(&self) -> bool {
486+
self.malleability == PackageMalleability::Malleable
487+
}
485488
pub(crate) fn outpoints(&self) -> Vec<&BitcoinOutPoint> {
486489
let mut outpoints = Vec::with_capacity(self.inputs.len());
487490
for (o, _) in self.inputs.iter() {
@@ -638,43 +641,6 @@ impl Readable for PackageTemplate {
638641
}
639642
}
640643

641-
/// BumpStrategy is a basic enum to encode a fee-committing strategy. We
642-
/// may extend it in the future with other stategies like BYOF-input.
643-
#[derive(PartialEq, Clone)]
644-
pub(crate) enum BumpStrategy {
645-
RBF,
646-
CPFP
647-
}
648-
649-
impl Writeable for BumpStrategy {
650-
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
651-
match self {
652-
BumpStrategy::RBF => {
653-
writer.write_all(&[0; 1])?;
654-
},
655-
BumpStrategy::CPFP => {
656-
writer.write_all(&[1; 1])?;
657-
}
658-
}
659-
Ok(())
660-
}
661-
}
662-
663-
impl Readable for BumpStrategy {
664-
fn read<R: ::std::io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
665-
let bump_strategy = match <u8 as Readable>::read(reader)? {
666-
0 => {
667-
BumpStrategy::RBF
668-
},
669-
1 => {
670-
BumpStrategy::CPFP
671-
},
672-
_ => return Err(DecodeError::UnknownVersion),
673-
};
674-
Ok(bump_strategy)
675-
}
676-
}
677-
678644
/// A structure to describe a claim content and its metadatas which is generated
679645
/// by ChannelMonitor and used by OnchainTxHandler to generate feerate-competive
680646
/// transactions.
@@ -700,10 +666,6 @@ pub struct OnchainRequest {
700666
// of a sooner-HTLC could be swallowed by the highest nLocktime of the HTLC set.
701667
// Do simplify we mark them as non-aggregable.
702668
pub(crate) aggregation: bool,
703-
// Content may lockdown with counter-signature of our counterparty
704-
// or fully-malleable by our own. Depending on this bumping strategy
705-
// must be adapted.
706-
pub(crate) bump_strategy: BumpStrategy,
707669
// Based feerate of previous broadcast. If resources available (either
708670
// output value or utxo bumping).
709671
pub(crate) feerate_previous: u64,
@@ -740,7 +702,6 @@ impl OnchainRequest {
740702
impl Writeable for OnchainRequest {
741703
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
742704
self.aggregation.write(writer)?;
743-
self.bump_strategy.write(writer)?;
744705
self.feerate_previous.write(writer)?;
745706
self.height_timer.write(writer)?;
746707
self.absolute_timelock.write(writer)?;
@@ -754,7 +715,6 @@ impl Writeable for OnchainRequest {
754715
impl Readable for OnchainRequest {
755716
fn read<R: ::std::io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
756717
let aggregation = Readable::read(reader)?;
757-
let bump_strategy = Readable::read(reader)?;
758718
let feerate_previous = Readable::read(reader)?;
759719
let height_timer = Readable::read(reader)?;
760720
let absolute_timelock = Readable::read(reader)?;
@@ -763,7 +723,6 @@ impl Readable for OnchainRequest {
763723

764724
Ok(OnchainRequest {
765725
aggregation,
766-
bump_strategy,
767726
feerate_previous,
768727
height_timer,
769728
absolute_timelock,

lightning/src/chain/onchaintx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use ln::chan_utils::{ChannelTransactionParameters, HolderCommitmentTransaction};
2727
use chain::chaininterface::{FeeEstimator, BroadcasterInterface};
2828
use chain::channelmonitor::{ANTI_REORG_DELAY, CLTV_SHARED_CLAIM_BUFFER};
2929
use chain::keysinterface::{Sign, KeysInterface};
30-
use chain::onchain_utils::{OnchainRequest, PackageTemplate, BumpStrategy};
30+
use chain::onchain_utils::{OnchainRequest, PackageTemplate};
3131
use chain::onchain_utils;
3232
use util::logger::Logger;
3333
use util::ser::{Readable, ReadableArgs, Writer, Writeable, VecWriter};
@@ -334,7 +334,7 @@ impl<ChannelSigner: Sign> OnchainTxHandler<ChannelSigner> {
334334
// didn't receive confirmation of it before, or not enough reorg-safe depth on top of it).
335335
let new_timer = Some(Self::get_height_timer(height, cached_request.absolute_timelock));
336336
let amt = cached_request.content.package_amount();
337-
if cached_request.bump_strategy == BumpStrategy::RBF {
337+
if cached_request.content.is_malleable() {
338338
let predicted_weight = cached_request.content.package_weight(&self.destination_script);
339339
if let Some((output_value, new_feerate)) = onchain_utils::compute_output_value(predicted_weight, amt, cached_request.feerate_previous, fee_estimator, logger) {
340340
assert!(new_feerate != 0);

0 commit comments

Comments
 (0)