Skip to content

Commit

Permalink
Merge pull request #159 from p2pderivatives/fix/do-not-panic-on-subch…
Browse files Browse the repository at this point in the history
…annel-force-closure
  • Loading branch information
luckysori authored Oct 24, 2023
2 parents 56e35f7 + f318fee commit 39882fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
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

0 comments on commit 39882fe

Please sign in to comment.