Yuntai Kyong
dc4a8c1de2
Document channel reserve behavior a bit better
2018-10-06 12:01:37 +09:00
Yuntai Kyong
f8cfc4228c
Fix checking of channel_reserve values
2018-10-06 12:01:31 +09:00
Yuntai Kyong
18ce6c8fd8
add a ChannelUnavailable error
2018-10-03 08:45:34 +09:00
Yuntai Kyong
eff730af18
raise APIError from close_channel
2018-10-03 08:36:39 +09:00
Matt Corallo
3f2d379835
Use new ChannelError in get_channel_announcement
2018-09-30 20:07:44 -04:00
Matt Corallo
ff644f4517
Use new ChannelError in channel_reestablish handling
2018-09-30 20:05:39 -04:00
Matt Corallo
ad77f72ff3
Use new ChannelError in HTLC-removal msgs, filling out more handling
2018-09-30 20:05:39 -04:00
Matt Corallo
662485a4dd
Use new ChannelError in funding_locked, filling out more handling
2018-09-30 20:05:39 -04:00
Matt Corallo
625e2b3532
Use new ChannelError type in accept_channel
2018-09-30 20:05:39 -04:00
Matt Corallo
aa2021dff5
Introduce a Channel-specific Err type and return it in a few places
...
This is way simpler than writing out the whole ErrorAction mess and
we can just convert it as appropriate in ChannelManager.
2018-09-30 20:05:38 -04:00
Yuntai Kyong
1dbc6fb0ef
Implement update_fee handling
2018-09-29 19:58:08 -04:00
Schalk van Heerden
b58bab0700
Added test for testing sciptpubkey of closing message per bolt 2 spec
2018-09-21 10:20:44 +02: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
c91f72c131
Drop MsgEncodable in favor of default fns on Writeable
2018-09-16 14:33:50 -04:00
Matt Corallo
e606f13664
Constify 2**48-1 and add some additional comments in Channel
2018-09-15 10:53:16 -04:00
Matt Corallo
28c5f6f309
Track peer-disconnection in Channel and handle channel_reestablish
2018-09-15 10:53:16 -04:00
Matt Corallo
ca712dfa36
Add a Disconnected ChannelState and check/handle it everywhere
...
Setting/removing it comes next
2018-09-15 10:53:16 -04:00
Matt Corallo
4bcf00e5b8
Clarify update_fail/fulfill_htlc holding cell allowed Errs
...
Specifically, there really should be no Errs, but in case there is
some case where duplicate HTLC removes are possible, return
IgnoreError and debug_assert to see if fuzzing can find them.
2018-09-15 10:53:16 -04:00
Matt Corallo
5fe598c073
Drop channels on disconnection if we haven't funded them yet
2018-09-15 10:53:16 -04:00
Matt Corallo
f55f055b4e
Remove/fail uncommitted HTLCs upon peer disconnection
2018-09-15 10:53:16 -04:00
Matt Corallo
2be7eda3b5
Merge pull request #179 from TheBlueMatt/2018-09-pre-178-cleanups
...
Pre-reconnect ChannelManager test cleanups
2018-09-15 10:50:57 -04:00
Yuntai Kyong
4e4fa56e2b
unwrap channel.get_open_channel
2018-09-15 07:33:20 +09:00
Matt Corallo
adee6719c4
Split up send_commitment into a const and non-const version
2018-09-14 16:24:30 -04:00
Matt Corallo
5ef88cea34
Do not fail-backwards LocalAnnounced HTLCs upon force-close.
...
This is completely unsafe as we have provided the remote side with
a commitment_signed which they can broadcast, including the HTLC
transaction, and then could claim it on-chain after we've failed it
backwards!
2018-09-14 15:27:53 -04:00
Matt Corallo
01c8e4f56f
Merge pull request #163 from ariard/claim_revoked_htlc_tx
...
Implement claiming of revoked HTLC transactions by ChannelMonitor
2018-09-13 13:53:47 -04:00
Yuntai Kyong
b6cbcc9f40
verify incoming sig first and fail earlier
2018-09-13 22:31:51 +09:00
Antoine Riard
d84c084df7
Implement set_their_delayed_payment_base_key in ChannelMonitor
...
Needed to build redeemscript on HTLC-Success/HTLC-Timeout tx from
remote revoked commitment tx
2018-09-12 23:17:20 +00: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
Matt Corallo
3b49837862
Split HTLC tracking into separate Inbound/Outbound types
...
This isnt as simplifying as I'd hoped, but still increases
compile-time checking, which is nice, and removes one of two
panic!()s.
2018-09-11 15:02:10 -04:00
Matt Corallo
a2d4889e32
panic on invalid calls to Channel::send_commitment instead of Err
2018-09-09 11:36:00 -04:00
Matt Corallo
8cad2ffa9b
Sync get_update_fail_htlc, get_update_fulfill_htlc state err result
...
Both get_update_fail_htlc and get_update_fulfill_htlc should never
be called before any HTLC could have been accepted (ie
pre-ChannelFunded) nor should they ever be called
post-ShutdownComplete as the Channel object should be destroyed at
that point. Previously get_update_fulfill_htlc would panic, but
get_update_fail_htlc would return an Err. For now make them both
panic but we can revisit this if we want to have fewer panics in
the future.
2018-09-09 11:36:00 -04:00
Matt Corallo
beee006365
Document Channel::get_funding_redeemscript precondition
2018-09-08 10:30:10 -04:00
Matt Corallo
ed650ec530
Ensure funding_created always returns Some(_) HandleError::action
2018-09-06 11:38:48 -04:00
Matt Corallo
d1568ca709
Drop HTLCState::LocalRemovedAwaitingCommitment
...
This was redundant and was included because the HTLC still needed
to be monitored, but that happens in ChannelMonitor, so there is no
need for it in Channel itself.
2018-09-05 19:47:01 -04:00
Matt Corallo
8e4c062f1b
Document+check commitment_signed generation success on send_htlc
...
Because we don't have an HTLCState for
update_add_htlc-generated-but-not-yet-commitment_signed to simplify
the mess of HTLCState match arms, any time a Channel::send_htlc
call returns Ok(Some(_)) we MUST call commitment_signed and it MUST
return success (or close the channel). We mention this in the docs
and panic if its not met in ChannelManager (which lets the fuzz
tester check this).
2018-09-05 19:47:01 -04:00
Matt Corallo
eeefdaf7a2
Always return an Error Message in invalid sig/key errors in Channel
2018-09-05 19:46:58 -04:00
Matt Corallo
7a234b6385
Fill out IgnoreError actions in get_channel_announcement
...
They are all just "its too early/late to get an announcement"
errors so simply ignoring them and not sending an announce is fine
2018-09-04 20:27:58 -04:00
Matt Corallo
f60b5d971c
Ensure Channel::new_from_req always returns an ErrorMessage on Err
2018-09-04 20:27:58 -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
cd9d680986
Merge pull request #145 from TheBlueMatt/2018-09-134-rebased
...
#134 rebased
2018-09-03 18:10:51 -04:00
Antoine Riard
4b4d8b6b9e
Add test_invalid_channel_announcemnt + test utilities
...
Fix typo
2018-09-03 17:40:12 -04:00
Matt Corallo
a9434db103
Check for misuse of funding_transaction_generated and panic
2018-08-31 17:00:44 -04:00
Matt Corallo
794212bb23
Fix crash that #127 intended to fix but did not completely fix
...
Introduced in #124 , and found by fuzzer
2018-08-30 12:37:21 -04:00
Matt Corallo
0881bf4b74
Correct excess-data handling in ChannelAnnouncement verif in Router
2018-08-29 17:59:25 -04:00
Matt Corallo
30b47bbb14
Clean up/clarify channel announcement_signatures handling
2018-08-28 12:56:29 -04:00
Matt Corallo
63bef2b44e
Make note about complying with BOLT 7 announcement_signatures
2018-08-28 12:12:27 -04:00
Matt Corallo
4ca5bcf8cf
Update PendingHTLCStatus to hold malformed HTLC error messages
2018-08-26 16:39:21 -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
4f77c812a4
Fix crash introduced in #124
...
I'm rapidly starting to regret holding failed HTLCs in Channel,
given we allow them to violate the no-duplicate-hashes
precondition.
Found by fuzzer
2018-08-24 16:58:27 -04:00
Matt Corallo
dfc04ad0b4
Fix duplicate payment_hashes one immediately failed, one fail crash
...
Found by fuzzer
2018-08-23 17:04:31 -04:00