Commit graph

2325 commits

Author SHA1 Message Date
Matt Corallo
81afc2f172 Require directional updates for a DirectionalChannelInfo
We currently construct `DirectedChannelInfo`s for routing before
checking if the given direction has its directional info filled in.
We then always check for directional info before actually deciding
to route over a channel, as otherwise we assume the channel is not
online.

This makes for somewhat redundant checks, and `DirectedCHannelInfo`
isn't, by itself, a very useful API. Because fetching the HTLC-max
or effective channel capacity gives spurious data if no directional
info is available, there's little reason to have that data
available, and so we here check for directional info first. This
effectively merges `DirectionalChannelInfo` and
`DirectionalChannelInfoWithUpdate`.
2022-10-29 20:38:54 +00:00
Matt Corallo
6957fb63f9
Merge pull request #1809 from valentinewallace/2022-10-custom-om-self
Give us a self when reading a custom onion message
2022-10-27 21:34:45 +00:00
Matt Corallo
150c87a089
Give us a self when reading a custom onion message
+ remove MaybeReadableArgs trait as it is now unused
+ remove onion_utils::DecodeInput as it would've now needed to be parameterized
by the CustomOnionMessageHandler trait, and we'd like to avoid either
implementing DecodeInput in messenger or having onion_utils depend on
onion_message::*

Co-authored-by: Matt Corallo <git@bluematt.me>
Co-authored-by: Valentine Wallace <vwallace@protonmail.com>
2022-10-27 15:58:33 -04:00
Matt Corallo
4ec4e89eec
Merge pull request #1805 from TheBlueMatt/2022-10-remote-useless-mut
Drop useless `mut` in `KeysInterface::sign_holder_anchor_input`
2022-10-27 16:11:28 +00:00
Matt Corallo
2c69e05d5c Export io::ErrorKind in bindings
The bindings have exported `io::Error` as, basically,
`io::ErrorKind`, for quite some time, so there's little reason to
not just export `io::ErrorKind` as well.
2022-10-27 01:29:05 +00:00
Matt Corallo
f63df167a1 Drop useless mut in KeysInterface::sign_holder_anchor_input
The `Transaction` is not modified so there's no reason to make the
reference `mut`
2022-10-26 20:46:34 +00:00
valentinewallace
2e343e78ca
Merge pull request #1797 from arik-so/2022-10-channel-manager-deparameterization
Deparametrize `ChannelManager` to infer `Signer` from its `KeysInterface`.
2022-10-26 13:32:09 -04:00
Arik Sosman
22c367b13b
Deparametrize ChannelManager to infer Signer from its KeysInterface. 2022-10-25 10:02:28 -07:00
Viktor Tigerström
6777ab643c Only create BOLT4 tlv payload format onions 2022-10-25 15:44:27 +02:00
Valentine Wallace
20eecd5a76
Remove outdated allow(unused) 2022-10-24 15:00:03 -04:00
Matt Corallo
35154a15c3 Bump crate versions to 0.0.112/invoice 0.20 2022-10-24 18:53:58 +00:00
Matt Corallo
a834a04e5c Do not export new anchors structs in events.rs without anchors
This avoids adding unused, effectively-dummy public structs in
`events.rs`.
2022-10-24 18:53:58 +00:00
Matt Corallo
a257906743
Merge pull request #1779 from valentinewallace/2022-10-node-pk-keysinterface
Add `KeysInterface::get_node_id` method
2022-10-24 17:37:25 +00:00
Valentine Wallace
7082d6cd2a
KeysInterface docs: note that Recipient type must be supported by impl 2022-10-24 11:38:30 -04:00
Wilmer Paulino
f4f1093edc
Bump workspace to rust edition 2018
Mostly motivated by the need of async/await.
2022-10-21 14:47:34 -07:00
Valentine Wallace
17c0fc82a4
Add KeysInterface::get_node_id method
Useful since we're working on getting rid of KeysInterface::get_node_secret to
complete support for remote signing.

Will be used in upcoming work to check whether an outbound onion message
blinded path has our node id as the introduction node id
2022-10-21 15:54:03 -04:00
valentinewallace
ad82c9ea5b
Merge pull request #1770 from jkczyz/2022-10-debug-route-hints
Add logging in route hint filtering
2022-10-21 13:04:45 -04:00
Matt Corallo
6ec9b5357f Add WriteableScore bindings impl for MultiThreadedLockableScore
In 56b07e52aa we made
`MultiThreadedLockableScore` fully bindings-compatible. However, it
did not add a `WriteableScore` implementation for it. This was an
oversight as it is a `WriteableScore` in Rust and needs to be for
use in other parts of the API.

Here we add the required impl in a way that the bindings generator
is able to handle it and add conversion utilities.
2022-10-21 01:08:30 +00:00
Jeffrey Czyz
90c976394c
Add logging in route hint filtering
Knowing why a channel was not included as an invoice route hint can be
valuable. Add logging on the decisions made when filtering channels.
2022-10-20 15:18:08 -05:00
Jeffrey Czyz
d6321e6e11
Merge pull request #1748 from valentinewallace/2022-10-custom-oms
Support custom onion messages
2022-10-19 17:15:33 -05:00
Valentine Wallace
4905268b65
Disallow sending invalid custom OM TLVs
Onion message data TLV types must be >= 64, enforce this on send
2022-10-19 16:07:01 -04:00
Valentine Wallace
7664957bc9
Implement sending and receiving custom onion messages
This uses the work done in the preceding commits to implement encoding a user's
custom TLV in outbound onion messages, and decoding custom TLVs in inbound
onion messages, to be provided to the new CustomOnionMessageHandler.
2022-10-19 16:06:58 -04:00
Matt Corallo
89747dc085
Merge pull request #1678 from TheBlueMatt/2022-08-funding-locked-mon-persist-fail
Handle async initial ChannelMonitor persistence failing on restart
2022-10-19 16:55:01 +00:00
Matt Corallo
958601f1af Rename ChannelState::MonitorUpdateFailed MonitorUpdateInProgress
As we're moving towards monitor update async being a supported
use-case, we shouldn't call an async monitor update "failed", but
rather "in progress". This simply updates the internal channel.rs
enum name to reflect the new thinking.
2022-10-19 14:41:30 +00:00
Matt Corallo
bee42b1659 Handle async initial ChannelMonitor persistence failing on restart
If the initial ChannelMonitor persistence is done asynchronously
but does not complete before the node restarts (with a
ChannelManager persistence), we'll start back up with a channel
present but no corresponding ChannelMonitor.

Because the Channel is pending-monitor-update and has not yet
broadcasted its initial funding transaction or sent channel_ready,
this is not a violation of our API contract nor a safety violation.
However, the previous code would refuse to deserialize the
ChannelManager treating it as an API contract violation.

The solution is to test for this case explicitly and drop the
channel entirely as if the peer disconnected before we received
the funding_signed for outbound channels or before sending the
channel_ready for inbound channels.
2022-10-19 14:41:30 +00:00
Jeffrey Czyz
c06ab02900
Merge pull request #1764 from G8XSU/rgs-ignore-error
Ignore Duplicate Gossip Error while updating networkGraph from RGS
2022-10-19 08:50:09 -05:00
Wilmer Paulino
abe85a1f44
Add public helper to build anchor input witnesses 2022-10-18 12:23:29 -07:00
Wilmer Paulino
2fa45ae891
Add holder anchor signing support to BaseSign 2022-10-18 12:23:25 -07:00
Wilmer Paulino
843b8263d5
Document expected call frequency of ChainMonitor::process_pending_events 2022-10-18 12:23:20 -07:00
Wilmer Paulino
892f8fe843
Yield channel close bump events 2022-10-18 12:23:15 -07:00
Wilmer Paulino
e9ac2b1669
Generate ClaimEvent for HolderFundingOutput inputs from anchor channels 2022-10-18 12:23:10 -07:00
Wilmer Paulino
bac1b79fbb
Refactor generate_claim_tx to return OnchainClaim enum 2022-10-18 12:23:04 -07:00
Wilmer Paulino
40b1d4f027
Split finalize_package into separate methods per malleability 2022-10-18 12:22:59 -07:00
Wilmer Paulino
ccf318e597
Track funding amount in HolderFundingOutput
This will be useful later on when determining the appropriate fee rate
to use on the anchor transaction to bump its commitment transaction.
2022-10-18 12:22:53 -07:00
Wilmer Paulino
492b24059e
Track whether HolderFundingOutput originated from an anchor channel 2022-10-18 12:22:46 -07:00
Wilmer Paulino
519ec902aa
Store anchors option for supported output types
As we integrate the support of anchor outputs, we'll want to know if
each input we're working with came from an anchor outputs channel.
Instead of threading through a `opt_anchors` boolean across several
methods on `PackageSolvingData` and `PackageTemplate`, we decide to
store a reference in each `PackageSolvingData` variant instead that
features a change in behavior between channels with and without anchor
outputs.
2022-10-18 12:22:28 -07:00
Gursharan Singh
7f089df1e3 Dedupe gossip msgs while updating networkGraph from RGS
While applying gossip info from RGS-server, number of harmless
errors might arise which should be ignored. E.g. client should not
fail if there is a duplicate gossip for same channel or duplicate
update.
2022-10-18 10:43:53 -07:00
Valentine Wallace
ec538d1816
Update send_onion_message API to take new OnionMessageContents enum
OnionMessageContents specifies the data TLV that the sender wants in the onion
message. This enum only has one variant for now, Custom. When offers are added,
additional variants for invoice, invoice_request, and invoice_error will be
added.

This commit does not actually implement sending the custom OM contents, just
the API change.
2022-10-18 13:28:29 -04:00
Valentine Wallace
87b637c990
Fix accidental newline in OnionMessenger docs 2022-10-18 13:14:35 -04:00
Valentine Wallace
333be69bb4
Tweak OnionMessenger log on inbound onion message receipt 2022-10-18 13:12:59 -04:00
Valentine Wallace
75fd0f3cbb
Parameterize OnionMessenger by new CustomOnionMessageHandler trait
OnionMessenger::new will now take a custom onion message handler trait
implementation. This handler will be used in upcoming commit(s) to handle
inbound custom onion messages.

The new trait also specifies what custom messages are supported via its
associated type, CustomMessage. This associated type must implement a new
CustomOnionMessagesContents trait, which requires custom messages to support
being written, being read, and supplying their TLV type.
2022-10-18 11:39:39 -04:00
Valentine Wallace
2a8179edb7
Optionally parameterize decode_tlv_stream with custom decode closure
Useful for decoding custom or user-provided TLVs. See macro docs for more info.

Used in upcoming commit(s) to support custom onion message TLVs
2022-10-17 16:07:42 -04:00
Valentine Wallace
a40e32b197
ser: Add MaybeReadableArgs trait
Useful in decoding a custom message, so (a) the message type can be provided to
the handler and (b) None can be returned if the message type is unknown.

Used in upcoming commit(s) to support custom onion messages.
2022-10-17 16:05:36 -04:00
Matt Corallo
e61f3a238a
Merge pull request #1763 from gcomte/feature/derive-eq
Derive Eq for all structs that derive PartialEq
2022-10-17 16:03:23 +00:00
Gabriel Comte
aa916bb594
Derive Eq for all structs that derive PartialEq 2022-10-14 13:24:02 +02:00
Gabriel Comte
8abf02ccfe
Remove redundant field names 2022-10-12 00:35:22 +02:00
Matt Corallo
9e8496659f Increase the default liquidity_offset_half_life to six hours
Even at relatively high payment volumes, decaying knowledge of each
individual channel every hour causes aggressive retrying of
channels as we quickly forget the state of a channel. Even with the
historical tracker, this isn't fully remedied, as we'll track the
history bounds with the decayed value.

Instead, we decay every six hours here, reducing how often we'll
retry a channel due to decay.

In addition to this, the decay likely needs to be substantially
more linear, as tracked in #1752.
2022-10-11 18:25:43 +00:00
Matt Corallo
fe531c583d Rewrite documentation some on ProbabilisticScorer
We had some user confusion on how the probabilistic scorer works,
especially in reference to the half-life parameter. This attempts
to clarify how the bounds work, and how they are decayed.
2022-10-11 18:25:43 +00:00
valentinewallace
559ed20f92
Merge pull request #1756 from TheBlueMatt/2022-10-rgs-no-std
Fix `rapid-gossip-sync` `no-std` and properly test no-std in CI
2022-10-07 17:01:10 -04:00
Valentine Wallace
a031ff952b
Specify full import path in decode_tlv macro
Prevents unresolved import error
2022-10-07 15:36:34 -04:00