@@ -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};
@@ -1498,21 +1497,6 @@ pub(super) struct ChannelContext<SP: Deref> where SP::Target: SignerProvider {
1498
1497
/// If we can't release a [`ChannelMonitorUpdate`] until some external action completes, we
1499
1498
/// store it here and only release it to the `ChannelManager` once it asks for it.
1500
1499
blocked_monitor_updates: Vec<PendingChannelMonitorUpdate>,
1501
- // The `next_funding_txid` field allows peers to finalize the signing steps of an interactive
1502
- // transaction construction, or safely abort that transaction if it was not signed by one of the
1503
- // peers, who has thus already removed it from its state.
1504
- //
1505
- // If we've sent `commtiment_signed` for an interactively constructed transaction
1506
- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
1507
- // to the txid of that interactive transaction, else we MUST NOT set it.
1508
- //
1509
- // See the spec for further details on this:
1510
- // * `channel_reestablish`-sending node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2466-L2470
1511
- // * `channel_reestablish`-receiving node: https://github.com/lightning/bolts/blob/247e83d/02-peer-protocol.md?plain=1#L2520-L2531
1512
- //
1513
- // TODO(dual_funding): Persist this when we actually contribute funding inputs. For now we always
1514
- // send an empty witnesses array in `tx_signatures` as a V2 channel acceptor
1515
- next_funding_txid: Option<Txid>,
1516
1500
}
1517
1501
1518
1502
/// A channel struct implementing this trait can receive an initial counterparty commitment
@@ -1747,10 +1731,6 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
1747
1731
}
1748
1732
};
1749
1733
1750
- if let HandleTxCompleteValue::SendTxComplete(_, ref signing_session) = tx_complete {
1751
- self.context_mut().next_funding_txid = Some(signing_session.unsigned_tx.compute_txid());
1752
- };
1753
-
1754
1734
HandleTxCompleteResult(Ok(tx_complete))
1755
1735
}
1756
1736
@@ -2217,8 +2197,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2217
2197
blocked_monitor_updates: Vec::new(),
2218
2198
2219
2199
is_manual_broadcast: false,
2220
-
2221
- next_funding_txid: None,
2222
2200
};
2223
2201
2224
2202
Ok(channel_context)
@@ -2451,7 +2429,6 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2451
2429
blocked_monitor_updates: Vec::new(),
2452
2430
local_initiated_shutdown: None,
2453
2431
is_manual_broadcast: false,
2454
- next_funding_txid: None,
2455
2432
})
2456
2433
}
2457
2434
@@ -5763,7 +5740,6 @@ impl<SP: Deref> Channel<SP> where
5763
5740
// We have a persisted channel monitor and and a finalized funding transaction, so we can move
5764
5741
// the channel state forward, set the funding transaction and reset the signing session fields.
5765
5742
self.context.funding_transaction = funding_tx_opt;
5766
- self.context.next_funding_txid = None;
5767
5743
self.interactive_tx_signing_session = None;
5768
5744
self.context.channel_state = ChannelState::AwaitingChannelReady(AwaitingChannelReadyFlags::new());
5769
5745
}
@@ -7782,6 +7758,25 @@ impl<SP: Deref> Channel<SP> where
7782
7758
}
7783
7759
}
7784
7760
7761
+ fn maybe_get_next_funding_txid(&self) -> Option<Txid> {
7762
+ // If we've sent `commtiment_signed` for an interactively constructed transaction
7763
+ // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
7764
+ // to the txid of that interactive transaction, else we MUST NOT set it.
7765
+ if let Some(signing_session) = &self.interactive_tx_signing_session {
7766
+ // Since we have a signing_session, this implies we've sent an initial `commitment_signed`...
7767
+ if !signing_session.counterparty_sent_tx_signatures {
7768
+ // ...but we didn't receive a `tx_signatures` from the counterparty yet.
7769
+ None
7770
+ } else {
7771
+ // ...and we received a `tx_signatures` from the counterparty.
7772
+ Some(self.funding_outpoint().txid)
7773
+ }
7774
+ } else {
7775
+ // We don't have an active signing session.
7776
+ None
7777
+ }
7778
+ }
7779
+
7785
7780
/// May panic if called on a channel that wasn't immediately-previously
7786
7781
/// self.remove_uncommitted_htlcs_and_mark_paused()'d
7787
7782
pub fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
@@ -7826,7 +7821,7 @@ impl<SP: Deref> Channel<SP> where
7826
7821
next_remote_commitment_number: INITIAL_COMMITMENT_NUMBER - self.context.cur_counterparty_commitment_transaction_number - 1,
7827
7822
your_last_per_commitment_secret: remote_last_secret,
7828
7823
my_current_per_commitment_point: dummy_pubkey,
7829
- next_funding_txid: self.context.next_funding_txid ,
7824
+ next_funding_txid: self.maybe_get_next_funding_txid() ,
7830
7825
}
7831
7826
}
7832
7827
@@ -10141,13 +10136,6 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
10141
10136
10142
10137
blocked_monitor_updates: blocked_monitor_updates.unwrap(),
10143
10138
is_manual_broadcast: is_manual_broadcast.unwrap_or(false),
10144
- // TODO(dual_funding): Instead of getting this from persisted value, figure it out based on the
10145
- // funding transaction and other channel state.
10146
- //
10147
- // If we've sent `commtiment_signed` for an interactively constructed transaction
10148
- // during a signing session, but have not received `tx_signatures` we MUST set `next_funding_txid`
10149
- // to the txid of that interactive transaction, else we MUST NOT set it.
10150
- next_funding_txid: None,
10151
10139
},
10152
10140
interactive_tx_signing_session: None,
10153
10141
})
0 commit comments