From 7d6aab7f22e8191b1838c3132cd8188c48f2796b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sun, 26 Aug 2018 16:30:01 -0400 Subject: [PATCH] Add update_fail_malformed_htlcs vec to CommitmentUpdate Not sure why this wasn't there to begin with --- src/ln/channel.rs | 2 ++ src/ln/channelmanager.rs | 13 ++++++++++--- src/ln/msgs.rs | 1 + src/ln/peer_handler.rs | 5 ++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/ln/channel.rs b/src/ln/channel.rs index d6e23a28..932bebb3 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -1643,6 +1643,7 @@ impl Channel { update_add_htlcs, update_fulfill_htlcs, update_fail_htlcs, + update_fail_malformed_htlcs: Vec::new(), commitment_signed, }, monitor_update))) }, @@ -1740,6 +1741,7 @@ impl Channel { update_add_htlcs: Vec::new(), update_fulfill_htlcs: Vec::new(), update_fail_htlcs: failed_htlcs, + update_fail_malformed_htlcs: Vec::new(), commitment_signed }), to_forward_infos, revoked_htlcs, monitor_update)) } else { diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index 3a98cd5a..9daa7ba6 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -958,6 +958,7 @@ impl ChannelManager { update_add_htlcs: vec![update_add], update_fulfill_htlcs: Vec::new(), update_fail_htlcs: Vec::new(), + update_fail_malformed_htlcs: Vec::new(), commitment_signed, }, }); @@ -1102,6 +1103,7 @@ impl ChannelManager { update_add_htlcs: add_htlc_msgs, update_fulfill_htlcs: Vec::new(), update_fail_htlcs: Vec::new(), + update_fail_malformed_htlcs: Vec::new(), commitment_signed: commitment_msg, }, })); @@ -1225,6 +1227,7 @@ impl ChannelManager { update_add_htlcs: Vec::new(), update_fulfill_htlcs: Vec::new(), update_fail_htlcs: vec![msg], + update_fail_malformed_htlcs: Vec::new(), commitment_signed: commitment_msg, }, }); @@ -1324,6 +1327,7 @@ impl ChannelManager { update_add_htlcs: Vec::new(), update_fulfill_htlcs: vec![msg], update_fail_htlcs: Vec::new(), + update_fail_malformed_htlcs: Vec::new(), commitment_signed: commitment_msg, } }); @@ -2487,9 +2491,10 @@ mod tests { impl SendEvent { fn from_event(event: Event) -> SendEvent { match event { - Event::UpdateHTLCs { node_id, updates: msgs::CommitmentUpdate { update_add_htlcs, update_fulfill_htlcs, update_fail_htlcs, commitment_signed } } => { + Event::UpdateHTLCs { node_id, updates: msgs::CommitmentUpdate { update_add_htlcs, update_fulfill_htlcs, update_fail_htlcs, update_fail_malformed_htlcs, commitment_signed } } => { assert!(update_fulfill_htlcs.is_empty()); assert!(update_fail_htlcs.is_empty()); + assert!(update_fail_malformed_htlcs.is_empty()); SendEvent { node_id: node_id, msgs: update_add_htlcs, commitment_msg: commitment_signed } }, _ => panic!("Unexpected event type!"), @@ -2646,10 +2651,11 @@ mod tests { let events = node.node.get_and_clear_pending_events(); assert_eq!(events.len(), 1); match events[0] { - Event::UpdateHTLCs { ref node_id, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref commitment_signed } } => { + Event::UpdateHTLCs { ref node_id, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref update_fail_malformed_htlcs, ref commitment_signed } } => { assert!(update_add_htlcs.is_empty()); assert_eq!(update_fulfill_htlcs.len(), 1); assert!(update_fail_htlcs.is_empty()); + assert!(update_fail_malformed_htlcs.is_empty()); expected_next_node = node_id.clone(); next_msgs = Some((update_fulfill_htlcs[0].clone(), commitment_signed.clone())); }, @@ -2770,10 +2776,11 @@ mod tests { let events = node.node.get_and_clear_pending_events(); assert_eq!(events.len(), 1); match events[0] { - Event::UpdateHTLCs { ref node_id, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref commitment_signed } } => { + Event::UpdateHTLCs { ref node_id, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref update_fail_malformed_htlcs, ref commitment_signed } } => { assert!(update_add_htlcs.is_empty()); assert!(update_fulfill_htlcs.is_empty()); assert_eq!(update_fail_htlcs.len(), 1); + assert!(update_fail_malformed_htlcs.is_empty()); expected_next_node = node_id.clone(); next_msgs = Some((update_fail_htlcs[0].clone(), commitment_signed.clone())); }, diff --git a/src/ln/msgs.rs b/src/ln/msgs.rs index 44d71bd3..6c7c8cfc 100644 --- a/src/ln/msgs.rs +++ b/src/ln/msgs.rs @@ -399,6 +399,7 @@ pub struct CommitmentUpdate { pub update_add_htlcs: Vec, pub update_fulfill_htlcs: Vec, pub update_fail_htlcs: Vec, + pub update_fail_malformed_htlcs: Vec, pub commitment_signed: CommitmentSigned, } diff --git a/src/ln/peer_handler.rs b/src/ln/peer_handler.rs index f941f47d..9315f569 100644 --- a/src/ln/peer_handler.rs +++ b/src/ln/peer_handler.rs @@ -697,7 +697,7 @@ impl PeerManager { Self::do_attempt_write_data(&mut descriptor, peer); continue; }, - Event::UpdateHTLCs { ref node_id, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref commitment_signed } } => { + Event::UpdateHTLCs { ref node_id, updates: msgs::CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref update_fail_malformed_htlcs, ref commitment_signed } } => { log_trace!(self, "Handling UpdateHTLCs event in peer_handler for node {} with {} adds, {} fulfills, {} fails for channel {}", log_pubkey!(node_id), update_add_htlcs.len(), @@ -716,6 +716,9 @@ impl PeerManager { for msg in update_fail_htlcs { peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!(msg, 131))); } + for msg in update_fail_malformed_htlcs { + peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!(msg, 135))); + } peer.pending_outbound_buffer.push_back(peer.channel_encryptor.encrypt_message(&encode_msg!(commitment_signed, 132))); Self::do_attempt_write_data(&mut descriptor, peer); continue; -- 2.30.2