Commit graph

73 commits

Author SHA1 Message Date
Matt Corallo
3db5798246 Stub out ChaCha20 non-HMAC encryption/decryption in fuzztarget 2018-08-02 22:37:28 -04:00
Matt Corallo
bd01f4e0c3 Fix fuzztarget ChannelKeys generation 2018-08-02 22:26:44 -04:00
Matt Corallo
cfc3fe3148 Fix panic!() in block_connected on unfunded channels (fixes #42)
The new full_stack_target fuzzing stuff was able to find this bug,
which gives me a bit of hope for full_stack_target's utility.
2018-08-02 22:26:44 -04:00
Matt Corallo
7e255b5cf5 Handle invalid funding tx in channelmanager 2018-07-29 13:30:04 -04:00
Matt Corallo
1051e53ecc Stop adding remote's payment_preimages to our channel monitor 2018-07-29 13:30:04 -04:00
Matt Corallo
b22519c0f9 Some match -> if let replacement 2018-07-29 13:30:04 -04:00
Matt Corallo
fb9f169279 Assert usize is 32 or 64 bits, as required in a TODO 2018-07-29 13:30:04 -04:00
Matt Corallo
d5e316f5a0 Remove some excess mut's 1.22 complains about 2018-07-29 13:30:04 -04:00
Matt Corallo
c26967348d Remove some useless Vecs 2018-07-29 02:23:02 -04:00
Matt Corallo
c7c8a123ba Add pending-HTLC-failure to and unify force_shutdown() handling
This patch got a bit bigger than I'd intended, but primarily this
unifies force_shutdown() handling so all the callsites at least
look similar. It also fails backwards any HTLCs which were
completely pending (ie hadn't been committed to) and ensures we
broadcast our local commitment transaction. It also adds a
force_close_channel method to ChannelManager to expose
force-closure.
2018-07-29 02:23:02 -04:00
Matt Corallo
5c32e3cb91 Clean up forward_/claimable_htlcs handling and document consistency 2018-07-28 18:36:24 -04:00
Matt Corallo
9aed28fbf0 Fix force_shutdown() bug where we lose knowledge of a preimage
In case we are in AwaitingRemoteRevoke and we go to claim an HTLC
(at which point we've already given up the money to the next hop in
the payment) we just write it to holding_cell_htlc_updates.
However, we should be ensuring we *also* write it to our
channel_monitor as we need to make sure we can still claim it after
a force_shutdown() or otherwise after hitting the chain.
2018-07-28 18:34:01 -04:00
Matt Corallo
982317a444
Merge pull request #95 from savil/rm-bitcoin-util-hexbytes
replace use of bitcoin::utils::misc::hex_bytes with hex::decode
2018-07-28 16:19:33 -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
e0c75caa3a Handle duplicate payment_hash send_payment()s
We don't bother doing anything smart, we just return an Err in
case we have a pending outbound HTLC with the payment_hash provided
for the send.

This doesn't resolve the TODO as users can still send duplicative
payments that have the same payment_hash as was already sent,
though the docs are updated and hopefully users do so on their own.
2018-07-26 19:39:26 -04: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
d7c1cfcc22 Make claim_funds_INTERNAL private 2018-07-24 22:33:12 -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
Matt Corallo
ad147a20e6 Half-ass some CLTV fixes for real channel creation 2018-07-23 23:31:37 -04:00
Matt Corallo
12a55ae6fc Set associated_data to payment_hash 2018-07-23 22:47:36 -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
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
Matt Corallo
7b4f382e26 Move shutdown sending to an event 2018-07-22 23:22:15 -04:00
Matt Corallo
e93c9fbeaf Migrate all Uint256s used for channel_ids to [u8; 32] 2018-07-22 18:55:20 -04:00
Matt Corallo
896f5b8d91 Fix failure sending FundingLocked for non-announced channels 2018-07-22 17:11:20 -04:00
Matt Corallo
88c301cf08 Test transaction watch registration in channelmonitor tests 2018-07-22 13:59:11 -04:00
Matt Corallo
4afb0d85fa
Merge pull request #53 from savil/rename-error-msg-to-action
[HandleError] rename msg field to action
2018-07-19 23:30:28 -04:00
Matt Corallo
de523c4ca3
Merge pull request #47 from ariard/block_disconnected_close_chan
Implement channel closing for block_disconnected on ChainListener + test
2018-07-19 23:05:22 -04: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
Antoine Riard
1b8544fd5d Implement channel closing for block_disconnected on ChainListener + test 2018-07-20 02:37:05 +00:00
Antoine Riard
584ad11c1d Erroneous failure codes, replace PERM|7 by UPDATE|7 2018-07-18 02:47:54 +00:00
Antoine Riard
f5b48104dd TODO already cleaned by #16 2018-07-13 02:51:45 +00:00
Matt Corallo
c47525cb84 Move open_channel message handling into an event
This simplifies client usage cause peer_handler doesn't have an
interface to shove arbitrary messages in.
2018-07-06 17:31:01 -04:00
Jean Pierre Dudey
6707db6eae Add MAX_FUNDING_SATOSHIS constant.
This constants defines the maximum value of `open_channel.funding_satoshis`,
currently it's defined to be 2^24 according to the BOLT #2 specification.
Also a test was added to check that the constant is never over 2,1x10^15
(maximum satoshis in bitcoin) if modified.

Signed-off-by: Jean Pierre Dudey <jeandudey@hotmail.com>
2018-06-30 11:13:18 -04:00
Matt Corallo
56842c2bea Cleanups after #33, plus one unrelated bugfix spotted in #33 review 2018-06-29 17:23:50 -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
a20eef17c9 Fix local route update broadcasts, annouce channel closures 2018-04-24 20:42:24 -04:00
Matt Corallo
2d8afeccdb Rewrite channelmonitor framework and implement a bunch of it 2018-04-24 20:42:24 -04:00
Matt Corallo
7400b3bb7c Fix some channel remove channelmanager consistency bugs 2018-04-24 16:01:14 -04:00
Matt Corallo
8e2974fc2a HTLC Failure message handling 2018-04-24 11:55:08 -04:00
Matt Corallo
53d1518566 Move ChannelKeys creation into channelmanager 2018-04-17 12:43:12 -04:00
Matt Corallo
4d75d4c099 Minor cleanups 2018-04-16 20:35:21 -04:00
Matt Corallo
0940db25ec Refactor channelmanager network tests significantly 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
e2b1b1be78 Prep HTLCFailReason for Channel holding it until revoke_and_ack 2018-04-16 20:35:21 -04:00
Matt Corallo
00c6f42452 Use libbitcoinconsensus to check tx validity in some tests 2018-04-16 20:35:19 -04:00
Matt Corallo
8b1a7ede27 Test that channel monitors get updated appropriately 2018-04-16 20:35:03 -04:00
Matt Corallo
021b3643cc Hand payment preimages into channel monitors when claimed 2018-04-16 20:35:03 -04:00
Matt Corallo
91b964ae1f Basic error handling framework in peer_handler 2018-04-02 18:31:23 -04:00