Commit graph

52 commits

Author SHA1 Message Date
Matt Corallo
12a50627a3 Add channel_reestablish + peer_connected events to channel handler 2018-09-15 10:53:16 -04:00
Yuntai Kyong
28a612f9f3 Migrate fuzz router/channel target to Readable
and be more specific about DecodeError::InvalidValue
2018-09-12 10:19:36 -04:00
Yuntai Kyong
89475381bb Implement Writeable for messages 2018-09-12 10:18:52 -04:00
Yuntai Kyong
1b8504a3f3 Implement Writer/Reader
with additional variants in DecodeError
2018-09-12 10:18:02 -04:00
SW van Heerden
f5e3a3ea81 change temp_channel from deserialise to copy 2018-09-06 10:49:36 -04:00
Matt Corallo
f78d7299d6 Also fwd channel_update and node_announcement immediately
Not really sure why the API was different for channel_announcement,
but this brings everything in sync.
2018-08-29 18:07:56 -04:00
Matt Corallo
faff5c2da3 Fail parsing node/channel announcements with unknown even features
This is required for BOLT 7 compliance
2018-08-29 18:06:06 -04:00
Matt Corallo
b9a793a0a0 Correct excess-data handling in NodeAnnouncement
Breaks parsing of padding within addresses, but nothing currently
generates such messages, and I'm proposing we remove it in the spec
2018-08-29 18:03:10 -04:00
Matt Corallo
9902fce585 Correct excess-data handling in ChannelUpdate 2018-08-29 18:01:15 -04:00
Matt Corallo
0881bf4b74 Correct excess-data handling in ChannelAnnouncement verif in Router 2018-08-29 17:59:25 -04:00
Matt Corallo
c1c7cc96ac Remove unused test variable left orphaned by 5d923e2a63 2018-08-29 17:54:57 -04:00
Yuntai Kyong
9a28496388 Use Option<DataLossProtect> for ChannelReestablish
and fix test
2018-08-30 01:48:36 +09:00
Yuntai Kyong
5d923e2a63 Fix test for ChannelReestablish 2018-08-29 13:00:34 +09:00
Yuntai Kyong
7dc215edcb Make my_current_per_commitment_point Option
Per Bolt #2, both your_last_per_commitment_secret &
my_current_per_commitment_point are optional depending on
`data_loss_protect`
2018-08-29 12:55:11 +09:00
Matt Corallo
42e908883f Return a malformed HTLC message when ephemeral pubkey is garbage
This resolves a spec-compliance bug with BOLT 4 where we simply
failed to deserialize the message and thus could never return an
HTLC failure message. However, note that BOLT 4 incorrectly hints
that a non-malformed message should be used ("...MUST report a
route failure to the origin node") which we cannot do as we cannot
derive a SharedSecret to encrypt a regular update_fail_htlc message
2018-08-27 11:47:11 -04:00
Matt Corallo
7d6aab7f22 Add update_fail_malformed_htlcs vec to CommitmentUpdate
Not sure why this wasn't there to begin with
2018-08-26 16:39:21 -04:00
Matt Corallo
755b76bf83 Update error deserialization in compliance with BOLT #1 2018-08-25 17:21:09 -04:00
Matt Corallo
a3247abb4e Handle Error messages by closing channels as required by BOLT 1 2018-08-25 17:20:58 -04:00
Matt Corallo
ab00e4ccff Merge HTLC-update events, remove FailHTLC ErrorAction
UpdateFailHTLC isn't really an error anymore now that its handled
async after channel commitment (as required by BOLT 2), and since
its unused this is free. To resolve the TODO which intended to use
it for HTLC failure when trying to route forwards, we instead opt
to merge all the HTLC update events into one UpdateHTLCs event
which just contains a CommitmentUpdate object.
2018-08-23 16:11:20 -04:00
Matt Corallo
11e5975523 Update to rust-secp256k1 v0.11 and rust-bitcoin v0.14 2018-08-23 14:52:43 -04:00
Matt Corallo
c52825d5f1 Fix UpdateAddHTLC serialize vec capacity default 2018-08-02 22:37:28 -04:00
Savil Srivastava
ca6b44b8cc replace use of bitcoin::utils::misc::hex_bytes with hex::decode
as requested in #84 discussion
https://github.com/rust-bitcoin/rust-lightning/pull/84#discussion_r205508845
2018-07-27 18:19:00 -07:00
Matt Corallo
66023b7886 Update NodeAnnouncement addr deserialization to check addr len.
This more aggressively checks the message contents are correct
before returning WrongLength so existing fuzz setup has an easier
time.
2018-07-25 15:57:36 -04:00
Matt Corallo
d4bb39a1dd Ensure all msg deserialization can provide extra bytes, rename err 2018-07-25 15:56:46 -04:00
Antoine Riard
20fa9d331d Add DisconnectPeer events
Add test for DisconnectPeer event
Update DisconnectPeer with optional ErrorMessage
Manage error for funding_transaction_generated
Add disconnect_socket to SocketDescriptor trait
2018-07-23 14:31:44 -04:00
Antoine Riard
1c12e83941 Implement ErrorMessage msg and ErrorAction::SendErrorMessage + fuzz test 2018-07-23 14:31:44 -04:00
Matt Corallo
ac941e19c9 Remove dangling spaces from #75 2018-07-22 23:54:30 -04:00
Savil Srivastava
0c1f47807a [msgs::ChannelReestablish] implement encoding and decoding
Summary:

Implementing these, taking inspiration from the surrounding code since i'm a rust n00b.

Test Plan:
```
cargo build
cargo test channel_reestablish
```
output:
```
running 3 tests
test ln::msgs::tests::encoding_channel_reestablish_with_secret ... ok
test ln::msgs::tests::decode_channel_reestablish_bad_length ... ok
test ln::msgs::tests::encoding_channel_reestablish_no_secret ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 14 filtered out
```
2018-07-22 23:26:47 -04:00
Matt Corallo
e93c9fbeaf Migrate all Uint256s used for channel_ids to [u8; 32] 2018-07-22 18:55:20 -04:00
Savil Srivastava
14c02c0652 update TODO message for renaming "msg" field of HandleError struct 2018-07-19 20:01:55 -07:00
Savil Srivastava
fd141bbed2 [Error] rename msg field to action
this was a TODO and also briefly discussed in https://github.com/rust-bitcoin/rust-lightning/pull/43#pullrequestreview-135649551

I'm not fully sure how to remove the `Option`, and make it completely required. Would love suggestions. So, have omitted that for now. Plus, better to make smaller, incremental changes.

Test Plan:
`cargo build`
`cargo test`
2018-07-19 20:01:55 -07:00
Matt Corallo
e3effa4622 Send initial_routing_sync-filled Init messages to the first 5 peers 2018-06-16 19:46:49 -04:00
Matt Corallo
05e2a7dc48 Support responding to Ping messages in peer_handler 2018-06-16 19:46:49 -04:00
Matt Corallo
d7b33fcd84 Support ignoring some errors, deserialize empty flags types 2018-06-16 19:45:32 -04:00
Matt Corallo
5481a5d653 Provide Send + Sync on message handlers (just changes trait) 2018-06-14 18:05:13 -04:00
Yuntai Kyong
fb1bf30263 filling unimplemented!() for many messages' encoding/decoding routines 2018-05-12 14:30:26 +09:00
Matt Corallo
8e2974fc2a HTLC Failure message handling 2018-04-24 11:55:08 -04:00
Matt Corallo
e9f9cda986 impl more message encodings 2018-04-16 20:35:21 -04:00
Matt Corallo
374ea1f05e Completely rewrite channel HTLC tracking and processing
It obviously was nonsensical prior, though its now way more
complicated...there's refactoring work to be done here, but it
should at least kinda sorta work now.
2018-04-16 20:35:21 -04:00
Matt Corallo
e79e61f595 Clean up channel error handling a ton 2018-04-02 18:31:23 -04:00
Matt Corallo
91b964ae1f Basic error handling framework in peer_handler 2018-04-02 18:31:23 -04:00
Matt Corallo
df9367adaf Rename ErrorMessage 2018-04-02 18:31:23 -04:00
Matt Corallo
7b0a25bdce Fix message decoding for features, build some encoding 2018-04-02 18:07:03 -04:00
Matt Corallo
c528ff3650 Handle incoming shutdown messages 2018-04-02 18:07:02 -04:00
Matt Corallo
9606f94caf Stop freeing holding cell in updates, fix freeing in revoke 2018-03-25 17:02:28 -04:00
Matt Corallo
942d760b83 impl more message decoders 2018-03-25 17:02:28 -04:00
Matt Corallo
298557c891 impl a bunch of additional messages, remove some useless mut 2018-03-22 17:43:20 -04:00
Matt Corallo
40ab09f627 Clarify roles in failing HTLCs, impl it, support rebalances 2018-03-22 17:35:30 -04:00
Matt Corallo
deb23a9309 Allow messages to be too long in accorance with spec 2018-03-20 14:03:33 -04:00
Matt Corallo
4f4c0a8179 Impl a few more msg deserializations, fix a channel panic!() bug 2018-03-19 17:46:37 -04:00