Commit graph

990 commits

Author SHA1 Message Date
Valentine Wallace
9c344b714c
Return new DecodeError::UnsupportedCompression
if we receive a message with zlib-compressed values.
2021-05-20 11:25:43 -04: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
Matt Corallo
5d74cae6c5
Merge pull request #923 from ariard/2021-05-split-sign-justice
Split `sign_justice_transaction` in two halves
2021-05-18 15:24:57 +00:00
Antoine Riard
6319690891 keysinterface: replace Result match with map_err 2021-05-17 22:32:02 -04:00
Antoine Riard
55eccfa7b3 Split sign_justice_transaction in two halves
To avoid caller data struct storing HTLC-related information when
a revokeable output is claimed on top of a commitment/second-stage
HTLC transactions, we split `keysinterface::sign_justice_transaction`
in two new halves `keysinterfaces::sign_justice_revoked_output` and
`keysinterfaces::sign_justice_revoked_htlc`.

Further, this split offers more flexibility to signer policy as a
commitment revokeable output might be of a value far more significant
than HTLC ones.
2021-05-17 22:31:28 -04:00
Matt Corallo
e0986de477
Merge pull request #916 from TheBlueMatt/2021-05-fix-disabled-announcements
Avoid persisting a ChannelManager after each timer tick and send update_channel re-enable messages
2021-05-15 00:44:40 +00:00
Matt Corallo
ee36d647c7 Simplify+expand per-channel check in test_announce_disable_channels 2021-05-14 23:20:27 +00:00
Matt Corallo
33c06c078b Rename Channel::UpdateStatus to be more descriptive and update docs 2021-05-14 23:20:27 +00:00
Matt Corallo
fdc11f2c76 Do not wait in PersistenceNotifier when the persist flag is set
When we had a event which caused us to set the persist flag in a
PersistenceNotifier in between wait calls, we will still wait,
potentially not persisting a ChannelManager when we should.

Worse, for wait_timeout, this caused us to always wait up to the
timeout, but then always return true that a persistence is needed.

Instead, we simply check the persist flag before waiting, returning
immediately if it is set.
2021-05-14 23:20:27 +00:00
Matt Corallo
316f01a42f Avoid persisting a ChannelManager update after each timer tick
Currently, when a user calls `ChannelManager::timer_tick_occurred`
we always set the persister's update flag to true. This results in
a ChannelManager persistence after each timer tick, even when
nothing happened.

Instead, we add a new flag to `PersistenceNotifierGuard` to
indicate if we should skip setting the update flag.
2021-05-14 23:20:27 +00:00
Matt Corallo
1dd9a4df88 Test new channel_update re-enabled announcements 2021-05-14 22:36:28 +00: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
ac3380e470 Send update_channel messages to re-enable a disabled channel
Currently, we only send an update_channel message after
disconnecting a peer and waiting some time. We do not send a
followup when the peer has been reconnected for some time.

This changes that behavior to make the disconnect and reconnect
channel updates symmetric, and also simplifies the state machine
somewhat to make it more clear.

Finally, it serializes the current announcement state so that we
usually know when we need to send a new update_channel.
2021-05-13 20:53:53 +00: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
d2955be5cf
Merge pull request #911 from TheBlueMatt/2021-05-fix-cltv-diff 2021-05-06 21:49:24 +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
71d640a64b Always log_info when we broadcast a transaction, including the txid 2021-05-06 18:49:11 +00:00
Matt Corallo
0ba727a079 Clarify comment on CHECK_CLTV_EXPIRE_SANITY_2 somewhat 2021-05-06 15:34:51 +00:00
Matt Corallo
68c2c44559 Correct MIN_FINAL_CLTV_EXPIRY to match our enforced requirements
Our enforced requirements for HTLC acceptance is that we have at
least HTLC_FAIL_BACK_BUFFER blocks before the HTLC expires. When we
receive an HTLC, the HTLC would be "already expired" if its
`cltv_expiry` is current-block + 1 (ie the next block could
broadcast the commitment transaction and time out the HTLC). From
there, we want an extra HTLC_FAIL_BACK_BUFFER in blocks, plus an
extra block or two to account for any differences in the view of
the current height before send or while the HTLC is transiting the
network.
2021-05-05 20:09:11 +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
37fe22fece By default sort network addrs before inclusion in node_announcements
In  #797, we stopped enforcing that read/sent node_announcements
had their addresses sorted. While this is fine in practice, we
should still make a best-effort to sort them to comply with the
spec's forward-compatibility requirements, which we do here in the
ChannelManager.
2021-05-05 00:22:14 +00:00
Matt Corallo
c60543c0ed
Merge pull request #909 from TheBlueMatt/2021-04-0.0.14
Bump versions to 0.0.14, lightning-invoice 0.5
2021-05-04 02:14:03 +00:00
Matt Corallo
d782df01ba
Merge pull request #901 from jkczyz/2021-04-invoice-feature-semantics
Hide InvoiceFeatures behind InvoiceBuilder API
2021-05-04 02:00:52 +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
Jeffrey Czyz
b5f0ebab77
Hide InvoiceFeatures behind InvoiceBuilder API
Instead of relying on users to set an invoice's features correctly,
enforce the semantics inside InvoiceBuilder. For instance, if the user
sets a PaymentSecret then InvoiceBuilder should ensure the appropriate
feature bits are set. Thus, for this example, the TaggedField
abstraction can be retained while still ensuring BOLT 11 semantics at
the builder abstraction.
2021-05-03 16:23:24 -07:00
Antoine Riard
ce56e3f00a Add bolt2_open_channel_sane_dust_limit 2021-05-03 15:37:40 -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
Matt Corallo
f551d5946b Bump versions to 0.0.14, lightning-invoice 0.5 2021-05-01 00:43:15 +00:00
Jeffrey Czyz
7310e2684c
Sanity test InvoiceFeatures 2021-04-30 12:04:35 -07:00
Jeffrey Czyz
1ec0232dc5
Require feature var_onion_optin
Feature payment_secret is required and depends on var_onion_optin, so
the latter must also be required.
2021-04-30 12:04:30 -07: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
Valentine Wallace
6f5d81631a
Make _test_utils depend on bitcoinconsensus feature 2021-04-29 18:39:47 -04:00
Valentine Wallace
9529226adf
invoice: swap PaymentSecret for ChannelManager's PaymentSecret 2021-04-29 18:39:47 -04:00
Matt Corallo
3be185ad13
Merge pull request #905 from TheBlueMatt/2021-04-mention-invoice-storage-docs
Mention storage req for users with a public invoice generation API
2021-04-29 22:26:12 +00:00
Matt Corallo
f02910f81e Mention storage req for users with a public invoice generation API 2021-04-29 22:02:48 +00:00
Devrandom
ec35fe62a1 Remove Send and Sync from core crate 2021-04-29 21:07:28 +02:00
Matt Corallo
c9afea2d16 Drop redundant generic parameter bounds on ChainMonitor trait impls
The ChannelSigner bounds are specified both in `impl<>` and in the
`where` clause, which the C bindings generator doesn't like. There
is no reason to have them specified twice.
2021-04-29 18:36:51 +00:00
Matt Corallo
2484c1afc2 Add no-export tags for lightning-invoice where we can't map to C 2021-04-29 15:48:16 +00:00
Matt Corallo
0725098eef
Merge pull request #900 from lightning-signer/init-asap
Send Init message immediately after handshake even if not initiator
2021-04-29 00:26:13 +00:00
Matt Corallo
615ef7d6f8 Add a const and docs for the min min_final_cltv_expiry we allow 2021-04-28 15:30:25 -04:00
Matt Corallo
fd0ebcf8ec Add some simple tests of payment secret tracking 2021-04-28 15:30:25 -04:00
Matt Corallo
f9a6cb2a8b Fail PendingInboundPayments after their expiry time is reached 2021-04-28 15:30:25 -04:00
Matt Corallo
3b8ac139ba Give users who use get_payment_secret_preimage the PaymentPreimage
For users who get PaymentPreimages via
`get_payment_secret_preimage`, they need to provide the
PaymentPreimage back in `claim_funds` but they aren't actually
given the preimage anywhere.

This commit gives users the PaymentPreimage in the
`PaymentReceived` event.
2021-04-28 15:30:25 -04:00
Matt Corallo
ecaeddca47 Make the PaymentSecret in PaymentReceived events non-Optional 2021-04-28 15:30:25 -04: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