Commit graph

155 commits

Author SHA1 Message Date
Wilmer Paulino
44fa3acae8
Rename UserConfig and LegacyChannelConfig fields
The current names aren't very clear to what each field represents, this
commit aims to improve that.
2022-06-13 13:57:00 -07:00
Matt Corallo
5421e1a6e7
Merge pull request #1529 from wpaulino/move-channel-config-static-fields
Move ChannelConfig static fields to ChannelHandshakeConfig
2022-06-13 04:04:23 -07:00
Matt Corallo
deac430f17 Update crate versions to 0.0.108/invoice 0.16 2022-06-10 14:53:23 +00: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
Jeffrey Czyz
b2e635f619
Bump crate versions to 0.0.107/invoice 0.15 2022-06-08 18:16:48 -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
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
Justin Moon
7b8f6843f5 Add 'repository' to lightning-invoice's Cargo.toml 2022-06-01 13:17:16 -05:00
Elias Rohrer
e98f68aee6 Rename FundingLocked to ChannelReady. 2022-05-30 17:07:09 -07:00
Jeffrey Czyz
75ca50f5c0
Merge pull request #1490 from arik-so/rust_beta_doc_fix
Fix rust beta docs for lightning-invoice crate.
2022-05-23 00:16:04 -05:00
Arik Sosman
46e58ae025
Merge pull request #1492 from tnull/2022-05-fix-bolts-url
Docs: Update to 'new' spec repository URL.
2022-05-20 11:20:55 -07:00
Arik Sosman
71d89d2c98
Fix rust beta docs lightning-invoice crate. 2022-05-20 08:31:56 -07:00
Elias Rohrer
ba7935d1f3 Use new spec repository URL. 2022-05-20 17:17:29 +02:00
Jeffrey Czyz
197cbc4d28
Pass effective capacity to scorer
Scorers could benefit from having the channel's EffectiveCapacity rather
than a u64 msat value. For instance, ProbabilisticScorer can give a more
accurate penalty when given the ExactLiquidity variant. Pass a struct
wrapping the effective capacity, the proposed amount, and any in-flight
HTLC value.
2022-05-19 14:25:22 -05:00
KaFai Choi
b7d6d0dc8e
add timeout retry strategy to outbound payment 2022-05-17 13:27:22 +07:00
Duncan Dean
ea016cd824
Address post-ACK formatting nits from #1474 2022-05-11 10:57:38 +02:00
Duncan Dean
3369b2962d
Add expiry to non-phantom invoice utils 2022-05-10 20:22:01 +02:00
Duncan Dean
15a840147a
Actually add expiry to phantom invoice utils 2022-05-10 20:18:06 +02:00
Devrandom
28d33ff9e0 bitcoin crate 0.28.1 2022-05-05 18:04:42 +02:00
Viktor Tigerström
3c67687066 Add htlc min/max to create invoice functions 2022-04-21 12:27:51 +02:00
Duncan Dean
8f047ca23f
Add expiry to inbound payment util functions 2022-04-16 22:49:28 +02:00
Matt Corallo
03f655003d
Merge pull request #1384 from valentinewallace/2022-03-chanmanless-phantom-invoices 2022-04-13 14:51:35 +00:00
Valentine Wallace
204dd42a7d
Expose methods for ChannelManager-less phantom invoice generation 2022-04-11 18:43:48 -04:00
Matt Corallo
ce5a9f528a Move lightning-invoice deser errors to lib.rs instead of pub use
Having public types in a private module is somewhat awkward from a
readability standpoint, but, more importantly, the bindings logic
has a relatively rough go of converting them - it doesn't implement
`pub use` as its "implement this function" logic is all within the
context of a module. We'd need to keep a set of re-exported things
to implement them when parsing modules...or we could just move two
enums from `de.rs` to `lib.rs` here, which is substantially less
work.
2022-04-04 13:19:41 +00:00
Jeffrey Czyz
de8bb8d261
Bump crate versions to 0.0.106/invoice 0.14 2022-04-03 08:05:08 -05:00
Luiz Parreira
7714393cf0
Create normal/phantom invoice with description hash 2022-03-18 15:08:00 -03:00
Viktor Tigerström
ff792e05bb Add phantom invoice route hints filtering tests 2022-03-16 11:24:12 +01:00
Viktor Tigerström
43cc81c893 Filter route hints for phantom invoices
Filter the route hints in `create_phantom_invoice` based on the
following criteria:

* Only one channel for every counterparty node per phantom
payment-receiving node in the invoice
* Always select the channel with the highest inbound capacity
* For each payment-receiving node, filter out channels with a lower
inbound capacity than the invoice amount, if any channel exists with
enough capacity to cover the invoice amount
* If any public channels exists for a payment-receiving node, push a
single RouteHintHop with the phantom route and let the sender find the
path to the payment-receiving node through the public channels.
2022-03-16 11:24:12 +01:00
Viktor Tigerström
eae5086b8d Add tests for create invoice route hints filtering 2022-03-16 11:24:12 +01:00
Viktor Tigerström
fe49fbd7b8 Filter route hints for create invoice
Filter the route hints in `create_invoice_from_channelmanager` based on
the following criteria:

* Only one channel per counterparty node
* Always select the channel with the highest inbound capacity
* Filter out channels with a lower inbound capacity than the invoice
amount, if any channel exists with enough capacity to cover the invoice
amount
* If any public channel exists, the invoice route_hints should be empty,
and the sender will need to find the path to the payment-receiving node
by looking at the public channels instead
2022-03-16 11:24:12 +01:00
Jeffrey Czyz
ca163c3fae
Merge pull request #1331 from TheBlueMatt/2022-02-no-copy-invoice-fields
Use &mut self in invoice updaters, not take-self-return-Self
2022-03-11 14:26:02 -06:00
Matt Corallo
b1cd5a7434
Merge pull request #1311 from TheBlueMatt/2022-02-0conf-part-1
Support for SCID Aliases
2022-03-10 00:47:23 +00:00
Matt Corallo
b2629afd88 Track SCID aliases from our counterparty and use them in invoices
New `funding_locked` messages can include SCID aliases which our
counterparty will recognize as "ours" for the purposes of relaying
transactions to us. This avoids telling the world about our
on-chain transactions every time we want to receive a payment, and
will allow for receiving payments before the funding transaction
appears on-chain.

Here we store the new SCID aliases and use them in invoices instead
of he "standard" SCIDs.
2022-03-09 19:14:38 +00:00
Elias Rohrer
e92b5a7ebd Add a random per-path CLTV offset for privacy. 2022-03-09 11:13:47 -06:00
Jeffrey Czyz
d70292d6c8
Fix compilation warnings with --features=no-std 2022-03-08 23:23:25 -06:00
Matt Corallo
def0628332 Bump crate versions to 0.0.105/invoice 0.13 2022-03-01 00:43:24 +00:00
Matt Corallo
b7d57ea83e Use &mut self in invoice updaters, not take-self-return-Self
The take-self-return-Self idiom in Rust is substantially less
usable than it is in Java, where its more common. Because we have
to take self by move, it prevents using the update methods to
actually update features, something we occasionally want to do.

See, eg, the change in lightning-invoice where we previously had
to copy and re-create an entire vec of fields just to update the
features field, which is nuts.

There are a few places where this makes things a little less clean,
but the tradeoff to enable more effecient and broader uses of the
update methods seems worth it.
2022-02-23 20:17:36 +00:00
Jeffrey Czyz
62b1e01ad9
Generate docs with features for docs.rs
Enable generating docs using --all-features or --features="std" where
applicable. Additionally, use doc_auto_cfg to tag items requiring a
feature.

https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#doc_auto_cfg-automatically-generate-doccfg

This requires building with nightly, which is what is used by docs.rs.

https://docs.rs/about/builds

To test locally, use:

RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc ...
2022-02-18 15:38:31 -06:00
Matt Corallo
acb4c539f7 Drop fuzztarget feature entirely
Some time ago we started transitioning to `cfg(fuzzing)` instead of
exposing a full feature. Here we complete the transition.
2022-02-18 17:03:04 +00:00
Valentine Wallace
c417a51b65
Support phantom payment receive in ChannelManager, with invoice util
See PhantomKeysManager and invoice util's create_phantom_invoice for more info
2022-02-14 14:25:53 -05:00
Valentine Wallace
f6c75d8ec3
KeysInterface::sign_invoice: indicate whether invoice is a phantom 2022-02-14 14:22:38 -05:00
Jeffrey Czyz
28faf89df3
Deprecate Scorer in favor of ProbabilisticScorer 2022-02-02 20:22:27 -06:00
Jeffrey Czyz
1aaf5fc5d0
Effective channel capacity for router and scoring
A channel's capacity may be inferred or learned and is used to make
routing decisions, including as a parameter to channel scoring. Define
an EffectiveCapacity for this purpose. Score::channel_penalty_msat takes
the effective capacity (less in-flight HTLCs for the same payment), and
never None. Thus, for hops given in an invoice, the effective capacity
is now considered (near) infinite if over a private channel or based on
learned information if over a public channel.

If a Score implementations needs the effective capacity when updating a
channel's score, i.e. in payment_path_failed or payment_path_successful,
it can access the channel's EffectiveCapacity via the NetworkGraph by
first looking up the channel and then specifying which direction is
desired using ChannelInfo::as_directed.
2022-02-02 19:46:58 -06:00
valentinewallace
f49662caa4
Merge pull request #1273 from jkczyz/2022-01-invoice-expiry
Support invoice expiry over a year
2022-01-26 09:51:14 -05:00
Jeffrey Czyz
3b14a76d01
Support invoice expiry over a year
The lightning-invoice crate represents timestamps as Duration since the
UNIX epoch rather than a SystemTime. Therefore, internal calculations
are in terms of u64-based Durations. This allows for relaxing the one
year maximum expiry.
2022-01-25 15:34:10 -06:00
valentinewallace
35d4ebb208
Merge pull request #1272 from lightning-signer/2022-01-sign-invoice-api
Improve KeysInterface::sign_invoice API
2022-01-24 11:39:58 -05:00
Devrandom
803d6b6e2f Improve KeysInterface::sign_invoice API
split hrp from invoice data, to allow parsing, since there is no delimiter between the two parts
2022-01-24 09:48:56 +01:00
Elias Rohrer
808477a5ce Rename Payee to PaymentParameters 2022-01-21 10:39:01 +01:00
dependabot[bot]
f39fa69b68
Update hex requirement from 0.3 to 0.4
Updates the requirements on [hex](https://github.com/KokaKiwi/rust-hex) to permit the latest version.
- [Release notes](https://github.com/KokaKiwi/rust-hex/releases)
- [Commits](https://github.com/KokaKiwi/rust-hex/compare/v0.3...v0.4.3)

---
updated-dependencies:
- dependency-name: hex
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-18 22:05:49 +00:00
Elias Rohrer
5490366a95 Fix unused return warning for 'transmute_copy'. 2022-01-18 14:45:43 +01:00