Skip to content

Commit 55686b9

Browse files
committed
Enforce segwit inputs for all "safe" funding transactions
8403755 introduced a separate path for funding a channel without a full funding transaction, relying on users to manually broadcast the funding tx. One of the major things that makes this path less safe is that for other paths we're supposed to validate that all inputs have witnesses, making the funding transaction (likely) txid-non-malleable. However, in one of several rewrites of that commit the funding tx tests ended up getting elided in some call paths, which is fixed here.
1 parent 3733103 commit 55686b9

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
@@ -4605,23 +4605,22 @@ where
46054605
/// If there is an error, all channels in the batch are to be considered closed.
46064606
pub fn batch_funding_transaction_generated(&self, temporary_channels: &[(&ChannelId, &PublicKey)], funding_transaction: Transaction) -> Result<(), APIError> {
46074607
let _persistence_guard = PersistenceNotifierGuard::notify_on_drop(self);
4608-
let mut result = Ok(());
4609-
4610-
if !funding_transaction.is_coinbase() {
4611-
for inp in funding_transaction.input.iter() {
4612-
if inp.witness.is_empty() {
4613-
result = result.and(Err(APIError::APIMisuseError {
4614-
err: "Funding transaction must be fully signed and spend Segwit outputs".to_owned()
4615-
}));
4616-
}
4617-
}
4618-
}
4619-
result.and(self.batch_funding_transaction_generated_intern(temporary_channels, FundingType::Checked(funding_transaction)))
4608+
self.batch_funding_transaction_generated_intern(temporary_channels, FundingType::Checked(funding_transaction))
46204609
}
46214610

46224611
fn batch_funding_transaction_generated_intern(&self, temporary_channels: &[(&ChannelId, &PublicKey)], funding: FundingType) -> Result<(), APIError> {
46234612
let mut result = Ok(());
46244613
if let FundingType::Checked(funding_transaction) = &funding {
4614+
if !funding_transaction.is_coinbase() {
4615+
for inp in funding_transaction.input.iter() {
4616+
if inp.witness.is_empty() {
4617+
result = result.and(Err(APIError::APIMisuseError {
4618+
err: "Funding transaction must be fully signed and spend Segwit outputs".to_owned()
4619+
}));
4620+
}
4621+
}
4622+
}
4623+
46254624
if funding_transaction.output.len() > u16::max_value() as usize {
46264625
result = result.and(Err(APIError::APIMisuseError {
46274626
err: "Transaction had more than 2^16 outputs, which is not supported".to_owned()

0 commit comments

Comments
 (0)