Commit graph

2908 commits

Author SHA1 Message Date
Matt Corallo
e12d88dfe1
Merge pull request #1093 from TheBlueMatt/2021-09-type-explicit-bounds
Make `ChainMonitor::get_claimable_balances` take a slice of refs
2021-09-22 16:49:02 +00:00
Matt Corallo
d718822874 Make ChainMonitor::get_claimable_balances take a slice of refs
For the same reason as `get_route`, a slice of objects isn't
practical to map to bindings - the objects in the bindings space
are structs with a pointer and some additional metadata. Thus, to
create a slice of them, we'd need to take ownership of the objects
behind the pointer, place them into a slace, and then restore them
to the pointer.

This would be a lot of memory copying and marshalling, not to
mention wouldn't be thread-safe, which the same function otherwise
would be if we used a slice of references instead of a slice of
objects.
2021-09-22 04:42:31 +00:00
Matt Corallo
aad1803517
Merge pull request #1092 from TheBlueMatt/2021-09-type-explicit-bounds
Move trait bounds on `wire::Type` from use to the trait itself
2021-09-22 02:46:25 +00:00
Matt Corallo
4c813186dc Move trait bounds on wire::Type from use to the trait itself
`wire::Type` is only (publicly) used as the `CustomMessage`
associated type in `CustomMessageReader`, where it has additional
trait bounds on `Debug` and `Writeable`. The documentation for
`Type` even mentions that you need to implement `Writeable` because
this is the one place it is used.

To make this more clear, we move the type bounds onto the trait
itself and not on the associated type.

This is also the only practical way to build C bindings for `Type`
as we cannot have a concrete, single, `Type` struct in C which only
optionally implements various subtraits, at least not without
runtime checking of the type bounds.
2021-09-22 01:07:30 +00:00
Matt Corallo
34dd7c5cbb
Merge pull request #1091 from TheBlueMatt/2021-09-997-winblowz
Fix windows-only test failure added in #997
2021-09-21 22:34:00 +00:00
Matt Corallo
0273ac52db
Merge pull request #1084 from valentinewallace/2021-09-rename-paymentfailed
Rename Event PaymentFailed -> PaymentPathFailed
2021-09-21 22:14:42 +00:00
Matt Corallo
ed3a6eeefd
Merge pull request #1061 from sr-gi/add-transaction-convert
Adds Transaction to lighting-block-sync::convert
2021-09-21 22:04:15 +00:00
Matt Corallo
5af0cb2887
Merge pull request #1088 from TheBlueMatt/2021-09-1063-fixups
Fix a panic in Route's new fee-calculation methods and clean up
2021-09-21 21:59:11 +00:00
Valentine Wallace
e5310dd5f0
Add path field to PaymentPathFailed event 2021-09-21 17:40:09 -04:00
Valentine Wallace
bf16dfd153
Rename PaymentFailed -> PaymentPathFailed
Since we don't want to imply to users that a payment has
completely failed when it really has just partially
failed
2021-09-21 17:39:40 -04:00
Matt Corallo
5262e77ae1
Merge pull request #1087 from TheBlueMatt/2021-09-event-backwards-compat-fix
Fix future unknown `Event` variant backwards compatibility
2021-09-21 21:37:32 +00:00
Matt Corallo
a233780c7e Fix windows-only test failure added in #997
This is a trivial bugfix to add a missing test updated required in
PR 997.
2021-09-21 21:16:51 +00:00
Matt Corallo
4d42284d2a
Merge pull request #1090 from TheBlueMatt/2021-09-absurd-timeouts
Bump HTTP read timeout to match reality of Bitcoin Core blocking
2021-09-21 21:12:34 +00:00
Sergi Delgado Segura
5718e43b65
Adds Transaction to lighting-block-sync::convert
Includes disclaimer in docs, see https://github.com/rust-bitcoin/rust-lightning/pull/1061#issuecomment-911960862
2021-09-21 22:59:50 +02:00
Matt Corallo
71e0173d8d Fix future unknown Event variant backwards compatibility
In 8ffc2d1742, in 0.0.100, we added
a backwards compatibility feature to the reading of `Event`s - if
the type was unknown and odd, we'd simply ignore the event and
treat it as no event. However, we failed to read the
length-prefixed TLV stream when doing so, resulting in us reading
some of the skipped-event data as the next event or other data in
the ChannelManager.

We fix this by reading the varint length prefix written, then
skipping that many bytes when we come across an unknown odd event
type.
2021-09-21 20:37:35 +00:00
Matt Corallo
2cf42aa388
Merge pull request #997 from ariard/2021-07-add-chan-closed
Add Event::ChannelClosed generation
2021-09-21 20:35:29 +00:00
Antoine Riard
d13c5cfa30 Add pending_events deadlock detection in handle_error 2021-09-21 15:46:42 -04:00
Antoine Riard
6ce7f3e1ce Add ChannelClosed generation at cooperative/force-close/error processing
When we detect a channel `is_shutdown()` or call on it
`force_shutdown()`, we notify the user with a Event::ChannelClosed
informing about the id and closure reason.
2021-09-21 15:46:42 -04:00
Antoine Riard
c29092c235 Extend MsgHandleErrInternal with a new chan_id field Option<[u8; 32]>
This field is used in next commit to generate appropriate
ChannelClosed event at `handle_error()` processing.
2021-09-21 15:46:42 -04:00
Antoine Riard
ea03b946bd Rename MonitorEvent::CommitmentTxBroadcasted to CommitmentTxConfirmed 2021-09-21 15:46:42 -04:00
Antoine Riard
e64467f512 Add Event::ChannelClosed generation at channel shutdown 2021-09-21 15:46:40 -04:00
Matt Corallo
0021320e7b Bump HTTP read timeout to match reality of Bitcoin Core blocking 2021-09-21 19:14:29 +00:00
Matt Corallo
59925c1fa0 Fix a panic in Route's new fee-calculation methods and clean up
This addresses Val's feedback on the new Route fee- and
amount-calculation methods, including fixing the panic she
identified and cleaning up various docs and comments.
2021-09-21 19:11:16 +00:00
Matt Corallo
4419191840
Merge pull request #1082 from vss96/process_events_docs
Update docs to specify where PeerManager::process_events is called
2021-09-21 18:54:19 +00:00
Matt Corallo
8f78bbda89
Merge pull request #1063 from galderz/t_total_fee_999
Add method to count total fees in a Route #999
2021-09-21 18:09:12 +00:00
vss96
2f0f0c9bf3 Update docs to specify where process events is called 2021-09-21 17:13:22 +00:00
Galder Zamarreño
03bb808e58 Add methods to count total fees and total amount in a Route #999
* Added `get_total_fees` method to route,
to calculate all the fees paid accross each path.
* Added `get_total_amount` method to route,
to calculate the total of actual amounts paid in each path.
2021-09-21 07:44:20 +02:00
Matt Corallo
801d6e5256
Merge pull request #1068 from TheBlueMatt/2021-09-ser-cleanup
Simplify Message Serialization and Parse TLV Suffix
2021-09-18 01:42:29 +00:00
Matt Corallo
997dc5f5f3 Convert most P2P msg serialization to a new macro with TLV suffixes
The network serialization format for all messages was changed some
time ago to include a TLV suffix for all messages, however we never
bothered to implement it as there isn't a lot of use validating a
TLV stream with nothing to do with it. However, messages are
increasingly utilizing the TLV suffix feature, and there are some
compatibility concerns with messages written as a part of other
structs having their format changed (see previous commit).

Thus, here we go ahead and convert most message serialization to a
new macro which includes a TLV suffix after a series of fields,
simplifying several serialization implementations in the process.
2021-09-18 01:01:41 +00:00
Matt Corallo
f60da31e56 Add forward-compat due serialization variants of HTLCFailureMsg
Going forward, all lightning messages have a TLV stream suffix,
allowing new fields to be added as needed. In the P2P protocol,
messages have an explicit length, so there is no implied length in
the TLV stream itself. HTLCFailureMsg enum variants have messages
in them, but without a size prefix or any explicit end. Thus, if a
HTLCFailureMsg is read as a part of a ChannelManager, with a TLV
stream at the end, there is no way to differentiate between the end
of the message and the next field(s) in the ChannelManager.

Here we add two new variant values for HTLCFailureMsg variants in
the read path, allowing us to switch to the new values if/when we
add new TLV fields in UpdateFailHTLC or UpdateFailMalformedHTLC so
that older versions can still read the new TLV fields.
2021-09-18 01:01:41 +00:00
Matt Corallo
7f9eef553c [fuzz] Swap mode on most messages to account for TLV suffix 2021-09-18 01:01:41 +00:00
Matt Corallo
07b674ecb1 Drop writer size hinting/message vec preallocation
In order to avoid significant malloc traffic, messages previously
explicitly stated their serialized length allowing for Vec
preallocation during the message serialization pipeline. This added
some amount of complexity in the serialization code, but did avoid
some realloc() calls.

Instead, here, we drop all the complexity in favor of a fixed 2KiB
buffer for all message serialization. This should not only be
simpler with a similar reduction in realloc() traffic, but also
may reduce heap fragmentation by allocating identically-sized
buffers more often.
2021-09-18 01:01:41 +00:00
Matt Corallo
831f124721
Merge pull request #1053 from valentinewallace/2021-08-dedup-payment-sent
Deduplicate PaymentSent events for MPP payments
2021-09-17 20:59:29 +00:00
Matt Corallo
8fad498900 Increase our default/minimum dust limit to 354 sat/vbytes
330 sat/vbyte, the current value, is not sufficient to ensure a
future segwit script longer than 32 bytes meets the dust limit if
used for a shutdown script. Thus, we can either check the value
on shutdown or we can simply require segwit outputs and require a
dust value of no less than 354 sat/vbyte.

We swap the minimum dust value to 354 sat/vbyte here, requiring
segwit scripts in a future commit.

See https://github.com/lightningnetwork/lightning-rfc/issues/905
2021-09-17 20:32:59 +00:00
Matt Corallo
57f54bcc11 Drop broken test that is unfixable due to being undocumented
This should be reverted at some point, but the test is deficient
and breaks on later changes that are important to land ASAP.
2021-09-17 20:32:59 +00:00
Valentine Wallace
c828ff42c0
Add all_paths_failed field to PaymentFailed
see field docs for details
2021-09-17 15:36:27 -04:00
Valentine Wallace
8f1763159e
Prevent duplicate PaymentSent events
by removing all pending outbound payments associated with the same
MPP payment after the preimage is received
2021-09-17 15:36:24 -04:00
Valentine Wallace
ad81addd98
Add MPP ID to pending_outbound_htlcs
We'll use this to correlate MPP shards in upcoming commits
2021-09-17 15:36:21 -04:00
Valentine Wallace
641e20763f
Implement Readable/Writeable for HashSet
To be used in upcoming commits for MPP ID storage
2021-09-17 15:23:45 -04:00
Valentine Wallace
c986e52ce8
Add MppId field to HTLCSource as a way to correlate mpp payment paths 2021-09-17 15:23:45 -04:00
Valentine Wallace
f6f950db75
test utils: refactor fail_payment_along_route for mpp 2021-09-17 15:23:42 -04:00
Valentine Wallace
612d1fb120
Update Watch docs to disallow dup channel outpoints
on watch_channel
2021-09-17 14:50:44 -04:00
Valentine Wallace
e06484b0f4
Don't apply monitor updates after watch_channel PermFail
The full stack fuzzer found an unreachable panic where we receive a
FundingSigned with a duplicate channel outpoint.
2021-09-17 14:50:20 -04:00
Matt Corallo
088daf79aa
Merge pull request #1070 from TheBlueMatt/2021-09-fix-bindings-ignore
Move CounterpartyForwardingInfo from channel to channelmanager
2021-09-17 17:26:54 +00:00
Matt Corallo
78d6c3cb01
Merge pull request #1066 from valentinewallace/2021-08-fix-double-temp-failure
Allow multiple calls to `monitor_update_failed`
2021-09-15 20:51:37 +00:00
Valentine Wallace
3d77cc790c
Allow multiple monitor_update_failed calls
without requiring calls to channel_monitor_updated in between.

Found by the fuzzer
2021-09-15 15:37:27 -04:00
Valentine Wallace
3af0c8e146
Update fuzz README with latest instructions 2021-09-15 15:37:27 -04:00
Matt Corallo
24065c89a9
Merge pull request #1074 from p2pderivatives/add-node-id-to-custom-msg-cb
Add node id to custom message callback
2021-09-15 18:54:15 +00:00
Matt Corallo
35573bb3d7
Merge pull request #1034 from TheBlueMatt/2021-07-maturing-claims
Expose in-flight claim balances
2021-09-15 18:44:04 +00:00
Matt Corallo
bb9df69d0d
Merge pull request #1043 from jkczyz/2021-07-network-update-handler
Handle network updates from failed payments in BackgroundProcessor
2021-09-15 18:13:20 +00:00