Skip to content

Commit 2ae2f0d

Browse files
committed
Add pending funding scopes to FundedChannel
Once a channel is funded, it may be spliced to add or remove funds. The new funding transaction is pending until confirmed on chain and thus needs to be tracked. Additionally, it may be replaced by another transaction using RBF with a higher fee. Hence, there may be more than one pending FundingScope to track for a splice. This commit adds support for tracking pending funding scopes. The following commits will account for any pending scopes where applicable (e.g., when handling commitment_signed).
1 parent e9f3e4d commit 2ae2f0d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Diff for: lightning/src/ln/channel.rs

+7
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ use crate::util::errors::APIError;
6565
use crate::util::config::{UserConfig, ChannelConfig, LegacyChannelConfig, ChannelHandshakeConfig, ChannelHandshakeLimits, MaxDustHTLCExposure};
6666
use crate::util::scid_utils::scid_from_parts;
6767

68+
use alloc::collections::BTreeMap;
69+
6870
use crate::io;
6971
use crate::prelude::*;
7072
use core::{cmp,mem,fmt};
@@ -1513,6 +1515,7 @@ impl<SP: Deref> Channel<SP> where
15131515
};
15141516
let mut funded_channel = FundedChannel {
15151517
funding: chan.funding,
1518+
pending_funding: BTreeMap::new(),
15161519
context: chan.context,
15171520
interactive_tx_signing_session: chan.interactive_tx_signing_session,
15181521
holder_commitment_point,
@@ -4820,6 +4823,7 @@ pub(super) struct DualFundingChannelContext {
48204823
// Counterparty designates channel data owned by the another channel participant entity.
48214824
pub(super) struct FundedChannel<SP: Deref> where SP::Target: SignerProvider {
48224825
pub funding: FundingScope,
4826+
pending_funding: BTreeMap<Txid, FundingScope>,
48234827
pub context: ChannelContext<SP>,
48244828
pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
48254829
holder_commitment_point: HolderCommitmentPoint,
@@ -9278,6 +9282,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
92789282

92799283
let mut channel = FundedChannel {
92809284
funding: self.funding,
9285+
pending_funding: BTreeMap::new(),
92819286
context: self.context,
92829287
interactive_tx_signing_session: None,
92839288
is_v2_established: false,
@@ -9545,6 +9550,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
95459550
// `ChannelMonitor`.
95469551
let mut channel = FundedChannel {
95479552
funding: self.funding,
9553+
pending_funding: BTreeMap::new(),
95489554
context: self.context,
95499555
interactive_tx_signing_session: None,
95509556
is_v2_established: false,
@@ -10785,6 +10791,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
1078510791
channel_transaction_parameters: channel_parameters,
1078610792
funding_transaction,
1078710793
},
10794+
pending_funding: BTreeMap::new(),
1078810795
context: ChannelContext {
1078910796
user_id,
1079010797

0 commit comments

Comments
 (0)