Commit graph

8128 commits

Author SHA1 Message Date
Matt Corallo
21904ffcb5 Add a constructor for the test SocketDescriptor and hang_writes
In testing, its useful to be able to tell the `SocketDescriptor` to
pretend the system network buffer is full, which we add here by
creating a new `hang_writes` flag. In order to simplify
constructing, we also add a new constructor which existing tests
are moved to.
2024-10-17 19:09:15 +00:00
Matt Corallo
bcad2571ac Fix the establish_connection utility method for a 2nd connection
The `establish_connection` method should work for more than one
connection per `PeerManager`, which we fix here.
2024-10-17 19:09:15 +00:00
Matt Corallo
1b711ed15f Reliably deliver gossip messages from our ChannelMessageHandler
When our `ChannelMessageHandler` creates gossip broadcast
`MessageSendEvent`s, we generally want these to be reliably
delivered to all our peers, even if there's not much buffer space
available.

Here we do this by passing an extra flag to `forward_broadcast_msg`
which indicates where the message came from, then ignoring the
buffer-full criteria when the flag is set.
2024-10-17 19:09:15 +00:00
Matt Corallo
d557334e31 Rename soonest_conf_deadline to counterparty_spendable_height
This renames the field in `PackageTemplate` which describes the
height at which a counterparty can make a claim to an output to
match its actual use.

Previously it had been set based on when a counterparty can claim
an output but also used for other purposes. In the previous commit
we cleaned up its use for fee-bumping-rate, so here we can rename
it as it is now only used as the `counteraprty_spendable_height`.
2024-10-17 18:34:33 +00:00
Matt Corallo
be915872c5 Clean up PackageTemplate::get_height_timer to consider type
`PackageTemplate::get_height_timer` is used to decide when to next
bump our feerate on claims which need to make it on chain within
some window. It does so by comparing the current height with some
deadline and increasing the bump rate as the deadline approaches.

However, the deadline used is the `counterparty_spendable_height`,
which is the height at which the counterparty might be able to
spend the same output, irrespective of why. This doesn't make sense
for all output types, for example outbound HTLCs are spendable by
our counteraprty immediately (by revealing the preimage), but we
don't need to get our HTLC timeout claims confirmed immedaitely,
as we actually have `MIN_CLTV_EXPIRY` blocks before the inbound
edge of a forwarded HTLC becomes claimable by our (other)
counterparty.

Thus, here, we adapt `get_height_timer` to look at the type of
output being claimed, and adjust the rate at which we bump the fee
according to the real deadline.
2024-10-17 18:34:33 +00:00
Matt Corallo
303a0c9a4e Stop passing current height to PackageTemplate::build_package
Now that we don't store the confirmation height of the inputs
being spent, passing the current height to
`PackageTemplate::build_package` is useless - we only use it to set
the height at which we should next bump the fee, but we just want
it to be "next block", so we might as well use `0` and avoid the
extra argument. Further, in one case we were already passing `0`,
so passing the argument is just confusing as we can't rely on it
being set.

Note that this does remove an assertion that we never merge
packages that were crated at different heights, and in the future
we may wish to do that (as there's no specific reason not to), but
we do not currently change the behavior.
2024-10-17 18:34:33 +00:00
Matt Corallo
8c4794df87 Drop unused PackageTemplate::height_original
This has never been used, and its set to a fixed value of zero for
HTLCs on local commitment transactions making it impossible to rely
on so might as well remove it.
2024-10-17 18:34:33 +00:00
Matt Corallo
81923c7340
Merge pull request #3330 from tnull/2024-09-add-macros-crate
Add `lightning-macros` crate and drop `bdk_macros` dependency
2024-10-17 15:34:18 +00:00
Matt Corallo
4a7b01aea7
Merge pull request #3371 from tnull/2024-10-allow-to-set-payment-and-description-hash
Invoice utils: allow to set both description hash and payment hash
2024-10-17 15:33:22 +00:00
Elias Rohrer
99ae425cad
Update lightning-transaction-sync to use macros crate 2024-10-17 16:26:42 +02:00
Elias Rohrer
0aed2b9c44
Add lightning-macros crate
Previously, we used the `bdk_macros` dependency for some simple proc
macros in `lightning-transaction-sync`. However, post-1.0 BDK doesn't
further maintain this crate and will at some point probably yank it
together with the old `bdk` crate that was split up.

Here, we create a new crate for utility proc macros and ~~steal~~ add
what we currently use (slightly modified for the latest `syn` version's
API though). In the future we may want to expand this crate, e.g., for
some `maybe_async` macros in the context of an `async KVStore`
implementation.
2024-10-17 16:26:41 +02:00
Matt Corallo
0c0cb6fccb Don't bump the next_node_counter when using a removed counter
If we manage to pull a `node_counter` from `removed_node_counters`
for reuse, `add_channel_between_nodes` would `unwrap_or` with the
`next_node_counter`-incremented value. This visually looks right,
except `unwrap_or` is always called, causing us to always increment
`next_node_counter` even if we don't use it.

This will result in the `node_counter`s always growing any time we
add a new node to our graph, leading to somewhat larger memory
usage when routing and a debug assertion failure in
`test_node_counter_consistency`.

The fix is trivial, this is what `unwrap_or_else` is for.
2024-10-16 22:45:10 +00:00
Matt Corallo
a19edbc32d Rename PackageTemplate::timelock counteraprty_spendable_height
This function was very confusing - its used to determine by when
we have to stop aggregating this claim with others as it starts to
be at risk of pinning due to the counterparty's ability to spend
the output.

It is not ever used as a timelock for a transaction, and thus its
name is very confusing.

Instead we rename it `counterparty_spendable_height`.
2024-10-16 21:04:48 +00:00
Matt Corallo
2f549eeb80 Rename claim cleaning match bool for accuracy
We don't actually care if a confirmed transaction claimed other
outputs, only that it claimed a superset of the outputs in the
pending claim we're looking at. Thus, the variable to detect that
is renamed `is_claim_subset_of_tx` instead of `are_sets_equal`.
2024-10-16 21:04:48 +00:00
Matt Corallo
d4e8b4994d
Merge pull request #3316 from optout21/signer_extend
[Splicing] Signer extended with method to sign prev funding transaction input
2024-10-16 18:43:09 +00:00
Elias Rohrer
43fd78b0b9
Invoice utils: allow to set both description hash and payment hash 2024-10-16 17:04:38 +02:00
optout
f22b011f93 Signer extended with method to sign prev funding transaction input 2024-10-15 23:13:14 +02:00
Gursharan Singh
0db051b75a
Merge pull request #3329 from arik-so/monitor_archive_docs_followup
Document monitor archival idempotency requirement (#3276 followup)
2024-10-15 13:54:46 -07:00
Matt Corallo
57dcc7d762 Deprecate the lightning::util::string re-export from types
Like we've done for `features` and `payment`, here we mark the
`lightning::util::string` re-export as deprecated.
2024-10-15 14:33:03 +00:00
Matt Corallo
50b5a6efa7 Drop the Payment{Hash,Preimage,Secret} re-exports in lightning
These re-exports were deprecated in 0.0.124 in favor of the
`lightning::types::payment::*` paths, which we use here.
2024-10-15 14:33:03 +00:00
Elias Rohrer
6004ee55bc
Merge pull request #3363 from G8XSU/event-logging-2
Revert "Add logging around event processing."
2024-10-15 09:32:37 +02:00
Elias Rohrer
77d3ff9a85
Merge pull request #3366 from TheBlueMatt/2024-10-0.0.125-relnotes
Add CHANGELOG entry for 0.0.125
2024-10-15 09:31:13 +02:00
Matt Corallo
80cdcc2644 Add CHANGELOG entry for 0.0.125 2024-10-14 19:37:03 +00:00
G8XSU
21e90366a3
Revert "Add logging around event processing."
This reverts commit 85eb8145fb.
Logging here can be overly verbose and moreover in case of event
handling failure, we loop back without any added delay.
2024-10-14 11:28:29 -07:00
Matt Corallo
46d8a0db79
Merge pull request #3354 from tnull/2024-10-fix-block-init-synchronize
`lightning-block-sync`: Fix `synchronize_listeners` always calling default implementation
2024-10-14 17:03:09 +00:00
Matt Corallo
64c12431b7 Drop lightning::ln::features::* type aliases
These were deprecated in 0.0.124, and we drop them here in favor of
`lightning::types::features::*`.
2024-10-13 13:52:56 +00:00
Arik Sosman
268675a743
Document monitor archival idempotency requirement. 2024-10-11 09:44:38 -07:00
Matt Corallo
ad19d93180
Merge pull request #3349 from TheBlueMatt/2024-10-3270-followups
Minor #3270 Followups
2024-10-11 13:47:39 +00:00
Matt Corallo
cb4584aff1
Merge pull request #3353 from tnull/2024-10-simplify-block-sync
Drop unnecessary `Result` in `RpcClient::new`
2024-10-11 13:45:53 +00:00
Elias Rohrer
f4fe450921
Fix synchronize_listeners calling default implementation
Previously, the `ChainListenerSet` `Listen` implementation wouldn't
forward to the listeners `block_connected` implementation outside of
tests. This would result in the default implementation of
`Listen::block_connected` being used and the listeners implementation
never being called.
2024-10-10 17:16:18 +02:00
Elias Rohrer
88cbb4ffff
Drop unnecessary Result in RestClient::new
.. as it's infallible
2024-10-09 19:35:42 +02:00
Elias Rohrer
4cdb12f912
Drop unnecessary Result in RpcClient::new
.. as it's infallible
2024-10-09 16:52:29 +02:00
Matt Corallo
43e28fe3a4
Merge pull request #3339 from arik-so/lint-script-file
Create script file for easy local linting
2024-10-09 14:09:13 +00:00
Arik Sosman
46c2c815bf
Create script file for easy local linting 2024-10-08 14:00:43 -07:00
Matt Corallo
a952d2d3d3
Merge pull request #3346 from TheBlueMatt/2024-10-dns-feature-flag
Add support for parsing the dns_resolver feature bit
2024-10-08 19:46:11 +00:00
Matt Corallo
f94bf98612
Merge pull request #3235 from Mirebella/add-local-balance-msats
Add `last_local_balance_msats` field
2024-10-08 17:56:46 +00:00
Matt Corallo
e4ec9176c5
Merge pull request #3351 from carlaKC/arch-update-keys-interface
docs/trivial: update diagram to reflect changes to KeysInterface
2024-10-08 15:30:56 +00:00
Mirebella
5d48d588ef Add Event::ChannelClosed::last_local_balance_msats
Users commonly want to know what their balance was when a channel
was closed, which this provides in a somewhat simplified manner.

It does not consider pending HTLCs and will always overstate our
balance by transaction fees.
2024-10-08 15:28:58 +00:00
Carla Kirk-Cohen
7c1db56d39
arch: update diagram to reflect changes to KeysInterface
KeysInterface was split into EntropySource, SignerProvider and
NodeSigner in #1930.
2024-10-08 10:35:14 -04:00
Matt Corallo
5c1440afec Hold a reference to byte arrays when serializing to bech32
When we serialize from a byte array to bech32 in
`lightning-invoice`, we can either copy the array itself into the
iterator or hold a reference to the array and iterate through that.

In aa2f6b47df we opted to copy the
array into the iterator, which is fine for the current array sizes
we're working with, but does result in additional memory on the
stack if, in the future, we end up writing large arrays.

Instead, here, we switch to using the slice serialization code when
writing arrays, (very marginally) reducing code size and reducing
stack usage.
2024-10-03 22:21:55 +00:00
Matt Corallo
052e7c3df0 Marginally reduce allocations in lightning-invoice
In aa2f6b47df we refactored
`lightning-invoice` de/serialization to use the new version of
`bech32`, but in order to keep the public API the same we
introduced one allocation we could have skipped.

Instead, here, we replace the public `Utf8Error` with
`FromUtf8Error` which contains the original data which failed
conversion, removing an allocation in the process.
2024-10-03 17:26:01 +00:00
Matt Corallo
c5658f6cc2 Check that the HRPs generated in BOLT 11 RawHrp are always valid
...in `debug_assertions`.
2024-10-03 17:24:59 +00:00
Matt Corallo
0abf068ad1 Drop one unnecessary allocation added in aa2f6b47df
In aa2f6b47df we refactored
`lightning-invoice` de/serialization to use the new version of
`bech32`, but ended up adding one unnecessary allocation in our
offers logic, which we drop here.
2024-10-03 17:23:32 +00:00
Matt Corallo
cc72f032dc Marginally reduce allocations in lightning-invoice
In aa2f6b47df we refactored
`lightning-invoice` de/serialization to use the new version of
`bech32`, also reducing some trivial unnecessary allocations when
we did so.

Here we drop a few additional allocations which came up in review.
2024-10-03 17:20:07 +00:00
Matt Corallo
bc1931bd0b
Merge pull request #3270 from optout21/bech32-iterser
Upgrade bech32 dependency (iterative)
2024-10-03 17:02:55 +00:00
optout
aa2f6b47df
Upgrade bech32 dependency, bech32 serialization improvements 2024-10-02 21:21:07 +02:00
Matt Corallo
457b634d09 Allow a DNSResolverMessageHandler to set dns_resolver feature
A `DNSResolverMessageHandler` which handles resolution requests
should want the `NodeFeatures` included in the node's
`node_announcement` to include `dns_resolver` to indicate to the
world that it provides that service. Here we enable this by
requesting extra feature flags from the `DNSResolverMessageHandler`
in the features `OnionMessenger`, in turn, provides to
`PeerManager` (which builds the `node_announcement`).
2024-10-02 18:24:40 +00:00
Matt Corallo
1abbe2a237 Add support for parsing the dns_resolver feature bit
This feature bit is used to indicate that a node will make DNS
queries on behalf of onion message senders, returning DNSSEC TXT
proofs for the requested names.

It is used to signal support for bLIP 32 resolution and can be used
to find nodes from which we can try to resolve BIP 32 HRNs.
2024-10-02 18:24:40 +00:00
Arik
d49a08a824
Merge pull request #3179 from TheBlueMatt/2024-07-human-readable-names-resolution-1
Add the core functionality required to resolve Human Readable Names
2024-10-02 10:00:13 -07:00
Matt Corallo
605952cefd
Merge pull request #3301 from dunxen/2024-9-fixnevertypefallback
Add an explicit_type TLV syntax for avoiding certain cases of type inference
2024-10-02 14:29:09 +00:00