Commit graph

516 commits

Author SHA1 Message Date
Matt Corallo
335012640a Update msg_targets with new, must-roundtrip, and hole messages 2018-08-29 18:04:55 -04:00
Matt Corallo
a34e80f4e9 Remove incorrect auto-generated header from error_message_target 2018-08-27 11:47:11 -04: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
755b76bf83 Update error deserialization in compliance with BOLT #1 2018-08-25 17:21:09 -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
6e50a84f14 Do not return UpdateFailHTLC updates until the HTLC is committed
This fixes a violation of BOLT 2 and will let us consolidate some
HTLC update handling. Good bit of code movement, but is mostly
refactor to store HTLC failure status in pending_htlcs in Channel.
2018-08-23 16:11:20 -04:00
Matt Corallo
0647cf4bf1 Restore push_msat in full_stack_target 2018-08-23 16:11:20 -04:00
Matt Corallo
a1bd563456 Restore full_stack_target fuzzer 2018-08-23 16:11:12 -04:00
Matt Corallo
11e5975523 Update to rust-secp256k1 v0.11 and rust-bitcoin v0.14 2018-08-23 14:52:43 -04:00
Antoine Riard
05552c0988 Check amt_to_forward and outgoing_cltv_value in add_update_htlc 2018-08-23 14:52:36 -04:00
Matt Corallo
06d3b4babe Add a full_stack_target sample test to avoid unintentional breakage 2018-08-20 13:58:31 -04:00
Matt Corallo
87aabff8ab Disable push_msat in full_stack_target temporarily 2018-08-20 13:58:31 -04:00
Matt Corallo
1b8f4acb27 Upgrade AFL to 0.4 with persistent mode fuzzing 2018-08-20 13:58:31 -04:00
Matt Corallo
9f2c67ae60 Expand full_stack_target somewhat 2018-08-20 13:58:31 -04:00
Matt Corallo
0f24a67c82
Merge pull request #118 from TheBlueMatt/2018-08-103-rebased
Rebase of #103
2018-08-17 14:00:50 -04:00
Yuntai Kyong
ada2154b40 Add push_msat to new outbound API
Also add APIMisuseError to be thrown to the API client
2018-08-17 13:18:28 -04:00
Matt Corallo
faf9864d9d Don't HTLC claim with no-possible-preimage in full_stack_target 2018-08-17 12:34:09 -04:00
Matt Corallo
ebd3bbba0f Remove some dead Logger code 2018-08-16 23:11:15 -04:00
Matt Corallo
09583f3116 Fix PaymentReceived/sha256 handling in full_stack_target
Sha256 in fuzztarget was updated some time ago to use XOR instead
of the first byte of a real SHA256 run and somehow received and
sent payments got crossed in full_stack_target.
2018-08-16 22:37:44 -04:00
Matt Corallo
609054eae0 Handle duplicate funding transaction gracefully.
This can otherwise cause strange behavior, including a panic on
force_close_all_channels found by full_stack_target fuzzing.
2018-08-16 22:37:44 -04:00
Matt Corallo
dde0ac4c29 Fix fee_base_msat overflowing entire fee range in RouteHint 2018-08-16 20:51:50 -04:00
Antoine Riard
0029f04fce Logging interface
Implement error, warn, info, debug and trace macros, internally calling
an instance of Logger, and passing it to every main structures
Build-time or client-side filtering.
Issue #54
2018-08-17 00:01:15 +00:00
Savil Srivastava
07d7b395e6 change hex version to 0.3, and leave out the minor bumps 2018-07-30 17:01:57 -07:00
Savil Srivastava
4c44b787f1 use hex::decode instead of extend_vec_from_hex 2018-07-28 10:09:29 -07:00
Matt Corallo
da014797b0 Properly calculate Channel::announce_publicly
For some reason we were only setting "announce_publicly" when
Channel::new_from_req had announce_publicly set to true and the
open_channel message had the relevant flag set. However, this
resulted in us rejecting peers for sending unsolicited
announcement_signatures messages, despite them having indicated,
and us having accepted, their announce-bit-set open_channel.
2018-07-26 15:11:36 -04:00
Matt Corallo
c45d8eb41e Only abort channel_target fuzz test on Err if ErrorAction says to 2018-07-25 16:25:12 -04:00
Matt Corallo
0ce6e397a7 Add router_target to fuzzing which fuzzes router msgs + get_route 2018-07-25 16:25:12 -04: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
Matt Corallo
af5c6e8186 PendingHTLCsForwardable really should just be upstreamed.
This is just a comment/docs/function rename change
2018-07-24 22:33:10 -04:00
Matt Corallo
b8b7cb238d Convert fee API to per_kw instead of per_vb
This (a) cuts down a bit on some conversions, reducing chances for
bugsand (b) provides greater accuracy for clients.
2018-07-24 20:34:56 -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
667cd66ede Add arg to get_route to specify our local channels explicitly
(and a new getter in ChannelManager to get the thing to pass in)
2018-07-23 13:33:00 -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
add1d9d9e5
Merge pull request #69 from savil/gen-target-fix
[fuzz] remove \L in sed regex for filenames in gen_target.sh
2018-07-22 23:25:30 -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
dee4ce5171 [fuzz] remove \L in sed regex for filenames in gen_target.sh
Summary:
on `master` branch, if i ran `gen_target.sh` i would get the following output:
https://gist.github.com/savil/2b3114eaf34c3ef8499b65005e374841

Without it, I get the files generated that are already checked-in (as expected).

Looking at the sed docs (https://www.gnu.org/software/sed/manual/html_node/Regular-Expressions.html) i don't see an explanation for what `\L` may do in whatever regex sed follows. Does this look correct? cc @yuntai
2018-07-20 23:00:31 -07:00
Matt Corallo
84cb40f859 Bump version for API overhauls, update deps and docs 2018-07-19 23:06:36 -04:00
Matt Corallo
77a96366ba Shorten channelmonitor_deserialize_target's name for AFL 2018-07-18 14:36:48 -04:00
Matt Corallo
0b82f5584f Test channelmonitor serialization roundtrip doesn't mutate state 2018-07-17 14:59:29 -04:00
Jean Pierre Dudey
d0e9137bc5 Add the OutPoint type for the ChannelMonitor's funding_txo field.
This structure replaces the (Sha256dHash, u16) tuple that was being used
for the funding output.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-06-29 12:12:17 -04:00
Matt Corallo
4de3cfe665 Fix message targets to not have an internal loop 2018-06-16 23:26:56 -04:00
Matt Corallo
a73dea7722 Add ping/pong fuzz targets 2018-06-16 23:26:56 -04:00
Matt Corallo
f462d8ac70 fuzztarget sha -> XOR, crates secp256k1 2018-06-04 20:02:07 -04:00
Matt Corallo
03d07bf73d Update msg_target_template to note auto-generation 2018-05-13 13:28:47 -04:00
Matt Corallo
98af41ba29 Fix indentation in fuzz_target utils 2018-05-13 13:23:22 -04:00
Matt Corallo
ce382c0979 Make travis check that msg_targets match the template 2018-05-13 13:23:22 -04:00
Yuntai Kyong
913ea887fe add fuzz target for messages
[[bin]] section for each new target in Cargo.toml
glob chanbes in travis-fuzz.sh
2018-05-13 05:22:55 +09:00
Yuntai Kyong
e2ff3393ea add script to generate msg test target 2018-05-13 05:10:23 +09:00