Commit graph

52 commits

Author SHA1 Message Date
Jeffrey Czyz
494fe6dad9
Remove unnecessary mut from reference
chain::Listen's interface is defined in terms of non-mutable references,
so there's no need to use mutable references in lightning-block-sync.
2022-02-13 09:22:55 -06:00
hackerrdave
d46c2a20e1 update repo name to use lightningdevkit 2021-12-26 22:53:16 -05:00
Matt Corallo
ec86e2a1a7 Bump versions to 0.0.104/invoice 0.12 2021-12-17 21:34:19 +00:00
Matt Corallo
2b837bb272 Bump crate versions to 0.0.103/invoice 0.11 2021-11-03 02:20:51 +00:00
Matt Corallo
f2e47e0db2 Bump crate versions to 0.0.102 and lightning-invoice 0.10 2021-10-18 18:32:36 +00:00
Matt Corallo
0dfb24e661 Move Persist trait to chainmonitor as that's the only reference 2021-10-14 00:16:50 +00:00
Matt Corallo
43fe3d55f1 Bump Crate versions to 0.0.101 (and invoice to 0.9) 2021-09-23 18:22:59 +00:00
Matt Corallo
ed3a6eeefd
Merge pull request #1061 from sr-gi/add-transaction-convert
Adds Transaction to lighting-block-sync::convert
2021-09-21 22:04:15 +00:00
Sergi Delgado Segura
5718e43b65
Adds Transaction to lighting-block-sync::convert
Includes disclaimer in docs, see https://github.com/rust-bitcoin/rust-lightning/pull/1061#issuecomment-911960862
2021-09-21 22:59:50 +02:00
Matt Corallo
0021320e7b Bump HTTP read timeout to match reality of Bitcoin Core blocking 2021-09-21 19:14:29 +00:00
Giles Cope
b74ab25b61
Not needed now. We refer to std::futures. 2021-09-11 20:11:10 +01:00
Matt Corallo
d523b6e42b
Merge pull request #1037 from sr-gi/add-txid-convert
Adds Txid to lighting-block-sync::convert
2021-08-24 18:57:51 +00:00
Sergi Delgado Segura
f65d05c23d
Adds Txid to lighting-block-sync::convert 2021-08-24 10:52:22 +02:00
Matt Corallo
11f78798d3 Update versions to 0.0.100 and lightning-invoice to 0.8 2021-08-17 18:55:07 +00:00
Matt Corallo
84909447e9 Check IO errors in test using raw_os_error() instead of kind()
std::io::ErrorKind is a `#[non_exhaustive]` enum as more specific
error types are to be added in the future. It was unclear in the
docs until very recently, however, that this is to be done by
re-defining `ErrorKind::Other` errors to new enum variants. Thus,
our tests which check explicitly for `ErrorKind::Other` as a
result of trying to access a directory as a file were incorrect.
Sadly, these generated no meaningful feedback from rustc at all,
except that they're suddenly failing in rustc beta!

After some back-and-forth, it seems rustc is moving forward
breaking existing code in future versions, so we move to the
"correct" check here, which is to check the raw IO error.

See rust-lang/rust#86442 and rust-lang/rust#85746 for more info.
2021-08-02 18:50:00 +00:00
Matt Corallo
3f229052ea Bump dependencies to bitcoin 0.27 and bech32 0.8 2021-07-31 18:29:07 +00:00
Matt Corallo
c9a8b26d58 Bump most crate versions to 0.0.99 and lightning-invoice to 0.7.0 2021-07-09 16:34:46 +00:00
Jeffrey Czyz
7302c8c38a
Remove unnecessary spaces 2021-06-18 00:26:36 -05:00
Jeffrey Czyz
8cc026b406
Increase poll::Validate visibility to pub
Previously, poll::Validate was pub(crate) to force external implementors
of Poll to define their implementation in terms of ChainPoller. This was
because ChainPoller::look_up_previous_header checks for consistency
between headers and any errors would be checked at that level rather
than by the caller. Otherwise, if performed by the caller, a Poll
implementation would not be aware if the underlying BlockSource was
providing bad data and therefore couldn't react accordingly.

Widening the visibility to pub relaxes this requirement, although it's
still encourage to use ChainPoller to implement Poll. This permits
either copying or moving lightning-block-sync's test utilities to a
separate crate since they use poll::Validate.
2021-06-18 00:26:33 -05:00
Matt Corallo
9c9081dfcb Bump versions to 0.0.98, lightning-invoice to 0.6.0 2021-06-08 21:08:29 +00:00
Jeffrey Czyz
4a12d7656e
Cache socket address in HttpClient for reconnect
If the HttpClient attempts to reconnect to bitcoind that is no longer
running, the client fails to get the address from the stream. Cache the
address when connecting to prevent this.
2021-05-27 08:53:14 -07:00
Jeffrey Czyz
b2f16ad821
Parse RPC errors as JSON content
Bitcoin Core's JSON RPC server returns errors as HTTP error responses
with JSON content in the body. Parse this content as JSON to give a more
meaningful error. Otherwise, "binary" is given because the content
contains ASCII control characters.
2021-05-26 10:57:39 -07:00
Jeffrey Czyz
61648fc804
Define an HttpError for returning error contents
Return an HTTP error response as a status code and contents. This allows
clients to interpret the response as desired (e.g., the contents as a
JSON-formatted error).
2021-05-26 10:51:16 -07:00
Matt Corallo
f0084e12e2 Don't return ASCII control characters in HTTP error messages 2021-05-13 21:58:01 +00:00
Valentine Wallace
4f880c6b75
Return more error details on http's read_response
Otherwise helpful error information gets swallowed
2021-05-13 13:18:26 -04:00
Matt Corallo
4ade6bcb69 Increase the timeout for RPC responses from Bitcoin Core
Early sample testing showed multiple users hitting
EWOULDBLOCK/EAGAIN waiting for an initial response from Bitcoin
Core while it was doing some long operation (eg UTXO cache
flushing). Instead of only waiting 5 seconds for each attempt, we
now wait a full two minutes, but only for the first header
response, not each byte.
2021-05-10 16:55:09 +00:00
Matt Corallo
b465318e12 Allow retrying HTTP requests if we hit a socket timeout 2021-05-10 16:55:09 +00:00
Matt Corallo
f551d5946b Bump versions to 0.0.14, lightning-invoice 0.5 2021-05-01 00:43:15 +00:00
Devrandom
ec35fe62a1 Remove Send and Sync from core crate 2021-04-29 21:07:28 +02:00
Valentine Wallace
85106c9768
Expose AsyncBlockSourceResult and BlockSourceResult as pub
Useful for writing objects that implement BlockSource trait.
2021-03-26 14:54:19 -04:00
Matt Corallo
836985a5e5 Drop all HTML-relative links since rustdoc now supports resolution 2021-03-18 11:28:23 -04:00
Matt Corallo
2c7c1a6a7a Enforce no missing docs in all crates (+ add docs that were missing) 2021-03-18 11:28:23 -04:00
Matt Corallo
18a0967758 Enforce doc link correctness during cargo doc runs and in CI 2021-03-18 11:28:23 -04:00
Matt Corallo
98c6566b01 Clean up some doc links in lightning_block_sync.
Relative HTML doc paths in doc links works locally, but breaks on
crates.io. Luckily, we can now use explicit full paths and rustdoc
will resolve them for us.
2021-03-18 11:28:23 -04:00
Matt Corallo
eeec6fac5c Update licenses and add missing fields in Cargo.toml files 2021-03-09 16:53:03 -05:00
Matt Corallo
d65d7e7257 Bump versions to 0.0.13 across the board
We also skip having different versions for different subcrates,
since that is confusing.
2021-03-09 14:11:11 -05: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
Jeffrey Czyz
f48e273560
Expose RpcClient and RestClient interfaces as pub
Useful for use outside of the BlockSource context, e.g., when
implementing fee estimation or transaction broadcasting.
2021-03-03 17:32:39 -08:00
Matt Corallo
793de5fe69
Merge pull request #819 from TheBlueMatt/2021-03-810-rebased
Change ChannelManager deserialization to return an optional blockhash
2021-03-02 16:04:23 -08: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
60f4daf2c2
Add validate_best_block_header utility
Refactor synchronize_listeners by pulling out a function returning the
validated block header of a BlockSource's best chain tip. This is needed
when a node is started from scratch and has no listeners to sync.
2021-03-02 10:03:11 -08:00
Jeffrey Czyz
e8ea0d9f04
Implement chain::Listen without using RefCell
The implementation of chain::Listen for ChannelMonitor required using a
RefCell since its block_connected method required a mutable borrow. This
is no longer the case since ChannelMonitor now uses interior mutability
via a Mutex. So the RefCell is no longer needed.
2021-03-01 22:12:26 -08:00
Matt Corallo
a51d5cef58 Update rust-bitcoin 2021-02-26 15:15:18 -05: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
Jeffrey Czyz
85fdfaaa9c
Implement BlockSource for REST and RPC clients
Interprets HTTP responses as either binary or JSON format, which are
then converted to the appropriate data types.
2021-02-04 07:38:42 -08:00