Commit graph

779 commits

Author SHA1 Message Date
Matt Corallo
da5d707f49 Allow duplicate-payment_hash HTLCs for HTLC forwards
This is required by BOLT 2 to ensure that no attacker can simply
relay every public node a duplicate-payment_hash HTLC for each HTLC
it receives to deduce where an HTLC came from.

Note that this makes the claim logic much less incentive-compatible
as we will not claim all available HTLCs with the same payment_hash
even if we know the preimage! This is OK because, most likely, any
attackers trying to map the network will use small-value payments
and, hopefully, we will move away from constant hashes across an
entire payment at some point in the near future.

This further simplifies the payment transition state a bit, so
hopefully at least we got some readability out of all of this
2018-09-12 11:15:47 -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
63cb37d346 Add fuzz targets for Writeable messages/migrate fuzz test 2018-09-12 10:19:36 -04:00
Yuntai Kyong
1b8504a3f3 Implement Writer/Reader
with additional variants in DecodeError
2018-09-12 10:18:02 -04:00
Matt Corallo
673912e769 Add force_close_channel call command to full_stack_target 2018-09-09 11:36:00 -04:00
Matt Corallo
90b545ffe3 Narrow ChainWatchInterface::install_watch_script 2018-09-08 02:30:28 +00:00
Matt Corallo
5adf125f42 Remove unused import in router_target 2018-09-06 12:39:36 -04:00
Matt Corallo
8c709d1b6f Dont return an Err from Channel::get_accept_channel that can't fail 2018-09-04 20:27:55 -04:00
Matt Corallo
6dfec329ea Provide better get_chain_utxo return coverage in router_target 2018-09-03 17:40:12 -04:00
Matt Corallo
4ee011441b Ensure we aren't duplicatively reading things in router_target 2018-09-03 17:40:12 -04:00
Antoine Riard
88fac35cd4 Add DummyChainWatcher in route_target 2018-09-03 17:40:12 -04:00
Antoine Riard
2079fe4ad2 Add ChainWatchInterface in Router 2018-09-03 17:40:05 -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
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