Add update_fail_malformed_htlcs vec to CommitmentUpdate
authorMatt Corallo <git@bluematt.me>
Sun, 26 Aug 2018 20:30:01 +0000 (16:30 -0400)
committerMatt Corallo <git@bluematt.me>
Sun, 26 Aug 2018 20:39:21 +0000 (16:39 -0400)
Not sure why this wasn't there to begin with

src/ln/channel.rs
src/ln/channelmanager.rs
src/ln/msgs.rs
src/ln/peer_handler.rs

index d6e23a2839274fc5b84ecbc0e7e2d870469bbb0d..932bebb3166ace8b81487ab20789237fee05a296 100644 (file)
@@ -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 {
index 3a98cd5a17647fb5a4a036abf5814411018bed22..9daa7ba6a9c26b95e142e8f58f10a44da6d6be73 100644 (file)
@@ -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()));
                                },
index 44d71bd332938bc3959f3cf768bfebe5bffcbdcb..6c7c8cfc7281682af919360df1c892342277e820 100644 (file)
@@ -399,6 +399,7 @@ pub struct CommitmentUpdate {
        pub update_add_htlcs: Vec<UpdateAddHTLC>,
        pub update_fulfill_htlcs: Vec<UpdateFulfillHTLC>,
        pub update_fail_htlcs: Vec<UpdateFailHTLC>,
+       pub update_fail_malformed_htlcs: Vec<UpdateFailMalformedHTLC>,
        pub commitment_signed: CommitmentSigned,
 }
 
index f941f47dc10e5c99f13460b5aa82b96fba3a13c4..9315f56902d767339285d146235c18f62cffb982 100644 (file)
@@ -697,7 +697,7 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
                                                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<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
                                                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;