@@ -216,12 +216,10 @@ pub enum SpliceContribution {
216
216
/// generated using `SignerProvider::get_destination_script`.
217
217
change_script: Option<ScriptBuf>,
218
218
},
219
- /// When only outputs are contributed to then funding transaction .
219
+ /// When funds are removed from a channel .
220
220
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.
225
223
outputs: Vec<TxOut>,
226
224
},
227
225
}
@@ -233,8 +231,14 @@ impl SpliceContribution {
233
231
SpliceContribution::SpliceIn { value, .. } => {
234
232
value.to_signed().unwrap_or(SignedAmount::MAX)
235
233
},
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
238
242
},
239
243
}
240
244
}
@@ -249,7 +253,7 @@ impl SpliceContribution {
249
253
pub(super) fn outputs(&self) -> &[TxOut] {
250
254
match self {
251
255
SpliceContribution::SpliceIn { .. } => &[],
252
- SpliceContribution::SpliceOut { outputs, .. } => &outputs[..],
256
+ SpliceContribution::SpliceOut { outputs } => &outputs[..],
253
257
}
254
258
}
255
259
@@ -258,7 +262,7 @@ impl SpliceContribution {
258
262
SpliceContribution::SpliceIn { inputs, change_script, .. } => {
259
263
(inputs, vec![], change_script)
260
264
},
261
- SpliceContribution::SpliceOut { outputs, .. } => (vec![], outputs, None),
265
+ SpliceContribution::SpliceOut { outputs } => (vec![], outputs, None),
262
266
}
263
267
}
264
268
}
0 commit comments