Skip to content

Commit 684b3b7

Browse files
committed
Introduce InteractiveTxSigningSession for signing interactively constructed txs
1 parent 24ba584 commit 684b3b7

File tree

3 files changed

+313
-54
lines changed

3 files changed

+313
-54
lines changed

lightning/src/ln/channel.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8564,7 +8564,7 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
85648564
/// Assumes chain_hash has already been checked and corresponds with what we expect!
85658565
pub fn new<ES: Deref, F: Deref, L: Deref>(
85668566
fee_estimator: &LowerBoundedFeeEstimator<F>, entropy_source: &ES, signer_provider: &SP,
8567-
counterparty_node_id: PublicKey, our_supported_features: &ChannelTypeFeatures,
8567+
holder_node_id: PublicKey, counterparty_node_id: PublicKey, our_supported_features: &ChannelTypeFeatures,
85688568
their_features: &InitFeatures, msg: &msgs::OpenChannelV2,
85698569
funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>, total_witness_weight: Weight,
85708570
user_id: u128, config: &UserConfig, current_chain_height: u32, logger: &L,
@@ -8640,6 +8640,8 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
86408640
let interactive_tx_constructor = Some(InteractiveTxConstructor::new(
86418641
InteractiveTxConstructorArgs {
86428642
entropy_source,
8643+
holder_node_id,
8644+
counterparty_node_id,
86438645
channel_id: context.channel_id,
86448646
feerate_sat_per_kw: dual_funding_context.funding_feerate_sat_per_1000_weight,
86458647
funding_tx_locktime: dual_funding_context.funding_tx_locktime,

lightning/src/ln/channelmanager.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7673,7 +7673,7 @@ where
76737673
},
76747674
OpenChannelMessage::V2(open_channel_msg) => {
76757675
InboundV2Channel::new(&self.fee_estimator, &self.entropy_source, &self.signer_provider,
7676-
*counterparty_node_id, &self.channel_type_features(), &peer_state.latest_features,
7676+
self.get_our_node_id(), *counterparty_node_id, &self.channel_type_features(), &peer_state.latest_features,
76777677
&open_channel_msg, funding_inputs, total_witness_weight, user_channel_id,
76787678
&self.default_configuration, best_block_height, &self.logger
76797679
).map_err(|_| MsgHandleErrInternal::from_chan_no_close(
@@ -7945,9 +7945,9 @@ where
79457945
},
79467946
OpenChannelMessageRef::V2(msg) => {
79477947
let channel = InboundV2Channel::new(&self.fee_estimator, &self.entropy_source,
7948-
&self.signer_provider, *counterparty_node_id, &self.channel_type_features(),
7949-
&peer_state.latest_features, msg, vec![], Weight::from_wu(0), user_channel_id,
7950-
&self.default_configuration, best_block_height, &self.logger
7948+
&self.signer_provider, self.get_our_node_id(), *counterparty_node_id,
7949+
&self.channel_type_features(), &peer_state.latest_features, msg, vec![], Weight::from_wu(0),
7950+
user_channel_id, &self.default_configuration, best_block_height, &self.logger
79517951
).map_err(|e| MsgHandleErrInternal::from_chan_no_close(e, msg.common_fields.temporary_channel_id))?;
79527952
let message_send_event = events::MessageSendEvent::SendAcceptChannelV2 {
79537953
node_id: *counterparty_node_id,
@@ -8266,9 +8266,11 @@ where
82668266
match peer_state.channel_by_id.entry(msg.channel_id) {
82678267
hash_map::Entry::Occupied(mut chan_phase_entry) => {
82688268
let channel_phase = chan_phase_entry.get_mut();
8269-
let (msg_send_event_opt, tx_opt) = match channel_phase {
8270-
ChannelPhase::UnfundedInboundV2(channel) => channel.tx_complete(msg).into_msg_send_event_or_tx(counterparty_node_id),
8271-
ChannelPhase::UnfundedOutboundV2(channel) => channel.tx_complete(msg).into_msg_send_event_or_tx(counterparty_node_id),
8269+
let (msg_send_event_opt, signing_session_opt) = match channel_phase {
8270+
ChannelPhase::UnfundedInboundV2(channel) => channel.tx_complete(msg)
8271+
.into_msg_send_event_or_signing_session(counterparty_node_id),
8272+
ChannelPhase::UnfundedOutboundV2(channel) => channel.tx_complete(msg)
8273+
.into_msg_send_event_or_signing_session(counterparty_node_id),
82728274
_ => try_chan_phase_entry!(self, peer_state, Err(ChannelError::Close(
82738275
(
82748276
"Got a tx_complete message with no interactive transaction construction expected or in-progress".into(),
@@ -8278,7 +8280,7 @@ where
82788280
if let Some(msg_send_event) = msg_send_event_opt {
82798281
peer_state.pending_msg_events.push(msg_send_event);
82808282
}
8281-
if let Some(tx) = tx_opt {
8283+
if let Some(signing_session) = signing_session_opt {
82828284
// TODO(dual_funding): Handle this unsigned transaction.
82838285
}
82848286
Ok(())

0 commit comments

Comments
 (0)