Skip to content

Commit 6451e2b

Browse files
committed
Add interactive tx constructor to ChannelContext
1 parent 87fc324 commit 6451e2b

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};
@@ -3633,6 +3635,9 @@ pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
36333635
pub context: ChannelContext<SP>,
36343636
#[cfg(any(dual_funding, splicing))]
36353637
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
3638+
/// The current interactive transaction construction session under negotiation.
3639+
#[cfg(any(dual_funding, splicing))]
3640+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
36363641
}
36373642

36383643
#[cfg(any(test, fuzzing))]
@@ -7734,6 +7739,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77347739
context: self.context,
77357740
#[cfg(any(dual_funding, splicing))]
77367741
dual_funding_channel_context: None,
7742+
#[cfg(any(dual_funding, splicing))]
7743+
interactive_tx_constructor: None,
77377744
};
77387745

77397746
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
@@ -7842,7 +7849,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
78427849
msg.push_msat,
78437850
msg.common_fields.clone(),
78447851
)?,
7845-
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
7852+
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 },
78467853
};
78477854
Ok(chan)
78487855
}
@@ -8025,6 +8032,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80258032
context: self.context,
80268033
#[cfg(any(dual_funding, splicing))]
80278034
dual_funding_channel_context: None,
8035+
#[cfg(any(dual_funding, splicing))]
8036+
interactive_tx_constructor: None,
80288037
};
80298038
let need_channel_ready = channel.check_get_channel_ready(0, logger).is_some();
80308039
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
@@ -8038,8 +8047,9 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80388047
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
80398048
pub context: ChannelContext<SP>,
80408049
pub unfunded_context: UnfundedChannelContext,
8041-
#[cfg(any(dual_funding, splicing))]
80428050
pub dual_funding_context: DualFundingChannelContext,
8051+
/// The current interactive transaction construction session under negotiation.
8052+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
80438053
}
80448054

80458055
#[cfg(any(dual_funding, splicing))]
@@ -8090,7 +8100,9 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
80908100
their_funding_satoshis: 0,
80918101
funding_tx_locktime,
80928102
funding_feerate_sat_per_1000_weight,
8093-
}
8103+
},
8104+
#[cfg(any(dual_funding, splicing))]
8105+
interactive_tx_constructor: None,
80948106
};
80958107
Ok(chan)
80968108
}
@@ -8163,6 +8175,8 @@ pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
81638175
pub context: ChannelContext<SP>,
81648176
pub unfunded_context: UnfundedChannelContext,
81658177
pub dual_funding_context: DualFundingChannelContext,
8178+
/// The current interactive transaction construction session under negotiation.
8179+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
81668180
}
81678181

81688182
#[cfg(any(dual_funding, splicing))]
@@ -8235,7 +8249,8 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
82358249
their_funding_satoshis: msg.common_fields.funding_satoshis,
82368250
funding_tx_locktime: msg.locktime,
82378251
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
8238-
}
8252+
},
8253+
interactive_tx_constructor: None,
82398254
};
82408255

82418256
Ok(chan)
@@ -9361,6 +9376,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
93619376
},
93629377
#[cfg(any(dual_funding, splicing))]
93639378
dual_funding_channel_context: None,
9379+
#[cfg(any(dual_funding, splicing))]
9380+
interactive_tx_constructor: None,
93649381
})
93659382
}
93669383
}

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7287,7 +7287,6 @@ where
72877287
// TODO(dual_funding): Combine this match arm with above.
72887288
#[cfg(any(dual_funding, splicing))]
72897289
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
7290-
let context = phase.context_mut();
72917290
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
72927291
let mut chan = remove_channel_phase!(self, chan_phase_entry);
72937292
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
@@ -9997,7 +9996,7 @@ where
99979996

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

0 commit comments

Comments
 (0)