Antoine Riard
d33cb3cca5
Add a KeysInterface which provides keys from user
...
Move ChannelKeys into keysinterface for generate a set of it from
master_seed and change return type to panic on bogus data
2018-10-27 09:34:45 -04:00
Antoine Riard
8c235d9e28
Generate Events from ChannelMonitor to indicate spendable ouputs
...
Extend KeyStorage with delayed_payment_base_key and per_commitment_point
to derive local_delayed private key
2018-10-27 09:34:28 -04:00
Matt Corallo
c36d23107c
Add Channel support for monitor-update-failed pausing
2018-10-23 16:03:30 -04:00
Matt Corallo
695eec23c4
Pull out regenerating RAA/CS in channel_reestablish handling
2018-10-23 16:03:30 -04:00
Matt Corallo
f059d9ce3f
Fix reconnect message order on remote updates while waiting on RAA
2018-10-23 15:26:11 -04:00
Matt Corallo
e86c84b2be
Add message ordering return value to handling channel_reestablish
2018-10-23 15:26:11 -04:00
Yuntai Kyong
d3ca7da672
Some changes in comments and error messages.
2018-10-23 10:50:03 -04:00
Yuntai Kyong
ed30a199e3
Error handling in decoding onion
2018-10-23 10:44:40 -04:00
Matt Corallo
df88525d44
Ensure channel is live, not usable for sending fee updates
...
+ a freebie TODO removal
2018-10-17 21:28:22 -04:00
Matt Corallo
1fe616db5a
Fix + test funding tx confirmation while peer is disconnected
2018-10-16 16:36:29 -04:00
Matt Corallo
17375b0551
Fix channel_reestablish exchanging in case of lost messages
...
This uses the new storage in HTLC state enums to reproduce the
various updates in a CommitmentUpdate group which is obviously
required to re-send a commitment_update after pending unreceived
updates were dropped.
Does not yet handle dropped update_fee updates properly.
2018-10-15 22:03:12 -04:00
Matt Corallo
b4dcbfa569
Store onion packet in OutboundHTLCState so we can regen update_add
2018-10-15 21:52:41 -04:00
Matt Corallo
4b231d5e6d
Store per-state HTLC data in the state enum itself (and store more)
2018-10-15 21:52:41 -04:00
Matt Corallo
99e01b2a64
Further simplify get_{inbound,outbound}_pending_htlc_stats
2018-10-06 12:06:29 +09:00
Yuntai Kyong
1f93a838c7
Split get_pending_htlc_stats
...
to get_inbound_pending_htlc_stats and get_outbound_pending_htlc_stats
2018-10-06 12:06:29 +09:00
Matt Corallo
e5974ce643
Check that reserves are met or progress is made on commitment tx gen
2018-10-06 12:06:29 +09:00
Yuntai Kyong
02b28d4513
Add simple test for channel_reserve/max_htlc_value_in_flight_msat
2018-10-06 12:06:29 +09:00
Yuntai Kyong
c6cc30d9d7
Add a ChannelValueStat getter to simplify tests
2018-10-06 12:03:24 +09:00
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