mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 15:20:24 +01:00
Merge pull request #265 from TheBlueMatt/2018-12-fuzz-fix-no-witness
Fix crash on no-witness tx in ChannelMonitor found by fuzzer
This commit is contained in:
commit
dfbc6c60a7
3 changed files with 5 additions and 3 deletions
|
@ -7,7 +7,7 @@ use bitcoin::blockdata::block::BlockHeader;
|
||||||
use bitcoin::blockdata::transaction::{Transaction, TxOut};
|
use bitcoin::blockdata::transaction::{Transaction, TxOut};
|
||||||
use bitcoin::blockdata::script::{Builder, Script};
|
use bitcoin::blockdata::script::{Builder, Script};
|
||||||
use bitcoin::blockdata::opcodes;
|
use bitcoin::blockdata::opcodes;
|
||||||
use bitcoin::consensus::encode::{deserialize, serialize};
|
use bitcoin::consensus::encode::deserialize;
|
||||||
use bitcoin::network::constants::Network;
|
use bitcoin::network::constants::Network;
|
||||||
use bitcoin::util::hash::{BitcoinHash, Sha256dHash, Hash160};
|
use bitcoin::util::hash::{BitcoinHash, Sha256dHash, Hash160};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@ pub struct TestLogger {}
|
||||||
|
|
||||||
impl Logger for TestLogger {
|
impl Logger for TestLogger {
|
||||||
fn log(&self, record: &Record) {
|
fn log(&self, record: &Record) {
|
||||||
#[cfg(any(test, not(feature = "fuzztarget")))]
|
#[cfg(test)]
|
||||||
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
|
println!("{:<5} [{} : {}, {}] {}", record.level.to_string(), record.module_path, record.file, record.line, record.args);
|
||||||
|
#[cfg(not(test))]
|
||||||
|
let _ = format!("{}", record.args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1386,7 +1386,7 @@ impl ChannelMonitor {
|
||||||
|
|
||||||
/// Generate a spendable output event when closing_transaction get registered onchain.
|
/// Generate a spendable output event when closing_transaction get registered onchain.
|
||||||
fn check_spend_closing_transaction(&self, tx: &Transaction) -> Option<SpendableOutputDescriptor> {
|
fn check_spend_closing_transaction(&self, tx: &Transaction) -> Option<SpendableOutputDescriptor> {
|
||||||
if tx.input[0].sequence == 0xFFFFFFFF && tx.input[0].witness.last().unwrap().len() == 71 {
|
if tx.input[0].sequence == 0xFFFFFFFF && !tx.input[0].witness.is_empty() && tx.input[0].witness.last().unwrap().len() == 71 {
|
||||||
match self.key_storage {
|
match self.key_storage {
|
||||||
KeyStorage::PrivMode { ref shutdown_pubkey, .. } => {
|
KeyStorage::PrivMode { ref shutdown_pubkey, .. } => {
|
||||||
let our_channel_close_key_hash = Hash160::from_data(&shutdown_pubkey.serialize());
|
let our_channel_close_key_hash = Hash160::from_data(&shutdown_pubkey.serialize());
|
||||||
|
|
Loading…
Add table
Reference in a new issue