Commit graph

343 commits

Author SHA1 Message Date
Matt Corallo
864375e5f2 [fuzz] Make get_secure_random_bytes in chanmon_consistency unique 2021-05-20 16:38:18 +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
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
Matt Corallo
8088e4ba15
Merge pull request #856 from TheBlueMatt/2021-03-check-tx
Take the full funding transaction from the user on generation
2021-04-10 20:27:24 +00:00
Matt Corallo
3f2efcdfa7 Take the full funding transaction from the user on generation
Instead of relying on the user to ensure the funding transaction is
correct (and panicing when it is confirmed), we should check it is
correct when it is generated. By taking the full funding transaciton
from the user on generation, we can also handle broadcasting for
them instead of doing so via an event.
2021-04-09 19:59:06 -04:00
Matt Corallo
e23c270720
Merge pull request #838 from TheBlueMatt/2021-03-skip-blocks
Make `Channel`'s block connection API more electrum-friendly
2021-04-05 22:12:45 +00:00
Matt Corallo
47ad3d6bd8 Handle 1-conf funding_locked in channel no matter the event order
See comment in the diff for more details
2021-04-05 17:33:04 -04:00
Matt Corallo
c88b707ac2 Drop ChannelManager::block_disconnected() entirely
It is now entirely redundant with ChannelManager::update_best_block
and is still accessible via `Listen::block_disconnected`.
2021-04-05 17:33:04 -04:00
Matt Corallo
a15c8541dc Make the ChannelManager::block_connected API more electrum-friendly
See the similar commit that operates on `Channel`'s internal API
for more details on the reasoning.
2021-04-05 17:33:04 -04:00
Matt Corallo
d015ff250e Fix two new compiler warnings in fuzz
This fixes two trivial compiler warnings in fuzz that point to
broken usage of explicit `panic!()`s.
2021-03-30 23:21:54 -04:00
Matt Corallo
b2c5e3aedb Add assertions for in-order block [dis]connection in ChannelManager
Sadly the connected-in-order tests have to be skipped in our normal
test suite as many tests violate it. Luckily we can still enforce
it in the tests which run in other crates.

Co-authored-by: Matt Corallo <git@bluematt.me>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
2021-03-19 23:32:38 -04:00
Valentine Wallace
c318ad87e0
Expose counterparty forwarding info in ChannelDetails.
Useful for constructing route hints for private channels in invoices.

Co-authored-by: Valentine Wallace <vwallace@protonmail.com>
Co-authored-by: Antoine Riard <ariard@student.42.fr>
2021-03-17 17:36:26 -04:00
Matt Corallo
9e57364a89 Add an Option<>al InvoiceFeatures object for the payee in get_route
We currently only use it to override the graph-specific features
returned in the route, though we should also use it to enable or
disable MPP.

Note that tests which relied on MPP behavior have had all of their
get_route calls upgraded to provide the MPP flag.
2021-03-08 17:19:23 -05:00
Jeffrey Czyz
d28fa54edb
Parameterize ChannelManager::new with a block hash
When ChannelMonitors are persisted, they need to store the most recent
block hash seen. However, for newly created channels the default block
hash is used. If persisted before a block is connected, the funding
output may be missed when syncing after a restart. Instead, initialize
ChannelManager with a "birthday" hash so it can be used later when
creating channels.
2021-03-05 15:44:54 -08:00
Jeffrey Czyz
4cd2e4e94b
Revert "Merge pull request #819 from TheBlueMatt/2021-03-810-rebased"
This reverts commit 793de5fe69, reversing
changes made to 03a5189651.
2021-03-05 13:35:07 -08:00
Matt Corallo
4894d52d30 Merge pull request #646 from naumenkogs/2020-06-router-mpp
MPP on the router side
2021-03-02 20:33:08 -05:00
Valentine Wallace
7c8e740b6e Change ChannelMonitor deserialization to return an optional blockhash.
See previous commit msg for details.
2021-03-02 14:30:56 -05:00
Valentine Wallace
ee995a3a55 Change ChannelManager deserialization to return an optional blockhash
If the ChannelManager never receives any blocks, it'll return a default blockhash
on deserialization. It's preferable for this to be an Option instead.
2021-03-02 14:30:56 -05:00
Jeffrey Czyz
b0978a86be
Move ChannelMonitor state behind a Mutex
ChainMonitor accesses a set of ChannelMonitors behind a single Mutex.
As a result, update_channel operations cannot be parallelized. It also
requires using a RefCell around a ChannelMonitor when implementing
chain::Listen.

Moving the Mutex into ChannelMonitor avoids these problems and aligns it
better with other interfaces. Note, however, that get_funding_txo and
get_outputs_to_watch now clone the underlying data rather than returning
references.
2021-03-01 22:12:26 -08:00
Matt Corallo
ea48a5a089 Rebuild full_stack_target test vector for new secp256k1 fuzz req 2021-02-26 23:47:03 -05:00
Matt Corallo
33da665647 Use lowmemory mode for secp256k1 fuzzing, reducing memcpy time 2021-02-26 23:47:03 -05:00
Matt Corallo
4594f6eee5 Use rust-secp256k1 PR 282 and bitcoin_hashes PR 111 in fuzzing 2021-02-26 23:47:03 -05:00
Matt Corallo
a51d5cef58 Update rust-bitcoin 2021-02-26 15:15:18 -05:00
Matt Corallo
523fcb6f3f Change Persist's Sign from an associated type to a generic param 2021-02-19 16:04:19 -05:00
Matt Corallo
ff00f6f886 Rename ChannelKeys -> Sign and generic it consistently
The `ChannelKeys` object really isn't about keys at all anymore,
its all about signing. At the same time, we rename the type aliases
used in traits from both `ChanKeySigner` and `Keys` to just
`Signer` (or, in contexts where Channel isnt clear, `ChanSigner`).
2021-02-19 15:54:41 -05:00
Matt Corallo
e885d0a774 Swap key_derivation_params (u64, u64) for channel_keys_id [u8; 32]
Instead of `key_derivation_params` being a rather strange type, we
call it `channel_keys_id` and give it a generic 32 byte array. This
should be much clearer for users and also more flexible.
2021-02-12 18:57:20 -05:00