Commit graph

333 commits

Author SHA1 Message Date
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
Matt Corallo
75d71cead3 Add additional Clone derives
The only API change outside of additional derives is to change
the inner field in `DecodeError::Io()` to an `std::io::ErrorKind`
instead of an `std::io::Error`. While `std::io::Error` obviously
makes more sense in context, it doesn't support Clone, and the
inner error largely doesn't have a lot of value on its own.
2021-02-10 22:34:19 -05:00
Matt Corallo
f151c02975
Merge pull request #764 from lightning-signer/revoke-enforcement
Revocation enforcement
2021-01-25 09:06:43 -08:00
Devrandom
142b0d624e Let some tests disable revocation policy check
When simulating a bad actor that broadcasts a revoked tx, the policy check would otherwise panic.
2021-01-21 11:37:28 -08:00
Sergi Delgado Segura
821f6cdd1e
Makes ChannelManager::force_close_channel fail for unknown chan_ids
ChannelManager::force_close_channel does not fail if a non-existing channel id is being passed, making it hard to catch from an API point of view.

Makes force_close_channel return in the same way close_channel does so the user calling the method with an unknown id can be warned.
2021-01-21 16:12:57 +01:00
Devrandom
bd4345d6a2 Fix fuzzing issue with revocation 2021-01-18 17:59:43 -08:00
Matt Corallo
990d1de99a Use KeysInterface::read_chan_signer for all channel keys deser
This drops any direct calls to a generic `ChannelKeys::read()` and
replaces it with the new `KeysInterface::read_chan_signer()`. Still,
under the hood all of our own `KeysInterface::read_chan_signer()`
implementations simply call out to a `Readable::read()` implemention.
2021-01-04 12:40:40 -05:00
Matt Corallo
45d4d26987 Add a new method read_chan_signer to KeysInterface
This adds a new method to the general cross-channel `KeysInterface`
which requires it to handle the deserialization of per-channel
signer objects. This allows the deserialization of per-channel
signers to have more context available, which, in the case of the
C bindings, includes the actual KeysInterface information itself.
2021-01-04 12:40:40 -05:00
Matt Corallo
0f5580afd4 Use Writeable for ChannelMonitor instead of a specific function.
There's no reason to have ChannelMonitor::write_for_disk instead of
just using the Writeable trait anymore. Previously, it was used to
differentiate with `write_for_watchtower`, but support for
watchtower-mode ChannelMonitors was never completed and the partial
bits were removed long ago.

This has the nice benefit of hitting the custom Writeable codepaths
in C bindings instead of trying to hit trait-generics paths.
2021-01-04 12:40:40 -05:00
Gleb Naumenko
368c534679 Store available routing amounts per channel to use it in routing decisions 2020-12-24 13:04:47 +02:00
bmancini55
d183b975da Add genesis block hash to NetworkGraph
This changes adds the genesis block hash as a BlockHash to the
NetworkGraph struct. Making the NetworkGraph aware allows the message
handler to validate the chain_hash for received messages. This change
also adds the hash value to the Writeable and Readable methods.
2020-12-09 15:02:32 -05:00