Skip to content

Commit fafa655

Browse files
authored
Merge pull request #3199 from TheBlueMatt/2024-07-funding-check
Enforce segwit inputs for all "safe" funding transactions
2 parents b049a7d + 55686b9 commit fafa655

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

lightning/src/ln/channelmanager.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -4629,23 +4629,22 @@ where
46294629
/// If there is an error, all channels in the batch are to be considered closed.
46304630
pub fn batch_funding_transaction_generated(&self, temporary_channels: &[(&ChannelId, &PublicKey)], funding_transaction: Transaction) -> Result<(), APIError> {
46314631
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
4632-
let mut result = Ok(());
4633-
4634-
if !funding_transaction.is_coinbase() {
4635-
for inp in funding_transaction.input.iter() {
4636-
if inp.witness.is_empty() {
4637-
result = result.and(Err(APIError::APIMisuseError {
4638-
err: "Funding transaction must be fully signed and spend Segwit outputs".to_owned()
4639-
}));
4640-
}
4641-
}
4642-
}
4643-
result.and(self.batch_funding_transaction_generated_intern(temporary_channels, FundingType::Checked(funding_transaction)))
4632+
self.batch_funding_transaction_generated_intern(temporary_channels, FundingType::Checked(funding_transaction))
46444633
}
46454634

46464635
fn batch_funding_transaction_generated_intern(&self, temporary_channels: &[(&ChannelId, &PublicKey)], funding: FundingType) -> Result<(), APIError> {
46474636
let mut result = Ok(());
46484637
if let FundingType::Checked(funding_transaction) = &funding {
4638+
if !funding_transaction.is_coinbase() {
4639+
for inp in funding_transaction.input.iter() {
4640+
if inp.witness.is_empty() {
4641+
result = result.and(Err(APIError::APIMisuseError {
4642+
err: "Funding transaction must be fully signed and spend Segwit outputs".to_owned()
4643+
}));
4644+
}
4645+
}
4646+
}
4647+
46494648
if funding_transaction.output.len() > u16::max_value() as usize {
46504649
result = result.and(Err(APIError::APIMisuseError {
46514650
err: "Transaction had more than 2^16 outputs, which is not supported".to_owned()

0 commit comments

Comments
 (0)