File tree Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Expand file tree Collapse file tree 1 file changed +3
-14
lines changed Original file line number Diff line number Diff line change @@ -2046,21 +2046,10 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
20462046 funding_inputs.push(prev_funding_input);
20472047 }
20482048
2049- let mut funding_inputs_prev_outputs: Vec<&TxOut> = Vec::with_capacity(funding_inputs.len());
2050- // Check that vouts exist for each TxIn in provided transactions.
2051- for (idx, (txin, tx)) in funding_inputs.iter().enumerate() {
2052- if let Some(output) = tx.as_transaction().output.get(txin.previous_output.vout as usize) {
2053- funding_inputs_prev_outputs.push(output);
2054- } else {
2055- return Err(APIError::APIMisuseError {
2056- err: format!("Transaction with txid {} does not have an output with vout of {} corresponding to TxIn at funding_inputs[{}]",
2057- tx.as_transaction().compute_txid(), txin.previous_output.vout, idx) });
2058- }
2059- }
2049+ let funding_inputs_prev_outputs = DualFundingChannelContext::txouts_from_input_prev_txs(&funding_inputs)
2050+ .map_err(|err| APIError::APIMisuseError { err: err.to_string() })?;
20602051
2061- let total_input_satoshis: u64 = funding_inputs.iter().map(
2062- |(txin, tx)| tx.as_transaction().output.get(txin.previous_output.vout as usize).map(|out| out.value.to_sat()).unwrap_or(0)
2063- ).sum();
2052+ let total_input_satoshis: u64 = funding_inputs_prev_outputs.iter().map(|txout| txout.value.to_sat()).sum();
20642053 if total_input_satoshis < self.dual_funding_context.our_funding_satoshis {
20652054 return Err(APIError::APIMisuseError {
20662055 err: format!("Total value of funding inputs must be at least funding amount. It was {} sats",
You can’t perform that action at this time.
0 commit comments