Commit graph

2035 commits

Author SHA1 Message Date
Matt Corallo
e77b16049b
Merge pull request #791 from jkczyz/2021-01-spv-client
SPV client utility for syncing a lightning node
2021-02-26 07:54:01 -08:00
Jeffrey Czyz
8bfdfdc9e4
Utility for syncing a set of chain listeners
Add a utility for syncing a set of chain listeners to a common chain
tip. Required to use before creating an SpvClient when the chain
listener used with the client is actually a set of listeners each of
which may have had left off at a different block. This would occur when
the listeners had been persisted individually at different frequencies
(e.g., a ChainMonitor's individual ChannelMonitors).
2021-02-26 00:54:43 -06:00
Jeffrey Czyz
8505382b19
Add SpvClient used to poll for the best chain tip
Adds a lightweight client for polling one or more block sources for the
best chain tip. Notifies listeners of blocks connected or disconnected
since the last poll. Useful for keeping a Lightning node in sync with
the chain.
2021-02-26 00:54:42 -06:00
Jeffrey Czyz
b1ecfe705d
Add ChainNotifier and define ChainListener trait
Add an interface for being notified of block connected and disconnected
events, along with a notifier for generating such events. Used while
polling block sources for a new tip in order to feed these events into
ChannelManager and ChainMonitor.
2021-02-26 00:54:42 -06:00
Jeffrey Czyz
05ec06129c
Add ChainPoller implementation of Poll trait
ChainPoller defines a strategy for polling a single BlockSource. It
handles validating chain data returned from the BlockSource. Thus, other
implementations of Poll must be defined in terms of ChainPoller.
2021-02-26 00:54:42 -06:00
Jeffrey Czyz
7d6fce7802
Define a Poll trait as an adaptor on BlockSource
SPV clients need to poll one or more block sources for the best chain
tip and to retrieve related chain data. The Poll trait serves as an
adaptor interface for BlockSource. Implementations may define an
appropriate polling strategy.
2021-02-26 00:54:41 -06:00
Matt Corallo
ad09a2f004
Merge pull request #794 from galderz/t_opt_shutdown_anysegwit_780
Add support for `opt_shutdown_anysegwit` feature #780
2021-02-25 07:34:16 -08:00
Galder Zamarreño
24ed1dc2ec Add support for opt_shutdown_anysegwit feature #780
* Implemented protocol.
* Made feature optional.
* Verify that the default value is true.
* Verify that on shutdown,
if Channel.supports_shutdown_anysegwit is enabled,
the script can be a witness program.
* Added a test that verifies that a scriptpubkey
for an unreleased segwit version is handled successfully.
* Added a test that verifies that
if node has op_shutdown_anysegwit disabled,
a scriptpubkey with an unreleased segwit version on shutdown
throws an error.
* Added peer InitFeatures to handle_shutdown
* Check if shutdown script is valid when given upfront.
* Added a test to verify that an invalid test results in error.
* Added a test to check that if a segwit script with version 0 is provided,
the updated anysegwit check detects it and returns unsupported.
* An empty script is only allowed when sent as upfront shutdown script,
so make sure that check is only done for accept/open_channel situations.
* Instead of reimplementing a variant of is_witness_script,
just call it and verify that the witness version is not 0.
2021-02-25 14:28:08 +01:00
Matt Corallo
d6f41d3c0b
Merge pull request #803 from TheBlueMatt/2021-02-derives
Standardize trait derives in network message and graph objects
2021-02-22 15:31:46 -08:00
Matt Corallo
c2297353b5 Update auto-generated bindings 2021-02-22 11:48:24 -05:00
Matt Corallo
4b04f3ff1e Allow cloning NetworkGraphs 2021-02-22 11:44:22 -05:00
Matt Corallo
8051fb0118 Standardize trait derives in network graph objects
In general, trivial structs that have no inner logic can/should
all derive, at least, `Clone, Debug, PartialEq`.
2021-02-22 11:44:22 -05:00
Matt Corallo
9a5d846c9e Standardize trait derives in network message objects
In general, trivial structs that have no inner logic can/should
all derive, at least, `Clone, Debug, PartialEq`.
2021-02-22 11:44:22 -05:00
Matt Corallo
94bb0c9128
Merge pull request #799 from TheBlueMatt/2021-02-chansigner-rename
Rename ChannelKeys -> Sign and generic it consistently
2021-02-22 08:44:00 -08:00
Matt Corallo
4b6f0a3b26 Further rename chan_keys variables to signers 2021-02-20 10:06:22 -05:00
Matt Corallo
fc416d6295 Update C++ bindings demo with new struct naming 2021-02-20 10:06:22 -05:00
Matt Corallo
aa3f84123d Update auto-generated bindings 2021-02-20 10:06:22 -05:00
Matt Corallo
aa127f55ed Use ChannelSigner instead of ChanSigner for type parameters 2021-02-19 16:04:19 -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
20a25967ef Use signer instead of keys_storage in OnchainTx to hold Sign 2021-02-19 15:54:43 -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
ee68ffa5fd
Merge pull request #801 from TheBlueMatt/2021-02-789-bindings
Bindings updates for 789
2021-02-19 12:42:17 -08:00
Matt Corallo
041d7aaa9d
Merge pull request #752 from valentinewallace/chanman-persistence
ChannelManager persistence
2021-02-19 12:37:24 -08:00
Valentine Wallace
a368093803
Add BackgroundProcessor for ChannelManager persistence and other
Other includes calling timer_chan_freshness_every_minute() and in the
future, possibly persisting channel graph data.

This struct is suitable for things that need to happen periodically and
can happen in the background.
2021-02-19 15:00:43 -05:00
Valentine Wallace
12c735ab3a
Add PersistenceNotifier to ChannelManager
This will allow the ChannelManager to signal when it has new
updates to persist, and adds a way for ChannelManager persisters
to be notified when they should re-persist the ChannelManager
to disk/backups.

Feature-gate the wait_timeout function because the core
lightning crate shouldn't depend on wallclock time unless
users opt into it.
2021-02-19 15:00:43 -05:00
Valentine Wallace
a88dfbfcca
Fix Windows persistence
Windows started giving 'Access is denied' errors after
a few rounds of persistence. This seems to fix it.
2021-02-19 15:00:43 -05:00
Valentine Wallace
36eaccc607
Abstract out disk-writing utilities from FilesystemPersister 2021-02-19 15:00:43 -05:00
Valentine Wallace
f41cfb4da9
Make logger macros public
These will be used in upcoming commits for the BackgroundProcessor
to log.
2021-02-19 15:00:41 -05:00
Matt Corallo
13e990e6ae
Merge pull request #762 from valentinewallace/chan-reserve-fuzz-failure
Don't include below-dust inbound HTLCs in commit tx fee calculation
2021-02-19 11:57:46 -08:00
Matt Corallo
68811da302 Update C bindings demos for new KeysManager API 2021-02-19 14:02:46 -05:00
Matt Corallo
5f0977260e - bindings updates 2021-02-19 14:02:46 -05:00
Matt Corallo
b7538b62d9 [bindings] Handle unnamed enum variants 2021-02-19 14:02:46 -05:00
Matt Corallo
1d0645f7e6 Add a no-bindings-map comment to std::io::ErrorKind in DecodeErr 2021-02-19 14:02:46 -05:00
Matt Corallo
6c0025439e [bindings] Correctly use access string in to-Rust container conv
`from_c_conversion_container_new_var` should use var_access when
it wishes to access the variable being converted, not `var_name`,
but in a few cases it did not. Note that this has no impact on the
generated bindings as of this commit.
2021-02-19 14:02:33 -05:00
Matt Corallo
02c21842fd - bindings updates 2021-02-19 14:01:10 -05:00
Matt Corallo
1a32e23050 [bindings] Ensure owned objects in Vec conversion are marked mut 2021-02-19 14:00:41 -05:00
Matt Corallo
2f06b53abf Switch from slice to slice-of-refs for spend_spendable_outputs
Sadly, there's just not really a practical way to map a slice of
objects in our current bindings infrastructure - either we take
ownership of the underlying objects and move them into a Vec, or we
need to leave the original objects in place and have a list of
pointers to the Rust objects. Thus, the only practical mapping is
to create a slice of references using the pointers we have.
2021-02-19 13:58:05 -05:00
Valentine Wallace
1079753f20
Ensure build_commitment_tx and next_local/remote_tx_fee agree on the fee 2021-02-18 13:09:17 -05:00
Valentine Wallace
3d4735cc0a
Don't include below-dust inbound HTLCs in commit tx fee calculation
Also remove part of the holding cell channel reserve test that's newly failing but
a bit of a redundant test anyway.
2021-02-18 13:09:17 -05:00
Matt Corallo
de58bcf271
Merge pull request #795 from TheBlueMatt/2021-02-features-bindings
Map Features objects in bindings
2021-02-18 09:54:59 -08:00
Matt Corallo
414e62230e
Merge pull request #789 from TheBlueMatt/2021-02-chansigner-util-fns
Add util fn for creating a Transaction from spendable outputs
2021-02-18 09:37:00 -08:00
Matt Corallo
954e66ed08 Update auto-generated bindings 2021-02-18 12:31:29 -05:00
Matt Corallo
0a9a7c5d73 [bindings] Silence c-bindings-gen compile warnings 2021-02-18 12:28:25 -05:00
Matt Corallo
6f5f27e901 [bindings] Handle impl Clone like impl ::core::clone::Clone 2021-02-18 12:28:25 -05:00
Matt Corallo
cdbe8333fa [bindings] Drop manual implementations of Features conversion
We now handle features properly in our own resolution, and these
appear to be self-inconsistent in some cases.
2021-02-18 12:28:25 -05:00
Matt Corallo
a387badfe8 [bindings] Handle generic-ized impl blocks by concretizing them
This handles, for example, the `impl<X: Y> for Features<X>` blocks
which are generic across a number of different contexts. We do so
by walking the set of structs which alias Features and then walking
their generic arguments to check that they meet the bounds
specified in the impl block. For each alias which does, we create
a dummy, explicit, `impl XFeatures` block with the same content as
the original and recurse.
2021-02-18 12:28:25 -05:00
Matt Corallo
842d2f6ce7 [bindings] Resolve type aliases mapped as opaque types
We already map type aliases which alias private types as opaque,
but we don't resolve them like we would any other opaque type,
preventing conversion printing or type use.
2021-02-18 12:28:25 -05:00
Matt Corallo
f3ce70660d [bindings] Track structs impling traits, incl priv traits 2021-02-18 12:28:25 -05:00
Matt Corallo
b49781e8d8 [bindings] Allow resolution of private types in some cases
We need this specifically for resolving the
features::sealed::Context trait which is inside the non-pub
`sealed` module.
2021-02-18 12:28:25 -05:00
Matt Corallo
61f5e79062 Drop a useless import and use Self in return values in Features
`Result` is in the standard prelude, so no need to ever use it.

Sadly, returning a Features<T> in the `impl Futures {}` block
will confuse our new alias-impl-printing logic, as we end up
running through the normal impl-block-printing logic as if we had
an explicit `impl ConcreteFeatures` block.
2021-02-18 12:28:25 -05:00