@@ -216,12 +216,10 @@ pub enum SpliceContribution {
216216 /// using `SignerProvider::get_destination_script`.
217217 change_script: Option<ScriptBuf>,
218218 },
219- /// When only outputs are contributed to then funding transaction .
219+ /// When funds are removed from a channel .
220220 SpliceOut {
221- /// The amount to remove from the channel.
222- value: Amount,
223- /// The outputs used for removing the amount. The total value of all outputs must equal
224- /// [`SpliceOut::value`].
221+ /// The outputs to include in the splice's funding transaction. The total value of all
222+ /// outputs will be the amount that is removed.
225223 outputs: Vec<TxOut>,
226224 },
227225}
@@ -233,8 +231,14 @@ impl SpliceContribution {
233231 SpliceContribution::SpliceIn { value, .. } => {
234232 value.to_signed().unwrap_or(SignedAmount::MAX)
235233 },
236- SpliceContribution::SpliceOut { value, .. } => {
237- value.to_signed().map(|value| -value).unwrap_or(SignedAmount::MIN)
234+ SpliceContribution::SpliceOut { outputs } => {
235+ let value_removed = outputs
236+ .iter()
237+ .map(|txout| txout.value)
238+ .sum::<Amount>()
239+ .to_signed()
240+ .unwrap_or(SignedAmount::MAX);
241+ -value_removed
238242 },
239243 }
240244 }
@@ -249,7 +253,7 @@ impl SpliceContribution {
249253 pub(super) fn outputs(&self) -> &[TxOut] {
250254 match self {
251255 SpliceContribution::SpliceIn { .. } => &[],
252- SpliceContribution::SpliceOut { outputs, .. } => &outputs[..],
256+ SpliceContribution::SpliceOut { outputs } => &outputs[..],
253257 }
254258 }
255259
@@ -258,7 +262,7 @@ impl SpliceContribution {
258262 SpliceContribution::SpliceIn { inputs, change_script, .. } => {
259263 (inputs, vec![], change_script)
260264 },
261- SpliceContribution::SpliceOut { outputs, .. } => (vec![], outputs, None),
265+ SpliceContribution::SpliceOut { outputs } => (vec![], outputs, None),
262266 }
263267 }
264268}
0 commit comments