Skip to content

Commit 7950451

Browse files
committed
Add interactive tx constructor to ChannelContext
1 parent 96fe185 commit 7950451

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};
@@ -3415,6 +3417,9 @@ pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
34153417
pub context: ChannelContext<SP>,
34163418
#[cfg(any(dual_funding, splicing))]
34173419
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
3420+
/// The current interactive transaction construction session under negotiation.
3421+
#[cfg(any(dual_funding, splicing))]
3422+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
34183423
}
34193424

34203425
#[cfg(any(test, fuzzing))]
@@ -7610,6 +7615,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
76107615
context: self.context,
76117616
#[cfg(any(dual_funding, splicing))]
76127617
dual_funding_channel_context: None,
7618+
#[cfg(any(dual_funding, splicing))]
7619+
interactive_tx_constructor: None,
76137620
};
76147621

76157622
let need_channel_ready = channel.check_get_channel_ready(0).is_some();
@@ -7718,7 +7725,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
77187725
msg.push_msat,
77197726
msg.common_fields.clone(),
77207727
)?,
7721-
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
7728+
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 },
77227729
};
77237730
Ok(chan)
77247731
}
@@ -7900,6 +7907,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
79007907
context: self.context,
79017908
#[cfg(any(dual_funding, splicing))]
79027909
dual_funding_channel_context: None,
7910+
#[cfg(any(dual_funding, splicing))]
7911+
interactive_tx_constructor: None,
79037912
};
79047913
let need_channel_ready = channel.check_get_channel_ready(0).is_some();
79057914
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
@@ -7913,8 +7922,9 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
79137922
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
79147923
pub context: ChannelContext<SP>,
79157924
pub unfunded_context: UnfundedChannelContext,
7916-
#[cfg(any(dual_funding, splicing))]
79177925
pub dual_funding_context: DualFundingChannelContext,
7926+
/// The current interactive transaction construction session under negotiation.
7927+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
79187928
}
79197929

79207930
#[cfg(any(dual_funding, splicing))]
@@ -7965,7 +7975,9 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
79657975
their_funding_satoshis: 0,
79667976
funding_tx_locktime,
79677977
funding_feerate_sat_per_1000_weight,
7968-
}
7978+
},
7979+
#[cfg(any(dual_funding, splicing))]
7980+
interactive_tx_constructor: None,
79697981
};
79707982
Ok(chan)
79717983
}
@@ -8038,6 +8050,8 @@ pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
80388050
pub context: ChannelContext<SP>,
80398051
pub unfunded_context: UnfundedChannelContext,
80408052
pub dual_funding_context: DualFundingChannelContext,
8053+
/// The current interactive transaction construction session under negotiation.
8054+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
80418055
}
80428056

80438057
#[cfg(any(dual_funding, splicing))]
@@ -8110,7 +8124,8 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
81108124
their_funding_satoshis: msg.common_fields.funding_satoshis,
81118125
funding_tx_locktime: msg.locktime,
81128126
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
8113-
}
8127+
},
8128+
interactive_tx_constructor: None,
81148129
};
81158130

81168131
Ok(chan)
@@ -9209,6 +9224,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
92099224
},
92109225
#[cfg(any(dual_funding, splicing))]
92119226
dual_funding_channel_context: None,
9227+
#[cfg(any(dual_funding, splicing))]
9228+
interactive_tx_constructor: None,
92129229
})
92139230
}
92149231
}

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7236,7 +7236,6 @@ where
72367236
// TODO(dual_funding): Combine this match arm with above.
72377237
#[cfg(any(dual_funding, splicing))]
72387238
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
7239-
let context = phase.context_mut();
72407239
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
72417240
let mut chan = remove_channel_phase!(self, chan_phase_entry);
72427241
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
@@ -9856,7 +9855,7 @@ where
98569855

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

0 commit comments

Comments
 (0)