@@ -60,7 +60,7 @@ use crate::sign::{EntropySource, ChannelSigner, SignerProvider, NodeSigner, Reci
60
60
use crate::events::{ClosureReason, Event};
61
61
use crate::events::bump_transaction::BASE_INPUT_WEIGHT;
62
62
use crate::routing::gossip::NodeId;
63
- use crate::util::ser::{Readable, ReadableArgs, TransactionU16LenLimited, Writeable, Writer};
63
+ use crate::util::ser::{Readable, ReadableArgs, RequiredWrapper, TransactionU16LenLimited, Writeable, Writer};
64
64
use crate::util::logger::{Logger, Record, WithContext};
65
65
use crate::util::errors::APIError;
66
66
use crate::util::config::{UserConfig, ChannelConfig, LegacyChannelConfig, ChannelHandshakeConfig, ChannelHandshakeLimits, MaxDustHTLCExposure};
@@ -1517,6 +1517,7 @@ impl<SP: Deref> Channel<SP> where
1517
1517
};
1518
1518
let mut funded_channel = FundedChannel {
1519
1519
funding: chan.funding,
1520
+ pending_funding: vec![],
1520
1521
context: chan.context,
1521
1522
interactive_tx_signing_session: chan.interactive_tx_signing_session,
1522
1523
holder_commitment_point,
@@ -1663,6 +1664,53 @@ pub(super) struct FundingScope {
1663
1664
funding_transaction: Option<Transaction>,
1664
1665
}
1665
1666
1667
+ impl Writeable for FundingScope {
1668
+ fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
1669
+ write_tlv_fields!(writer, {
1670
+ (1, self.value_to_self_msat, required),
1671
+ (3, self.counterparty_selected_channel_reserve_satoshis, option),
1672
+ (5, self.holder_selected_channel_reserve_satoshis, required),
1673
+ (7, self.channel_transaction_parameters, (required: ReadableArgs, None)),
1674
+ (9, self.funding_transaction, option),
1675
+ });
1676
+ Ok(())
1677
+ }
1678
+ }
1679
+
1680
+ impl Readable for FundingScope {
1681
+ fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
1682
+ let mut value_to_self_msat = RequiredWrapper(None);
1683
+ let mut counterparty_selected_channel_reserve_satoshis = None;
1684
+ let mut holder_selected_channel_reserve_satoshis = RequiredWrapper(None);
1685
+ let mut channel_transaction_parameters = RequiredWrapper(None);
1686
+ let mut funding_transaction = None;
1687
+
1688
+ read_tlv_fields!(reader, {
1689
+ (1, value_to_self_msat, required),
1690
+ (3, counterparty_selected_channel_reserve_satoshis, option),
1691
+ (5, holder_selected_channel_reserve_satoshis, required),
1692
+ (7, channel_transaction_parameters, (required: ReadableArgs, None)),
1693
+ (9, funding_transaction, option),
1694
+ });
1695
+
1696
+ Ok(Self {
1697
+ value_to_self_msat: value_to_self_msat.0.unwrap(),
1698
+ counterparty_selected_channel_reserve_satoshis,
1699
+ holder_selected_channel_reserve_satoshis: holder_selected_channel_reserve_satoshis.0.unwrap(),
1700
+ #[cfg(debug_assertions)]
1701
+ holder_max_commitment_tx_output: Mutex::new((0, 0)),
1702
+ #[cfg(debug_assertions)]
1703
+ counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
1704
+ channel_transaction_parameters: channel_transaction_parameters.0.unwrap(),
1705
+ funding_transaction,
1706
+ #[cfg(any(test, fuzzing))]
1707
+ next_local_commitment_tx_fee_info_cached: Mutex::new(None),
1708
+ #[cfg(any(test, fuzzing))]
1709
+ next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
1710
+ })
1711
+ }
1712
+ }
1713
+
1666
1714
impl FundingScope {
1667
1715
pub fn get_value_satoshis(&self) -> u64 {
1668
1716
self.channel_transaction_parameters.channel_value_satoshis
@@ -4943,6 +4991,7 @@ pub(super) struct DualFundingChannelContext {
4943
4991
// Counterparty designates channel data owned by the another channel participant entity.
4944
4992
pub(super) struct FundedChannel<SP: Deref> where SP::Target: SignerProvider {
4945
4993
pub funding: FundingScope,
4994
+ pending_funding: Vec<FundingScope>,
4946
4995
pub context: ChannelContext<SP>,
4947
4996
pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
4948
4997
holder_commitment_point: HolderCommitmentPoint,
@@ -9531,6 +9580,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
9531
9580
9532
9581
let mut channel = FundedChannel {
9533
9582
funding: self.funding,
9583
+ pending_funding: vec![],
9534
9584
context: self.context,
9535
9585
interactive_tx_signing_session: None,
9536
9586
is_v2_established: false,
@@ -9807,6 +9857,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
9807
9857
// `ChannelMonitor`.
9808
9858
let mut channel = FundedChannel {
9809
9859
funding: self.funding,
9860
+ pending_funding: vec![],
9810
9861
context: self.context,
9811
9862
interactive_tx_signing_session: None,
9812
9863
is_v2_established: false,
@@ -10605,6 +10656,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10605
10656
(49, self.context.local_initiated_shutdown, option), // Added in 0.0.122
10606
10657
(51, is_manual_broadcast, option), // Added in 0.0.124
10607
10658
(53, funding_tx_broadcast_safe_event_emitted, option), // Added in 0.0.124
10659
+ (54, self.pending_funding, optional_vec), // Added in 0.2
10608
10660
});
10609
10661
10610
10662
Ok(())
@@ -10829,7 +10881,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10829
10881
_ => return Err(DecodeError::InvalidValue),
10830
10882
};
10831
10883
10832
- let channel_parameters: ChannelTransactionParameters = ReadableArgs::<u64>::read(reader, channel_value_satoshis)?;
10884
+ let channel_parameters: ChannelTransactionParameters = ReadableArgs::<Option< u64>> ::read(reader, Some( channel_value_satoshis) )?;
10833
10885
let funding_transaction: Option<Transaction> = Readable::read(reader)?;
10834
10886
10835
10887
let counterparty_cur_commitment_point = Readable::read(reader)?;
@@ -10896,6 +10948,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10896
10948
let mut next_holder_commitment_point_opt: Option<PublicKey> = None;
10897
10949
let mut is_manual_broadcast = None;
10898
10950
10951
+ let mut pending_funding = Some(Vec::new());
10952
+
10899
10953
read_tlv_fields!(reader, {
10900
10954
(0, announcement_sigs, option),
10901
10955
(1, minimum_depth, option),
@@ -10931,6 +10985,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10931
10985
(49, local_initiated_shutdown, option),
10932
10986
(51, is_manual_broadcast, option),
10933
10987
(53, funding_tx_broadcast_safe_event_emitted, option),
10988
+ (54, pending_funding, optional_vec), // Added in 0.2
10934
10989
});
10935
10990
10936
10991
let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
@@ -11072,6 +11127,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11072
11127
channel_transaction_parameters: channel_parameters,
11073
11128
funding_transaction,
11074
11129
},
11130
+ pending_funding: pending_funding.unwrap(),
11075
11131
context: ChannelContext {
11076
11132
user_id,
11077
11133
0 commit comments