@@ -1905,16 +1905,11 @@ impl FundingScope {
1905
1905
struct PendingSplice {
1906
1906
/// Intended contributions to the splice from our end
1907
1907
pub our_funding_contribution: i64,
1908
- pub funding_feerate_per_kw: u32,
1909
- pub locktime: u32,
1910
- /// The funding inputs that we plan to contributing to the splice.
1911
- /// Stored between [`splice_channel`] and [`splice_ack`]
1912
- pub our_funding_inputs: Vec<(TxIn, TransactionU16LenLimited)>,
1913
1908
/// Set when splice_ack has been processed (on the initiator side),
1914
1909
/// used to prevent processing of multiple splice_ack's.
1915
1910
awaiting_splice_ack: bool,
1916
1911
funding_scope: Option<FundingScope>,
1917
- funding_negotiation_context: Option< FundingNegotiationContext> ,
1912
+ funding_negotiation_context: FundingNegotiationContext,
1918
1913
/// The current interactive transaction construction session under negotiation.
1919
1914
interactive_tx_constructor: Option<InteractiveTxConstructor>,
1920
1915
interactive_tx_signing_session: Option<InteractiveTxSigningSession>,
@@ -5289,18 +5284,21 @@ impl<SP: Deref> FundedChannel<SP> where
5289
5284
fn as_renegotiating_channel(&mut self) -> Result<NegotiatingV2ChannelView<SP>, &'static str> {
5290
5285
if let Some(ref mut pending_splice) = &mut self.pending_splice {
5291
5286
if let Some(ref mut funding) = &mut pending_splice.funding_scope {
5292
- if let Some(ref mut funding_negotiation_context) = &mut pending_splice.funding_negotiation_context {
5287
+ if
5288
+ pending_splice.funding_negotiation_context.our_funding_satoshis != 0 ||
5289
+ pending_splice.funding_negotiation_context.their_funding_satoshis.unwrap_or_default() != 0
5290
+ {
5293
5291
Ok(NegotiatingV2ChannelView {
5294
5292
context: &mut self.context,
5295
5293
funding,
5296
- funding_negotiation_context,
5294
+ funding_negotiation_context: &mut pending_splice.funding_negotiation_context ,
5297
5295
interactive_tx_constructor: &mut pending_splice.interactive_tx_constructor,
5298
5296
interactive_tx_signing_session: &mut pending_splice.interactive_tx_signing_session,
5299
5297
holder_commitment_transaction_number: self.holder_commitment_point.transaction_number(),
5300
5298
is_splice: true,
5301
5299
})
5302
5300
} else {
5303
- Err("Channel is not refunding")
5301
+ Err("Channel is not actively refunding")
5304
5302
}
5305
5303
} else {
5306
5304
Err("Channel is not refunding")
@@ -8868,14 +8866,18 @@ impl<SP: Deref> FundedChannel<SP> where
8868
8866
funding_inputs.push((tx_in.clone(), tx16));
8869
8867
}
8870
8868
8869
+ let funding_negotiation_context = FundingNegotiationContext {
8870
+ our_funding_satoshis: 0, // set at later phase
8871
+ their_funding_satoshis: None, // set at later phase
8872
+ funding_tx_locktime: LockTime::from_consensus(locktime),
8873
+ funding_feerate_sat_per_1000_weight: funding_feerate_per_kw,
8874
+ our_funding_inputs: funding_inputs,
8875
+ };
8871
8876
self.pending_splice = Some(PendingSplice {
8872
8877
our_funding_contribution: our_funding_contribution_satoshis,
8873
- funding_feerate_per_kw,
8874
- locktime,
8875
- our_funding_inputs: funding_inputs,
8876
8878
awaiting_splice_ack: true, // we await splice_ack
8877
8879
funding_scope: None,
8878
- funding_negotiation_context: None ,
8880
+ funding_negotiation_context,
8879
8881
interactive_tx_constructor: None,
8880
8882
interactive_tx_signing_session: None,
8881
8883
});
@@ -9024,12 +9026,9 @@ impl<SP: Deref> FundedChannel<SP> where
9024
9026
9025
9027
self.pending_splice = Some(PendingSplice {
9026
9028
our_funding_contribution,
9027
- funding_feerate_per_kw: msg.funding_feerate_per_kw,
9028
- locktime: msg.locktime,
9029
- our_funding_inputs: Vec::new(), // inputs go directly to [`FundingNegotiationContext`] above
9030
9029
awaiting_splice_ack: false, // we don't need any additional message for the handshake
9031
9030
funding_scope: Some(funding_scope),
9032
- funding_negotiation_context: Some(funding_negotiation_context) ,
9031
+ funding_negotiation_context,
9033
9032
interactive_tx_constructor: None,
9034
9033
interactive_tx_signing_session: None,
9035
9034
});
@@ -9099,24 +9098,15 @@ impl<SP: Deref> FundedChannel<SP> where
9099
9098
9100
9099
let funding_scope = self.funding_scope_for_splice(our_funding_satoshis, post_channel_value);
9101
9100
9102
- let mut funding_negotiation_context = FundingNegotiationContext {
9103
- our_funding_satoshis,
9104
- their_funding_satoshis: Some(their_funding_satoshis),
9105
- funding_tx_locktime: LockTime::from_consensus(pending_splice.locktime),
9106
- funding_feerate_sat_per_1000_weight: pending_splice.funding_feerate_per_kw,
9107
- our_funding_inputs: Vec::new(), // set below
9108
- };
9109
- if let Some(ref mut pending_splice_mut) = &mut self.pending_splice {
9110
- funding_negotiation_context.our_funding_inputs = std::mem::take(&mut pending_splice_mut.our_funding_inputs);
9111
- };
9112
-
9113
9101
let pre_funding_transaction = &self.funding.funding_transaction;
9114
9102
let pre_funding_txo = &self.funding.get_funding_txo();
9115
9103
// We need the current funding tx as an extra input
9116
9104
let prev_funding_input = Self::get_input_of_previous_funding(pre_funding_transaction, pre_funding_txo)?;
9117
9105
if let Some(ref mut pending_splice) = &mut self.pending_splice {
9118
9106
pending_splice.funding_scope = Some(funding_scope);
9119
- pending_splice.funding_negotiation_context = Some(funding_negotiation_context);
9107
+ // update funding values
9108
+ pending_splice.funding_negotiation_context.our_funding_satoshis = our_funding_satoshis;
9109
+ pending_splice.funding_negotiation_context.their_funding_satoshis = Some(their_funding_satoshis);
9120
9110
pending_splice.interactive_tx_constructor = None;
9121
9111
pending_splice.interactive_tx_signing_session = None;
9122
9112
debug_assert!(pending_splice.awaiting_splice_ack);
0 commit comments