Commit graph

5565 commits

Author SHA1 Message Date
benthecarman
0b8bdbf968
Allow get_shutdown_scriptpubkey and get_destination_script to return an error 2023-05-02 02:39:54 -05:00
benthecarman
0517b18a01
Incorporate low-R values into estimate signature size 2023-05-02 02:18:14 -05:00
Duncan Dean
16d0f2ff4a
Make DataLossProtect fields required and remove wrappers
The fields provided by `DataLossProtect` have been mandatory since
https://github.com/lightning/bolts/pull/754/commits/6656b70, regardless
of whether `option_dataloss_protect` or `option_remote_key` feature bits
are set.

We move the fields out of `DataLossProtect` to make encoding definitions
more succinct with `impl_writeable_msg!` and to reduce boilerplate.

This paves the way for completely removing `OptionalField` in subsequent
commits.
2023-05-01 22:41:12 +02:00
Matt Corallo
524981ddf4 Move the CustomMessageHandler into the MessageHandler struct
`PeerManager` takes a `MessageHandler` struct which contains all
the known message handlers for it to pass messages to. It then,
separately, takes a `CustomMessageHandler`. This makes no sense, we
should simply include the `CustomMessageHandler` in the
`MessageHandler` struct for consistency.
2023-04-30 04:03:55 +00:00
Wilmer Paulino
0e8da58895
Merge pull request #2245 from TheBlueMatt/2023-04-ping-count-overflow
Fix overflow in `awaiting_pong_timer...` with too many peers
2023-04-28 12:15:02 -07:00
Wilmer Paulino
3a643df997
Merge pull request #2217 from alecchendev/2023-04-expose-hash-in-balance
Expose `PaymentHash` and `PaymentPreimage` in `Balance`
2023-04-28 11:11:01 -07:00
Wilmer Paulino
41e94f9404
Merge pull request #2239 from valentinewallace/2023-04-remove-redundant-final-cltv-param
Remove redundant `final_cltv_delta` param from `get_route`
2023-04-28 10:46:51 -07:00
Matt Corallo
fa33f98a42 Fix overflow in awaiting_pong_timer... with too many peers
If we have more than
127 / `MAX_BUFFER_DRAIN_TICK_INTERVALS_PER_PEER` (31) peers,
`awaiting_pong_timer_tick_intervals` can overflow before we hit
the limit. This isn't super harmful, we'll still disconnect peers
as long as they don't send *any* messages between two pings, but it
does cause us to not disconnect peers which are extremely slow in
responding to messages, e.g. because they are overloaded.
2023-04-28 16:19:04 +00:00
Matt Corallo
88c63e9dbb
Merge pull request #2230 from freddiekrugerrand/2228-validatechainhash
Check chain hash for channel announcement and update
2023-04-27 23:00:42 +00:00
Matt Corallo
c3de782a2b
Merge pull request #2044 from freddiekrugerrand/1782-limitchannelhints
Limit route hints to three channels
2023-04-27 22:02:16 +00:00
Valentine Wallace
cae41c17ee
Remove redundant final_cltv_delta param from get_route
PaymentParameters already includes this value.

This set us up to better support route blinding, since there is no known
final_cltv_delta when paying to a blinded route.
2023-04-27 17:09:19 -04:00
Matt Corallo
4f806f5660
Merge pull request #2234 from dunxen/2023-04-bpteststemp
Use `env::temp_dir()` for BP tests
2023-04-26 17:49:52 +00:00
Matt Corallo
cbfff99124
Merge pull request #2229 from TheBlueMatt/2023-04-115-bindings-upstream-2
Trivial Bindings Updates
2023-04-26 17:34:18 +00:00
Wilmer Paulino
d4fc1a71e5
Merge pull request #2233 from TheBlueMatt/2023-04-fix-future-leak
Fix a leak in FutureState when a Notifier is dropped un-woken
2023-04-26 10:27:29 -07:00
Fred Walker
bd962fc2eb
Check chain hash for channel announcement and update 2023-04-26 08:58:05 -04:00
Duncan Dean
4abf3ba206
Use env::temp_dir() for BP tests
Currently `BackgroundProcessor` tests create persister directories in the
current working directory and rely on cleaning up in a `Drop` implementation.

Unfortunately, it seems that in the async tests that nodes are not
`drop()`ed for some reason and so the directories created by those
tests remain behind in the current working directory.

This commit at least ensures that these test directories are created in
a temporary location for the OS using `temp_dir()`. It doesn't aim to
solve the lack of cleanup in the async tests.

Partial fix for #2224 but I believe it's enough to resolve it as these
temp directories that do remain will be purged by the OS at some stage
and are overwritten by subsequent tests if there is a conflict.
2023-04-26 14:57:18 +02:00
Matt Corallo
7caa584051 Fix a leak in FutureState when a Notifier is dropped un-woken
If a `Notifier` has an internal `FutureState` which gathers some
sleeper callbacks, but is never actaully woken, those callbacks
will leak due to a circular `Arc` reference when the `Notifier` is
`drop`'d.

Because `Notifier`s are rarely `drop`'d in production this isn't a
huge deal, but shows up materially in bindings tests as they spawn
many nodes over the course of a short test.

Fixes #2232
2023-04-26 05:43:23 +00:00
Matt Corallo
3873afcb75 Hold a reference to the Arc<FutureState> when completing futures
This will allow us to pass in that state to the callbacks in the
next commit.
2023-04-26 05:39:25 +00:00
Matt Corallo
53c48c1c8f Add a bindings constructor for lightning-invoice's Sha256 wrapper 2023-04-25 22:51:18 +00:00
Matt Corallo
28e16aedd2 [bindings] Disable BOLT12 builders which require move semantics 2023-04-25 22:51:18 +00:00
Fred Walker
905cd8bc65
Limit phantom invoice hints to 3 2023-04-25 15:46:20 -04:00
Fred Walker
3e65e625be
Move phantom route hint selection into its own function 2023-04-25 15:46:03 -04:00
Matt Corallo
c1825672ed
Merge pull request #2222 from benthecarman/pub-utxo-resolver 2023-04-25 02:01:06 +00:00
Matt Corallo
b73473579e
Merge pull request #2211 from TheBlueMatt/2023-04-0.0.115-cut
Cut 0.0.115
2023-04-25 00:20:18 +00:00
Matt Corallo
dafa095413 Add 0.0.115 CHANGELOG entries 2023-04-24 22:40:40 +00:00
Matt Corallo
fb424009e3 Bump crate versions to 0.0.115/invoice 0.23 2023-04-24 22:40:17 +00:00
Matt Corallo
ec3aa49495
Merge pull request #2004 from tnull/2023-02-add-async-bp-example
Add Tokio example to `process_events_async` docs
2023-04-24 22:38:40 +00:00
Matt Corallo
8f4bd19c04
Merge pull request #2209 from TheBlueMatt/2023-04-better-discon-err-msg
Clarify the error message when we disconnect a peer
2023-04-24 21:22:06 +00:00
Matt Corallo
c89fd38f2a
Merge pull request #2220 from TheBlueMatt/2023-04-dont-ban-cln
Don't remove nodes if there's no channel_update for a temp failure
2023-04-24 21:15:08 +00:00
Elias Rohrer
feda5d343e
Add Tokio example to process_events_async docs 2023-04-24 22:26:09 +02:00
benthecarman
09e29c86db
Add function for updating network graph with announcement with no UTXO resolver 2023-04-24 14:10:25 -05:00
Matt Corallo
67ad6c40f0 Don't remove nodes if there's no channel_update for a temp failure
Previously, we were requiring any `UPDATE` onion errors to include
a `channel_update`, as the spec mandates[1]. If we see an onion
error which is missing one we treat it as a misbehaving node that
isn't behaving according to the spec and simply remove the node.

Sadly, it appears at least some versions of CLN are such nodes, and
opt to not include `channel_update` at all if they're returning a
`temporary_channel_failure`. This causes us to completely remove
CLN nodes from our graph after they fail to forward our HTLC.

While CLN is violating the spec here, there's not a lot of reason
to not allow it, so we go ahead and do so here, treating it simply
as any other failure by letting the scorer handle it.

[1] The spec says `Please note that the channel_update field is
mandatory in messages whose failure_code includes the UPDATE flag`
however doesn't repeat it in the requirements section so its not
crazy that someone missed it when implementing.
2023-04-24 18:52:05 +00:00
Matt Corallo
3dcd490bbf Remove unused import in functional_test_utils 2023-04-24 17:58:06 +00:00
Matt Corallo
3dab242f08 Fix unused Secp256k1 context in monitor_tests 2023-04-24 17:58:06 +00:00
Matt Corallo
f1761e06e6
Merge pull request #2221 from TheBlueMatt/2023-04-bp-exit-fast
Check for `background-processor` exit condition before+after sleep
2023-04-24 16:47:47 +00:00
Matt Corallo
607727fae7
Merge pull request #2146 from valentinewallace/2023-03-blinded-pathfinding-groundwork
Blinded pathfinding groundwork
2023-04-24 16:46:15 +00:00
Matt Corallo
05535913b3 Check for background-processor exit condition before+after sleep
In a synchronous `BackgroundProcessor`, the exit is done by setting
an atomic flag, which is most likely to happen while we're asleep.
Thus, we previously checked for the exit condition after the sleep
(and after we persisted the `ChannelManager`, if required, though
this is no longer required and dates back to when we didn't do a
re-persist after breaking out of the main loop).

For an async `background-processor`, this is also fine, however
because of the relatively longer sleep time, if the exit flag is
set via a sleep check returning true during event processing, we
may end up delaying exit rather substantially.

In order to avoid this, we simply check for the exit condition both
before and immediately after the sleep in `background-processor`.
2023-04-24 03:49:48 +00:00
Alec Chen
29b9eb3936 Add payment hash to MaybePreimageClaimableHTLC 2023-04-23 02:04:31 -05:00
Alec Chen
ba9e51764d Add payment hash to MaybeTimeoutClaimableHTLC 2023-04-23 02:04:24 -05:00
Alec Chen
0f933efc58 Add payment preimage and hash to ContentiousClaimable 2023-04-23 01:56:05 -05:00
Alec Chen
84da915a12 DRY up repeated HTLC Balances in tests
This makes it easier to add a new field on the `Balance` variants.
2023-04-23 01:07:01 -05:00
Alec Chen
53c79711b4 Add PartialOrd, Ord to PaymentHash, PaymentPreimage for tests 2023-04-22 23:04:29 -05:00
Matt Corallo
bc54441424
Merge pull request #2212 from wpaulino/off-by-one-locktime
Fix off-by-one finalized transaction locktime
2023-04-22 21:54:06 +00:00
Wilmer Paulino
97e4344bea
Fix off-by-one finalized transaction locktime
While these transactions were still valid, we incorrectly assumed that
they would propagate with a locktime of `current_height + 1`, when in
reality, only those with a locktime strictly lower than the next height
in the chain are allowed to enter the mempool.
2023-04-22 11:16:32 -07:00
Wilmer Paulino
e904d68fa8
Catch up test nodes to latest block height
In a future commit, we plan to correctly enforce that the spending
transaction has a valid locktime relative to the chain for the node
broascasting it in `TestBroadcaster::broadcast_transaction` to. We catch
up these test node instances to their expected height, such that we do
not fail said enforcement.
2023-04-22 11:16:32 -07:00
Wilmer Paulino
69d0bfacd9
Use current height when generating claims on block_disconnected
The `height` argument passed to `OnchainTxHandler::block_disconnected`
represents the height being disconnected, and not the current height.
Due to the incorrect assumption, we'd generate a claim with a locktime
in the future.

Ultimately, we shouldn't be generating claims within
`block_disconnected`. Rather, we should retry the claim at a later block
height, since the bitcoin blockchain does not ever roll back without
connecting a new block. Addressing this is left for future work.
2023-04-22 11:16:28 -07:00
Matt Corallo
5f96d13344
Merge pull request #2199 from tnull/2023-04-fix-async-event-processing
Allow async events processing without holding `total_consistency_lock`
2023-04-22 01:45:06 +00:00
Matt Corallo
02ae5cb9a7
Merge pull request #2208 from wpaulino/monitor-rebroadcast-pending-claims
Implement pending claim rebroadcast on force-closed channels
2023-04-21 23:33:52 +00:00
Wilmer Paulino
453b3a1055
Call ChainMonitor::rebroadcast_pending_claims on REBROADCAST_TIMER tick
This will prompt monitors to rebroadcast/fee-bump their pending claims
on a force-closed channel once on startup and every 30 seconds after.
2023-04-21 14:34:42 -07:00
Wilmer Paulino
db123f74be
Implement pending claim rebroadcast on force-closed channels
This attempts to rebroadcast/fee-bump each pending claim a monitor is
tracking for a force-closed channel. This is crucial in preventing
certain classes of pinning attacks and ensures reliability if
broadcasting fails. For implementations of `FeeEstimator` that also
support mempool fee estimation, we may broadcast a fee-bumped claim
instead, ensuring we can also react to mempool fee spikes between
blocks.
2023-04-21 14:34:41 -07:00