@@ -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};
@@ -9244,7 +9245,16 @@ impl<SP: Deref> Writeable for Channel<SP> where SP::Target: SignerProvider {
9244
9245
self.context.channel_id.write(writer)?;
9245
9246
{
9246
9247
let mut channel_state = self.context.channel_state;
9247
- if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_)) {
9248
+ if matches!(channel_state, ChannelState::AwaitingChannelReady(_)|ChannelState::ChannelReady(_))
9249
+ {
9250
+ channel_state.set_peer_disconnected();
9251
+ } else if self.interactive_tx_signing_session.is_some() {
9252
+ if !matches!(channel_state, ChannelState::FundingNegotiated) {
9253
+ debug_assert!(false, "V2 channels in pre-signing state should not be written");
9254
+ }
9255
+ // This is a V2 session which has an active signing session
9256
+ // TODO(dual_funding): When we allow contributing funds to dual-funded channels,
9257
+ // we will need to handle persisting appropriate signing session state.
9248
9258
channel_state.set_peer_disconnected();
9249
9259
} else {
9250
9260
debug_assert!(false, "Pre-funded/shutdown channels should not be written");
@@ -9898,6 +9908,28 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
9898
9908
let mut next_holder_commitment_point_opt: Option<PublicKey> = None;
9899
9909
let mut is_manual_broadcast = None;
9900
9910
9911
+ let interactive_tx_signing_session = if matches!(channel_state, ChannelState::FundingNegotiated) {
9912
+ if let Some(ref funding_tx) = funding_transaction {
9913
+ // TODO(dual_funding): When we allow contributing funds to dual-funded channels,
9914
+ // we will need to handle persisting appropriate signing session state.
9915
+ Some(InteractiveTxSigningSession {
9916
+ unsigned_tx: ConstructedTransaction::default(),
9917
+ counterparty_sent_tx_signatures: false,
9918
+ holder_sends_tx_signatures_first: true, // TODO(dual_funding): Fixed to true as we currently don't contribute inputs.
9919
+ received_commitment_signed: true, // We only enter the FundingNegotiated state once we have persisted the initial channel monitor.
9920
+ holder_tx_signatures: Some(msgs::TxSignatures {
9921
+ channel_id,
9922
+ tx_hash: funding_tx.compute_txid(),
9923
+ witnesses: vec![], // TODO(dual_funding): Fixed to true as we currently don't contribute inputs.
9924
+ shared_input_signature: None, // TODO(splicing): Only relevant to splicing
9925
+ })
9926
+ })
9927
+ } else {
9928
+ debug_assert!(false, "Tried to read V2 channel with signing session but there is no funding transaction");
9929
+ None
9930
+ }
9931
+ } else { None };
9932
+
9901
9933
read_tlv_fields!(reader, {
9902
9934
(0, announcement_sigs, option),
9903
9935
(1, minimum_depth, option),
@@ -10194,7 +10226,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10194
10226
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
10195
10227
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
10196
10228
},
10197
- interactive_tx_signing_session: None ,
10229
+ interactive_tx_signing_session,
10198
10230
})
10199
10231
}
10200
10232
}
0 commit comments