Commit graph

3784 commits

Author SHA1 Message Date
Wilmer Paulino
ec7ccf0415
Introduce LegacyChannelConfig to remain backwards compatible
ChannelConfig now has its static fields removed. We introduce a new
LegacyChannelConfig struct that maintains the serialization as
previously defined by ChannelConfig to remain backwards compatible with
clients running 0.0.107 and earlier.
2022-06-09 16:18:15 -07:00
Wilmer Paulino
8027c2ff06
Move commit_upfront_shutdown_pubkey to ChannelHandshakeConfig
As like the previous commit, `commit_upfront_shutdown_pubkey` is another
static field that cannot change after the initial channel handshake. We
therefore move it out from its existing place in `ChannelConfig`.
2022-06-09 16:18:01 -07:00
Wilmer Paulino
850ca13fbc
Move announced_channel to ChannelHandshakeConfig
In the near future, we plan to allow users to update their
`ChannelConfig` after the initial channel handshake. In order to reuse
the same struct and expose it to users, we opt to move out all static
fields that cannot be updated after the initial channel handshake.
2022-06-09 16:11:15 -07:00
Arik Sosman
22dc96481b
Merge pull request #1496 from TheBlueMatt/2022-05-macro-function-bonus
Make `expect_payment_failed_conditions` a function
2022-06-09 12:10:27 -04:00
Matt Corallo
70acdf93d1 Make expect_payment_failed_conditions a function
This reduces macro generated code in tests a good bit, and moves us
one step further away from using macros everywhere when we don't
need to.
2022-06-09 11:35:41 +00:00
valentinewallace
6e00c28a55
Merge pull request #1513 from TheBlueMatt/2022-06-fix-fuzz-nonbug
Do not panic on early tx broadcasts in fuzzing
2022-06-08 18:32:22 -07:00
Matt Corallo
7adf2c7f5f
Merge pull request #1524 from ViktorTigerstrom/2022-06-update-fail-holding-cell-htlcs-args
Pass `counterparty_node_id` to `fail_holding_cell_htlcs`
2022-06-08 17:12:20 -07:00
Matt Corallo
5c788a09f8
Merge pull request #1525 from jkczyz/2022-05-release-0.0.107
Cut 0.0.107
2022-06-08 16:44:03 -07:00
Jeffrey Czyz
b2e635f619
Bump crate versions to 0.0.107/invoice 0.15 2022-06-08 18:16:48 -05:00
Jeffrey Czyz
e19024225a
Update CHANGELOG for 0.0.107 2022-06-08 18:16:48 -05:00
Viktor Tigerström
6032a56439 Pass peer_node_id to fail_holding_cell_htlcs 2022-06-08 11:00:11 +02:00
Jeffrey Czyz
aa1de2d9ef
Add lightning-rapid-gossip-sync to README 2022-06-07 23:50:48 -05:00
Matt Corallo
a551a6219c
Merge pull request #1517 from jkczyz/2022-06-gossip-sync-enum
Support only one `GossipSync` in `BackgroundProcessor`
2022-06-07 03:17:29 -07:00
Jeffrey Czyz
c032e2888b
Support only one GossipSync in BackgroundProcessor
BackgroundProcessor can take an optional P2PGossipSync and an optional
RapidGossipSync, but doing so may be easy to misuse. Each has a
reference to a NetworkGraph, which could be different between the two,
but only one is actually used.

Instead, allow passing one object wrapped in a GossipSync enum. Also,
fix a bug where the NetworkGraph is not persisted on shutdown if only a
RapidGossipSync is given.
2022-06-06 13:03:16 -05:00
Jeffrey Czyz
4ccf4451c2
Implement EventHandler for NetworkGraph
Instead of implementing EventHandler for P2PGossipSync, implement it on
NetworkGraph. This allows RapidGossipSync to handle events, too, by
delegating to its NetworkGraph.
2022-06-06 13:02:47 -05:00
Jeffrey Czyz
67736b7480
Parameterize NetworkGraph with Logger
P2PGossipSync logs before delegating to NetworkGraph in its
EventHandler. In order to share this handling with RapidGossipSync,
NetworkGraph needs to take a logger so that it can implement
EventHandler instead.
2022-06-06 13:02:43 -05:00
Matt Corallo
8e5cf75771
Merge pull request #1501 from tnull/2022-05-mention-compat-level
Mention backwards compatibility in CONTRIBUTING.
2022-06-03 17:14:01 -07:00
Jeffrey Czyz
0f73d6adcf
Move Secp256k1 context to NetworkGraph
P2PGossipSync has a Secp256k1 context field, which it only uses to pass
to NetworkGraph methods. Move the field to NetworkGraph so other callers
don't need to pass in a Secp256k1 context.
2022-06-02 23:08:57 -07:00
Matt Corallo
0017bc88a8
Merge pull request #1159 from jkczyz/2021-11-network-gossip
Rename network-related types
2022-06-02 16:53:32 -07:00
Jeffrey Czyz
574870e9f8
Move network_graph.rs to gossip.rs
The routing::network_graph module contains a few structs related to p2p
gossip. So renaming the module to 'gossip' seems more appropriate.
2022-06-02 15:15:30 -07:00
Jeffrey Czyz
ac35492877
Rename NetGraphMsgHandler to P2PGossipSync
NetGraphMsgHandler implements RoutingMessageHandler to handle gossip
messages defined in BOLT 7 and maintains a view of the network by
updating NetworkGraph. Rename it to P2PGossipSync, which better
describes its purpose, and to contrast with RapidGossipSync.
2022-06-02 15:15:30 -07:00
Jeffrey Czyz
3b3a4ba0a6
Rename ChannelClosed to ChannelFailure
A NetworkUpdate indicating ChannelClosed actually corresponds to a
channel failure as described in BOLT 4:

0x2000 (NODE): node failure (otherwise channel)

Rename the enum variant to ChannelFailure and rename NetworkGraph
methods close_channel_from_update and fail_node to channel_failed and
node_failed, respectively.
2022-06-02 15:15:29 -07:00
Jeffrey Czyz
dcffefae3d
Update missed references to get_route in docs 2022-06-02 13:15:15 -07:00
Jeffrey Czyz
8c5ca95d99
Fix build warnings 2022-06-02 13:15:05 -07:00
valentinewallace
ab20284e26
Merge pull request #1505 from tnull/2022-05-support-0conf-channeltype
Support `ZeroConf` channel type.
2022-06-02 13:02:25 -07:00
Jeffrey Czyz
9c5008334c
Merge pull request #1433 from arik-so/2022-04-rapid-sync-bg-processor
Allow indication to BackgroundProcessor that graph sync is pending
2022-06-02 14:10:00 -05:00
Arik Sosman
784addcaa9
Create separate timer for scorer persistence in background processor 2022-06-02 10:14:13 -07:00
Arik Sosman
312f765bd7
Indicate ongoing rapid sync to background processor.
Create a wrapper struct for rapid gossip sync that can be passed to
BackgroundProcessor's start method, allowing it to only start pruning
the network graph upon rapid gossip sync's completion.
2022-06-02 10:14:08 -07:00
Matt Corallo
47045b0ac8 Do not panic on early tx broadcasts in fuzzing
If the user broadcasts a funding transaction before the
counterparty provides a `funding_signed` we will panic in
`check_get_channel_ready`. This is expected - the user did
something which may lead to loss of funds, and we *really* need to
let them know.

However, the fuzzer can do this and we shouldn't treat it as a bug,
its a totally expected panic. Thus, we disable the panic in fuzz.

Thanks to Chaincode for providing fuzzing resources which managed
to hit this panic.
2022-06-02 03:39:42 +00:00
Elias Rohrer
efad02b8be Implement ZeroConf feature. 2022-06-01 17:05:17 -07:00
Jeffrey Czyz
a3ad88ac69
Merge pull request #1512 from tnull/2022-05-remove-deprecated-scorer
Remove previously deprecated `Scorer`
2022-06-01 18:29:15 -05:00
Matt Corallo
4808afee03
Merge pull request #1509 from shamardy/main
Update regex to 1.5.6
2022-06-01 15:54:46 -07:00
Elias Rohrer
84c94a8fd9 Remove previously deprecated Scorer 2022-06-01 14:50:41 -07:00
Jeffrey Czyz
f84ce03cab
Merge pull request #1504 from TheBlueMatt/2022-05-pub-io
Re-export `core2::io` or `std::io` depending on feature flags
2022-06-01 15:57:18 -05:00
Jeffrey Czyz
324655477b
Merge pull request #1511 from justinmoon/repository
Add 'repository' to lightning-invoice's Cargo.toml
2022-06-01 15:52:20 -05:00
Justin Moon
7b8f6843f5 Add 'repository' to lightning-invoice's Cargo.toml 2022-06-01 13:17:16 -05:00
shamardy
a87b53ae9a Update regex to 1.5.6 2022-06-01 17:25:15 +02:00
Arik Sosman
0b7700830b
Merge pull request #1500 from arik-so/2022-05-network-graph-rapid-sync-timestamp
Add optional last_rapid_gossip_sync_timestamp field to NetworkGraph to enable optimized differential rapid syncing.
2022-05-31 11:57:18 -07:00
Matt Corallo
994fa07793
Merge pull request #1506 from tnull/2022-05-rename-funding-locked
Rename `FundingLocked` to `ChannelReady`.
2022-05-31 10:48:09 -07:00
Arik Sosman
c3bbfe5a17
Add optional last_rapid_gossip_sync_timestamp field to NetworkGraph to enable optimized differental rapid syncing. 2022-05-31 10:17:51 -07:00
Matt Corallo
b4a9b962dd Re-export core2::io or std::io depending on feature flags
This is useful in bindings as the `lightning::io` module is used in
the public interface, but also useful for users who want to refer
to the `io` as used in lightning irrespective of the feature flags.
2022-05-31 00:17:40 +00:00
Elias Rohrer
e98f68aee6 Rename FundingLocked to ChannelReady. 2022-05-30 17:07:09 -07:00
valentinewallace
a534a5e7af
Merge pull request #1434 from TheBlueMatt/2022-04-robust-payment-claims
Improve Robustness of Inbound MPP Claims Across Restart
2022-05-30 10:05:01 -07:00
Matt Corallo
531d6c8663 Change Event amt fields to amount_msat for clarity 2022-05-28 18:50:32 +00:00
Elias Rohrer
cefac7231a Mention backwards compatibility in CONTRIBUTING. 2022-05-27 17:18:22 -07:00
Matt Corallo
8a5670245a Add internal docs for ChannelMonitor::payment_preimages 2022-05-28 00:02:49 +00:00
Matt Corallo
a12d37e063 Drop return value from fail_htlc_backwards, clarify docs
`ChannelManager::fail_htlc_backwards`' bool return value is quite
confusing - just because it returns false doesn't mean the payment
wasn't (already) failed. Worse, in some race cases around shutdown
where a payment was claimed before an unclean shutdown and then
retried on startup, `fail_htlc_backwards` could return true even
though (a duplicate copy of the same payment) was claimed, but the
claim event has not been seen by the user yet.

While its possible to use it correctly, its somewhat confusing to
have a return value at all, and definitely lends itself to misuse.

Instead, we should push users towards a model where they don't care
if `fail_htlc_backwards` succeeds - either they've locally marked
the payment as failed (prior to seeing any `PaymentReceived`
events) and will fail any attempts to pay it, or they have not and
the payment is still receivable until its timeout time is reached.

We can revisit this decision based on user feedback, but will need
to very carefully document the potential failure modes here if we
do.
2022-05-28 00:02:49 +00:00
Matt Corallo
11c2f12baa Do additional pre-flight checks before claiming a payment
As additional sanity checks, before claiming a payment, we check
that we have the full amount available in `claimable_htlcs` that
the payment should be for. Concretely, this prevents one
somewhat-absurd edge case where a user may receive an MPP payment,
wait many *blocks* before claiming it, allowing us to fail the
pending HTLCs and the sender to retry some subset of the payment
before we go to claim. More generally, this is just good
belt-and-suspenders against any edge cases we may have missed.
2022-05-28 00:02:49 +00:00
Matt Corallo
0e2542176b Provide a redundant Event::PaymentClaimed on restart if needed
If we crashed during a payment claim and then detected a partial
claim on restart, we should ensure the user is aware that the
payment has been claimed. We do so here by using the new
partial-claim detection logic to create a `PaymentClaimed` event.
2022-05-28 00:02:49 +00:00
Matt Corallo
0a2a40c4fd Add a PaymentClaimed event to indicate a payment was claimed
This replaces the return value of `claim_funds` with an event. It
does not yet change behavior in any material way.
2022-05-28 00:02:49 +00:00