Skip to content

Commit c218186

Browse files
committed
Add interactive tx constructor to ChannelContext
1 parent 7326334 commit c218186

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};
@@ -3602,6 +3604,9 @@ pub(super) struct Channel<SP: Deref> where SP::Target: SignerProvider {
36023604
pub context: ChannelContext<SP>,
36033605
#[cfg(any(dual_funding, splicing))]
36043606
pub dual_funding_channel_context: Option<DualFundingChannelContext>,
3607+
/// The current interactive transaction construction session under negotiation.
3608+
#[cfg(any(dual_funding, splicing))]
3609+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
36053610
}
36063611

36073612
#[cfg(any(test, fuzzing))]
@@ -7797,6 +7802,8 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77977802
context: self.context,
77987803
#[cfg(any(dual_funding, splicing))]
77997804
dual_funding_channel_context: None,
7805+
#[cfg(any(dual_funding, splicing))]
7806+
interactive_tx_constructor: None,
78007807
};
78017808

78027809
let need_channel_ready = channel.check_get_channel_ready(0).is_some();
@@ -7905,7 +7912,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
79057912
msg.push_msat,
79067913
msg.common_fields.clone(),
79077914
)?,
7908-
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 }
7915+
unfunded_context: UnfundedChannelContext { unfunded_channel_age_ticks: 0 },
79097916
};
79107917
Ok(chan)
79117918
}
@@ -8087,6 +8094,8 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
80878094
context: self.context,
80888095
#[cfg(any(dual_funding, splicing))]
80898096
dual_funding_channel_context: None,
8097+
#[cfg(any(dual_funding, splicing))]
8098+
interactive_tx_constructor: None,
80908099
};
80918100
let need_channel_ready = channel.check_get_channel_ready(0).is_some();
80928101
channel.monitor_updating_paused(false, false, need_channel_ready, Vec::new(), Vec::new(), Vec::new());
@@ -8100,8 +8109,9 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
81008109
pub(super) struct OutboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
81018110
pub context: ChannelContext<SP>,
81028111
pub unfunded_context: UnfundedChannelContext,
8103-
#[cfg(any(dual_funding, splicing))]
81048112
pub dual_funding_context: DualFundingChannelContext,
8113+
/// The current interactive transaction construction session under negotiation.
8114+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
81058115
}
81068116

81078117
#[cfg(any(dual_funding, splicing))]
@@ -8152,7 +8162,9 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
81528162
their_funding_satoshis: 0,
81538163
funding_tx_locktime,
81548164
funding_feerate_sat_per_1000_weight,
8155-
}
8165+
},
8166+
#[cfg(any(dual_funding, splicing))]
8167+
interactive_tx_constructor: None,
81568168
};
81578169
Ok(chan)
81588170
}
@@ -8225,6 +8237,8 @@ pub(super) struct InboundV2Channel<SP: Deref> where SP::Target: SignerProvider {
82258237
pub context: ChannelContext<SP>,
82268238
pub unfunded_context: UnfundedChannelContext,
82278239
pub dual_funding_context: DualFundingChannelContext,
8240+
/// The current interactive transaction construction session under negotiation.
8241+
interactive_tx_constructor: Option<InteractiveTxConstructor>,
82288242
}
82298243

82308244
#[cfg(any(dual_funding, splicing))]
@@ -8297,7 +8311,8 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
82978311
their_funding_satoshis: msg.common_fields.funding_satoshis,
82988312
funding_tx_locktime: msg.locktime,
82998313
funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
8300-
}
8314+
},
8315+
interactive_tx_constructor: None,
83018316
};
83028317

83038318
Ok(chan)
@@ -9396,6 +9411,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
93969411
},
93979412
#[cfg(any(dual_funding, splicing))]
93989413
dual_funding_channel_context: None,
9414+
#[cfg(any(dual_funding, splicing))]
9415+
interactive_tx_constructor: None,
93999416
})
94009417
}
94019418
}

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7550,7 +7550,6 @@ where
75507550
// TODO(dual_funding): Combine this match arm with above.
75517551
#[cfg(any(dual_funding, splicing))]
75527552
ChannelPhase::UnfundedInboundV2(_) | ChannelPhase::UnfundedOutboundV2(_) => {
7553-
let context = phase.context_mut();
75547553
log_error!(self.logger, "Immediately closing unfunded channel {} as peer asked to cooperatively shut it down (which is unnecessary)", &msg.channel_id);
75557554
let mut chan = remove_channel_phase!(self, chan_phase_entry);
75567555
finish_shutdown = Some(chan.context_mut().force_shutdown(false, ClosureReason::CounterpartyCoopClosedUnfundedChannel));
@@ -10170,7 +10169,7 @@ where
1017010169

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

0 commit comments

Comments
 (0)