Commit graph

65 commits

Author SHA1 Message Date
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
Jeffrey Czyz
eff9a47075
Refactor PaymentFailureNetworkUpdate event
MessageSendEvent::PaymentFailureNetworkUpdate served as a hack to pass
an HTLCFailChannelUpdate from ChannelManager to NetGraphMsgHandler via
PeerManager. Instead, remove the event entirely and move the contained
data (renamed NetworkUpdate) to Event::PaymentFailed to be processed by
an event handler.
2021-09-15 11:50:27 -05:00
Jeffrey Czyz
a6e650630d
Pass Event by reference to EventHandler
Passing an Event by reference rather and by move gives more flexibility
for composing event handlers without needing to clone events.
2021-09-09 22:57:51 -05:00
Tibo-lg
2e5e40e0b2 Add custom message handler to peer manager 2021-08-25 13:22:09 +09:00
Matt Corallo
803d8041f1
Merge pull request #1048 from TheBlueMatt/2021-08-no-net-print
Remove explicit print in lightning-net-tokio, reduce redundant block connection logging
2021-08-18 00:31:28 +00:00
Matt Corallo
ecf1d656ef Stop printing to stderr in lightning-net-tokio for disconnections
It isn't exactly a critical error situation when we disconnect a
socket, so we shouldn't be printing to stderr, entirely bypassing
user logging, when it happens. We do still print to stderr if we
fail to write the first message to the socket, but this should
never happen unless the user has a reasonably-configured system
with at least one packet in bytes available for the socket buffer.
2021-08-17 21:03:14 +00: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
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
Matt Corallo
656ed89388 No longer block disconnect_socket calls in lightning-net-tokio
See the previous commit for more information.
2021-06-23 00:51:31 +00: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
a1f95de734
Remove event channel from lightning-net-tokio
It is unnecessary since ChannelManager has a notification interface as
of 12c735ab3a.
2021-05-25 00:28:59 -07:00
Jeffrey Czyz
7c465d69dc
Refactor EventsProvider to take an EventHandler 2021-05-24 14:16:16 -07: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
Matt Corallo
18a0967758 Enforce doc link correctness during cargo doc runs and in CI 2021-03-18 11:28:23 -04:00
Valentine Wallace
e8a0824dd4
Pass channel updates to ChannelManager and Channel.
This will be used to expose forwarding info for route hints in the next commit.

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
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
Matt Corallo
7caadd446b
Merge pull request #816 from valentinewallace/remove-simple-outer-arcs
Remove simple outer arcs
2021-03-02 16:02:44 -08: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
a51d5cef58 Update rust-bitcoin 2021-02-26 15:15:18 -05: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
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
32abba7201 Drop spurious semicolon that new rustc complains about 2021-02-02 16:43:07 -05:00
Matt Corallo
5a403bdb13 Update tokio to 1.0
This requires ensuring TcpStreams are set in nonblocking mode as
tokio doesn't handle this for us anymore, so we adapt the public
API to just accept std TcpStreams instead of an extra conversion
hop. Luckily converting them is cheap.
2021-01-26 18:37:04 -05:00
bmancini55
e0bb63bc60 Remove should_request_full_sync from RoutingMessageHandler
This method was used to set the initial_routing_sync flag when sending
an outbound Init message to a peer. Since we are now relying on
gossip_queries instead of initial_routing_sync, synchronization can be
fully encapsulate into RoutingMessageHandler via sync_routing_table.

This commit removes should_request_full_sync from the trait
RoutingMessageHandler. The implementation is still used in
NetGraphMsgHandler and has been converted into a private method instead
of a trait function.
2020-12-14 12:52:59 -05:00
bmancini55
7a4a29ffe0 Pass Init message to sync_routing_table method
This commit modifies sync_routing_table in RoutingMessageHandler to
accept a reference to the Init message received by the peer. This allows
the method to use the Peer's features to drive the operations of the
gossip_queries routing table sync.
2020-12-09 15:02:32 -05:00
bmancini55
7e1e0ac97c Pass gossip_queries messages to handler via ownership
This change modifies gossip_queries methods in RoutingMessageHandler to
move the message instead of passing a reference. This allows the message
handler to be more efficient by not requiring a full copy of SCIDs
passed in messages.
2020-12-09 15:02:32 -05:00
bmancini55
14d4492b68 Refactor gossip_queries sync to be stateless
This commit simplifies the sync process for routing gossip messages. When
a sync is initiated, the process is handled statelessly by immediately
issuing SCID queries as channel range replies are received. This greatly
simplifies the state machine at the cost of fully validating and
conforming to the current spec.
2020-12-09 15:02:32 -05:00
bmancini55
55e5aafcfe Add gossip_queries methods to RoutingMessageHandler trait
Defines message handlers for gossip_queries messages in the RoutingMessageHandler
trait. The MessageSendEventsProvider supertrait is added to RoutingMessageHandler
so that the implementor can use SendMessageEvents to send messages to a
peer at the appropriate time.

The trait methods are stubbed in NetGraphMsgHandler which implements
RoutingMessageHandler and return a "not implemented" error.
2020-12-09 15:02:32 -05:00
Matt Corallo
f3774050aa Bump lightning-net-tokio crate version. 2020-11-24 17:55:56 -05:00
Matt Corallo
4aa8e9cda7 Bump version to 0.0.12 2020-11-24 16:35:20 -05:00
Valentine Wallace
9c3f3e76e5
Integrate Persist into ChainMonitor.
- The ChainMonitor should:
  Whenever a new channel is added or updated, these updates
  should be conveyed to the persister and persisted to disk.
  Even if the update errors while it's being applied, the
  updated monitor still needs to be persisted.
2020-10-16 11:30:34 -04:00
Jeffrey Czyz
51a5a1a50f
Move ln/channelmonitor.rs to chain/chainmonitor.rs 2020-10-01 08:50:15 -07:00
Jeffrey Czyz
98bc46beb9
Replace WatchEventProvider with chain::Filter
WatchEventProvider served as a means for replacing ChainWatchInterface.
However, it requires users to explicitly fetch WatchEvents, even if not
interested in them. Replace WatchEventProvider by chain::Filter, which
is an optional member of ChainMonitor. If set, interesting transactions
and output spends are registered such that blocks containing them can be
retrieved from a chain source in an efficient manner.

This is useful when the chain source is not a full node. For Electrum,
it allows for pre-filtered blocks. For BIP157/158, it serves as a means
to match against compact filters.
2020-09-30 22:40:33 -07:00
Jeffrey Czyz
851283d9e5
Remove Key parameter from ChainMonitor
ChainMonitor's template Key parameter was meant to allow supporting
both local monitoring, where Key=OutPoint, and watchtowers, where Key=
(PublicKey, u32). Use OutPoint directly since the watchtower case will
not be supported this way.
2020-09-30 22:39:55 -07:00
Jeffrey Czyz
6662e959c8
Rename SimpleManyChannelMonitor to ChainMonitor
ManyChannelMonitor was renamed chain::Watch in the previous commit. Use
a more concise name for an implementation that monitors the chain for
channel activity. Future work will parameterize the struct to allow for
different varieties of persistence. Thus, users usually will be able to
use ChainMonitor directly rather than implementing a chain::Watch that
wraps it.
2020-09-30 22:39:55 -07:00
Jeffrey Czyz
3ee6a27bc6
Replace ChainWatchInterface in NetGraphMsgHandler
ChainWatchInterface was intended as an interface for watching rather
than accessing the chain. Remove get_chain_utxo and add chain::Access
trait for this behavior. Wrap it with an Option in NetGraphMsgHandler in
order to simplify the error interface.
2020-09-30 22:39:38 -07:00
Jeffrey Czyz
87398be293
Remove ChainWatchInterface from channelmonitor.rs
Use of ChainWatchInterface was replaced with WatchEvent in the previous
commit. Remove it from the parameterization of SimpleManyChannelMonitor
since it is no longer needed.
2020-09-30 22:39:12 -07:00
Matt Corallo
b9707da138 Update to latest upstream rust-bitcoin 2020-09-10 16:20:01 -04:00
Matt Corallo
4395b92cc8 Relicense as dual Apache-2.0 + MIT
This changes the LICENSE file and adds license headers to most files
to relicense under dual Apache-2.0 and MIT. This is helpful in that
we retain the patent grant issued under Apache-2.0-licensed work,
avoiding some sticky patent issues, while still allowing users who
are more comfortable with the simpler MIT license to use that.

See https://github.com/rust-bitcoin/rust-lightning/issues/659 for
relicensing statements from code authors.
2020-08-10 21:12:44 -04:00
John L. Jegutanis
1945f6c6c3 Fix typo 2020-07-15 16:43:18 +03:00
Matt Corallo
fab5d7e0ae Make RoutingMessageHandler a generic Deref instead of an Arc
We also update to use single idents when referencing the Deref=*
types since the automated code generator is pretty braindead.

This also moves some test utils out of peer_handler.rs and into
util::test_utils to standardize things a little bit, which we need
to concretize the PeerHandler types used in testing.
2020-05-22 14:28:13 -04:00
Valentine Wallace
222f0cbdd2
PeerManager Logger Arc --> Deref 2020-05-17 13:02:32 -04:00
Valentine Wallace
87126b391b
ChannelManager+Router++ Logger Arc --> Deref
This caused a bunch of cascading changes, including
passing loggers down to Channels in function calls
rather than having each Channel have a pointer to the
ChannelManager's Logger (which was a circular reference).
Other structs that the Channel had passed its Logger to also
had their loggers removed. Other newly unused Loggers were
also removed, especially when keeping them would've caused
a bunch of extra test changes to be necessary, e.g. with
the ChainWatchInterfaceUtil's Logger.
2020-05-17 12:33:43 -04:00