Commit graph

4121 commits

Author SHA1 Message Date
Valentine Wallace
81b7b03d4f
Fix fuzzer-found underflow 2022-08-15 12:46:39 -04:00
Valentine Wallace
dfbebbf4c3
Rename HighZeroBytesDroppedVarInt to HighZeroBytesDroppedBigSize
As observed by @wpaulino, this struct encodes its bytes as big-endian,
therefore it's a BigSize, not a VarInt.
2022-08-15 11:41:59 -04:00
Valentine Wallace
a23681fde1
Fix bug in onion payment payload decode
Prior to this change, we could have failed to decode a valid payload of size
>253. This is because we were decoding the length (a BigSize, big-endian) as a
VarInt (little-endian).

Found in #1652.
2022-08-15 11:41:56 -04:00
Matt Corallo
47e9ca15b2 Rename PersistenceNotifier to simply Notifier
... as it is no longer persistence-specific (though still only used
for persistence).
2022-08-12 23:55:28 +00:00
Matt Corallo
b414c0641b
Merge pull request #1658 from lightning-signer/2022-08-bitcoin-0-29
Update bitcoin crate to 0.29.0
2022-08-12 23:51:06 +00:00
Devrandom
11166aa836 Modify ecdh to take Scalar 2022-08-11 00:21:26 +02:00
Devrandom
7e05623bef Update bitcoin crate to 0.29.0 2022-08-11 00:21:26 +02:00
Matt Corallo
4f6da92c4e Clarify comment on BUFFER_DRAIN_MSGS_PER_TICK. 2022-08-10 19:29:39 +00:00
Valentine Wallace
4a1ee5f9a9 Use util methods in Peer to decide when to forward
This consolidates our various checks on peer buffer space into the
`Peer` impl itself, making the thresholds at which we stop taking
various actions on a peer more readable as a whole.

This commit was primarily authored by `Valentine Wallace
<vwallace@protonmail.com>` with some amendments by `Matt Corallo
<git@bluematt.me>`.
2022-08-10 19:29:39 +00:00
valentinewallace
d2191d9c6d
Merge pull request #1655 from valentinewallace/2022-08-fix-ci-doc-links-check
Fix CI to error on doc links to private items
2022-08-09 12:49:40 -04:00
Matt Corallo
68b3d2e453 Move PersistenceNotifier to a new util module
It was always somewhat strange to have a bunch of notification
logic in `channelmanager`, and with the next commit adding a bunch
more, its moved here first.
2022-08-09 06:06:18 +00:00
Matt Corallo
d02425121e
Merge pull request #1651 from TheBlueMatt/2022-08-export-chan-list
[C Bindings] Expose channel and nodes list in `ReadOnlyNetworkGraph`
2022-08-08 16:59:53 +00:00
valentinewallace
11b7ab7a38
Merge pull request #1654 from TheBlueMatt/2022-08-update-libfuzzer
Update libfuzzer-sys to new upstream inclusion method
2022-08-08 11:37:42 -04:00
Matt Corallo
353b1e7e46 Update libfuzzer-sys to new upstream inclusion method
Dunno why they changed it, but the old "depend directly on git"
thing that cargo-fuzz used forever is now deprecated that that
repo is archived, they've now moved to another repo and publish
properly on crates.io.
2022-08-07 19:02:33 +00:00
Valentine Wallace
c242003dd3
Fix CI to error on doc links to private items
Somehow we weren't doing this.
2022-08-07 13:49:12 -04:00
Valentine Wallace
dcef41d17b
Minor msgs::OnionHopData cleanups 2022-08-05 22:34:36 -04:00
Matt Corallo
fc771d3b20 [C Bindings] Expose channel and nodes list in ReadOnlyNetworkGraph 2022-08-05 21:14:36 +00:00
Matt Corallo
b4521f52e2
Merge pull request #1638 from ViktorTigerstrom/2022-07-update-decode-update-add-htlc-onion-return-parameters
Don't return `channel_state` from `decode_update_add_htlc_onion`
2022-08-03 17:44:46 +00:00
Matt Corallo
736c0b9e7f
Merge pull request #1619 from G8XSU/main
Add config support for 'their_channel_reserve_proportional_millionths' [#1498]
2022-08-03 17:37:51 +00:00
Matt Corallo
28c9b56113
Merge pull request #1503 from valentinewallace/2022-05-onion-msgs
Onion messages v1
2022-08-03 04:39:56 +00:00
Valentine Wallace
17ec697f8f
Fix possible incomplete read bug on onion packet decode
Pre-existing to this PR, we were reading next packet bytes with io::Read::read,
which is not guaranteed to read all the bytes we need, only guaranteed to read
*some* bytes.

We fix this to be read_exact, which is guaranteed to read all the next hop
packet bytes.
2022-08-02 19:19:39 -04:00
Valentine Wallace
39397d4e14
Error when attempting to send an OM to a blinded route with 0 hops 2022-08-02 19:19:39 -04:00
Valentine Wallace
6500c99f29
Add SendError enum for onion messages and error on too-big packets 2022-08-02 19:19:39 -04:00
Valentine Wallace
eaff561e24
Add test utilities and integration tests for onion messages 2022-08-02 19:19:39 -04:00
Valentine Wallace
b26fb851cd
Significantly expand onion message documentation 2022-08-02 19:19:39 -04:00
Valentine Wallace
bf007ea763
Implement receiving and forwarding onion messages
This required adapting `onion_utils::decode_next_hop` to work for both payments
and onion messages.

Currently we just print out the path_id of any onion messages we receive. In
the future, these received onion messages will be redirected to their
respective handlers: i.e. an invoice_request will go to an InvoiceHandler,
custom onion messages will go to a custom handler, etc.
2022-08-02 19:19:37 -04:00
Valentine Wallace
9051c38ebe
Support sending onion messages
This adds several utilities in service of then adding
OnionMessenger::send_onion_message, which can send to either an unblinded
pubkey or a blinded route. Sending custom TLVs and sending an onion message
containing a reply path are not yet supported.

We also need to split the construct_keys_callback macro into two macros to
avoid an unused assignment warning.
2022-08-02 19:17:27 -04:00
Valentine Wallace
4c8dc2c2a0
Add baseline OnionMessenger and msgs::OnionMessage and its serialization
OnionMessenger will be hooked up to the PeerManager to send and receive OMs in
a follow-up PR.
2022-08-02 19:17:26 -04:00
Valentine Wallace
6017379b8e
KeysInterface: add new ecdh method
This method will help us avoid retrieving our node secret, something we want to
get rid of entirely.  It will be used in upcoming commits when decoding the
onion message packet, and in future PRs to help us get rid of
KeysInterface::get_node_secret usages across the codebase
2022-08-02 19:17:23 -04:00
Valentine Wallace
33ff2746ef
Add onion_message::Packet and adapt construct_onion_packet_with_init_noise for it
We need to add a new Packet struct because onion message packet hop_data fields
can be of variable length, whereas regular payment packets are always 1366
bytes.

Co-authored-by: Valentine Wallace <vwallace@protonmail.com>
Co-authored-by: Jeffrey Czyz <jkczyz@gmail.com>
2022-08-02 19:17:19 -04:00
Gursharan Singh
092d1c1f0d Add config support for 'their_channel_reserve_proportional_millionths' [#1498]
It is proportion of the channel value to configure as the
`their_channel_reserve_satoshis` for both outbound and inbound channels.
It decides the minimum balance that the other node has to maintain on their
side, at all times.
2022-08-02 14:33:01 -07:00
Viktor Tigerström
65e6fb7467 Don't return channel_state from decode_update_add_htlc_onion
Currently `decode_update_add_htlc_onion` returns the `channel_state`
lock to ensure that `internal_update_add_htlc` holds a single
`channel_state` lock in when the entire function execution. This is
unnecessary, and since we are moving the channel storage to the
`per_peer_state`, this no longer achieves the goal it was intended for.

We therefore avoid returning the `channel_state` from
`decode_update_add_htlc_onion`, and just retake the lock in
`internal_update_add_htlc` instead.
2022-08-02 23:16:17 +02:00
Matt Corallo
4ebc8e5284
Merge pull request #1637 from tnull/2022-07-contrib-remove-slack
Remove Slack and update `CONTRIBUTING`
2022-08-02 19:19:12 +00:00
Elias Rohrer
afdad4921c Remove Slack and update CONTRIBUTING 2022-08-02 19:51:06 +02:00
Valentine Wallace
4e5381a50f
Add onion messages module + enable the construction of blinded routes
Blinded routes can be provided as destinations for onion messages, when the
recipient prefers to remain anonymous.

We also add supporting utilities for constructing blinded path keys, and
control TLVs structs representing blinded payloads prior to being
encoded/encrypted. These utilities and struct will be re-used in upcoming
commits for sending and receiving/forwarding onion messages.

Finally, add utilities for reading the padding from an onion message's
encrypted TLVs without an intermediate Vec.
2022-08-02 12:11:11 -04:00
Matt Corallo
4905df8894
Merge pull request #1628 from tnull/2022-07-readme-remove-slack
Remove Slack link and other updates to `README`
2022-07-27 19:10:04 +00:00
Matt Corallo
018a78328e
Merge pull request #1635 from TheBlueMatt/2022-07-accessor-pub
Expose `ChannelMonitor::get_counterparty_node_id`
2022-07-27 18:46:52 +00:00
valentinewallace
a6b03033db
Merge pull request #1633 from TheBlueMatt/2022-07-110
Set release date on 0.0.110 release
2022-07-27 14:03:44 -04:00
Matt Corallo
6b1ec5c738
Merge pull request #1632 from TheBlueMatt/2022-07-warnings
Fix compilation warnings
2022-07-27 16:29:09 +00:00
Elias Rohrer
cf7655a1a4 Remove 'slack' (and other things) 2022-07-27 09:00:47 +02:00
Matt Corallo
75b111291f Expose ChannelMonitor::get_counterparty_node_id
This fixes an oversight in ac842ed9dd
namely that it left users unable to implement their own
`ChainMonitor` from outside of the `rust-lightning` crate.
2022-07-27 03:53:47 +00:00
Matt Corallo
7812215a1e Set release date on 0.0.110 release 2022-07-26 23:43:58 +00:00
Matt Corallo
36bffb56e8
Merge pull request #1629 from TheBlueMatt/2022-07-110
Cut 0.0.110
2022-07-26 23:40:45 +00:00
Matt Corallo
e10dfe4fd0 Bump crate versions to 0.0.110/invoice 0.18 2022-07-26 22:01:09 +00:00
Matt Corallo
a22ba39916 Add CHANGELOG entry for 0.0.110 2022-07-26 22:01:09 +00:00
Matt Corallo
4da6f23cff Drop unused test code in lightning-invoice::payment 2022-07-26 20:31:17 +00:00
Matt Corallo
10aa4aa42f Fix new compilation warnings in debug_sync module 2022-07-26 20:29:36 +00:00
Matt Corallo
b84b53a14c
Merge pull request #1631 from dunxen/2022-07-disabledflags
Specify why flags for `channel_disabled` error are zero
2022-07-26 15:53:34 +00:00
Duncan Dean
b2a2b1fb02
Specify why flags for channel_disabled error are zero
We can remove the TODO for this and specify why the flags are zero
as it's now fully specified in BOLT 4.

See https://github.com/lightning/bolts/blob/341ec84/04-onion-routing.md?plain=1#L1008
2022-07-26 10:29:12 +02:00
Jeffrey Czyz
f0b818952b
Merge pull request #1403 from jurvis/jurvis/add-paymentforwardingfailed-event
Add HTLCHandlingFailed event
2022-07-25 19:23:53 -05:00