@@ -31,9 +31,8 @@ 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, HandleTxCompleteValue, HandleTxCompleteResult, InteractiveTxConstructor,
35
- InteractiveTxConstructorArgs, InteractiveTxSigningSession, InteractiveTxMessageSendResult,
36
- TX_COMMON_FIELDS_WEIGHT,
34
+ get_output_weight, HandleTxCompleteResult, InteractiveTxConstructor, InteractiveTxConstructorArgs,
35
+ InteractiveTxSigningSession, InteractiveTxMessageSendResult, TX_COMMON_FIELDS_WEIGHT,
37
36
};
38
37
use crate::ln::msgs;
39
38
use crate::ln::msgs::{ClosingSigned, ClosingSignedFeeRange, DecodeError};
@@ -1845,21 +1844,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1845
1844
/// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
1846
1845
/// store it here and only release it to the `ChannelManager` once it asks for it.
1847
1846
blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
1848
- // The `next_funding_txid` field allows peers to finalize the signing steps of an interactive
1849
- // transaction construction, or safely abort that transaction if it was not signed by one of the
1850
- // peers, who has thus already removed it from its state.
1851
- //
1852
- // If we've sent `commtiment_signed` for an interactively constructed transaction
1853
- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
1854
- // to the txid of that interactive transaction, else we MUST NOT set it.
1855
- //
1856
- // See the spec for further details on this:
1857
- // * `channel_reestablish`-sending node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
1858
- // * `channel_reestablish`-receiving node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
1859
- //
1860
- // TODO(dual_funding): Persist this when we actually contribute funding inputs. For now we always
1861
- // send an empty witnesses array in `tx_signatures` as a V2 channel acceptor
1862
- next_funding_txid: Option<Txid>,
1863
1847
}
1864
1848
1865
1849
/// A channel struct implementing this trait can receive an initial counterparty commitment
@@ -2090,10 +2074,6 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
2090
2074
}
2091
2075
};
2092
2076
2093
- if let HandleTxCompleteValue::SendTxComplete(_, ref signing_session) = tx_complete {
2094
- self.context.next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
2095
- };
2096
-
2097
2077
HandleTxCompleteResult(Ok(tx_complete))
2098
2078
}
2099
2079
@@ -2526,8 +2506,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2526
2506
blocked_monitor_updates: Vec::new(),
2527
2507
2528
2508
is_manual_broadcast: false,
2529
-
2530
- next_funding_txid: None,
2531
2509
};
2532
2510
2533
2511
Ok(channel_context)
@@ -2754,7 +2732,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2754
2732
blocked_monitor_updates: Vec::new(),
2755
2733
local_initiated_shutdown: None,
2756
2734
is_manual_broadcast: false,
2757
- next_funding_txid: None,
2758
2735
})
2759
2736
}
2760
2737
@@ -6024,7 +6001,6 @@ impl<SP: Deref> FundedChannel<SP> where
6024
6001
// We have a persisted channel monitor and and a finalized funding transaction, so we can move
6025
6002
// the channel state forward, set the funding transaction and reset the signing session fields.
6026
6003
self.context.funding_transaction = funding_tx_opt;
6027
- self.context.next_funding_txid = None;
6028
6004
self.interactive_tx_signing_session = None;
6029
6005
self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
6030
6006
}
@@ -8045,6 +8021,25 @@ impl<SP: Deref> FundedChannel<SP> where
8045
8021
}
8046
8022
}
8047
8023
8024
+ fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
8025
+ // If we've sent `commtiment_signed` for an interactively constructed transaction
8026
+ // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
8027
+ // to the txid of that interactive transaction, else we MUST NOT set it.
8028
+ if let Some(signing_session) = &self.interactive_tx_signing_session {
8029
+ // Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
8030
+ if !signing_session.counterparty_sent_tx_signatures {
8031
+ // ...but we didn't receive a `tx_signatures` from the counterparty yet.
8032
+ Some(self.funding_outpoint().txid)
8033
+ } else {
8034
+ // ...and we received a `tx_signatures` from the counterparty.
8035
+ None
8036
+ }
8037
+ } else {
8038
+ // We don't have an active signing session.
8039
+ None
8040
+ }
8041
+ }
8042
+
8048
8043
/// May panic if called on a channel that wasn't immediately-previously
8049
8044
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
8050
8045
fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
@@ -8095,7 +8090,7 @@ impl<SP: Deref> FundedChannel<SP> where
8095
8090
next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
8096
8091
your_last_per_commitment_secret: remote_last_secret,
8097
8092
my_current_per_commitment_point: dummy_pubkey,
8098
- next_funding_txid: self.context.next_funding_txid ,
8093
+ next_funding_txid: self.maybe_get_next_funding_txid() ,
8099
8094
}
8100
8095
}
8101
8096
@@ -10455,13 +10450,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10455
10450
10456
10451
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
10457
10452
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
10458
- // TODO(dual_funding): Instead of getting this from persisted value, figure it out based on the
10459
- // funding transaction and other channel state.
10460
- //
10461
- // If we've sent `commtiment_signed` for an interactively constructed transaction
10462
- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
10463
- // to the txid of that interactive transaction, else we MUST NOT set it.
10464
- next_funding_txid: None,
10465
10453
},
10466
10454
interactive_tx_signing_session: None,
10467
10455
is_v2_established,
0 commit comments