Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lightning/src/chain/chaininterface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@

use core::{cmp, ops::Deref};

use crate::ln::funding::FundingContribution;
use crate::ln::types::ChannelId;
use crate::prelude::*;

use bitcoin::hash_types::Txid;
use bitcoin::secp256k1::PublicKey;
use bitcoin::transaction::Transaction;

/// Represents the class of transaction being broadcast.
///
/// This is used to provide context about the type of transaction being broadcast, which may be
/// useful for logging, filtering, or prioritization purposes.
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum TransactionType {
/// A funding transaction establishing a new channel.
///
Expand Down Expand Up @@ -114,6 +116,12 @@ pub enum TransactionType {
counterparty_node_id: PublicKey,
/// The ID of the channel being spliced.
channel_id: ChannelId,
/// The local node's contribution to this splice/RBF round, or `None` if we did not
/// contribute (e.g., a pure acceptor with zero value added).
contribution: Option<FundingContribution>,
/// For an RBF replacement, the txid of the prior negotiated splice candidate being
/// replaced. `None` for the first splice attempt.
replaced_txid: Option<Txid>,
},
}

Expand Down
7 changes: 7 additions & 0 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9358,9 +9358,16 @@ where
);
}

let replaced_txid =
pending_splice.negotiated_candidates.len().checked_sub(2).and_then(|idx| {
pending_splice.negotiated_candidates[idx].get_funding_txid()
});
let contribution = pending_splice.contributions.last().cloned();
let tx_type = TransactionType::Splice {
counterparty_node_id: self.context.counterparty_node_id,
channel_id: self.context.channel_id,
contribution,
replaced_txid,
};
funding_tx_signed.funding_tx = Some((funding_tx, tx_type));
funding_tx_signed.splice_negotiated = Some(splice_negotiated);
Expand Down
25 changes: 21 additions & 4 deletions lightning/src/ln/funding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,6 @@ impl_writeable_tlv_based!(FundingContribution, {
});

impl FundingContribution {
pub(super) fn feerate(&self) -> FeeRate {
self.feerate
}

pub(super) fn is_splice(&self) -> bool {
self.is_splice
}
Expand All @@ -731,6 +727,16 @@ impl FundingContribution {
self.value_added
}

/// Returns the estimated on-chain fee this contribution is responsible for paying.
pub fn estimated_fee(&self) -> Amount {
self.estimated_fee
}

/// Returns the inputs included in this contribution.
pub fn inputs(&self) -> &[FundingTxInput] {
&self.inputs
}

/// Returns the outputs (e.g., withdrawal destinations) included in this contribution.
///
/// This does not include the change output; see [`FundingContribution::change_output`].
Expand All @@ -746,6 +752,17 @@ impl FundingContribution {
self.change_output.as_ref()
}

/// Returns the fee rate used to select `inputs` (the minimum feerate).
pub fn feerate(&self) -> FeeRate {
self.feerate
}

/// Returns the maximum fee rate this contribution will accept as acceptor before rejecting
/// the splice.
pub fn max_feerate(&self) -> FeeRate {
self.max_feerate
}

pub(super) fn into_tx_parts(self) -> (Vec<FundingTxInput>, Vec<TxOut>) {
let FundingContribution { inputs, mut outputs, change_output, .. } = self;

Expand Down
Loading
Loading