Skip to content

Commit aee14fd

Browse files
committed
Add interactive tx constructor to ChannelContext
1 parent b8cdde8 commit aee14fd

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

lightning/src/ln/channel.rs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ use bitcoin::secp256k1;
2727

2828
use crate::ln::types::{ChannelId, PaymentPreimage, PaymentHash};
2929
use crate::ln::features::{ChannelTypeFeatures, InitFeatures};
30+
#[cfg(any(dual_funding, splicing))]
31+
use crate::ln::interactivetxs::InteractiveTxConstructor;
3032
use crate::ln::msgs;
3133
use crate::ln::msgs::DecodeError;
3234
use crate::ln::script::{self, ShutdownScript};
@@ -3496,6 +3498,9 @@ pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
34963498
pub context: ChannelContext<SP>,
34973499
#[cfg(any(dual_funding, splicing))]
34983500
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
3501+
/// The current interactive transaction construction session under negotiation.
3502+
#[cfg(any(dual_funding, splicing))]
3503+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
34993504
}
35003505

35013506
#[cfg(any(test, fuzzing))]
@@ -7722,6 +7727,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77227727
context: self.context,
77237728
#[cfg(any(dual_funding, splicing))]
77247729
dual_funding_channel_context: None,
7730+
#[cfg(any(dual_funding, splicing))]
7731+
interactive_tx_constructor: None,
77257732
};
77267733

77277734
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -7830,7 +7837,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
78307837
msg.push_msat,
78317838
msg.common_fields.clone(),
78327839
)?,
7833-
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
7840+
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 },
78347841
};
78357842
Ok(chan)
78367843
}
@@ -8013,6 +8020,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80138020
context: self.context,
80148021
#[cfg(any(dual_funding, splicing))]
80158022
dual_funding_channel_context: None,
8023+
#[cfg(any(dual_funding, splicing))]
8024+
interactive_tx_constructor: None,
80168025
};
80178026
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
80188027
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
@@ -8026,8 +8035,9 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80268035
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
80278036
pub context: ChannelContext<SP>,
80288037
pub unfunded_context: UnfundedChannelContext,
8029-
#[cfg(any(dual_funding, splicing))]
80308038
pub dual_funding_context: DualFundingChannelContext,
8039+
/// The current interactive transaction construction session under negotiation.
8040+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
80318041
}
80328042

80338043
#[cfg(any(dual_funding, splicing))]
@@ -8078,7 +8088,9 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
80788088
their_funding_satoshis: 0,
80798089
funding_tx_locktime,
80808090
funding_feerate_sat_per_1000_weight,
8081-
}
8091+
},
8092+
#[cfg(any(dual_funding, splicing))]
8093+
interactive_tx_constructor: None,
80828094
};
80838095
Ok(chan)
80848096
}
@@ -8151,6 +8163,8 @@ pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
81518163
pub context: ChannelContext<SP>,
81528164
pub unfunded_context: UnfundedChannelContext,
81538165
pub dual_funding_context: DualFundingChannelContext,
8166+
/// The current interactive transaction construction session under negotiation.
8167+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
81548168
}
81558169

81568170
#[cfg(any(dual_funding, splicing))]
@@ -8223,7 +8237,8 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
82238237
their_funding_satoshis: msg.common_fields.funding_satoshis,
82248238
funding_tx_locktime: msg.locktime,
82258239
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
8226-
}
8240+
},
8241+
interactive_tx_constructor: None,
82278242
};
82288243

82298244
Ok(chan)
@@ -9349,6 +9364,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
93499364
},
93509365
#[cfg(any(dual_funding, splicing))]
93519366
dual_funding_channel_context: None,
9367+
#[cfg(any(dual_funding, splicing))]
9368+
interactive_tx_constructor: None,
93529369
})
93539370
}
93549371
}

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7270,7 +7270,6 @@ where
72707270
// TODO(dual_funding): Combine this match arm with above.
72717271
#[cfg(any(dual_funding, splicing))]
72727272
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
7273-
let context = phase.context_mut();
72747273
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
72757274
let mut chan = remove_channel_phase!(self, chan_phase_entry);
72767275
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
@@ -9980,7 +9979,7 @@ where
99809979

99819980
// TODO(dual_funding): Combine this match arm with above once #[cfg(any(dual_funding, splicing))] is removed.
99829981
#[cfg(any(dual_funding, splicing))]
9983-
ChannelPhase::UnfundedInboundV2(channel) => {
9982+
ChannelPhase::UnfundedInboundV2(_) => {
99849983
// Since unfunded inbound channel maps are cleared upon disconnecting a peer,
99859984
// they are not persisted and won't be recovered after a crash.
99869985
// Therefore, they shouldn't exist at this point.

0 commit comments

Comments
 (0)