Commit graph

516 commits

Author SHA1 Message Date
Matt Corallo
12253e5331
Merge pull request #988 from TheBlueMatt/2021-07-chan-details-usability
Improve ChannelDetails readability significantly.
2021-07-08 17:25:53 +00:00
Matt Corallo
2b08a47e88 Improve ChannelDetails readability significantly.
After the merge of #984, Jeff pointed out that `ChannelDetails` has
become a bit of a "bag of variables", and that a few of the variable
names in #984 were more confusing than necessary in context.

This addresses several issues by:
 * Splitting counterparty parameters into a separate
   `ChannelCounterpartyParameters` struct,
 * using the name `unspendable_punishment_reserve` for both outbound
   and inbound channel reserves, differentiating them based on their
   position in the counterparty parameters struct or not,
 * Using the name `force_close_spend_delay` instead of
   `spend_csv_on_our_commitment_funds` to better communicate what
   is occurring.
2021-07-08 16:46:57 +00:00
Matt Corallo
99938455f7
Merge pull request #949 from TheBlueMatt/2021-06-send-priv-update
Send channel_update messages to direct peers on private channels
2021-07-07 20:17:10 +00:00
Matt Corallo
e3968e0993 Send channel_update messages to direct peers on private channels
If we are a public node and have a private channel, our
counterparty needs to know the fees which we will charge to forward
payments to them. Without sending them a channel_update, they have
no way to learn that information, resulting in the channel being
effectively useless for outbound-from-us payments.

This commit fixes our lack of channel_update messages to private
channel counterparties, ensuring we always send them a
channel_update after the channel funding is confirmed.
2021-07-07 19:45:33 +00:00
Matt Corallo
da298e498f Expose the current best chain tip from ChannelManager + Monitors
Fixes #979
2021-07-06 00:18:27 +00:00
Matt Corallo
0882655680 Expand the fields exposed to users in ChannelDetails
This adds four new fields in `ChannelDetails`:
1. holder_selected_ and counterparty_selected_channel_reserve_delay
   are useful to determine what amount of the channel is
   unavailable for payments.
2. confirmations_required is useful when awaiting funding
   confirmation to determine how long you will need to wait.
3. to_self_delay is useful to determine how long it will take to
   receive funds after a force-close.

Fixes #983.
2021-07-06 00:18:27 +00:00
Matt Corallo
95f9523097 Drop rust-bitcoin crate patches in fuzz now that they're merged
These patches have been merged upstream and are in releases now so
we don't need to patch them locally.
2021-06-23 01:35:26 +00:00
Matt Corallo
d61d698bb8 Don't print file paths in fuzz logger as they can be very long 2021-06-23 01:35:23 +00:00
Jeffrey Czyz
200f3d155c
Accept multi-hop route hints in get_route
Lightning invoices allow for zero or more multi-hop route hints. Update
get_route's interface to accept such hints, although only the last hop
from each is used for the time being.

Moves RouteHint from lightning-invoice crate to lightning crate. Adds a
PrivateRoute wrapper around RouteHint for use in lightning-invoice.
2021-06-11 08:44:32 -07:00
Matt Corallo
c05347f48a
Merge pull request #892 from TheBlueMatt/2021-04-fix-htlc-ser
Correct Channel outbound HTLC serialization and expand fuzzing coverage
2021-05-31 23:52:22 +00:00
Matt Corallo
e003c43183 [fuzz] Expand chanmon_consistency to do single message delivery
While trying to debug the issue ultimately tracked down to a
`PeerHandler` locking bug in #891, the ability to deliver only
individual messages at a time in chanmon_consistency looked
important. Specifically, it initially appeared there may be a race
when an update_add_htlc was delivered, then a node sent a payment,
and only after that, the corresponding commitment-signed was
delivered.

This commit adds such an ability, greatly expanding the potential
for chanmon_consistency to identify channel state machine bugs.
2021-05-31 18:20:22 +00:00
Matt Corallo
b780cbdbfc [fuzz] Fix hang due to double-lock in full_stack_target 2021-05-31 18:20:22 +00:00
Matt Corallo
a53764a58b [fuzz] Do not fail in FST if a channel is closed before we fund it 2021-05-31 18:20:22 +00:00
Matt Corallo
29a780e9e0 Delay broadcast of PackageTemplate packages until their locktime
This stores transaction templates temporarily until their locktime
is reached, avoiding broadcasting (or RBF bumping) transactions
prior to their locktime. For those broadcasting transactions
(potentially indirectly) via Bitcoin Core RPC, this ensures no
automated rebroadcast of transactions on the client side is
required to get transactions confirmed.
2021-05-28 23:56:44 +00:00
Jeffrey Czyz
7c465d69dc
Refactor EventsProvider to take an EventHandler 2021-05-24 14:16:16 -07:00
Matt Corallo
34fcd99f51 Add trace to ci-fuzz.sh to make debugging CI issues easier 2021-05-21 15:10:45 +00:00
Matt Corallo
da54848ba4 Read monitors from our KeysInterface in chanmon_consistency_fuzz
If the fuzz target is failing due to a channel force-close, the
immediately-visible error is that we're signing a stale state. This
is because the ChannelMonitorUpdateStep::ChannelForceClosed event
results in a signature in the test clone which was deserialized
using a OnlyReadsKeysInterface. Instead, we need to deserialize
using the full KeysInterface instance.
2021-05-21 15:10:45 +00:00
Matt Corallo
8acdbaf2a4 [fuzz] Handle monitor updates during get_and_clear_pending_msg_events
Because we may now generate a monitor update during
get_and_clear_pending_msg_events calls, we need to ensure we
re-serialize the relevant ChannelManager before attempting to
reload it, if such a monitor update occurred.
2021-05-21 15:10:45 +00:00
Matt Corallo
1fa2da391c [fuzz] Allow SendAnnouncementSigs events in chanmon_consistency
Because of the merge between peer reconnection and channel monitor
updating channel restoration code, we now sometimes generate
(somewhat spurious) announcement signatures when restoring channel
monitor updating. This should not result in a fuzzing failure.
2021-05-20 21:18:35 +00:00
Matt Corallo
d90aac8d95 [fuzz] Be more strict about msg events in chanmon_consistency
This fails chanmon_consistency on IgnoreError error events and on
messages left over to be sent to a just-disconnected peer, which
should have been drained.

These should never appear, so consider them a fuzzer fail case.
2021-05-20 21:18:35 +00:00
Matt Corallo
acc9ff6274 [fuzz] Print the output of all failed test cases, not one test.
Our fuzz tests previously only printed the log output of the first
fuzz test case to fail. This commit changes that (with lots of
auto-generated updates) to ensure we print all log outputs.
2021-05-20 21:18:35 +00:00
Matt Corallo
b6de28182f
Merge pull request #918 from TheBlueMatt/2021-05-dup-claims
Make payments not duplicatively fail/succeed on reload/reconnect
2021-05-20 17:10:52 +00:00
Matt Corallo
864375e5f2 [fuzz] Make get_secure_random_bytes in chanmon_consistency unique 2021-05-20 16:38:18 +00:00
Valentine Wallace
438e70e083
Add new DecodeError for messages that include zlib-compressed values
No need to disconnect peers if this error is encountered. It just means
we can't use some of their gossip messages.
2021-05-20 11:25:39 -04:00
Valentine Wallace
4503ef3523
Correct default expiry.
We previously stated in the codebase that the default invoice expiry
stated in the spec is 2 hours. It's actually 1 hour.
2021-05-14 16:51:46 -04:00
Matt Corallo
7297e13871
Merge pull request #912 from TheBlueMatt/2021-05-more-chan-info
Add flags for if a channel is pub and funding txo in ChannelDetails
2021-05-07 15:19:44 +00:00
Matt Corallo
62f466a0a2 Rename ChannelDetails::is_live to is_usable
This matches is_usable_channels and slightly better captures the
meaning.
2021-05-06 20:49:20 +00:00
Matt Corallo
6a79eece21 Indiciate if a channel is outbound/confirmed in ChannelDetails 2021-05-06 20:49:20 +00:00
Matt Corallo
2d6f060c06 Add flags for if a channel is pub and funding txo in ChannelDetails 2021-05-06 20:49:20 +00:00
Matt Corallo
e84f5edbc5 Increase the CLTV delay required on payments and forwards
This increases the CLTV_CLAIM_BUFFER constant to 18, much better
capturing how long it takes to go on chain to claim payments.
This is also more in line with other clients, and the spec, which
sets the default CLTV delay in invoices to 18.

As a side effect, we have to increase MIN_CLTV_EXPIRY_DELTA as
otherwise as are subject to an attack where someone can hold an
HTLC being forwarded long enough that we *also* close the channel
on which we received the HTLC.
2021-05-05 20:09:11 +00:00
Matt Corallo
58e4ce251e
Merge pull request #845 from ariard/2021-03-hardcode-dust
Switch to a max counterparty's `dust_limit_satoshis` constant
2021-05-04 01:44:18 +00:00
Matt Corallo
b307c1f2ad Make third HTLC non-dust again in the full_stack_target demo seed 2021-05-03 19:14:50 -04:00
Antoine Riard
16619ff590 Replace config max counterpary dust_limit_satoshis by a constant.
Current Bitcoin Core's policy will reject a p2wsh as a dust if it's
under 330 satoshis. A typical p2wsh output is 43 bytes big to which
Core's `GetDustThreshold()` sums up a minimal spend of 67 bytes (even
if a p2wsh witnessScript might be smaller). `dustRelayFee` is set
to 3000 sat/kb, thus 110 * 3000 / 1000 = 330. As all time-sensitive
outputs are p2wsh, a value of 330 sat is the lower bound desired
to ensure good propagation of transactions. We give a bit margin to
our counterparty and pick up 660 satoshis as an accepted
`dust_limit_satoshis` upper bound.

As this reasoning is tricky and error-prone we hardcode it instead of
letting the user picking up a non-sense value.

Further, this lower bound of 330 sats is also hardcoded as another constant
(MIN_DUST_LIMIT_SATOSHIS) instead of being dynamically computed on
feerate (derive_holder_dust_limit_satoshis`). Reducing risks of
non-propagating transactions in casee of failing fee festimation.
2021-05-03 15:37:38 -04:00
Valentine Wallace
feb882f6a4
Move invoice signing behind KeysInterface 2021-04-29 18:39:47 -04:00
Valentine Wallace
f24bbd63cc
Move PaymentPreimage+PaymentHash+PaymentSecret to top-level ln module 2021-04-29 18:39:47 -04:00
Devrandom
ec35fe62a1 Remove Send and Sync from core crate 2021-04-29 21:07:28 +02:00
Matt Corallo
6494e53a8f
Merge pull request #902 from TheBlueMatt/2021-04-fix-fuzz-test
Fix fuzz secp patch by bumping the rust-secp version number in patch
2021-04-29 00:24:40 +00:00
Matt Corallo
5e968114b6 Drop the amount parameter to claim_funds
Like the payment_secret parameter, this paramter has been the source
of much confusion, so we just drop it.

Users should prefer to do this check when registering the payment
secret instead of at claim-time.
2021-04-28 15:30:25 -04:00
Matt Corallo
5a1404809f Drop now-useless PaymentSecret parameters when claiming/failing-back 2021-04-28 15:30:25 -04:00
Matt Corallo
210b887d7c Add a user_payment_id to get_payment_secret+PaymentReceived
This allows users to store metadata about an invoice at
invoice-generation time and then index into that storage with a
general-purpose id when they call `get_payment_secret`. They will
then be provided the same index when the payment has been received.
2021-04-28 15:30:25 -04:00
Matt Corallo
533a003472 [fuzz] Always use PaymentSecrets in chanmon_consistency 2021-04-28 15:30:25 -04:00
Matt Corallo
2ef384db2d Fix fuzz secp patch by bumping the rust-secp version number in patch 2021-04-28 15:17:59 -04:00
Matt Corallo
0d75a63ead
Merge pull request #889 from jkczyz/2021-04-electrum-trait
Define chain::Confirm trait for use by Electrum clients
2021-04-23 19:13:23 +00:00
Jeffrey Czyz
99e2283aee
Drop pub functions for ChainMonitor's Listen impl 2021-04-22 14:17:26 -07:00
Jeffrey Czyz
23c4c8b7c7
Implement chain::Confirm for relevant structs 2021-04-22 14:17:26 -07:00
Matt Corallo
f40e47c1ef
Merge pull request #887 from valentinewallace/invoice-use-RL-routehint
invoice: swap RouteHop for RouteHint
2021-04-21 15:21:39 +00:00
Valentine Wallace
ad900658ce
Rename RouteHint to RouteHintHop (which is more accurate) 2021-04-20 16:26:56 -04:00
Matt Corallo
e6c922803f
Merge pull request #844 from sr-gi/843-ln-signing
Adds lightning message signing/verification/pk_recovery
2021-04-20 00:45:30 +00:00
Matt Corallo
7c9302f6a7
Fix a number of bugs in zbase32 and add a fuzzer which caught them. 2021-04-16 07:35:03 +02:00
Jeffrey Czyz
5610ca193d
Combine ChannelManager's block hash and height
There is a possible race condition when both the latest block hash and
height are needed. Combine these in one struct and place them behind a
single lock.
2021-04-14 12:57:04 -07:00