Commit graph

127 commits

Author SHA1 Message Date
Matt Corallo
74588b2519 Send back the actual received amount, not expected on HTLC fails
This resolves an incorrect implementation of the spec and fixes a
major privacy leak.

Fixes GH #289.
2019-01-24 16:55:01 -05:00
Matt Corallo
49d63302c3 Add a fuzz target to test monitor update failure handling
Sadly this requires reducing the honggfuzz iterations to fit within
Travis' runtime limits.
2019-01-24 13:17:00 -05:00
Matt Corallo
aa9a848f79 Take the logger from test_utils into fuzz::test_utils 2019-01-24 13:16:59 -05:00
Yuko Roodt
4d77e9d752 Added tests to check the bolt 2 specs for Sending Node Channel 2019-01-23 14:54:10 -05:00
Matt Corallo
12d25576c1 Upgrade to secp256k1 v12, bitcoin v16, and crates bitcoin_hashes 2019-01-22 13:49:15 -05:00
Matt Corallo
7fd294db3d
Merge pull request #285 from TheBlueMatt/2019-01-fuzz-cleanups
Trivial cleanups in full_stack_target/fuzztarget
2019-01-16 10:11:32 -05:00
Matt Corallo
90ce97198c Simplify and expand logging in is_resolving_htlc_output
This clarifies all the conditions we can hit and also ensures they
are all logged in a clear and consistent manner.
2019-01-08 23:03:07 -05:00
Matt Corallo
5801d19a69 Switch to bitcoin_hashes Hash160 in full_stack_target 2019-01-08 14:04:06 -05:00
Matt Corallo
d8dcb1a9d3 Add doc to full_stack_target 2019-01-08 14:04:06 -05:00
Matt Corallo
cdf9b4f8ba Add option to use libfuzzer sys in full_stack_target
Note that there doesn't appear to be a way to conditionally set
 #[no_main] so that has to happen manually at compile-time.
2019-01-08 14:04:06 -05:00
Matt Corallo
044edd6e86 Fail HTLCs backwards asynchronously 2018-12-21 15:17:42 -05:00
Matt Corallo
7ea39a13b2 Use bitcoin_hashes' fixed_time_eq, removing the rust-crypto dep 2018-12-19 20:02:36 -05:00
Matt Corallo
8e07259326 Use bitcoin_hashes' Ripemd160/Hash160 from rust-crypto+rust-bitcoin
Note that this requires rewriting full_stack_target tests, which
sucks, but it does let the fuzzer hit more stuff since the real
ripemd160 isn't ever actually called anymore.
2018-12-19 20:02:36 -05:00
Matt Corallo
f1e400f142 Switch Sha256 to using bitcoin_hashes and our own HKDF 2018-12-19 17:13:25 -05:00
Matt Corallo
caeff85368 Update incorrect_payment_amount generation/handling for BOLT uptd
ie dont generate them as they're a really obvious privacy leak.
Luckily we were already handling them the same aside from log
printing so don't have to touch anything there. I was lazy in
updating tests but it only effects log printing, so whatever.
2018-12-17 22:57:47 -05:00
Matt Corallo
f5ccd4b4ef Add additional log traces in channelmonitor/manager 2018-12-14 17:01:12 -05:00
Antoine Riard
7a483e597c Typify payment_hash and payment_preimage
Fix variable name as payment_hash instead of txid for index
of remote_hash_commitment_number in ChannelMonitor reader
2018-12-14 17:00:50 -05:00
Matt Corallo
221bfa6bd4 Move monitor-generated HTLC event handling to manager event-getters
This is somewhat awkward, but prevents a slew of duplicate events.
Really this should probably be more explicit, but would be easy to
move that along with a slew of block_connected-event-processing
refactors, see-also GH #80.

This affects full_stack_target only on accident cause the demo test
didn't continue onwards with another block connection.
2018-12-14 17:00:22 -05:00
Matt Corallo
4f9b0fbd3f Avoid writing to stdout during fuzz tests 2018-12-03 13:58:50 -05:00
Matt Corallo
7e94d3a617 Remove unused import in full_stack_target 2018-12-03 13:30:38 -05:00
Yuntai Kyong
7e59e1e392 Add a method to get session secret for onion packet to KeysInterface 2018-11-27 10:44:51 +09:00
Matt Corallo
3a066ccbf2 Ensure fuzz release builds use codegen-units=1 and LTO 2018-11-18 16:17:06 -05:00
Steven Roose
7ff7561f2d Update to rust-bitcoin v0.15 2018-11-14 11:43:54 +00:00
Matt Corallo
38584e3efe Avoid double-panic in full_stack_target to assist debugging 2018-11-02 10:54:25 -04:00
Schalk van Heerden
a0be4d1758 Added config interface to allow users to specify channel limits 2018-10-31 15:45:30 -04:00
Matt Corallo
9189d0e61d Require at least 1k sat for outbound channels and meet BTC's dust 2018-10-31 15:45:30 -04:00
Matt Corallo
46f573b787 [full_stack_target] don't allow double-confirming txn 2018-10-29 17:16:29 -04:00
Matt Corallo
64bd2eaa7f Give ManyChannelMonitor a logger and trace add_update events 2018-10-29 14:26:05 -04:00
Matt Corallo
56513f2927 Track last_block_hash in ChannelMonitor and expose it on deser
Also make block_connected take a &mut self to ensure serialized
state will always be self-consistent.
2018-10-27 09:42:04 -04:00
Matt Corallo
47fe673c57 Give ChannelMonitor a logger via new ReadableArgs trait 2018-10-27 09:42:04 -04:00
Matt Corallo
4342114345 Send RAA/CS messages out-of-band to ensure ordered delivery 2018-10-27 09:42:04 -04:00
Matt Corallo
c962a27156 Send funding_signed messages out-of-band to ensure ordered delivery 2018-10-27 09:42:04 -04:00
Matt Corallo
608d517f92 Send AcceptChannel responses out-of-band to ensure ordered delivery 2018-10-27 09:42:04 -04:00
Matt Corallo
e397cb9960 Split Event, move MessageSendEvent push() inside channel_state lock 2018-10-27 09:42:04 -04:00
Antoine Riard
5180686b1d Integrate destination_script from KeysInterface in ChannelManager/Channel
Drop channel_monitor_claim_key from ChannelKeys
2018-10-27 09:42:04 -04:00
Antoine Riard
32a9378909 Integrate shutdown_pubkey from KeysInterface in ChannelManager/Channel
Drop channel_close_key from ChannelKeys
2018-10-27 09:42:04 -04:00
Antoine Riard
e361fed0f1 Integrate KeysInterface to ChannelManager with Arc 2018-10-27 09:42:04 -04:00
Yuntai Kyong
f133554697 Add PaymentFailReason for fail_htlc_backwards
to indicate fail reason after a PaymentReceived event
2018-10-25 21:24:53 +09:00
Yuntai Kyong
ba30061c87 Add is_permanent field to ChannelClosed message and add NodeFailure
message
2018-10-23 10:30:49 -04:00
Matt Corallo
79a0a0c959 Migrate ChannelMonitor serialization to new ser framework(ish)
Sadly we can't straight up use the new serialization framework as
we have a few different serialization variants, but that's OK, it
looks identical and is just missing the Writeable impl
2018-09-20 10:46:13 -04:00
Matt Corallo
28d0d44e44 Move ChannelMonitor deserialization to new ser framework 2018-09-20 10:46:13 -04:00
Matt Corallo
c43e535bc0 Simplify DecodeError enum by removing some useless distinctions 2018-09-20 10:46:12 -04:00
Matt Corallo
da6171d50d Remove fuzz channel_target.
It has bitrotted a lot and doesn't really make sense given all the
precondition enforcement that is in channelmanager, sadly.
2018-09-19 22:47:07 -04:00
Matt Corallo
19b92448c5 Utilize Writer size hinting in message fuzz targets and check them 2018-09-16 14:33:50 -04:00
Matt Corallo
1f1f82569a Simplify serialization a bit by removing the useless newtypes 2018-09-16 14:33:50 -04:00
Yuntai Kyong
4e4fa56e2b unwrap channel.get_open_channel 2018-09-15 07:33:20 +09:00
Matt Corallo
aa17defa04 Tweak + extend full_stack_target sample to incl HTLC tx broadcasts 2018-09-14 15:27:54 -04:00
Matt Corallo
f27c74b35c
Merge pull request #167 from TheBlueMatt/2018-09-dup-htlc
Allow duplicate-payment_hash HTLCs for HTLC forwards
2018-09-12 13:07:13 -04:00
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