use bitcoin::hash_types::{Txid, BlockHash};
use lightning::blinded_path::BlindedPath;
-use lightning::blinded_path::message::ForwardNode;
use lightning::blinded_path::payment::ReceiveTlvs;
use lightning::chain;
use lightning::chain::{BestBlock, ChannelMonitorUpdateStatus, Confirm, Listen};
use lightning::sign::{InMemorySigner, Recipient, KeyMaterial, EntropySource, NodeSigner, SignerProvider};
use lightning::events::Event;
use lightning::ln::{ChannelId, PaymentHash, PaymentPreimage, PaymentSecret};
-use lightning::ln::channelmanager::{ChainParameters, ChannelDetails, ChannelManager, PaymentId, RecipientOnionFields, Retry, InterceptId};
+use lightning::ln::channel_state::ChannelDetails;
+use lightning::ln::channelmanager::{ChainParameters, ChannelManager, PaymentId, RecipientOnionFields, Retry, InterceptId};
use lightning::ln::peer_handler::{MessageHandler,PeerManager,SocketDescriptor,IgnoringMessageHandler};
use lightning::ln::msgs::{self, DecodeError};
use lightning::ln::script::ShutdownScript;
use std::convert::TryInto;
use std::cmp;
use std::sync::{Arc, Mutex};
-use std::sync::atomic::{AtomicU64,AtomicUsize,Ordering};
+use std::sync::atomic::{AtomicU64,AtomicUsize,AtomicBool,Ordering};
use bech32::u5;
#[inline]
struct InputData {
data: Vec<u8>,
read_pos: AtomicUsize,
+ halt_fee_est_reads: AtomicBool,
}
impl InputData {
fn get_slice(&self, len: usize) -> Option<&[u8]> {
}
impl FeeEstimator for FuzzEstimator {
fn get_est_sat_per_1000_weight(&self, _: ConfirmationTarget) -> u32 {
+ if self.input.halt_fee_est_reads.load(Ordering::Acquire) {
+ return 253;
+ }
//TODO: We should actually be testing at least much more than 64k...
match self.input.get_slice(2) {
Some(slice) => cmp::max(slice_to_be16(slice) as u32, 253),
}
fn create_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
- &self, _recipient: PublicKey, _peers: Vec<ForwardNode>, _secp_ctx: &Secp256k1<T>,
+ &self, _recipient: PublicKey, _peers: Vec<PublicKey>, _secp_ctx: &Secp256k1<T>,
) -> Result<Vec<BlindedPath>, ()> {
unreachable!()
}
height: usize,
max_height: usize,
blocks_connected: u32,
+ error_message: String,
}
impl<'a> MoneyLossDetector<'a> {
pub fn new(peers: &'a RefCell<[bool; 256]>,
height: 0,
max_height: 0,
blocks_connected: 0,
+ error_message: "Channel force-closed".to_string(),
}
}
}
// Force all channels onto the chain (and time out claim txn)
- self.manager.force_close_all_channels_broadcasting_latest_txn();
+ self.manager.force_close_all_channels_broadcasting_latest_txn(self.error_message.to_string());
}
}
}
let input = Arc::new(InputData {
data: data.to_vec(),
read_pos: AtomicUsize::new(0),
+ halt_fee_est_reads: AtomicBool::new(false),
});
let fee_est = Arc::new(FuzzEstimator {
input: input.clone(),
11 => {
let mut txn = broadcast.txn_broadcasted.lock().unwrap().split_off(0);
if !txn.is_empty() {
+ input.halt_fee_est_reads.store(true, Ordering::Release);
loss_detector.connect_block(&txn[..]);
for _ in 2..100 {
loss_detector.connect_block(&[]);
}
+ input.halt_fee_est_reads.store(false, Ordering::Release);
}
for tx in txn.drain(..) {
loss_detector.funding_txn.push(tx);
14 => {
let mut channels = channelmanager.list_channels();
let channel_id = get_slice!(1)[0] as usize;
+ let error_message = "Channel force-closed";
if channel_id >= channels.len() { return; }
channels.sort_by(|a, b| { a.channel_id.cmp(&b.channel_id) });
- channelmanager.force_close_broadcasting_latest_txn(&channels[channel_id].channel_id, &channels[channel_id].counterparty.node_id).unwrap();
+ channelmanager.force_close_broadcasting_latest_txn(&channels[channel_id].channel_id, &channels[channel_id].counterparty.node_id, error_message.to_string()).unwrap();
},
// 15, 16, 17, 18 is above
19 => {