Skip to content

Commit 0bca4bc

Browse files
committed
Let validate_splice_contribution construct the new FundingScope
We will validate the reserve requirements on the new `FundingScope` in `validate_splice_contribution`.
1 parent bd156cc commit 0bca4bc

File tree

1 file changed

+28
-32
lines changed

1 file changed

+28
-32
lines changed

lightning/src/ln/channel.rs

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10944,6 +10944,8 @@ where
1094410944
)));
1094510945
}
1094610946

10947+
// TODO(splicing): Once splice acceptor can contribute, check that inputs are sufficient,
10948+
// similarly to the check in `splice_channel`.
1094710949
debug_assert_eq!(our_funding_contribution, SignedAmount::ZERO);
1094810950

1094910951
// TODO(splicing): Move this check once user-provided contributions are supported for
@@ -10965,33 +10967,18 @@ where
1096510967
}
1096610968

1096710969
let their_funding_contribution = SignedAmount::from_sat(msg.funding_contribution_satoshis);
10968-
self.validate_splice_contribution(their_funding_contribution)?;
10969-
10970-
// TODO(splicing): Check that channel balance does not go below the channel reserve
10971-
10972-
let splice_funding = FundingScope::for_splice(
10973-
&self.funding,
10974-
&self.context,
10970+
self.validate_splice_contribution(
1097510971
our_funding_contribution,
1097610972
their_funding_contribution,
1097710973
msg.funding_pubkey,
10978-
);
10979-
10980-
// TODO(splicing): Once splice acceptor can contribute, check that inputs are sufficient,
10981-
// similarly to the check in `splice_channel`.
10982-
10983-
// Note on channel reserve requirement pre-check: as the splice acceptor does not contribute,
10984-
// it can't go below reserve, therefore no pre-check is done here.
10985-
10986-
// TODO(splicing): Early check for reserve requirement
10987-
10988-
Ok(splice_funding)
10974+
)
1098910975
}
1099010976

1099110977
#[cfg(splicing)]
1099210978
fn validate_splice_contribution(
10993-
&self, their_funding_contribution: SignedAmount,
10994-
) -> Result<(), ChannelError> {
10979+
&self, our_funding_contribution: SignedAmount, their_funding_contribution: SignedAmount,
10980+
counterparty_funding_pubkey: PublicKey,
10981+
) -> Result<FundingScope, ChannelError> {
1099510982
if their_funding_contribution > SignedAmount::MAX_MONEY {
1099610983
return Err(ChannelError::WarnAndDisconnect(format!(
1099710984
"Channel {} cannot be spliced in; their {} contribution exceeds the total bitcoin supply",
@@ -11024,7 +11011,25 @@ where
1102411011
)));
1102511012
}
1102611013

11027-
Ok(())
11014+
let splice_funding = FundingScope::for_splice(
11015+
&self.funding,
11016+
&self.context,
11017+
our_funding_contribution,
11018+
their_funding_contribution,
11019+
counterparty_funding_pubkey,
11020+
);
11021+
11022+
// TODO(splicing): Check that channel balance does not go below the channel reserve
11023+
11024+
// Note on channel reserve requirement pre-check: as the splice acceptor does not contribute,
11025+
// it can't go below reserve, therefore no pre-check is done here.
11026+
11027+
// TODO(splicing): Early check for reserve requirement
11028+
11029+
// TODO(splicing): Pre-check for reserve requirement
11030+
// (Note: It should also be checked later at tx_complete)
11031+
11032+
Ok(splice_funding)
1102811033
}
1102911034

1103011035
#[cfg(splicing)]
@@ -11179,20 +11184,11 @@ where
1117911184
debug_assert!(our_funding_contribution.abs() <= SignedAmount::MAX_MONEY);
1118011185

1118111186
let their_funding_contribution = SignedAmount::from_sat(msg.funding_contribution_satoshis);
11182-
self.validate_splice_contribution(their_funding_contribution)?;
11183-
11184-
let splice_funding = FundingScope::for_splice(
11185-
&self.funding,
11186-
&self.context,
11187+
self.validate_splice_contribution(
1118711188
our_funding_contribution,
1118811189
their_funding_contribution,
1118911190
msg.funding_pubkey,
11190-
);
11191-
11192-
// TODO(splicing): Pre-check for reserve requirement
11193-
// (Note: It should also be checked later at tx_complete)
11194-
11195-
Ok(splice_funding)
11191+
)
1119611192
}
1119711193

1119811194
#[cfg(splicing)]

0 commit comments

Comments
 (0)