@@ -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};
@@ -1519,6 +1519,7 @@ impl<SP: Deref> Channel<SP> where
1519
1519
};
1520
1520
let mut funded_channel = FundedChannel {
1521
1521
funding: chan.funding,
1522
+ pending_funding: vec![],
1522
1523
context: chan.context,
1523
1524
interactive_tx_signing_session: chan.interactive_tx_signing_session,
1524
1525
holder_commitment_point,
@@ -1665,6 +1666,53 @@ pub(super) struct FundingScope {
1665
1666
funding_transaction: Option<Transaction>,
1666
1667
}
1667
1668
1669
+ impl Writeable for FundingScope {
1670
+ fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
1671
+ write_tlv_fields!(writer, {
1672
+ (1, self.value_to_self_msat, required),
1673
+ (3, self.counterparty_selected_channel_reserve_satoshis, option),
1674
+ (5, self.holder_selected_channel_reserve_satoshis, required),
1675
+ (7, self.channel_transaction_parameters, (required: ReadableArgs, None)),
1676
+ (9, self.funding_transaction, option),
1677
+ });
1678
+ Ok(())
1679
+ }
1680
+ }
1681
+
1682
+ impl Readable for FundingScope {
1683
+ fn read<R: io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
1684
+ let mut value_to_self_msat = RequiredWrapper(None);
1685
+ let mut counterparty_selected_channel_reserve_satoshis = None;
1686
+ let mut holder_selected_channel_reserve_satoshis = RequiredWrapper(None);
1687
+ let mut channel_transaction_parameters = RequiredWrapper(None);
1688
+ let mut funding_transaction = None;
1689
+
1690
+ read_tlv_fields!(reader, {
1691
+ (1, value_to_self_msat, required),
1692
+ (3, counterparty_selected_channel_reserve_satoshis, option),
1693
+ (5, holder_selected_channel_reserve_satoshis, required),
1694
+ (7, channel_transaction_parameters, (required: ReadableArgs, None)),
1695
+ (9, funding_transaction, option),
1696
+ });
1697
+
1698
+ Ok(Self {
1699
+ value_to_self_msat: value_to_self_msat.0.unwrap(),
1700
+ counterparty_selected_channel_reserve_satoshis,
1701
+ holder_selected_channel_reserve_satoshis: holder_selected_channel_reserve_satoshis.0.unwrap(),
1702
+ #[cfg(debug_assertions)]
1703
+ holder_max_commitment_tx_output: Mutex::new((0, 0)),
1704
+ #[cfg(debug_assertions)]
1705
+ counterparty_max_commitment_tx_output: Mutex::new((0, 0)),
1706
+ channel_transaction_parameters: channel_transaction_parameters.0.unwrap(),
1707
+ funding_transaction,
1708
+ #[cfg(any(test, fuzzing))]
1709
+ next_local_commitment_tx_fee_info_cached: Mutex::new(None),
1710
+ #[cfg(any(test, fuzzing))]
1711
+ next_remote_commitment_tx_fee_info_cached: Mutex::new(None),
1712
+ })
1713
+ }
1714
+ }
1715
+
1668
1716
impl FundingScope {
1669
1717
pub fn get_value_satoshis(&self) -> u64 {
1670
1718
self.channel_transaction_parameters.channel_value_satoshis
@@ -4945,6 +4993,7 @@ pub(super) struct DualFundingChannelContext {
4945
4993
// Counterparty designates channel data owned by the another channel participant entity.
4946
4994
pub(super) struct FundedChannel<SP: Deref> where SP::Target: SignerProvider {
4947
4995
pub funding: FundingScope,
4996
+ pending_funding: Vec<FundingScope>,
4948
4997
pub context: ChannelContext<SP>,
4949
4998
pub interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
4950
4999
holder_commitment_point: HolderCommitmentPoint,
@@ -9548,6 +9597,7 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
9548
9597
9549
9598
let mut channel = FundedChannel {
9550
9599
funding: self.funding,
9600
+ pending_funding: vec![],
9551
9601
context: self.context,
9552
9602
interactive_tx_signing_session: None,
9553
9603
is_v2_established: false,
@@ -9824,6 +9874,7 @@ impl<SP: Deref> InboundV1Channel<SP> where SP::Target: SignerProvider {
9824
9874
// `ChannelMonitor`.
9825
9875
let mut channel = FundedChannel {
9826
9876
funding: self.funding,
9877
+ pending_funding: vec![],
9827
9878
context: self.context,
9828
9879
interactive_tx_signing_session: None,
9829
9880
is_v2_established: false,
@@ -10633,6 +10684,7 @@ impl<SP: Deref> Writeable for FundedChannel<SP> where SP::Target: SignerProvider
10633
10684
(49, self.context.local_initiated_shutdown, option), // Added in 0.0.122
10634
10685
(51, is_manual_broadcast, option), // Added in 0.0.124
10635
10686
(53, funding_tx_broadcast_safe_event_emitted, option), // Added in 0.0.124
10687
+ (54, self.pending_funding, optional_vec), // Added in 0.2
10636
10688
(55, removed_htlc_failure_attribution_data, optional_vec), // Added in 0.2
10637
10689
(57, holding_cell_failure_attribution_data, optional_vec), // Added in 0.2
10638
10690
});
@@ -10862,7 +10914,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10862
10914
_ => return Err(DecodeError::InvalidValue),
10863
10915
};
10864
10916
10865
- let channel_parameters: ChannelTransactionParameters = ReadableArgs::<u64>::read(reader, channel_value_satoshis)?;
10917
+ let channel_parameters: ChannelTransactionParameters = ReadableArgs::<Option< u64>> ::read(reader, Some( channel_value_satoshis) )?;
10866
10918
let funding_transaction: Option<Transaction> = Readable::read(reader)?;
10867
10919
10868
10920
let counterparty_cur_commitment_point = Readable::read(reader)?;
@@ -10932,6 +10984,8 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10932
10984
let mut next_holder_commitment_point_opt: Option<PublicKey> = None;
10933
10985
let mut is_manual_broadcast = None;
10934
10986
10987
+ let mut pending_funding = Some(Vec::new());
10988
+
10935
10989
read_tlv_fields!(reader, {
10936
10990
(0, announcement_sigs, option),
10937
10991
(1, minimum_depth, option),
@@ -10967,6 +11021,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
10967
11021
(49, local_initiated_shutdown, option),
10968
11022
(51, is_manual_broadcast, option),
10969
11023
(53, funding_tx_broadcast_safe_event_emitted, option),
11024
+ (54, pending_funding, optional_vec), // Added in 0.2
10970
11025
(55, removed_htlc_failure_attribution_data, optional_vec),
10971
11026
(57, holding_cell_failure_attribution_data, optional_vec),
10972
11027
});
@@ -11142,6 +11197,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, &'c Channel
11142
11197
channel_transaction_parameters: channel_parameters,
11143
11198
funding_transaction,
11144
11199
},
11200
+ pending_funding: pending_funding.unwrap(),
11145
11201
context: ChannelContext {
11146
11202
user_id,
11147
11203
0 commit comments