Commit graph

2197 commits

Author SHA1 Message Date
Matt Corallo
9fba7c92ad
Merge pull request #802 from TheBlueMatt/2021-01-update-rust-bitcoin
Update rust-bitcoin and add secp256k1 context randomization
2021-02-28 16:43:08 -08:00
Matt Corallo
beb88e69a9
Merge pull request #806 from valentinewallace/monitor-data-persistence-path
persist: Persist ChannelMonitors in their own directory.
2021-02-27 16:34:54 -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
c5c0abb88d Log full signed remote commitment transaction hex in channel
This is useful when rebuilding the full_stack_target test vector
2021-02-26 23:47:03 -05:00
Matt Corallo
1521633ca2 Randomize secp contexts for marginally better sidechannel resistance 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
Valentine Wallace
a2d9fca9d5
SimpleArcPeerManager type: remove outer Arc for flexibility 2021-02-26 17:58:56 -05:00
Valentine Wallace
eecc3b7223
SimpleArcChannelManager type: remove outer Arc for flexibility 2021-02-26 17:56:53 -05:00
Matt Corallo
9b7609a8c5 Apply --cfg=fuzzing when fuzzing, as required by new secp256k1
Note that rust-fuzz wrappers (including honggfuzz) already apply
this for us.
2021-02-26 15:15:18 -05:00
Matt Corallo
a51d5cef58 Update rust-bitcoin 2021-02-26 15:15:18 -05:00
Valentine Wallace
bfaec717ae
persist: Persist ChannelMonitors in their own directory. 2021-02-26 12:38:47 -05:00
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