Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not panic on attempting to force-close a subchannel #159

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bitcoin-test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ pub fn from_hex(hex: &str, target: &mut [u8]) -> Result<usize, ()> {
/// Transforms an hex string to a Vec<u8>.
/// Panics if the string is not valid hex.
pub fn str_to_hex(hex_str: &str) -> Vec<u8> {
let mut hex = Vec::<u8>::new();
hex.resize(hex_str.len() / 2, 0);
let mut hex = vec![0; hex_str.len() / 2];
from_hex(hex_str, &mut hex).unwrap();
hex
}
Expand Down
8 changes: 7 additions & 1 deletion dlc-manager/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ macro_rules! check_for_timed_out_channels {
let is_timed_out = timeout < $manager.time.unix_time_now();
if is_timed_out {
let sub_channel = if channel.is_sub_channel() {
unimplemented!();
log::info!(
"Skipping force-closure of subchannel {}: not supported",
bitcoin::hashes::hex::ToHex::to_hex(&channel.channel_id[..])
);
continue;

// TODO: Implement subchannel force closing
// let s = get_sub_channel_in_state!(
// $manager,
// channel.channel_id,
Expand Down
4 changes: 1 addition & 3 deletions dlc-messages/src/message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ impl CustomMessageHandler for MessageHandler {
org: &PublicKey,
) -> Result<(), LightningError> {
let mut segment_readers = self.segment_readers.lock().unwrap();
let segment_reader = segment_readers
.entry(*org)
.or_insert_with(SegmentReader::new);
let segment_reader = segment_readers.entry(*org).or_default();

if segment_reader.expecting_chunk() {
match msg {
Expand Down