Merged
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
12 changes: 5 additions & 7 deletions lightning/src/ln/channel.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,7 @@ use crate::ln::channelmanager::{
PendingHTLCStatus, RAACommitmentOrder, SentHTLCId, TrustedChannelFeatures, BREAKDOWN_TIMEOUT,
MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput,
};
use crate::ln::funding::{FeeRateAdjustmentError, FundingContribution, FundingTemplate};
use crate::ln::interactivetxs::{
AbortReason, HandleTxCompleteValue, InteractiveTxConstructor, InteractiveTxConstructorArgs,
InteractiveTxMessageSend, InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput,
Expand DownExpand Up@@ -87,7 +85,7 @@ use crate::util::errors::APIError;
use crate::util::logger::{Level as LoggerLevel, Logger, Record, WithContext};
use crate::util::scid_utils::{block_from_scid, scid_from_parts};
use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, Writeable, Writer};
use crate::util::wallet_utils::Input;
use crate::util::wallet_utils::{ConfirmedUtxo, Input};
use crate::{impl_readable_for_vec, impl_writeable_for_vec};

use alloc::collections::{btree_map, BTreeMap};
Expand DownExpand Up@@ -3100,7 +3098,7 @@ impl FundingNegotiation {
funding: FundingScope, context: &ChannelContext<SP>, entropy_source: &ES,
holder_node_id: &PublicKey, our_funding_contribution: SignedAmount,
prev_funding_input: SharedOwnedInput, locktime: u32, feerate_sat_per_1000_weight: u32,
our_funding_inputs: Vec<FundingTxInput>, our_funding_outputs: Vec<TxOut>,
our_funding_inputs: Vec<ConfirmedUtxo>, our_funding_outputs: Vec<TxOut>,
) -> FundingNegotiation {
let funding_negotiation_context = FundingNegotiationContext {
is_initiator: false,
Expand DownExpand Up@@ -6905,7 +6903,7 @@ pub(super) struct FundingNegotiationContext {
pub shared_funding_input: Option<SharedOwnedInput>,
/// The funding inputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_inputs: Vec<FundingTxInput>,
pub our_funding_inputs: Vec<ConfirmedUtxo>,
/// The funding outputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_outputs: Vec<TxOut>,
Expand DownExpand Up@@ -15402,7 +15400,7 @@ impl<SP: SignerProvider> PendingV2Channel<SP> {
pub fn new_outbound<ES: EntropySource, F: FeeEstimator, L: Logger>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
funding_inputs: Vec<FundingTxInput>, user_id: u128, config: &UserConfig,
funding_inputs: Vec<ConfirmedUtxo>, user_id: u128, config: &UserConfig,
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
logger: L, trusted_channel_features: Option<TrustedChannelFeatures>,
) -> Result<Self, APIError> {
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ use crate::ln::channelmanager::{
AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, PaymentId,
RAACommitmentOrder, TrustedChannelFeatures, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{FundingContribution, FundingTxInput};
use crate::ln::funding::FundingContribution;
use crate::ln::msgs::{self, OpenChannel};
use crate::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, RoutingMessageHandler,
Expand All@@ -55,7 +55,7 @@ use crate::util::test_channel_signer::SignerOp;
use crate::util::test_channel_signer::TestChannelSigner;
use crate::util::test_utils::{self, TestLogger};
use crate::util::test_utils::{TestChainMonitor, TestKeysInterface, TestScorer};
use crate::util::wallet_utils::{WalletSourceSync, WalletSync};
use crate::util::wallet_utils::{ConfirmedUtxo, WalletSourceSync, WalletSync};

use bitcoin::amount::Amount;
use bitcoin::block::{Block, Header, Version as BlockVersion};
Expand DownExpand Up@@ -1512,7 +1512,7 @@ fn internal_create_funding_transaction<'a, 'b, 'c>(
/// Return the inputs (with prev tx), and the total witness weight for these inputs
pub fn create_dual_funding_utxos_with_prev_txs(
node: &Node<'_, '_, '_>, utxo_values_in_satoshis: &[u64],
) -> Vec<FundingTxInput> {
) -> Vec<ConfirmedUtxo> {
// Ensure we have unique transactions per node by using the locktime.
let tx = Transaction {
version: TxVersion::TWO,
Expand All@@ -1536,7 +1536,7 @@ pub fn create_dual_funding_utxos_with_prev_txs(
.iter()
.enumerate()
.map(|(index, _)| index as u32)
.map(|vout| FundingTxInput::new_p2wpkh(tx.clone(), vout).unwrap())
.map(|vout| ConfirmedUtxo::new_p2wpkh(tx.clone(), vout).unwrap())
.collect()
}

Expand Down
48 changes: 22 additions & 26 deletions lightning/src/ln/funding.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ use crate::ln::LN_MAX_MSG_LEN;
use crate::prelude::*;
use crate::util::native_async::MaybeSend;
use crate::util::wallet_utils::{
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, Input,
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, ConfirmedUtxo, Input,
};

/// Error returned when a [`FundingContribution`] cannot be adjusted to a target feerate.
Expand DownExpand Up@@ -370,7 +370,7 @@ impl FundingTemplate {
/// when that is set. `max_feerate` is the highest feerate we are willing to tolerate if we end
/// up as the acceptor, and must be at least `min_feerate`.
pub fn splice_in_inputs(
self, inputs: Vec<FundingTxInput>, min_feerate: FeeRate, max_feerate: FeeRate,
self, inputs: Vec<ConfirmedUtxo>, min_feerate: FeeRate, max_feerate: FeeRate,
) -> Result<FundingContribution, FundingContributionError> {
self.with_prior_contribution(min_feerate, max_feerate).add_inputs(inputs)?.build()
}
Expand DownExpand Up@@ -466,8 +466,8 @@ impl FundingTemplate {
}

fn estimate_transaction_fee(
inputs: &[FundingTxInput], outputs: &[TxOut], change_output: Option<&TxOut>,
is_initiator: bool, is_splice: bool, feerate: FeeRate,
inputs: &[ConfirmedUtxo], outputs: &[TxOut], change_output: Option<&TxOut>, is_initiator: bool,
is_splice: bool, feerate: FeeRate,
) -> Amount {
let input_weight: u64 = inputs
.iter()
Expand DownExpand Up@@ -515,7 +515,7 @@ fn estimate_transaction_fee(
Weight::from_wu(weight) * feerate
}

fn validate_inputs(inputs: &[FundingTxInput]) -> Result<(), FundingContributionError> {
fn validate_inputs(inputs: &[ConfirmedUtxo]) -> Result<(), FundingContributionError> {
let mut total_value = Amount::ZERO;
for (idx, input) in inputs.iter().enumerate() {
if inputs[..idx]
Expand DownExpand Up@@ -559,7 +559,7 @@ enum FundingInputs {
/// Replaces the contribution's inputs with the provided set and fully consumes them without a
/// change output. The amount added to the channel is recomputed from the input total minus fees,
/// while explicit withdrawal outputs still reduce the splice's net value.
ManuallySelected { inputs: Vec<FundingTxInput> },
ManuallySelected { inputs: Vec<ConfirmedUtxo> },
}

impl FundingInputs {
Expand All@@ -584,7 +584,7 @@ impl FundingInputs {
}
}

fn manually_selected_inputs(&self) -> &[FundingTxInput] {
fn manually_selected_inputs(&self) -> &[ConfirmedUtxo] {
match self {
FundingInputs::ManuallySelected { inputs } => inputs,
FundingInputs::CoinSelected { .. } => &[],
Expand DownExpand Up@@ -613,7 +613,7 @@ pub struct FundingContribution {
///
/// For coin-selected contributions, excess value is returned via [`Self::change_output`]. For
/// manually selected inputs, the full input value is consumed and no change output is created.
inputs: Vec<FundingTxInput>,
inputs: Vec<ConfirmedUtxo>,

/// The outputs to include in the funding transaction.
///
Expand DownExpand Up@@ -691,7 +691,7 @@ impl FundingContribution {
}

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

Expand DownExpand Up@@ -827,7 +827,7 @@ impl FundingContribution {
Some(new_contribution_at_target_feerate)
}

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

if let Some(change_output) = change_output {
Expand DownExpand Up@@ -1131,10 +1131,6 @@ impl FundingContribution {
}
}

/// An input to contribute to a channel's funding transaction either when using the v2 channel
/// establishment protocol or when splicing.
pub type FundingTxInput = crate::util::wallet_utils::ConfirmedUtxo;

#[derive(Debug, Clone, PartialEq, Eq)]
struct NoCoinSelectionSource;
#[derive(Debug, Clone, PartialEq, Eq)]
Expand DownExpand Up@@ -1472,7 +1468,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_input(self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
pub fn add_input(self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
self.0.add_input_inner(input).map(FundingBuilder)
}

Expand All@@ -1490,7 +1486,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_inputs(self, inputs: Vec<FundingTxInput>) -> Result<Self, FundingContributionError> {
pub fn add_inputs(self, inputs: Vec<ConfirmedUtxo>) -> Result<Self, FundingContributionError> {
self.0.add_inputs_inner(inputs).map(FundingBuilder)
}

Expand DownExpand Up@@ -1585,7 +1581,7 @@ impl<State> FundingBuilderInner<State> {
Ok(self)
}

fn add_input_inner(mut self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
fn add_input_inner(mut self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => {
self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs: vec![input] })
Expand All@@ -1599,7 +1595,7 @@ impl<State> FundingBuilderInner<State> {
}

fn add_inputs_inner(
mut self, inputs: Vec<FundingTxInput>,
mut self, inputs: Vec<ConfirmedUtxo>,
) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs }),
Expand DownExpand Up@@ -1875,11 +1871,11 @@ impl<W: CoinSelectionSourceSync> SyncFundingBuilder<W> {
mod tests {
use super::{
estimate_transaction_fee, FeeRateAdjustmentError, FundingBuilder, FundingContribution,
FundingContributionError, FundingInputMode, FundingTemplate, FundingTxInput,
SyncCoinSelectionSource, SyncFundingBuilder,
FundingContributionError, FundingInputMode, FundingTemplate, SyncCoinSelectionSource,
SyncFundingBuilder,
};
use crate::chain::ClaimId;
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, Input};
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, ConfirmedUtxo, Input};
use bitcoin::hashes::Hash;
use bitcoin::transaction::{Transaction, TxOut, Version};
use bitcoin::{Amount, FeeRate, Psbt, ScriptBuf, SignedAmount, WPubkeyHash, WScriptHash};
Expand DownExpand Up@@ -1960,7 +1956,7 @@ mod tests {
}

#[rustfmt::skip]
fn funding_input_sats(input_value_sats: u64) -> FundingTxInput {
fn funding_input_sats(input_value_sats: u64) -> ConfirmedUtxo {
let prevout = TxOut {
value: Amount::from_sat(input_value_sats),
script_pubkey: ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros()),
Expand All@@ -1970,7 +1966,7 @@ mod tests {
version: Version::TWO, lock_time: bitcoin::absolute::LockTime::ZERO,
};

FundingTxInput::new_p2wpkh(prevtx, 0).unwrap()
ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap()
}

fn funding_output_sats(output_value_sats: u64) -> TxOut {
Expand All@@ -1995,7 +1991,7 @@ mod tests {
}

struct MustPayToWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
expected_must_pay_to_values: Vec<Amount>,
}
Expand DownExpand Up@@ -2805,7 +2801,7 @@ mod tests {
assert!(prevtx.serialized_length() > crate::ln::LN_MAX_MSG_LEN);

let wallet = SingleUtxoWallet {
utxo: FundingTxInput::new_p2wpkh(prevtx, 0).unwrap(),
utxo: ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap(),
change_output: None,
};
assert!(matches!(
Expand DownExpand Up@@ -3713,7 +3709,7 @@ mod tests {

/// A mock wallet that returns a single UTXO for coin selection.
struct SingleUtxoWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
}

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
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
12 changes: 5 additions & 7 deletions lightning/src/ln/channel.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,7 @@ use crate::ln::channelmanager::{
PendingHTLCStatus, RAACommitmentOrder, SentHTLCId, TrustedChannelFeatures, BREAKDOWN_TIMEOUT,
MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput,
};
use crate::ln::funding::{FeeRateAdjustmentError, FundingContribution, FundingTemplate};
use crate::ln::interactivetxs::{
AbortReason, HandleTxCompleteValue, InteractiveTxConstructor, InteractiveTxConstructorArgs,
InteractiveTxMessageSend, InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput,
Expand DownExpand Up@@ -87,7 +85,7 @@ use crate::util::errors::APIError;
use crate::util::logger::{Level as LoggerLevel, Logger, Record, WithContext};
use crate::util::scid_utils::{block_from_scid, scid_from_parts};
use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, Writeable, Writer};
use crate::util::wallet_utils::Input;
use crate::util::wallet_utils::{ConfirmedUtxo, Input};
use crate::{impl_readable_for_vec, impl_writeable_for_vec};

use alloc::collections::{btree_map, BTreeMap};
Expand DownExpand Up@@ -3100,7 +3098,7 @@ impl FundingNegotiation {
funding: FundingScope, context: &ChannelContext<SP>, entropy_source: &ES,
holder_node_id: &PublicKey, our_funding_contribution: SignedAmount,
prev_funding_input: SharedOwnedInput, locktime: u32, feerate_sat_per_1000_weight: u32,
our_funding_inputs: Vec<FundingTxInput>, our_funding_outputs: Vec<TxOut>,
our_funding_inputs: Vec<ConfirmedUtxo>, our_funding_outputs: Vec<TxOut>,
) -> FundingNegotiation {
let funding_negotiation_context = FundingNegotiationContext {
is_initiator: false,
Expand DownExpand Up@@ -6905,7 +6903,7 @@ pub(super) struct FundingNegotiationContext {
pub shared_funding_input: Option<SharedOwnedInput>,
/// The funding inputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_inputs: Vec<FundingTxInput>,
pub our_funding_inputs: Vec<ConfirmedUtxo>,
/// The funding outputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_outputs: Vec<TxOut>,
Expand DownExpand Up@@ -15402,7 +15400,7 @@ impl<SP: SignerProvider> PendingV2Channel<SP> {
pub fn new_outbound<ES: EntropySource, F: FeeEstimator, L: Logger>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
funding_inputs: Vec<FundingTxInput>, user_id: u128, config: &UserConfig,
funding_inputs: Vec<ConfirmedUtxo>, user_id: u128, config: &UserConfig,
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
logger: L, trusted_channel_features: Option<TrustedChannelFeatures>,
) -> Result<Self, APIError> {
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ use crate::ln::channelmanager::{
AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, PaymentId,
RAACommitmentOrder, TrustedChannelFeatures, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{FundingContribution, FundingTxInput};
use crate::ln::funding::FundingContribution;
use crate::ln::msgs::{self, OpenChannel};
use crate::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, RoutingMessageHandler,
Expand All@@ -55,7 +55,7 @@ use crate::util::test_channel_signer::SignerOp;
use crate::util::test_channel_signer::TestChannelSigner;
use crate::util::test_utils::{self, TestLogger};
use crate::util::test_utils::{TestChainMonitor, TestKeysInterface, TestScorer};
use crate::util::wallet_utils::{WalletSourceSync, WalletSync};
use crate::util::wallet_utils::{ConfirmedUtxo, WalletSourceSync, WalletSync};

use bitcoin::amount::Amount;
use bitcoin::block::{Block, Header, Version as BlockVersion};
Expand DownExpand Up@@ -1512,7 +1512,7 @@ fn internal_create_funding_transaction<'a, 'b, 'c>(
/// Return the inputs (with prev tx), and the total witness weight for these inputs
pub fn create_dual_funding_utxos_with_prev_txs(
node: &Node<'_, '_, '_>, utxo_values_in_satoshis: &[u64],
) -> Vec<FundingTxInput> {
) -> Vec<ConfirmedUtxo> {
// Ensure we have unique transactions per node by using the locktime.
let tx = Transaction {
version: TxVersion::TWO,
Expand All@@ -1536,7 +1536,7 @@ pub fn create_dual_funding_utxos_with_prev_txs(
.iter()
.enumerate()
.map(|(index, _)| index as u32)
.map(|vout| FundingTxInput::new_p2wpkh(tx.clone(), vout).unwrap())
.map(|vout| ConfirmedUtxo::new_p2wpkh(tx.clone(), vout).unwrap())
.collect()
}

Expand Down
48 changes: 22 additions & 26 deletions lightning/src/ln/funding.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ use crate::ln::LN_MAX_MSG_LEN;
use crate::prelude::*;
use crate::util::native_async::MaybeSend;
use crate::util::wallet_utils::{
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, Input,
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, ConfirmedUtxo, Input,
};

/// Error returned when a [`FundingContribution`] cannot be adjusted to a target feerate.
Expand DownExpand Up@@ -370,7 +370,7 @@ impl FundingTemplate {
/// when that is set. `max_feerate` is the highest feerate we are willing to tolerate if we end
/// up as the acceptor, and must be at least `min_feerate`.
pub fn splice_in_inputs(
self, inputs: Vec<FundingTxInput>, min_feerate: FeeRate, max_feerate: FeeRate,
self, inputs: Vec<ConfirmedUtxo>, min_feerate: FeeRate, max_feerate: FeeRate,
) -> Result<FundingContribution, FundingContributionError> {
self.with_prior_contribution(min_feerate, max_feerate).add_inputs(inputs)?.build()
}
Expand DownExpand Up@@ -466,8 +466,8 @@ impl FundingTemplate {
}

fn estimate_transaction_fee(
inputs: &[FundingTxInput], outputs: &[TxOut], change_output: Option<&TxOut>,
is_initiator: bool, is_splice: bool, feerate: FeeRate,
inputs: &[ConfirmedUtxo], outputs: &[TxOut], change_output: Option<&TxOut>, is_initiator: bool,
is_splice: bool, feerate: FeeRate,
) -> Amount {
let input_weight: u64 = inputs
.iter()
Expand DownExpand Up@@ -515,7 +515,7 @@ fn estimate_transaction_fee(
Weight::from_wu(weight) * feerate
}

fn validate_inputs(inputs: &[FundingTxInput]) -> Result<(), FundingContributionError> {
fn validate_inputs(inputs: &[ConfirmedUtxo]) -> Result<(), FundingContributionError> {
let mut total_value = Amount::ZERO;
for (idx, input) in inputs.iter().enumerate() {
if inputs[..idx]
Expand DownExpand Up@@ -559,7 +559,7 @@ enum FundingInputs {
/// Replaces the contribution's inputs with the provided set and fully consumes them without a
/// change output. The amount added to the channel is recomputed from the input total minus fees,
/// while explicit withdrawal outputs still reduce the splice's net value.
ManuallySelected { inputs: Vec<FundingTxInput> },
ManuallySelected { inputs: Vec<ConfirmedUtxo> },
}

impl FundingInputs {
Expand All@@ -584,7 +584,7 @@ impl FundingInputs {
}
}

fn manually_selected_inputs(&self) -> &[FundingTxInput] {
fn manually_selected_inputs(&self) -> &[ConfirmedUtxo] {
match self {
FundingInputs::ManuallySelected { inputs } => inputs,
FundingInputs::CoinSelected { .. } => &[],
Expand DownExpand Up@@ -613,7 +613,7 @@ pub struct FundingContribution {
///
/// For coin-selected contributions, excess value is returned via [`Self::change_output`]. For
/// manually selected inputs, the full input value is consumed and no change output is created.
inputs: Vec<FundingTxInput>,
inputs: Vec<ConfirmedUtxo>,

/// The outputs to include in the funding transaction.
///
Expand DownExpand Up@@ -691,7 +691,7 @@ impl FundingContribution {
}

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

Expand DownExpand Up@@ -827,7 +827,7 @@ impl FundingContribution {
Some(new_contribution_at_target_feerate)
}

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

if let Some(change_output) = change_output {
Expand DownExpand Up@@ -1131,10 +1131,6 @@ impl FundingContribution {
}
}

/// An input to contribute to a channel's funding transaction either when using the v2 channel
/// establishment protocol or when splicing.
pub type FundingTxInput = crate::util::wallet_utils::ConfirmedUtxo;

#[derive(Debug, Clone, PartialEq, Eq)]
struct NoCoinSelectionSource;
#[derive(Debug, Clone, PartialEq, Eq)]
Expand DownExpand Up@@ -1472,7 +1468,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_input(self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
pub fn add_input(self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
self.0.add_input_inner(input).map(FundingBuilder)
}

Expand All@@ -1490,7 +1486,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_inputs(self, inputs: Vec<FundingTxInput>) -> Result<Self, FundingContributionError> {
pub fn add_inputs(self, inputs: Vec<ConfirmedUtxo>) -> Result<Self, FundingContributionError> {
self.0.add_inputs_inner(inputs).map(FundingBuilder)
}

Expand DownExpand Up@@ -1585,7 +1581,7 @@ impl<State> FundingBuilderInner<State> {
Ok(self)
}

fn add_input_inner(mut self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
fn add_input_inner(mut self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => {
self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs: vec![input] })
Expand All@@ -1599,7 +1595,7 @@ impl<State> FundingBuilderInner<State> {
}

fn add_inputs_inner(
mut self, inputs: Vec<FundingTxInput>,
mut self, inputs: Vec<ConfirmedUtxo>,
) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs }),
Expand DownExpand Up@@ -1875,11 +1871,11 @@ impl<W: CoinSelectionSourceSync> SyncFundingBuilder<W> {
mod tests {
use super::{
estimate_transaction_fee, FeeRateAdjustmentError, FundingBuilder, FundingContribution,
FundingContributionError, FundingInputMode, FundingTemplate, FundingTxInput,
SyncCoinSelectionSource, SyncFundingBuilder,
FundingContributionError, FundingInputMode, FundingTemplate, SyncCoinSelectionSource,
SyncFundingBuilder,
};
use crate::chain::ClaimId;
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, Input};
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, ConfirmedUtxo, Input};
use bitcoin::hashes::Hash;
use bitcoin::transaction::{Transaction, TxOut, Version};
use bitcoin::{Amount, FeeRate, Psbt, ScriptBuf, SignedAmount, WPubkeyHash, WScriptHash};
Expand DownExpand Up@@ -1960,7 +1956,7 @@ mod tests {
}

#[rustfmt::skip]
fn funding_input_sats(input_value_sats: u64) -> FundingTxInput {
fn funding_input_sats(input_value_sats: u64) -> ConfirmedUtxo {
let prevout = TxOut {
value: Amount::from_sat(input_value_sats),
script_pubkey: ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros()),
Expand All@@ -1970,7 +1966,7 @@ mod tests {
version: Version::TWO, lock_time: bitcoin::absolute::LockTime::ZERO,
};

FundingTxInput::new_p2wpkh(prevtx, 0).unwrap()
ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap()
}

fn funding_output_sats(output_value_sats: u64) -> TxOut {
Expand All@@ -1995,7 +1991,7 @@ mod tests {
}

struct MustPayToWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
expected_must_pay_to_values: Vec<Amount>,
}
Expand DownExpand Up@@ -2805,7 +2801,7 @@ mod tests {
assert!(prevtx.serialized_length() > crate::ln::LN_MAX_MSG_LEN);

let wallet = SingleUtxoWallet {
utxo: FundingTxInput::new_p2wpkh(prevtx, 0).unwrap(),
utxo: ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap(),
change_output: None,
};
assert!(matches!(
Expand DownExpand Up@@ -3713,7 +3709,7 @@ mod tests {

/// A mock wallet that returns a single UTXO for coin selection.
struct SingleUtxoWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
}

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
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
12 changes: 5 additions & 7 deletions lightning/src/ln/channel.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,7 @@ use crate::ln::channelmanager::{
PendingHTLCStatus, RAACommitmentOrder, SentHTLCId, TrustedChannelFeatures, BREAKDOWN_TIMEOUT,
MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput,
};
use crate::ln::funding::{FeeRateAdjustmentError, FundingContribution, FundingTemplate};
use crate::ln::interactivetxs::{
AbortReason, HandleTxCompleteValue, InteractiveTxConstructor, InteractiveTxConstructorArgs,
InteractiveTxMessageSend, InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput,
Expand DownExpand Up@@ -87,7 +85,7 @@ use crate::util::errors::APIError;
use crate::util::logger::{Level as LoggerLevel, Logger, Record, WithContext};
use crate::util::scid_utils::{block_from_scid, scid_from_parts};
use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, Writeable, Writer};
use crate::util::wallet_utils::Input;
use crate::util::wallet_utils::{ConfirmedUtxo, Input};
use crate::{impl_readable_for_vec, impl_writeable_for_vec};

use alloc::collections::{btree_map, BTreeMap};
Expand DownExpand Up@@ -3100,7 +3098,7 @@ impl FundingNegotiation {
funding: FundingScope, context: &ChannelContext<SP>, entropy_source: &ES,
holder_node_id: &PublicKey, our_funding_contribution: SignedAmount,
prev_funding_input: SharedOwnedInput, locktime: u32, feerate_sat_per_1000_weight: u32,
our_funding_inputs: Vec<FundingTxInput>, our_funding_outputs: Vec<TxOut>,
our_funding_inputs: Vec<ConfirmedUtxo>, our_funding_outputs: Vec<TxOut>,
) -> FundingNegotiation {
let funding_negotiation_context = FundingNegotiationContext {
is_initiator: false,
Expand DownExpand Up@@ -6905,7 +6903,7 @@ pub(super) struct FundingNegotiationContext {
pub shared_funding_input: Option<SharedOwnedInput>,
/// The funding inputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_inputs: Vec<FundingTxInput>,
pub our_funding_inputs: Vec<ConfirmedUtxo>,
/// The funding outputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_outputs: Vec<TxOut>,
Expand DownExpand Up@@ -15402,7 +15400,7 @@ impl<SP: SignerProvider> PendingV2Channel<SP> {
pub fn new_outbound<ES: EntropySource, F: FeeEstimator, L: Logger>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
funding_inputs: Vec<FundingTxInput>, user_id: u128, config: &UserConfig,
funding_inputs: Vec<ConfirmedUtxo>, user_id: u128, config: &UserConfig,
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
logger: L, trusted_channel_features: Option<TrustedChannelFeatures>,
) -> Result<Self, APIError> {
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ use crate::ln::channelmanager::{
AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, PaymentId,
RAACommitmentOrder, TrustedChannelFeatures, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{FundingContribution, FundingTxInput};
use crate::ln::funding::FundingContribution;
use crate::ln::msgs::{self, OpenChannel};
use crate::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, RoutingMessageHandler,
Expand All@@ -55,7 +55,7 @@ use crate::util::test_channel_signer::SignerOp;
use crate::util::test_channel_signer::TestChannelSigner;
use crate::util::test_utils::{self, TestLogger};
use crate::util::test_utils::{TestChainMonitor, TestKeysInterface, TestScorer};
use crate::util::wallet_utils::{WalletSourceSync, WalletSync};
use crate::util::wallet_utils::{ConfirmedUtxo, WalletSourceSync, WalletSync};

use bitcoin::amount::Amount;
use bitcoin::block::{Block, Header, Version as BlockVersion};
Expand DownExpand Up@@ -1512,7 +1512,7 @@ fn internal_create_funding_transaction<'a, 'b, 'c>(
/// Return the inputs (with prev tx), and the total witness weight for these inputs
pub fn create_dual_funding_utxos_with_prev_txs(
node: &Node<'_, '_, '_>, utxo_values_in_satoshis: &[u64],
) -> Vec<FundingTxInput> {
) -> Vec<ConfirmedUtxo> {
// Ensure we have unique transactions per node by using the locktime.
let tx = Transaction {
version: TxVersion::TWO,
Expand All@@ -1536,7 +1536,7 @@ pub fn create_dual_funding_utxos_with_prev_txs(
.iter()
.enumerate()
.map(|(index, _)| index as u32)
.map(|vout| FundingTxInput::new_p2wpkh(tx.clone(), vout).unwrap())
.map(|vout| ConfirmedUtxo::new_p2wpkh(tx.clone(), vout).unwrap())
.collect()
}

Expand Down
48 changes: 22 additions & 26 deletions lightning/src/ln/funding.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ use crate::ln::LN_MAX_MSG_LEN;
use crate::prelude::*;
use crate::util::native_async::MaybeSend;
use crate::util::wallet_utils::{
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, Input,
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, ConfirmedUtxo, Input,
};

/// Error returned when a [`FundingContribution`] cannot be adjusted to a target feerate.
Expand DownExpand Up@@ -370,7 +370,7 @@ impl FundingTemplate {
/// when that is set. `max_feerate` is the highest feerate we are willing to tolerate if we end
/// up as the acceptor, and must be at least `min_feerate`.
pub fn splice_in_inputs(
self, inputs: Vec<FundingTxInput>, min_feerate: FeeRate, max_feerate: FeeRate,
self, inputs: Vec<ConfirmedUtxo>, min_feerate: FeeRate, max_feerate: FeeRate,
) -> Result<FundingContribution, FundingContributionError> {
self.with_prior_contribution(min_feerate, max_feerate).add_inputs(inputs)?.build()
}
Expand DownExpand Up@@ -466,8 +466,8 @@ impl FundingTemplate {
}

fn estimate_transaction_fee(
inputs: &[FundingTxInput], outputs: &[TxOut], change_output: Option<&TxOut>,
is_initiator: bool, is_splice: bool, feerate: FeeRate,
inputs: &[ConfirmedUtxo], outputs: &[TxOut], change_output: Option<&TxOut>, is_initiator: bool,
is_splice: bool, feerate: FeeRate,
) -> Amount {
let input_weight: u64 = inputs
.iter()
Expand DownExpand Up@@ -515,7 +515,7 @@ fn estimate_transaction_fee(
Weight::from_wu(weight) * feerate
}

fn validate_inputs(inputs: &[FundingTxInput]) -> Result<(), FundingContributionError> {
fn validate_inputs(inputs: &[ConfirmedUtxo]) -> Result<(), FundingContributionError> {
let mut total_value = Amount::ZERO;
for (idx, input) in inputs.iter().enumerate() {
if inputs[..idx]
Expand DownExpand Up@@ -559,7 +559,7 @@ enum FundingInputs {
/// Replaces the contribution's inputs with the provided set and fully consumes them without a
/// change output. The amount added to the channel is recomputed from the input total minus fees,
/// while explicit withdrawal outputs still reduce the splice's net value.
ManuallySelected { inputs: Vec<FundingTxInput> },
ManuallySelected { inputs: Vec<ConfirmedUtxo> },
}

impl FundingInputs {
Expand All@@ -584,7 +584,7 @@ impl FundingInputs {
}
}

fn manually_selected_inputs(&self) -> &[FundingTxInput] {
fn manually_selected_inputs(&self) -> &[ConfirmedUtxo] {
match self {
FundingInputs::ManuallySelected { inputs } => inputs,
FundingInputs::CoinSelected { .. } => &[],
Expand DownExpand Up@@ -613,7 +613,7 @@ pub struct FundingContribution {
///
/// For coin-selected contributions, excess value is returned via [`Self::change_output`]. For
/// manually selected inputs, the full input value is consumed and no change output is created.
inputs: Vec<FundingTxInput>,
inputs: Vec<ConfirmedUtxo>,

/// The outputs to include in the funding transaction.
///
Expand DownExpand Up@@ -691,7 +691,7 @@ impl FundingContribution {
}

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

Expand DownExpand Up@@ -827,7 +827,7 @@ impl FundingContribution {
Some(new_contribution_at_target_feerate)
}

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

if let Some(change_output) = change_output {
Expand DownExpand Up@@ -1131,10 +1131,6 @@ impl FundingContribution {
}
}

/// An input to contribute to a channel's funding transaction either when using the v2 channel
/// establishment protocol or when splicing.
pub type FundingTxInput = crate::util::wallet_utils::ConfirmedUtxo;

#[derive(Debug, Clone, PartialEq, Eq)]
struct NoCoinSelectionSource;
#[derive(Debug, Clone, PartialEq, Eq)]
Expand DownExpand Up@@ -1472,7 +1468,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_input(self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
pub fn add_input(self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
self.0.add_input_inner(input).map(FundingBuilder)
}

Expand All@@ -1490,7 +1486,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_inputs(self, inputs: Vec<FundingTxInput>) -> Result<Self, FundingContributionError> {
pub fn add_inputs(self, inputs: Vec<ConfirmedUtxo>) -> Result<Self, FundingContributionError> {
self.0.add_inputs_inner(inputs).map(FundingBuilder)
}

Expand DownExpand Up@@ -1585,7 +1581,7 @@ impl<State> FundingBuilderInner<State> {
Ok(self)
}

fn add_input_inner(mut self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
fn add_input_inner(mut self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => {
self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs: vec![input] })
Expand All@@ -1599,7 +1595,7 @@ impl<State> FundingBuilderInner<State> {
}

fn add_inputs_inner(
mut self, inputs: Vec<FundingTxInput>,
mut self, inputs: Vec<ConfirmedUtxo>,
) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs }),
Expand DownExpand Up@@ -1875,11 +1871,11 @@ impl<W: CoinSelectionSourceSync> SyncFundingBuilder<W> {
mod tests {
use super::{
estimate_transaction_fee, FeeRateAdjustmentError, FundingBuilder, FundingContribution,
FundingContributionError, FundingInputMode, FundingTemplate, FundingTxInput,
SyncCoinSelectionSource, SyncFundingBuilder,
FundingContributionError, FundingInputMode, FundingTemplate, SyncCoinSelectionSource,
SyncFundingBuilder,
};
use crate::chain::ClaimId;
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, Input};
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, ConfirmedUtxo, Input};
use bitcoin::hashes::Hash;
use bitcoin::transaction::{Transaction, TxOut, Version};
use bitcoin::{Amount, FeeRate, Psbt, ScriptBuf, SignedAmount, WPubkeyHash, WScriptHash};
Expand DownExpand Up@@ -1960,7 +1956,7 @@ mod tests {
}

#[rustfmt::skip]
fn funding_input_sats(input_value_sats: u64) -> FundingTxInput {
fn funding_input_sats(input_value_sats: u64) -> ConfirmedUtxo {
let prevout = TxOut {
value: Amount::from_sat(input_value_sats),
script_pubkey: ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros()),
Expand All@@ -1970,7 +1966,7 @@ mod tests {
version: Version::TWO, lock_time: bitcoin::absolute::LockTime::ZERO,
};

FundingTxInput::new_p2wpkh(prevtx, 0).unwrap()
ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap()
}

fn funding_output_sats(output_value_sats: u64) -> TxOut {
Expand All@@ -1995,7 +1991,7 @@ mod tests {
}

struct MustPayToWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
expected_must_pay_to_values: Vec<Amount>,
}
Expand DownExpand Up@@ -2805,7 +2801,7 @@ mod tests {
assert!(prevtx.serialized_length() > crate::ln::LN_MAX_MSG_LEN);

let wallet = SingleUtxoWallet {
utxo: FundingTxInput::new_p2wpkh(prevtx, 0).unwrap(),
utxo: ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap(),
change_output: None,
};
assert!(matches!(
Expand DownExpand Up@@ -3713,7 +3709,7 @@ mod tests {

/// A mock wallet that returns a single UTXO for coin selection.
struct SingleUtxoWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
}

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
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
12 changes: 5 additions & 7 deletions lightning/src/ln/channel.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,7 @@ use crate::ln::channelmanager::{
PendingHTLCStatus, RAACommitmentOrder, SentHTLCId, TrustedChannelFeatures, BREAKDOWN_TIMEOUT,
MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput,
};
use crate::ln::funding::{FeeRateAdjustmentError, FundingContribution, FundingTemplate};
use crate::ln::interactivetxs::{
AbortReason, HandleTxCompleteValue, InteractiveTxConstructor, InteractiveTxConstructorArgs,
InteractiveTxMessageSend, InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput,
Expand DownExpand Up@@ -87,7 +85,7 @@ use crate::util::errors::APIError;
use crate::util::logger::{Level as LoggerLevel, Logger, Record, WithContext};
use crate::util::scid_utils::{block_from_scid, scid_from_parts};
use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, Writeable, Writer};
use crate::util::wallet_utils::Input;
use crate::util::wallet_utils::{ConfirmedUtxo, Input};
use crate::{impl_readable_for_vec, impl_writeable_for_vec};

use alloc::collections::{btree_map, BTreeMap};
Expand DownExpand Up@@ -3100,7 +3098,7 @@ impl FundingNegotiation {
funding: FundingScope, context: &ChannelContext<SP>, entropy_source: &ES,
holder_node_id: &PublicKey, our_funding_contribution: SignedAmount,
prev_funding_input: SharedOwnedInput, locktime: u32, feerate_sat_per_1000_weight: u32,
our_funding_inputs: Vec<FundingTxInput>, our_funding_outputs: Vec<TxOut>,
our_funding_inputs: Vec<ConfirmedUtxo>, our_funding_outputs: Vec<TxOut>,
) -> FundingNegotiation {
let funding_negotiation_context = FundingNegotiationContext {
is_initiator: false,
Expand DownExpand Up@@ -6905,7 +6903,7 @@ pub(super) struct FundingNegotiationContext {
pub shared_funding_input: Option<SharedOwnedInput>,
/// The funding inputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_inputs: Vec<FundingTxInput>,
pub our_funding_inputs: Vec<ConfirmedUtxo>,
/// The funding outputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_outputs: Vec<TxOut>,
Expand DownExpand Up@@ -15402,7 +15400,7 @@ impl<SP: SignerProvider> PendingV2Channel<SP> {
pub fn new_outbound<ES: EntropySource, F: FeeEstimator, L: Logger>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
funding_inputs: Vec<FundingTxInput>, user_id: u128, config: &UserConfig,
funding_inputs: Vec<ConfirmedUtxo>, user_id: u128, config: &UserConfig,
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
logger: L, trusted_channel_features: Option<TrustedChannelFeatures>,
) -> Result<Self, APIError> {
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ use crate::ln::channelmanager::{
AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, PaymentId,
RAACommitmentOrder, TrustedChannelFeatures, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{FundingContribution, FundingTxInput};
use crate::ln::funding::FundingContribution;
use crate::ln::msgs::{self, OpenChannel};
use crate::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, RoutingMessageHandler,
Expand All@@ -55,7 +55,7 @@ use crate::util::test_channel_signer::SignerOp;
use crate::util::test_channel_signer::TestChannelSigner;
use crate::util::test_utils::{self, TestLogger};
use crate::util::test_utils::{TestChainMonitor, TestKeysInterface, TestScorer};
use crate::util::wallet_utils::{WalletSourceSync, WalletSync};
use crate::util::wallet_utils::{ConfirmedUtxo, WalletSourceSync, WalletSync};

use bitcoin::amount::Amount;
use bitcoin::block::{Block, Header, Version as BlockVersion};
Expand DownExpand Up@@ -1512,7 +1512,7 @@ fn internal_create_funding_transaction<'a, 'b, 'c>(
/// Return the inputs (with prev tx), and the total witness weight for these inputs
pub fn create_dual_funding_utxos_with_prev_txs(
node: &Node<'_, '_, '_>, utxo_values_in_satoshis: &[u64],
) -> Vec<FundingTxInput> {
) -> Vec<ConfirmedUtxo> {
// Ensure we have unique transactions per node by using the locktime.
let tx = Transaction {
version: TxVersion::TWO,
Expand All@@ -1536,7 +1536,7 @@ pub fn create_dual_funding_utxos_with_prev_txs(
.iter()
.enumerate()
.map(|(index, _)| index as u32)
.map(|vout| FundingTxInput::new_p2wpkh(tx.clone(), vout).unwrap())
.map(|vout| ConfirmedUtxo::new_p2wpkh(tx.clone(), vout).unwrap())
.collect()
}

Expand Down
48 changes: 22 additions & 26 deletions lightning/src/ln/funding.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ use crate::ln::LN_MAX_MSG_LEN;
use crate::prelude::*;
use crate::util::native_async::MaybeSend;
use crate::util::wallet_utils::{
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, Input,
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, ConfirmedUtxo, Input,
};

/// Error returned when a [`FundingContribution`] cannot be adjusted to a target feerate.
Expand DownExpand Up@@ -370,7 +370,7 @@ impl FundingTemplate {
/// when that is set. `max_feerate` is the highest feerate we are willing to tolerate if we end
/// up as the acceptor, and must be at least `min_feerate`.
pub fn splice_in_inputs(
self, inputs: Vec<FundingTxInput>, min_feerate: FeeRate, max_feerate: FeeRate,
self, inputs: Vec<ConfirmedUtxo>, min_feerate: FeeRate, max_feerate: FeeRate,
) -> Result<FundingContribution, FundingContributionError> {
self.with_prior_contribution(min_feerate, max_feerate).add_inputs(inputs)?.build()
}
Expand DownExpand Up@@ -466,8 +466,8 @@ impl FundingTemplate {
}

fn estimate_transaction_fee(
inputs: &[FundingTxInput], outputs: &[TxOut], change_output: Option<&TxOut>,
is_initiator: bool, is_splice: bool, feerate: FeeRate,
inputs: &[ConfirmedUtxo], outputs: &[TxOut], change_output: Option<&TxOut>, is_initiator: bool,
is_splice: bool, feerate: FeeRate,
) -> Amount {
let input_weight: u64 = inputs
.iter()
Expand DownExpand Up@@ -515,7 +515,7 @@ fn estimate_transaction_fee(
Weight::from_wu(weight) * feerate
}

fn validate_inputs(inputs: &[FundingTxInput]) -> Result<(), FundingContributionError> {
fn validate_inputs(inputs: &[ConfirmedUtxo]) -> Result<(), FundingContributionError> {
let mut total_value = Amount::ZERO;
for (idx, input) in inputs.iter().enumerate() {
if inputs[..idx]
Expand DownExpand Up@@ -559,7 +559,7 @@ enum FundingInputs {
/// Replaces the contribution's inputs with the provided set and fully consumes them without a
/// change output. The amount added to the channel is recomputed from the input total minus fees,
/// while explicit withdrawal outputs still reduce the splice's net value.
ManuallySelected { inputs: Vec<FundingTxInput> },
ManuallySelected { inputs: Vec<ConfirmedUtxo> },
}

impl FundingInputs {
Expand All@@ -584,7 +584,7 @@ impl FundingInputs {
}
}

fn manually_selected_inputs(&self) -> &[FundingTxInput] {
fn manually_selected_inputs(&self) -> &[ConfirmedUtxo] {
match self {
FundingInputs::ManuallySelected { inputs } => inputs,
FundingInputs::CoinSelected { .. } => &[],
Expand DownExpand Up@@ -613,7 +613,7 @@ pub struct FundingContribution {
///
/// For coin-selected contributions, excess value is returned via [`Self::change_output`]. For
/// manually selected inputs, the full input value is consumed and no change output is created.
inputs: Vec<FundingTxInput>,
inputs: Vec<ConfirmedUtxo>,

/// The outputs to include in the funding transaction.
///
Expand DownExpand Up@@ -691,7 +691,7 @@ impl FundingContribution {
}

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

Expand DownExpand Up@@ -827,7 +827,7 @@ impl FundingContribution {
Some(new_contribution_at_target_feerate)
}

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

if let Some(change_output) = change_output {
Expand DownExpand Up@@ -1131,10 +1131,6 @@ impl FundingContribution {
}
}

/// An input to contribute to a channel's funding transaction either when using the v2 channel
/// establishment protocol or when splicing.
pub type FundingTxInput = crate::util::wallet_utils::ConfirmedUtxo;

#[derive(Debug, Clone, PartialEq, Eq)]
struct NoCoinSelectionSource;
#[derive(Debug, Clone, PartialEq, Eq)]
Expand DownExpand Up@@ -1472,7 +1468,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_input(self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
pub fn add_input(self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
self.0.add_input_inner(input).map(FundingBuilder)
}

Expand All@@ -1490,7 +1486,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_inputs(self, inputs: Vec<FundingTxInput>) -> Result<Self, FundingContributionError> {
pub fn add_inputs(self, inputs: Vec<ConfirmedUtxo>) -> Result<Self, FundingContributionError> {
self.0.add_inputs_inner(inputs).map(FundingBuilder)
}

Expand DownExpand Up@@ -1585,7 +1581,7 @@ impl<State> FundingBuilderInner<State> {
Ok(self)
}

fn add_input_inner(mut self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
fn add_input_inner(mut self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => {
self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs: vec![input] })
Expand All@@ -1599,7 +1595,7 @@ impl<State> FundingBuilderInner<State> {
}

fn add_inputs_inner(
mut self, inputs: Vec<FundingTxInput>,
mut self, inputs: Vec<ConfirmedUtxo>,
) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs }),
Expand DownExpand Up@@ -1875,11 +1871,11 @@ impl<W: CoinSelectionSourceSync> SyncFundingBuilder<W> {
mod tests {
use super::{
estimate_transaction_fee, FeeRateAdjustmentError, FundingBuilder, FundingContribution,
FundingContributionError, FundingInputMode, FundingTemplate, FundingTxInput,
SyncCoinSelectionSource, SyncFundingBuilder,
FundingContributionError, FundingInputMode, FundingTemplate, SyncCoinSelectionSource,
SyncFundingBuilder,
};
use crate::chain::ClaimId;
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, Input};
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, ConfirmedUtxo, Input};
use bitcoin::hashes::Hash;
use bitcoin::transaction::{Transaction, TxOut, Version};
use bitcoin::{Amount, FeeRate, Psbt, ScriptBuf, SignedAmount, WPubkeyHash, WScriptHash};
Expand DownExpand Up@@ -1960,7 +1956,7 @@ mod tests {
}

#[rustfmt::skip]
fn funding_input_sats(input_value_sats: u64) -> FundingTxInput {
fn funding_input_sats(input_value_sats: u64) -> ConfirmedUtxo {
let prevout = TxOut {
value: Amount::from_sat(input_value_sats),
script_pubkey: ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros()),
Expand All@@ -1970,7 +1966,7 @@ mod tests {
version: Version::TWO, lock_time: bitcoin::absolute::LockTime::ZERO,
};

FundingTxInput::new_p2wpkh(prevtx, 0).unwrap()
ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap()
}

fn funding_output_sats(output_value_sats: u64) -> TxOut {
Expand All@@ -1995,7 +1991,7 @@ mod tests {
}

struct MustPayToWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
expected_must_pay_to_values: Vec<Amount>,
}
Expand DownExpand Up@@ -2805,7 +2801,7 @@ mod tests {
assert!(prevtx.serialized_length() > crate::ln::LN_MAX_MSG_LEN);

let wallet = SingleUtxoWallet {
utxo: FundingTxInput::new_p2wpkh(prevtx, 0).unwrap(),
utxo: ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap(),
change_output: None,
};
assert!(matches!(
Expand DownExpand Up@@ -3713,7 +3709,7 @@ mod tests {

/// A mock wallet that returns a single UTXO for coin selection.
struct SingleUtxoWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
}

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
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
12 changes: 5 additions & 7 deletions lightning/src/ln/channel.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,7 @@ use crate::ln::channelmanager::{
PendingHTLCStatus, RAACommitmentOrder, SentHTLCId, TrustedChannelFeatures, BREAKDOWN_TIMEOUT,
MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput,
};
use crate::ln::funding::{FeeRateAdjustmentError, FundingContribution, FundingTemplate};
use crate::ln::interactivetxs::{
AbortReason, HandleTxCompleteValue, InteractiveTxConstructor, InteractiveTxConstructorArgs,
InteractiveTxMessageSend, InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput,
Expand DownExpand Up@@ -87,7 +85,7 @@ use crate::util::errors::APIError;
use crate::util::logger::{Level as LoggerLevel, Logger, Record, WithContext};
use crate::util::scid_utils::{block_from_scid, scid_from_parts};
use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, Writeable, Writer};
use crate::util::wallet_utils::Input;
use crate::util::wallet_utils::{ConfirmedUtxo, Input};
use crate::{impl_readable_for_vec, impl_writeable_for_vec};

use alloc::collections::{btree_map, BTreeMap};
Expand DownExpand Up@@ -3100,7 +3098,7 @@ impl FundingNegotiation {
funding: FundingScope, context: &ChannelContext<SP>, entropy_source: &ES,
holder_node_id: &PublicKey, our_funding_contribution: SignedAmount,
prev_funding_input: SharedOwnedInput, locktime: u32, feerate_sat_per_1000_weight: u32,
our_funding_inputs: Vec<FundingTxInput>, our_funding_outputs: Vec<TxOut>,
our_funding_inputs: Vec<ConfirmedUtxo>, our_funding_outputs: Vec<TxOut>,
) -> FundingNegotiation {
let funding_negotiation_context = FundingNegotiationContext {
is_initiator: false,
Expand DownExpand Up@@ -6905,7 +6903,7 @@ pub(super) struct FundingNegotiationContext {
pub shared_funding_input: Option<SharedOwnedInput>,
/// The funding inputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_inputs: Vec<FundingTxInput>,
pub our_funding_inputs: Vec<ConfirmedUtxo>,
/// The funding outputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_outputs: Vec<TxOut>,
Expand DownExpand Up@@ -15402,7 +15400,7 @@ impl<SP: SignerProvider> PendingV2Channel<SP> {
pub fn new_outbound<ES: EntropySource, F: FeeEstimator, L: Logger>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
funding_inputs: Vec<FundingTxInput>, user_id: u128, config: &UserConfig,
funding_inputs: Vec<ConfirmedUtxo>, user_id: u128, config: &UserConfig,
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
logger: L, trusted_channel_features: Option<TrustedChannelFeatures>,
) -> Result<Self, APIError> {
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ use crate::ln::channelmanager::{
AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, PaymentId,
RAACommitmentOrder, TrustedChannelFeatures, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{FundingContribution, FundingTxInput};
use crate::ln::funding::FundingContribution;
use crate::ln::msgs::{self, OpenChannel};
use crate::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, RoutingMessageHandler,
Expand All@@ -55,7 +55,7 @@ use crate::util::test_channel_signer::SignerOp;
use crate::util::test_channel_signer::TestChannelSigner;
use crate::util::test_utils::{self, TestLogger};
use crate::util::test_utils::{TestChainMonitor, TestKeysInterface, TestScorer};
use crate::util::wallet_utils::{WalletSourceSync, WalletSync};
use crate::util::wallet_utils::{ConfirmedUtxo, WalletSourceSync, WalletSync};

use bitcoin::amount::Amount;
use bitcoin::block::{Block, Header, Version as BlockVersion};
Expand DownExpand Up@@ -1512,7 +1512,7 @@ fn internal_create_funding_transaction<'a, 'b, 'c>(
/// Return the inputs (with prev tx), and the total witness weight for these inputs
pub fn create_dual_funding_utxos_with_prev_txs(
node: &Node<'_, '_, '_>, utxo_values_in_satoshis: &[u64],
) -> Vec<FundingTxInput> {
) -> Vec<ConfirmedUtxo> {
// Ensure we have unique transactions per node by using the locktime.
let tx = Transaction {
version: TxVersion::TWO,
Expand All@@ -1536,7 +1536,7 @@ pub fn create_dual_funding_utxos_with_prev_txs(
.iter()
.enumerate()
.map(|(index, _)| index as u32)
.map(|vout| FundingTxInput::new_p2wpkh(tx.clone(), vout).unwrap())
.map(|vout| ConfirmedUtxo::new_p2wpkh(tx.clone(), vout).unwrap())
.collect()
}

Expand Down
48 changes: 22 additions & 26 deletions lightning/src/ln/funding.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ use crate::ln::LN_MAX_MSG_LEN;
use crate::prelude::*;
use crate::util::native_async::MaybeSend;
use crate::util::wallet_utils::{
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, Input,
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, ConfirmedUtxo, Input,
};

/// Error returned when a [`FundingContribution`] cannot be adjusted to a target feerate.
Expand DownExpand Up@@ -370,7 +370,7 @@ impl FundingTemplate {
/// when that is set. `max_feerate` is the highest feerate we are willing to tolerate if we end
/// up as the acceptor, and must be at least `min_feerate`.
pub fn splice_in_inputs(
self, inputs: Vec<FundingTxInput>, min_feerate: FeeRate, max_feerate: FeeRate,
self, inputs: Vec<ConfirmedUtxo>, min_feerate: FeeRate, max_feerate: FeeRate,
) -> Result<FundingContribution, FundingContributionError> {
self.with_prior_contribution(min_feerate, max_feerate).add_inputs(inputs)?.build()
}
Expand DownExpand Up@@ -466,8 +466,8 @@ impl FundingTemplate {
}

fn estimate_transaction_fee(
inputs: &[FundingTxInput], outputs: &[TxOut], change_output: Option<&TxOut>,
is_initiator: bool, is_splice: bool, feerate: FeeRate,
inputs: &[ConfirmedUtxo], outputs: &[TxOut], change_output: Option<&TxOut>, is_initiator: bool,
is_splice: bool, feerate: FeeRate,
) -> Amount {
let input_weight: u64 = inputs
.iter()
Expand DownExpand Up@@ -515,7 +515,7 @@ fn estimate_transaction_fee(
Weight::from_wu(weight) * feerate
}

fn validate_inputs(inputs: &[FundingTxInput]) -> Result<(), FundingContributionError> {
fn validate_inputs(inputs: &[ConfirmedUtxo]) -> Result<(), FundingContributionError> {
let mut total_value = Amount::ZERO;
for (idx, input) in inputs.iter().enumerate() {
if inputs[..idx]
Expand DownExpand Up@@ -559,7 +559,7 @@ enum FundingInputs {
/// Replaces the contribution's inputs with the provided set and fully consumes them without a
/// change output. The amount added to the channel is recomputed from the input total minus fees,
/// while explicit withdrawal outputs still reduce the splice's net value.
ManuallySelected { inputs: Vec<FundingTxInput> },
ManuallySelected { inputs: Vec<ConfirmedUtxo> },
}

impl FundingInputs {
Expand All@@ -584,7 +584,7 @@ impl FundingInputs {
}
}

fn manually_selected_inputs(&self) -> &[FundingTxInput] {
fn manually_selected_inputs(&self) -> &[ConfirmedUtxo] {
match self {
FundingInputs::ManuallySelected { inputs } => inputs,
FundingInputs::CoinSelected { .. } => &[],
Expand DownExpand Up@@ -613,7 +613,7 @@ pub struct FundingContribution {
///
/// For coin-selected contributions, excess value is returned via [`Self::change_output`]. For
/// manually selected inputs, the full input value is consumed and no change output is created.
inputs: Vec<FundingTxInput>,
inputs: Vec<ConfirmedUtxo>,

/// The outputs to include in the funding transaction.
///
Expand DownExpand Up@@ -691,7 +691,7 @@ impl FundingContribution {
}

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

Expand DownExpand Up@@ -827,7 +827,7 @@ impl FundingContribution {
Some(new_contribution_at_target_feerate)
}

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

if let Some(change_output) = change_output {
Expand DownExpand Up@@ -1131,10 +1131,6 @@ impl FundingContribution {
}
}

/// An input to contribute to a channel's funding transaction either when using the v2 channel
/// establishment protocol or when splicing.
pub type FundingTxInput = crate::util::wallet_utils::ConfirmedUtxo;

#[derive(Debug, Clone, PartialEq, Eq)]
struct NoCoinSelectionSource;
#[derive(Debug, Clone, PartialEq, Eq)]
Expand DownExpand Up@@ -1472,7 +1468,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_input(self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
pub fn add_input(self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
self.0.add_input_inner(input).map(FundingBuilder)
}

Expand All@@ -1490,7 +1486,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_inputs(self, inputs: Vec<FundingTxInput>) -> Result<Self, FundingContributionError> {
pub fn add_inputs(self, inputs: Vec<ConfirmedUtxo>) -> Result<Self, FundingContributionError> {
self.0.add_inputs_inner(inputs).map(FundingBuilder)
}

Expand DownExpand Up@@ -1585,7 +1581,7 @@ impl<State> FundingBuilderInner<State> {
Ok(self)
}

fn add_input_inner(mut self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
fn add_input_inner(mut self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => {
self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs: vec![input] })
Expand All@@ -1599,7 +1595,7 @@ impl<State> FundingBuilderInner<State> {
}

fn add_inputs_inner(
mut self, inputs: Vec<FundingTxInput>,
mut self, inputs: Vec<ConfirmedUtxo>,
) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs }),
Expand DownExpand Up@@ -1875,11 +1871,11 @@ impl<W: CoinSelectionSourceSync> SyncFundingBuilder<W> {
mod tests {
use super::{
estimate_transaction_fee, FeeRateAdjustmentError, FundingBuilder, FundingContribution,
FundingContributionError, FundingInputMode, FundingTemplate, FundingTxInput,
SyncCoinSelectionSource, SyncFundingBuilder,
FundingContributionError, FundingInputMode, FundingTemplate, SyncCoinSelectionSource,
SyncFundingBuilder,
};
use crate::chain::ClaimId;
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, Input};
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, ConfirmedUtxo, Input};
use bitcoin::hashes::Hash;
use bitcoin::transaction::{Transaction, TxOut, Version};
use bitcoin::{Amount, FeeRate, Psbt, ScriptBuf, SignedAmount, WPubkeyHash, WScriptHash};
Expand DownExpand Up@@ -1960,7 +1956,7 @@ mod tests {
}

#[rustfmt::skip]
fn funding_input_sats(input_value_sats: u64) -> FundingTxInput {
fn funding_input_sats(input_value_sats: u64) -> ConfirmedUtxo {
let prevout = TxOut {
value: Amount::from_sat(input_value_sats),
script_pubkey: ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros()),
Expand All@@ -1970,7 +1966,7 @@ mod tests {
version: Version::TWO, lock_time: bitcoin::absolute::LockTime::ZERO,
};

FundingTxInput::new_p2wpkh(prevtx, 0).unwrap()
ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap()
}

fn funding_output_sats(output_value_sats: u64) -> TxOut {
Expand All@@ -1995,7 +1991,7 @@ mod tests {
}

struct MustPayToWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
expected_must_pay_to_values: Vec<Amount>,
}
Expand DownExpand Up@@ -2805,7 +2801,7 @@ mod tests {
assert!(prevtx.serialized_length() > crate::ln::LN_MAX_MSG_LEN);

let wallet = SingleUtxoWallet {
utxo: FundingTxInput::new_p2wpkh(prevtx, 0).unwrap(),
utxo: ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap(),
change_output: None,
};
assert!(matches!(
Expand DownExpand Up@@ -3713,7 +3709,7 @@ mod tests {

/// A mock wallet that returns a single UTXO for coin selection.
struct SingleUtxoWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
}

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
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
12 changes: 5 additions & 7 deletions lightning/src/ln/channel.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,7 @@ use crate::ln::channelmanager::{
PendingHTLCStatus, RAACommitmentOrder, SentHTLCId, TrustedChannelFeatures, BREAKDOWN_TIMEOUT,
MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput,
};
use crate::ln::funding::{FeeRateAdjustmentError, FundingContribution, FundingTemplate};
use crate::ln::interactivetxs::{
AbortReason, HandleTxCompleteValue, InteractiveTxConstructor, InteractiveTxConstructorArgs,
InteractiveTxMessageSend, InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput,
Expand DownExpand Up@@ -87,7 +85,7 @@ use crate::util::errors::APIError;
use crate::util::logger::{Level as LoggerLevel, Logger, Record, WithContext};
use crate::util::scid_utils::{block_from_scid, scid_from_parts};
use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, Writeable, Writer};
use crate::util::wallet_utils::Input;
use crate::util::wallet_utils::{ConfirmedUtxo, Input};
use crate::{impl_readable_for_vec, impl_writeable_for_vec};

use alloc::collections::{btree_map, BTreeMap};
Expand DownExpand Up@@ -3100,7 +3098,7 @@ impl FundingNegotiation {
funding: FundingScope, context: &ChannelContext<SP>, entropy_source: &ES,
holder_node_id: &PublicKey, our_funding_contribution: SignedAmount,
prev_funding_input: SharedOwnedInput, locktime: u32, feerate_sat_per_1000_weight: u32,
our_funding_inputs: Vec<FundingTxInput>, our_funding_outputs: Vec<TxOut>,
our_funding_inputs: Vec<ConfirmedUtxo>, our_funding_outputs: Vec<TxOut>,
) -> FundingNegotiation {
let funding_negotiation_context = FundingNegotiationContext {
is_initiator: false,
Expand DownExpand Up@@ -6905,7 +6903,7 @@ pub(super) struct FundingNegotiationContext {
pub shared_funding_input: Option<SharedOwnedInput>,
/// The funding inputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_inputs: Vec<FundingTxInput>,
pub our_funding_inputs: Vec<ConfirmedUtxo>,
/// The funding outputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_outputs: Vec<TxOut>,
Expand DownExpand Up@@ -15402,7 +15400,7 @@ impl<SP: SignerProvider> PendingV2Channel<SP> {
pub fn new_outbound<ES: EntropySource, F: FeeEstimator, L: Logger>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
funding_inputs: Vec<FundingTxInput>, user_id: u128, config: &UserConfig,
funding_inputs: Vec<ConfirmedUtxo>, user_id: u128, config: &UserConfig,
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
logger: L, trusted_channel_features: Option<TrustedChannelFeatures>,
) -> Result<Self, APIError> {
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ use crate::ln::channelmanager::{
AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, PaymentId,
RAACommitmentOrder, TrustedChannelFeatures, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{FundingContribution, FundingTxInput};
use crate::ln::funding::FundingContribution;
use crate::ln::msgs::{self, OpenChannel};
use crate::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, RoutingMessageHandler,
Expand All@@ -55,7 +55,7 @@ use crate::util::test_channel_signer::SignerOp;
use crate::util::test_channel_signer::TestChannelSigner;
use crate::util::test_utils::{self, TestLogger};
use crate::util::test_utils::{TestChainMonitor, TestKeysInterface, TestScorer};
use crate::util::wallet_utils::{WalletSourceSync, WalletSync};
use crate::util::wallet_utils::{ConfirmedUtxo, WalletSourceSync, WalletSync};

use bitcoin::amount::Amount;
use bitcoin::block::{Block, Header, Version as BlockVersion};
Expand DownExpand Up@@ -1512,7 +1512,7 @@ fn internal_create_funding_transaction<'a, 'b, 'c>(
/// Return the inputs (with prev tx), and the total witness weight for these inputs
pub fn create_dual_funding_utxos_with_prev_txs(
node: &Node<'_, '_, '_>, utxo_values_in_satoshis: &[u64],
) -> Vec<FundingTxInput> {
) -> Vec<ConfirmedUtxo> {
// Ensure we have unique transactions per node by using the locktime.
let tx = Transaction {
version: TxVersion::TWO,
Expand All@@ -1536,7 +1536,7 @@ pub fn create_dual_funding_utxos_with_prev_txs(
.iter()
.enumerate()
.map(|(index, _)| index as u32)
.map(|vout| FundingTxInput::new_p2wpkh(tx.clone(), vout).unwrap())
.map(|vout| ConfirmedUtxo::new_p2wpkh(tx.clone(), vout).unwrap())
.collect()
}

Expand Down
48 changes: 22 additions & 26 deletions lightning/src/ln/funding.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ use crate::ln::LN_MAX_MSG_LEN;
use crate::prelude::*;
use crate::util::native_async::MaybeSend;
use crate::util::wallet_utils::{
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, Input,
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, ConfirmedUtxo, Input,
};

/// Error returned when a [`FundingContribution`] cannot be adjusted to a target feerate.
Expand DownExpand Up@@ -370,7 +370,7 @@ impl FundingTemplate {
/// when that is set. `max_feerate` is the highest feerate we are willing to tolerate if we end
/// up as the acceptor, and must be at least `min_feerate`.
pub fn splice_in_inputs(
self, inputs: Vec<FundingTxInput>, min_feerate: FeeRate, max_feerate: FeeRate,
self, inputs: Vec<ConfirmedUtxo>, min_feerate: FeeRate, max_feerate: FeeRate,
) -> Result<FundingContribution, FundingContributionError> {
self.with_prior_contribution(min_feerate, max_feerate).add_inputs(inputs)?.build()
}
Expand DownExpand Up@@ -466,8 +466,8 @@ impl FundingTemplate {
}

fn estimate_transaction_fee(
inputs: &[FundingTxInput], outputs: &[TxOut], change_output: Option<&TxOut>,
is_initiator: bool, is_splice: bool, feerate: FeeRate,
inputs: &[ConfirmedUtxo], outputs: &[TxOut], change_output: Option<&TxOut>, is_initiator: bool,
is_splice: bool, feerate: FeeRate,
) -> Amount {
let input_weight: u64 = inputs
.iter()
Expand DownExpand Up@@ -515,7 +515,7 @@ fn estimate_transaction_fee(
Weight::from_wu(weight) * feerate
}

fn validate_inputs(inputs: &[FundingTxInput]) -> Result<(), FundingContributionError> {
fn validate_inputs(inputs: &[ConfirmedUtxo]) -> Result<(), FundingContributionError> {
let mut total_value = Amount::ZERO;
for (idx, input) in inputs.iter().enumerate() {
if inputs[..idx]
Expand DownExpand Up@@ -559,7 +559,7 @@ enum FundingInputs {
/// Replaces the contribution's inputs with the provided set and fully consumes them without a
/// change output. The amount added to the channel is recomputed from the input total minus fees,
/// while explicit withdrawal outputs still reduce the splice's net value.
ManuallySelected { inputs: Vec<FundingTxInput> },
ManuallySelected { inputs: Vec<ConfirmedUtxo> },
}

impl FundingInputs {
Expand All@@ -584,7 +584,7 @@ impl FundingInputs {
}
}

fn manually_selected_inputs(&self) -> &[FundingTxInput] {
fn manually_selected_inputs(&self) -> &[ConfirmedUtxo] {
match self {
FundingInputs::ManuallySelected { inputs } => inputs,
FundingInputs::CoinSelected { .. } => &[],
Expand DownExpand Up@@ -613,7 +613,7 @@ pub struct FundingContribution {
///
/// For coin-selected contributions, excess value is returned via [`Self::change_output`]. For
/// manually selected inputs, the full input value is consumed and no change output is created.
inputs: Vec<FundingTxInput>,
inputs: Vec<ConfirmedUtxo>,

/// The outputs to include in the funding transaction.
///
Expand DownExpand Up@@ -691,7 +691,7 @@ impl FundingContribution {
}

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

Expand DownExpand Up@@ -827,7 +827,7 @@ impl FundingContribution {
Some(new_contribution_at_target_feerate)
}

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

if let Some(change_output) = change_output {
Expand DownExpand Up@@ -1131,10 +1131,6 @@ impl FundingContribution {
}
}

/// An input to contribute to a channel's funding transaction either when using the v2 channel
/// establishment protocol or when splicing.
pub type FundingTxInput = crate::util::wallet_utils::ConfirmedUtxo;

#[derive(Debug, Clone, PartialEq, Eq)]
struct NoCoinSelectionSource;
#[derive(Debug, Clone, PartialEq, Eq)]
Expand DownExpand Up@@ -1472,7 +1468,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_input(self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
pub fn add_input(self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
self.0.add_input_inner(input).map(FundingBuilder)
}

Expand All@@ -1490,7 +1486,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_inputs(self, inputs: Vec<FundingTxInput>) -> Result<Self, FundingContributionError> {
pub fn add_inputs(self, inputs: Vec<ConfirmedUtxo>) -> Result<Self, FundingContributionError> {
self.0.add_inputs_inner(inputs).map(FundingBuilder)
}

Expand DownExpand Up@@ -1585,7 +1581,7 @@ impl<State> FundingBuilderInner<State> {
Ok(self)
}

fn add_input_inner(mut self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
fn add_input_inner(mut self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => {
self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs: vec![input] })
Expand All@@ -1599,7 +1595,7 @@ impl<State> FundingBuilderInner<State> {
}

fn add_inputs_inner(
mut self, inputs: Vec<FundingTxInput>,
mut self, inputs: Vec<ConfirmedUtxo>,
) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs }),
Expand DownExpand Up@@ -1875,11 +1871,11 @@ impl<W: CoinSelectionSourceSync> SyncFundingBuilder<W> {
mod tests {
use super::{
estimate_transaction_fee, FeeRateAdjustmentError, FundingBuilder, FundingContribution,
FundingContributionError, FundingInputMode, FundingTemplate, FundingTxInput,
SyncCoinSelectionSource, SyncFundingBuilder,
FundingContributionError, FundingInputMode, FundingTemplate, SyncCoinSelectionSource,
SyncFundingBuilder,
};
use crate::chain::ClaimId;
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, Input};
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, ConfirmedUtxo, Input};
use bitcoin::hashes::Hash;
use bitcoin::transaction::{Transaction, TxOut, Version};
use bitcoin::{Amount, FeeRate, Psbt, ScriptBuf, SignedAmount, WPubkeyHash, WScriptHash};
Expand DownExpand Up@@ -1960,7 +1956,7 @@ mod tests {
}

#[rustfmt::skip]
fn funding_input_sats(input_value_sats: u64) -> FundingTxInput {
fn funding_input_sats(input_value_sats: u64) -> ConfirmedUtxo {
let prevout = TxOut {
value: Amount::from_sat(input_value_sats),
script_pubkey: ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros()),
Expand All@@ -1970,7 +1966,7 @@ mod tests {
version: Version::TWO, lock_time: bitcoin::absolute::LockTime::ZERO,
};

FundingTxInput::new_p2wpkh(prevtx, 0).unwrap()
ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap()
}

fn funding_output_sats(output_value_sats: u64) -> TxOut {
Expand All@@ -1995,7 +1991,7 @@ mod tests {
}

struct MustPayToWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
expected_must_pay_to_values: Vec<Amount>,
}
Expand DownExpand Up@@ -2805,7 +2801,7 @@ mod tests {
assert!(prevtx.serialized_length() > crate::ln::LN_MAX_MSG_LEN);

let wallet = SingleUtxoWallet {
utxo: FundingTxInput::new_p2wpkh(prevtx, 0).unwrap(),
utxo: ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap(),
change_output: None,
};
assert!(matches!(
Expand DownExpand Up@@ -3713,7 +3709,7 @@ mod tests {

/// A mock wallet that returns a single UTXO for coin selection.
struct SingleUtxoWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
}

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
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
12 changes: 5 additions & 7 deletions lightning/src/ln/channel.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,7 @@ use crate::ln::channelmanager::{
PendingHTLCStatus, RAACommitmentOrder, SentHTLCId, TrustedChannelFeatures, BREAKDOWN_TIMEOUT,
MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput,
};
use crate::ln::funding::{FeeRateAdjustmentError, FundingContribution, FundingTemplate};
use crate::ln::interactivetxs::{
AbortReason, HandleTxCompleteValue, InteractiveTxConstructor, InteractiveTxConstructorArgs,
InteractiveTxMessageSend, InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput,
Expand DownExpand Up@@ -87,7 +85,7 @@ use crate::util::errors::APIError;
use crate::util::logger::{Level as LoggerLevel, Logger, Record, WithContext};
use crate::util::scid_utils::{block_from_scid, scid_from_parts};
use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, Writeable, Writer};
use crate::util::wallet_utils::Input;
use crate::util::wallet_utils::{ConfirmedUtxo, Input};
use crate::{impl_readable_for_vec, impl_writeable_for_vec};

use alloc::collections::{btree_map, BTreeMap};
Expand DownExpand Up@@ -3100,7 +3098,7 @@ impl FundingNegotiation {
funding: FundingScope, context: &ChannelContext<SP>, entropy_source: &ES,
holder_node_id: &PublicKey, our_funding_contribution: SignedAmount,
prev_funding_input: SharedOwnedInput, locktime: u32, feerate_sat_per_1000_weight: u32,
our_funding_inputs: Vec<FundingTxInput>, our_funding_outputs: Vec<TxOut>,
our_funding_inputs: Vec<ConfirmedUtxo>, our_funding_outputs: Vec<TxOut>,
) -> FundingNegotiation {
let funding_negotiation_context = FundingNegotiationContext {
is_initiator: false,
Expand DownExpand Up@@ -6905,7 +6903,7 @@ pub(super) struct FundingNegotiationContext {
pub shared_funding_input: Option<SharedOwnedInput>,
/// The funding inputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_inputs: Vec<FundingTxInput>,
pub our_funding_inputs: Vec<ConfirmedUtxo>,
/// The funding outputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_outputs: Vec<TxOut>,
Expand DownExpand Up@@ -15402,7 +15400,7 @@ impl<SP: SignerProvider> PendingV2Channel<SP> {
pub fn new_outbound<ES: EntropySource, F: FeeEstimator, L: Logger>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
funding_inputs: Vec<FundingTxInput>, user_id: u128, config: &UserConfig,
funding_inputs: Vec<ConfirmedUtxo>, user_id: u128, config: &UserConfig,
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
logger: L, trusted_channel_features: Option<TrustedChannelFeatures>,
) -> Result<Self, APIError> {
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ use crate::ln::channelmanager::{
AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, PaymentId,
RAACommitmentOrder, TrustedChannelFeatures, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{FundingContribution, FundingTxInput};
use crate::ln::funding::FundingContribution;
use crate::ln::msgs::{self, OpenChannel};
use crate::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, RoutingMessageHandler,
Expand All@@ -55,7 +55,7 @@ use crate::util::test_channel_signer::SignerOp;
use crate::util::test_channel_signer::TestChannelSigner;
use crate::util::test_utils::{self, TestLogger};
use crate::util::test_utils::{TestChainMonitor, TestKeysInterface, TestScorer};
use crate::util::wallet_utils::{WalletSourceSync, WalletSync};
use crate::util::wallet_utils::{ConfirmedUtxo, WalletSourceSync, WalletSync};

use bitcoin::amount::Amount;
use bitcoin::block::{Block, Header, Version as BlockVersion};
Expand DownExpand Up@@ -1512,7 +1512,7 @@ fn internal_create_funding_transaction<'a, 'b, 'c>(
/// Return the inputs (with prev tx), and the total witness weight for these inputs
pub fn create_dual_funding_utxos_with_prev_txs(
node: &Node<'_, '_, '_>, utxo_values_in_satoshis: &[u64],
) -> Vec<FundingTxInput> {
) -> Vec<ConfirmedUtxo> {
// Ensure we have unique transactions per node by using the locktime.
let tx = Transaction {
version: TxVersion::TWO,
Expand All@@ -1536,7 +1536,7 @@ pub fn create_dual_funding_utxos_with_prev_txs(
.iter()
.enumerate()
.map(|(index, _)| index as u32)
.map(|vout| FundingTxInput::new_p2wpkh(tx.clone(), vout).unwrap())
.map(|vout| ConfirmedUtxo::new_p2wpkh(tx.clone(), vout).unwrap())
.collect()
}

Expand Down
48 changes: 22 additions & 26 deletions lightning/src/ln/funding.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ use crate::ln::LN_MAX_MSG_LEN;
use crate::prelude::*;
use crate::util::native_async::MaybeSend;
use crate::util::wallet_utils::{
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, Input,
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, ConfirmedUtxo, Input,
};

/// Error returned when a [`FundingContribution`] cannot be adjusted to a target feerate.
Expand DownExpand Up@@ -370,7 +370,7 @@ impl FundingTemplate {
/// when that is set. `max_feerate` is the highest feerate we are willing to tolerate if we end
/// up as the acceptor, and must be at least `min_feerate`.
pub fn splice_in_inputs(
self, inputs: Vec<FundingTxInput>, min_feerate: FeeRate, max_feerate: FeeRate,
self, inputs: Vec<ConfirmedUtxo>, min_feerate: FeeRate, max_feerate: FeeRate,
) -> Result<FundingContribution, FundingContributionError> {
self.with_prior_contribution(min_feerate, max_feerate).add_inputs(inputs)?.build()
}
Expand DownExpand Up@@ -466,8 +466,8 @@ impl FundingTemplate {
}

fn estimate_transaction_fee(
inputs: &[FundingTxInput], outputs: &[TxOut], change_output: Option<&TxOut>,
is_initiator: bool, is_splice: bool, feerate: FeeRate,
inputs: &[ConfirmedUtxo], outputs: &[TxOut], change_output: Option<&TxOut>, is_initiator: bool,
is_splice: bool, feerate: FeeRate,
) -> Amount {
let input_weight: u64 = inputs
.iter()
Expand DownExpand Up@@ -515,7 +515,7 @@ fn estimate_transaction_fee(
Weight::from_wu(weight) * feerate
}

fn validate_inputs(inputs: &[FundingTxInput]) -> Result<(), FundingContributionError> {
fn validate_inputs(inputs: &[ConfirmedUtxo]) -> Result<(), FundingContributionError> {
let mut total_value = Amount::ZERO;
for (idx, input) in inputs.iter().enumerate() {
if inputs[..idx]
Expand DownExpand Up@@ -559,7 +559,7 @@ enum FundingInputs {
/// Replaces the contribution's inputs with the provided set and fully consumes them without a
/// change output. The amount added to the channel is recomputed from the input total minus fees,
/// while explicit withdrawal outputs still reduce the splice's net value.
ManuallySelected { inputs: Vec<FundingTxInput> },
ManuallySelected { inputs: Vec<ConfirmedUtxo> },
}

impl FundingInputs {
Expand All@@ -584,7 +584,7 @@ impl FundingInputs {
}
}

fn manually_selected_inputs(&self) -> &[FundingTxInput] {
fn manually_selected_inputs(&self) -> &[ConfirmedUtxo] {
match self {
FundingInputs::ManuallySelected { inputs } => inputs,
FundingInputs::CoinSelected { .. } => &[],
Expand DownExpand Up@@ -613,7 +613,7 @@ pub struct FundingContribution {
///
/// For coin-selected contributions, excess value is returned via [`Self::change_output`]. For
/// manually selected inputs, the full input value is consumed and no change output is created.
inputs: Vec<FundingTxInput>,
inputs: Vec<ConfirmedUtxo>,

/// The outputs to include in the funding transaction.
///
Expand DownExpand Up@@ -691,7 +691,7 @@ impl FundingContribution {
}

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

Expand DownExpand Up@@ -827,7 +827,7 @@ impl FundingContribution {
Some(new_contribution_at_target_feerate)
}

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

if let Some(change_output) = change_output {
Expand DownExpand Up@@ -1131,10 +1131,6 @@ impl FundingContribution {
}
}

/// An input to contribute to a channel's funding transaction either when using the v2 channel
/// establishment protocol or when splicing.
pub type FundingTxInput = crate::util::wallet_utils::ConfirmedUtxo;

#[derive(Debug, Clone, PartialEq, Eq)]
struct NoCoinSelectionSource;
#[derive(Debug, Clone, PartialEq, Eq)]
Expand DownExpand Up@@ -1472,7 +1468,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_input(self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
pub fn add_input(self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
self.0.add_input_inner(input).map(FundingBuilder)
}

Expand All@@ -1490,7 +1486,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_inputs(self, inputs: Vec<FundingTxInput>) -> Result<Self, FundingContributionError> {
pub fn add_inputs(self, inputs: Vec<ConfirmedUtxo>) -> Result<Self, FundingContributionError> {
self.0.add_inputs_inner(inputs).map(FundingBuilder)
}

Expand DownExpand Up@@ -1585,7 +1581,7 @@ impl<State> FundingBuilderInner<State> {
Ok(self)
}

fn add_input_inner(mut self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
fn add_input_inner(mut self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => {
self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs: vec![input] })
Expand All@@ -1599,7 +1595,7 @@ impl<State> FundingBuilderInner<State> {
}

fn add_inputs_inner(
mut self, inputs: Vec<FundingTxInput>,
mut self, inputs: Vec<ConfirmedUtxo>,
) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs }),
Expand DownExpand Up@@ -1875,11 +1871,11 @@ impl<W: CoinSelectionSourceSync> SyncFundingBuilder<W> {
mod tests {
use super::{
estimate_transaction_fee, FeeRateAdjustmentError, FundingBuilder, FundingContribution,
FundingContributionError, FundingInputMode, FundingTemplate, FundingTxInput,
SyncCoinSelectionSource, SyncFundingBuilder,
FundingContributionError, FundingInputMode, FundingTemplate, SyncCoinSelectionSource,
SyncFundingBuilder,
};
use crate::chain::ClaimId;
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, Input};
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, ConfirmedUtxo, Input};
use bitcoin::hashes::Hash;
use bitcoin::transaction::{Transaction, TxOut, Version};
use bitcoin::{Amount, FeeRate, Psbt, ScriptBuf, SignedAmount, WPubkeyHash, WScriptHash};
Expand DownExpand Up@@ -1960,7 +1956,7 @@ mod tests {
}

#[rustfmt::skip]
fn funding_input_sats(input_value_sats: u64) -> FundingTxInput {
fn funding_input_sats(input_value_sats: u64) -> ConfirmedUtxo {
let prevout = TxOut {
value: Amount::from_sat(input_value_sats),
script_pubkey: ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros()),
Expand All@@ -1970,7 +1966,7 @@ mod tests {
version: Version::TWO, lock_time: bitcoin::absolute::LockTime::ZERO,
};

FundingTxInput::new_p2wpkh(prevtx, 0).unwrap()
ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap()
}

fn funding_output_sats(output_value_sats: u64) -> TxOut {
Expand All@@ -1995,7 +1991,7 @@ mod tests {
}

struct MustPayToWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
expected_must_pay_to_values: Vec<Amount>,
}
Expand DownExpand Up@@ -2805,7 +2801,7 @@ mod tests {
assert!(prevtx.serialized_length() > crate::ln::LN_MAX_MSG_LEN);

let wallet = SingleUtxoWallet {
utxo: FundingTxInput::new_p2wpkh(prevtx, 0).unwrap(),
utxo: ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap(),
change_output: None,
};
assert!(matches!(
Expand DownExpand Up@@ -3713,7 +3709,7 @@ mod tests {

/// A mock wallet that returns a single UTXO for coin selection.
struct SingleUtxoWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
}

Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
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
12 changes: 5 additions & 7 deletions lightning/src/ln/channel.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,7 @@ use crate::ln::channelmanager::{
PendingHTLCStatus, RAACommitmentOrder, SentHTLCId, TrustedChannelFeatures, BREAKDOWN_TIMEOUT,
MAX_LOCAL_BREAKDOWN_TIMEOUT, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{
FeeRateAdjustmentError, FundingContribution, FundingTemplate, FundingTxInput,
};
use crate::ln::funding::{FeeRateAdjustmentError, FundingContribution, FundingTemplate};
use crate::ln::interactivetxs::{
AbortReason, HandleTxCompleteValue, InteractiveTxConstructor, InteractiveTxConstructorArgs,
InteractiveTxMessageSend, InteractiveTxSigningSession, SharedOwnedInput, SharedOwnedOutput,
Expand DownExpand Up@@ -87,7 +85,7 @@ use crate::util::errors::APIError;
use crate::util::logger::{Level as LoggerLevel, Logger, Record, WithContext};
use crate::util::scid_utils::{block_from_scid, scid_from_parts};
use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, Writeable, Writer};
use crate::util::wallet_utils::Input;
use crate::util::wallet_utils::{ConfirmedUtxo, Input};
use crate::{impl_readable_for_vec, impl_writeable_for_vec};

use alloc::collections::{btree_map, BTreeMap};
Expand DownExpand Up@@ -3100,7 +3098,7 @@ impl FundingNegotiation {
funding: FundingScope, context: &ChannelContext<SP>, entropy_source: &ES,
holder_node_id: &PublicKey, our_funding_contribution: SignedAmount,
prev_funding_input: SharedOwnedInput, locktime: u32, feerate_sat_per_1000_weight: u32,
our_funding_inputs: Vec<FundingTxInput>, our_funding_outputs: Vec<TxOut>,
our_funding_inputs: Vec<ConfirmedUtxo>, our_funding_outputs: Vec<TxOut>,
) -> FundingNegotiation {
let funding_negotiation_context = FundingNegotiationContext {
is_initiator: false,
Expand DownExpand Up@@ -6905,7 +6903,7 @@ pub(super) struct FundingNegotiationContext {
pub shared_funding_input: Option<SharedOwnedInput>,
/// The funding inputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_inputs: Vec<FundingTxInput>,
pub our_funding_inputs: Vec<ConfirmedUtxo>,
/// The funding outputs we will be contributing to the channel.
#[allow(dead_code)] // TODO(dual_funding): Remove once contribution to V2 channels is enabled.
pub our_funding_outputs: Vec<TxOut>,
Expand DownExpand Up@@ -15402,7 +15400,7 @@ impl<SP: SignerProvider> PendingV2Channel<SP> {
pub fn new_outbound<ES: EntropySource, F: FeeEstimator, L: Logger>(
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
counterparty_node_id: PublicKey, their_features: &InitFeatures, funding_satoshis: u64,
funding_inputs: Vec<FundingTxInput>, user_id: u128, config: &UserConfig,
funding_inputs: Vec<ConfirmedUtxo>, user_id: u128, config: &UserConfig,
current_chain_height: u32, outbound_scid_alias: u64, funding_confirmation_target: ConfirmationTarget,
logger: L, trusted_channel_features: Option<TrustedChannelFeatures>,
) -> Result<Self, APIError> {
Expand Down
8 changes: 4 additions & 4 deletions lightning/src/ln/functional_test_utils.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@ use crate::ln::channelmanager::{
AChannelManager, ChainParameters, ChannelManager, ChannelManagerReadArgs, PaymentId,
RAACommitmentOrder, TrustedChannelFeatures, MIN_CLTV_EXPIRY_DELTA,
};
use crate::ln::funding::{FundingContribution, FundingTxInput};
use crate::ln::funding::FundingContribution;
use crate::ln::msgs::{self, OpenChannel};
use crate::ln::msgs::{
BaseMessageHandler, ChannelMessageHandler, MessageSendEvent, RoutingMessageHandler,
Expand All@@ -55,7 +55,7 @@ use crate::util::test_channel_signer::SignerOp;
use crate::util::test_channel_signer::TestChannelSigner;
use crate::util::test_utils::{self, TestLogger};
use crate::util::test_utils::{TestChainMonitor, TestKeysInterface, TestScorer};
use crate::util::wallet_utils::{WalletSourceSync, WalletSync};
use crate::util::wallet_utils::{ConfirmedUtxo, WalletSourceSync, WalletSync};

use bitcoin::amount::Amount;
use bitcoin::block::{Block, Header, Version as BlockVersion};
Expand DownExpand Up@@ -1512,7 +1512,7 @@ fn internal_create_funding_transaction<'a, 'b, 'c>(
/// Return the inputs (with prev tx), and the total witness weight for these inputs
pub fn create_dual_funding_utxos_with_prev_txs(
node: &Node<'_, '_, '_>, utxo_values_in_satoshis: &[u64],
) -> Vec<FundingTxInput> {
) -> Vec<ConfirmedUtxo> {
// Ensure we have unique transactions per node by using the locktime.
let tx = Transaction {
version: TxVersion::TWO,
Expand All@@ -1536,7 +1536,7 @@ pub fn create_dual_funding_utxos_with_prev_txs(
.iter()
.enumerate()
.map(|(index, _)| index as u32)
.map(|vout| FundingTxInput::new_p2wpkh(tx.clone(), vout).unwrap())
.map(|vout| ConfirmedUtxo::new_p2wpkh(tx.clone(), vout).unwrap())
.collect()
}

Expand Down
48 changes: 22 additions & 26 deletions lightning/src/ln/funding.rs
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ use crate::ln::LN_MAX_MSG_LEN;
use crate::prelude::*;
use crate::util::native_async::MaybeSend;
use crate::util::wallet_utils::{
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, Input,
CoinSelection, CoinSelectionSource, CoinSelectionSourceSync, ConfirmedUtxo, Input,
};

/// Error returned when a [`FundingContribution`] cannot be adjusted to a target feerate.
Expand DownExpand Up@@ -370,7 +370,7 @@ impl FundingTemplate {
/// when that is set. `max_feerate` is the highest feerate we are willing to tolerate if we end
/// up as the acceptor, and must be at least `min_feerate`.
pub fn splice_in_inputs(
self, inputs: Vec<FundingTxInput>, min_feerate: FeeRate, max_feerate: FeeRate,
self, inputs: Vec<ConfirmedUtxo>, min_feerate: FeeRate, max_feerate: FeeRate,
) -> Result<FundingContribution, FundingContributionError> {
self.with_prior_contribution(min_feerate, max_feerate).add_inputs(inputs)?.build()
}
Expand DownExpand Up@@ -466,8 +466,8 @@ impl FundingTemplate {
}

fn estimate_transaction_fee(
inputs: &[FundingTxInput], outputs: &[TxOut], change_output: Option<&TxOut>,
is_initiator: bool, is_splice: bool, feerate: FeeRate,
inputs: &[ConfirmedUtxo], outputs: &[TxOut], change_output: Option<&TxOut>, is_initiator: bool,
is_splice: bool, feerate: FeeRate,
) -> Amount {
let input_weight: u64 = inputs
.iter()
Expand DownExpand Up@@ -515,7 +515,7 @@ fn estimate_transaction_fee(
Weight::from_wu(weight) * feerate
}

fn validate_inputs(inputs: &[FundingTxInput]) -> Result<(), FundingContributionError> {
fn validate_inputs(inputs: &[ConfirmedUtxo]) -> Result<(), FundingContributionError> {
let mut total_value = Amount::ZERO;
for (idx, input) in inputs.iter().enumerate() {
if inputs[..idx]
Expand DownExpand Up@@ -559,7 +559,7 @@ enum FundingInputs {
/// Replaces the contribution's inputs with the provided set and fully consumes them without a
/// change output. The amount added to the channel is recomputed from the input total minus fees,
/// while explicit withdrawal outputs still reduce the splice's net value.
ManuallySelected { inputs: Vec<FundingTxInput> },
ManuallySelected { inputs: Vec<ConfirmedUtxo> },
}

impl FundingInputs {
Expand All@@ -584,7 +584,7 @@ impl FundingInputs {
}
}

fn manually_selected_inputs(&self) -> &[FundingTxInput] {
fn manually_selected_inputs(&self) -> &[ConfirmedUtxo] {
match self {
FundingInputs::ManuallySelected { inputs } => inputs,
FundingInputs::CoinSelected { .. } => &[],
Expand DownExpand Up@@ -613,7 +613,7 @@ pub struct FundingContribution {
///
/// For coin-selected contributions, excess value is returned via [`Self::change_output`]. For
/// manually selected inputs, the full input value is consumed and no change output is created.
inputs: Vec<FundingTxInput>,
inputs: Vec<ConfirmedUtxo>,

/// The outputs to include in the funding transaction.
///
Expand DownExpand Up@@ -691,7 +691,7 @@ impl FundingContribution {
}

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

Expand DownExpand Up@@ -827,7 +827,7 @@ impl FundingContribution {
Some(new_contribution_at_target_feerate)
}

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

if let Some(change_output) = change_output {
Expand DownExpand Up@@ -1131,10 +1131,6 @@ impl FundingContribution {
}
}

/// An input to contribute to a channel's funding transaction either when using the v2 channel
/// establishment protocol or when splicing.
pub type FundingTxInput = crate::util::wallet_utils::ConfirmedUtxo;

#[derive(Debug, Clone, PartialEq, Eq)]
struct NoCoinSelectionSource;
#[derive(Debug, Clone, PartialEq, Eq)]
Expand DownExpand Up@@ -1472,7 +1468,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_input(self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
pub fn add_input(self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
self.0.add_input_inner(input).map(FundingBuilder)
}

Expand All@@ -1490,7 +1486,7 @@ impl FundingBuilder {
///
/// Returns [`FundingContributionError::InvalidSpliceValue`] if the builder already has a
/// coin-selected value request.
pub fn add_inputs(self, inputs: Vec<FundingTxInput>) -> Result<Self, FundingContributionError> {
pub fn add_inputs(self, inputs: Vec<ConfirmedUtxo>) -> Result<Self, FundingContributionError> {
self.0.add_inputs_inner(inputs).map(FundingBuilder)
}

Expand DownExpand Up@@ -1585,7 +1581,7 @@ impl<State> FundingBuilderInner<State> {
Ok(self)
}

fn add_input_inner(mut self, input: FundingTxInput) -> Result<Self, FundingContributionError> {
fn add_input_inner(mut self, input: ConfirmedUtxo) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => {
self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs: vec![input] })
Expand All@@ -1599,7 +1595,7 @@ impl<State> FundingBuilderInner<State> {
}

fn add_inputs_inner(
mut self, inputs: Vec<FundingTxInput>,
mut self, inputs: Vec<ConfirmedUtxo>,
) -> Result<Self, FundingContributionError> {
match &mut self.funding_inputs {
None => self.funding_inputs = Some(FundingInputs::ManuallySelected { inputs }),
Expand DownExpand Up@@ -1875,11 +1871,11 @@ impl<W: CoinSelectionSourceSync> SyncFundingBuilder<W> {
mod tests {
use super::{
estimate_transaction_fee, FeeRateAdjustmentError, FundingBuilder, FundingContribution,
FundingContributionError, FundingInputMode, FundingTemplate, FundingTxInput,
SyncCoinSelectionSource, SyncFundingBuilder,
FundingContributionError, FundingInputMode, FundingTemplate, SyncCoinSelectionSource,
SyncFundingBuilder,
};
use crate::chain::ClaimId;
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, Input};
use crate::util::wallet_utils::{CoinSelection, CoinSelectionSourceSync, ConfirmedUtxo, Input};
use bitcoin::hashes::Hash;
use bitcoin::transaction::{Transaction, TxOut, Version};
use bitcoin::{Amount, FeeRate, Psbt, ScriptBuf, SignedAmount, WPubkeyHash, WScriptHash};
Expand DownExpand Up@@ -1960,7 +1956,7 @@ mod tests {
}

#[rustfmt::skip]
fn funding_input_sats(input_value_sats: u64) -> FundingTxInput {
fn funding_input_sats(input_value_sats: u64) -> ConfirmedUtxo {
let prevout = TxOut {
value: Amount::from_sat(input_value_sats),
script_pubkey: ScriptBuf::new_p2wpkh(&WPubkeyHash::all_zeros()),
Expand All@@ -1970,7 +1966,7 @@ mod tests {
version: Version::TWO, lock_time: bitcoin::absolute::LockTime::ZERO,
};

FundingTxInput::new_p2wpkh(prevtx, 0).unwrap()
ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap()
}

fn funding_output_sats(output_value_sats: u64) -> TxOut {
Expand All@@ -1995,7 +1991,7 @@ mod tests {
}

struct MustPayToWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
expected_must_pay_to_values: Vec<Amount>,
}
Expand DownExpand Up@@ -2805,7 +2801,7 @@ mod tests {
assert!(prevtx.serialized_length() > crate::ln::LN_MAX_MSG_LEN);

let wallet = SingleUtxoWallet {
utxo: FundingTxInput::new_p2wpkh(prevtx, 0).unwrap(),
utxo: ConfirmedUtxo::new_p2wpkh(prevtx, 0).unwrap(),
change_output: None,
};
assert!(matches!(
Expand DownExpand Up@@ -3713,7 +3709,7 @@ mod tests {

/// A mock wallet that returns a single UTXO for coin selection.
struct SingleUtxoWallet {
utxo: FundingTxInput,
utxo: ConfirmedUtxo,
change_output: Option<TxOut>,
}

Expand Down
Loading
Loading