@@ -31,8 +31,9 @@ use crate::ln::types::ChannelId;
31
31
use crate::types::payment::{PaymentPreimage, PaymentHash};
32
32
use crate::types::features::{ChannelTypeFeatures, InitFeatures};
33
33
use crate::ln::interactivetxs::{
34
- get_output_weight, HandleTxCompleteResult, InteractiveTxConstructor, InteractiveTxConstructorArgs,
35
- InteractiveTxSigningSession, InteractiveTxMessageSendResult, TX_COMMON_FIELDS_WEIGHT,
34
+ ConstructedTransaction, get_output_weight, HandleTxCompleteResult, InteractiveTxConstructor,
35
+ InteractiveTxConstructorArgs, InteractiveTxSigningSession, InteractiveTxMessageSendResult,
36
+ TX_COMMON_FIELDS_WEIGHT,
36
37
};
37
38
use crate::ln::msgs;
38
39
use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError};
@@ -9239,7 +9240,16 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
9239
9240
self.context.channel_id.write(writer)?;
9240
9241
{
9241
9242
let mut channel_state = self.context.channel_state;
9242
- if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_)) {
9243
+ if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_))
9244
+ {
9245
+ channel_state.set_peer_disconnected();
9246
+ } else if self.interactive_tx_signing_session.is_some() {
9247
+ if !matches!(channel_state, ChannelState::FundingNegotiated) {
9248
+ debug_assert!(false, "V2 channels in pre-signing state should not be written");
9249
+ }
9250
+ // This is a V2 session which has an active signing session
9251
+ // TODO(dual_funding): When we allow contributing funds to dual-funded channels,
9252
+ // we will need to handle persisting appropriate signing session state.
9243
9253
channel_state.set_peer_disconnected();
9244
9254
} else {
9245
9255
debug_assert!(false, "Pre-funded/shutdown channels should not be written");
@@ -9893,6 +9903,28 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
9893
9903
let mut next_holder_commitment_point_opt: Option<PublicKey> = None;
9894
9904
let mut is_manual_broadcast = None;
9895
9905
9906
+ let interactive_tx_signing_session = if matches!(channel_state, ChannelState::FundingNegotiated) {
9907
+ if let Some(ref funding_tx) = funding_transaction {
9908
+ // TODO(dual_funding): When we allow contributing funds to dual-funded channels,
9909
+ // we will need to handle persisting appropriate signing session state.
9910
+ Some(InteractiveTxSigningSession {
9911
+ unsigned_tx: ConstructedTransaction::default(),
9912
+ counterparty_sent_tx_signatures: false,
9913
+ holder_sends_tx_signatures_first: true, // TODO(dual_funding): Fixed to true as we currently don't contribute inputs.
9914
+ received_commitment_signed: true, // We only enter the FundingNegotiated state once we have persisted the initial channel monitor.
9915
+ holder_tx_signatures: Some(msgs::TxSignatures {
9916
+ channel_id,
9917
+ tx_hash: funding_tx.compute_txid(),
9918
+ witnesses: vec![], // TODO(dual_funding): Fixed to true as we currently don't contribute inputs.
9919
+ shared_input_signature: None, // TODO(splicing): Only relevant to splicing
9920
+ })
9921
+ })
9922
+ } else {
9923
+ debug_assert!(false, "Tried to read V2 channel with signing session but there is no funding transaction");
9924
+ None
9925
+ }
9926
+ } else { None };
9927
+
9896
9928
read_tlv_fields!(reader, {
9897
9929
(0, announcement_sigs, option),
9898
9930
(1, minimum_depth, option),
@@ -10189,7 +10221,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10189
10221
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
10190
10222
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
10191
10223
},
10192
- interactive_tx_signing_session: None ,
10224
+ interactive_tx_signing_session,
10193
10225
})
10194
10226
}
10195
10227
}
0 commit comments