1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-02-22 14:22:39 +01:00
Commit graph

2623 commits

Author SHA1 Message Date
Thomas HUET
47c7a45767
Monitor onion messages (#2877)
Improve metrics for for onion messages.
We count messages sent and received, throttled and that couldn't be relayed.
2024-07-11 10:49:57 +02:00
Thomas HUET
9762af8bef
Update test vector for onion messages (#2876)
Copied test vectors from https://github.com/lightning/bolts/blob/master/bolt04/blinded-onion-message-onion-test.json
Also improve JSON parsing
2024-07-10 12:29:08 +02:00
Bastien Teinturier
791edf78b6
Improve Origin and Upstream (#2872)
We move the `Upstream` trait closer to the `Origin`, and make it more
obvious than a hot `Origin` is:

- an `Upstream` referencing the upstream HTLCs
- an actor requesting the outgoing payment

We also improve the cold trampoline relay class to record the incoming
HTLC amount, which we previously didn't bother encoding but is useful to
compute the fees collected during relay. To ensure backwards-compat, it
is set to `0 msat` for pending HTLCs. It will only affect HTLCs that
were pending during the upgrade, which is acceptable.
2024-06-27 16:28:15 +02:00
Bastien Teinturier
c53b32c781
Reject unspendable inputs in interactive-tx (#2870)
When we require inputs to be confirmed, we can reliably check whether
they are unspent. We can't reliably check this for unconfirmed inputs,
because they could be valid but simply not in our mempool, in which
case bitcoind would incorrectly consider them unspendable.

We want to reject unspendable inputs early to immediately fail the
funding attempt, instead of waiting to detect the double-spend later.
2024-06-26 16:17:17 +02:00
Richard Myers
71bad3a210
Update Bitcoin Core to v27.1 (#2862)
Bitcoin Core 27.1 adds the coingrinder coin selection algorithm which will help lower on-chain fees during feerate spikes.
2024-06-18 14:41:37 +02:00
Richard Myers
d960266445
Fix flaky test for punishing a published revoked commit (#2871)
A race exists because node C can publish the txs to spend the htlcs from the revoked commitment *before* F publishes their txs to spend two of the htlc outputs.

 Instead we handle the rare case of a `txn-mempool-conflict` failure.

 We will sometimes miss testing that C claims those two htlcs via 3rd stage txs.
2024-06-18 08:16:42 +02:00
Bastien Teinturier
3277e6d01c
Add EncodedNodeId for mobile wallets (#2867)
We define a new type of `EncodedNodeId` that can be provided in blinded
paths to let a wallet provider know that the next node is a mobile
wallet.
2024-06-13 09:27:19 +02:00
Bastien Teinturier
741ac492e2
Register can forward messages to nodes (#2863)
We add a `ForwardNodeId` command to the `Register` to forward messages
to a `Peer` actor based on its `node_id`.
2024-06-12 10:38:52 +02:00
Bastien Teinturier
f0e3985d10
Add paysCommitTxFees flag to LocalParams (#2845)
The channel initiator traditionally pays the commit tx fees, but we may
want to override that when providing services to wallet users. We thus
split the current `isInitiator` flag into two flags:

- `isChannelOpener`
- `paysCommitTxFees`

We always set `paysCommitTxFees` to the same value as `isChannelOpener`.
Custom feature bits may override that behavior if necessary.

Note that backwards compatibility is preserved since our previous `bool8`
codec encodes `true` as `0xff` and `false` as `0x00`.
2024-06-12 10:33:35 +02:00
Pierre-Marie Padiou
40f13f4de5
(Minor) Log local inputs in interactive-tx (#2864)
We do log all incoming/outgoing messages, including `TxAddInput`, but
the `toString()` prints the whole serialized tx, not the txid, making
grepping more difficult.

Co-authored-by: Bastien Teinturier <31281497+t-bast@users.noreply.github.com>
2024-06-11 16:12:03 +02:00
Thomas HUET
3bb5f3e9f2
Unwrap blinded routes that start at our node (#2858)
Sending a payment to a blinded route that starts at our node can be tricky, we remove this problem by unwrapping such routes before starting the payment flow.

---------

Co-authored-by: t-bast <bastien@acinq.fr>
2024-06-07 16:07:05 +02:00
Bastien Teinturier
414f72898b
Accept onion failure without a channel_update (#2854)
https://github.com/lightning/bolts/pull/1163 makes the channel update in
onion failures optional. One reason for this change is that it can be a
privacy issue: by applying a `channel_update` received from an payment
attempt, you may reveal that you are the sender. Another reason is that
some nodes have been omitting that field for years (which was arguably
a bug), and it's better to be able to correctly handle such failures.
2024-06-04 16:48:31 +02:00
Thomas HUET
b73a009a1d
Cleanup of RouteBlinding feature (#2856)
RouteBlinding is not an invoice feature.
2024-05-22 10:47:18 +02:00
Thomas HUET
bbd52fab02
Fix TransactionsSpec tests (#2857)
TransactionsSpec reads test cases from the spec, however the spec was recently updated to remove half of the test cases.
2024-05-22 09:32:58 +02:00
Thomas HUET
c4934930aa
Implicit node id in offers with blinded paths (#2852)
To save space in the offer, we can skip the node id for offers that use blinded paths.
The node id used to sign the invoice will be the last blinded node id of the path used to request the invoice.

We also make the description optional for offers without amount.
2024-04-30 14:55:25 +02:00
Bastien Teinturier
35295af73c
Update Bitcoin Core to v26.1 (#2851)
Bitcoin Core 26.1 contains ancestor-aware funding: it will automatically
fetch unconfirmed ancestors during funding and adapt the fee to apply
the target feerate to the whole unconfirmed package.

We had custom code to implement this entirely in eclair, which we can
now remove.
2024-04-23 10:28:25 +02:00
Bastien Teinturier
c6e586ab89
Relax assumptions about gossip_queries (#2842)
https://github.com/lightning/bolts/pull/1092 initially made the
`gossip_queries` feature mandatory and assumed: however it generally
doesn't make sense for mobile wallets. It was thus relaxed in the last
commits of this BOLTs PR, so we revert our change to `mandatory` to
make this optional and avoid sending gossip queries to nodes who don't
activate the feature.
2024-04-16 17:45:24 +02:00
Pierre-Marie Padiou
7ab42bfad5
Remove redundant check on remoteScriptPubkey (#2844)
If the peer had `option_shutdown_anysegwit` enabled when they initially sent their `remoteScriptPubkey`, but reconnected later with `option_shutdown_anysegwit` disabled, then `isValidFinalScriptPubkey` may not pass anymore.
2024-04-11 13:50:49 +02:00
rorp
c8184b3e43
Update the CLI tools (#2837)
The latest eclair release added some RPCs that were missing from the CLI documentation.
2024-03-13 10:47:20 +01:00
Richard Myers
40ef3655cf
Fixup quiescence timeout when initiating splice (#2836)
Should use the quiescence timeout value instead of the revocation timeout value (copy-paste error) when initiating a splice.
2024-03-11 16:21:17 +01:00
Thomas HUET
1b3e4b0dae
Allow relaying messages to self (#2834)
Allow sending messages to self

Fixes corner cases caused by compact encoding of node ids. Every message to be relayed now follows the same path and `MessageRelay` can relay to self.
2024-03-04 15:44:55 +01:00
Bastien Teinturier
c866be321c
Fix flaky test (#2833)
We started using dual-funding by default in some integration tests. One
of the changes is that we consider the channel created once we send our
commitment signatures. At that point, we are not yet in a state where
we have fully signed commitments: that will happen once we receive our
peer's signatures.

Some tests assumed that when receiving the `ChannelCreated` event, we
would have fully signed commitment. We update those tests to handle the
case where we are actually still exchanging signatures.
2024-02-29 14:47:42 +01:00
Fabrice Drouin
82dbbdbf3f
Use bitcoin-lib 0.33 (#2822) 2024-02-29 14:20:37 +01:00
Bastien Teinturier
145d0f4860
Back to dev (#2832)
After the v0.10.0 release.
2024-02-29 10:35:38 +01:00
Bastien Teinturier
a63d2c2909
Eclair v0.10.0 release (#2831) 2024-02-28 17:39:44 +01:00
Bastien Teinturier
8723d355c4
Activate dual funding by default (#2825)
And update the release notes.
2024-02-28 15:57:12 +01:00
Bastien Teinturier
fd0cdf6fc1
Allow plugins to set a dual funding contribution (#2829)
We support dual funding, but we cannot decide for the node operator when
to contribute to channels that are being opened to us. Node operators
may want very different policies depending on their goals. Instead of
trying to figure out a general set of policies, we let plugins decide
when to contribute to channels and how much. Node operators are thus
free to implement whatever logic makes sense for them in a plugin.
2024-02-27 17:03:21 +01:00
Bastien Teinturier
36a3c8897c
More fine grained support for fee diff errors (#2815)
When there is a mismatch between the feerate of a channel and the
feerate we get from our estimator, we may want to force-close because
that could be exploited by our peer to steal HTLCs. But that's only the
case if the feerate is too low, not if it's too high. We previously
force-closed in both cases, whereas we only need to do it when the
feerate is too low.

This should avoid some unnecessary force-close that we've observed and
are due to buggy fee estimators (fee estimation is hard!), or to peers
who simply do some smoothing and slightly delay lowering the feerate of
our channels.
2024-02-27 13:52:01 +01:00
Bastien Teinturier
5d6a1db9fb
Skip anchor tx when remote commit has been evicted (#2830)
When we detect that the remote commit has been published, we spend our
anchor output from that commit if the fees are too low and we have funds
at risk. But if the remote commit is then evicted from our mempool, we
cannot publish our anchor tx and must instead skip it, since we don't
provide the fully signed remote commitment to the publisher.

We otherwise error when calling `fundrawtransaction`, where `bitcoind`
fails because it cannot find the external non-wallet utxo. This change
gets rid of those errors that can be quite confusing for node operators.
2024-02-22 09:21:13 +01:00
Bastien Teinturier
cd4d9fd4b0
Unlock non-wallet inputs (#2828)
When funding a transaction that contains inputs that are external to our
bitcoin wallet, bitcoin core will add a lock to those external inputs,
thinking that they may be wallet inputs that it doesn't know about yet.
In our case, those are never wallet inputs, they are instead:

- the current channel output, when creating a splice transaction
- an output of the commitment transaction, when force-closing

We previously explicitly filtered those inputs before calling `unlock`,
which was wrong. We now also unlock those utxos.
2024-02-22 09:20:27 +01:00
Bastien Teinturier
0393cfc275
Add require_confirmed_inputs to RBF messages (#2783)
This was missing from the spec, but is more flexible and clearer than
inheriting values from the previous attempt.

Fixes #2782
2024-02-21 17:50:12 +01:00
Pierre-Marie Padiou
e32044f05f
Unlock utxos on reconnect when signatures haven't been sent (#2827)
In the case where we have not sent our `TxSignatures`, and our peer replies with an error at reconnection, we can safely unlock our local inputs.
2024-02-20 15:00:23 +01:00
Thomas HUET
86c483708a
Relay onion messages to compact node id (#2821)
To save space, blinded routes may use a compact node id (scid + direction instead of public key) as an introduction node.
When using such a compact route, the sender must use it's knowledge of the network to convert that to a public key, however trampoline users don't have that knowledge, they must transmit the compact route to the trempoline provider.
We extend the spec to allow compact node ids in the `next_node_id` field.


Co-authored-by: t-bast <bastien@acinq.fr>
2024-02-19 16:25:00 +01:00
Pierre-Marie Padiou
62b739aa22
fixup! Asynchronously clean up obsolete HTLC info from DB (#2705) (#2824)
Fixes a regression caused by #2705 reported by @fishcakeday.
2024-02-15 15:43:19 +01:00
Bastien Teinturier
f41bd22d69
Asynchronously clean up obsolete HTLC info from DB (#2705)
When a channel is closed, we can forget the data from historical HTLCs
sent and received through that channel (which is otherwise required to
punish cheating attempts by our peer).

We previously synchronously removed that data from the DB when the closing
transaction confirmed. However, this could create performance issues as
the `htlc_infos` table can be very large for busy nodes and many concurrent
writes may be happening at the same time.

We don't need to get rid of this data immediately: we only want to remove
it to avoid degrading the performance of active channels that read and
write to the `htlc_infos` table. We now mark channels as closed in a
dedicated table, and run a background actor that deletes batches of
obsolete htlc data at regular intervals. This ensures that the table is
eventually cleaned up, without impacting the performance of active
channels.

When a splice transaction confirms, all the revoked commitment transactions
that only applied to the previous funding transaction cannot be published
anymore, because the previous funding output has already been spent.

We can thus forget all the historical HTLCs that were included in those
commitments, because we will never need to generate the corresponding
penalty transactions.

This ensures that the growth of our DB is bounded, and will shrink every
time a splice transaction is confirmed.

Fixes #2610, #2702 and #2740
2024-02-14 14:06:17 +01:00
Bastien Teinturier
599f9afa2c
Test bitcoind wallet behavior during mempool eviction (#2817)
* Test bitcoind wallet behavior during mempool eviction

When transactions are being evicted from the mempool, we want to make
sure that bitcoind keeps the corresponding wallet inputs locked to
avoid accidentally double-spending ourselves. We update our unit test
to be closer to common scenarios (chain of unconfirmed splice txs and
commit txs replaced by the remote version).

This test confirms that bitcoind keeps wallet inputs locked, and we
have to call `abandontransaction` to free up utxos used in txs that
have been permanently double-spent.

* Test bitcoind wallet behavior during double spend

When one of our wallet transactions is directly double-spent, the
bitcoin wallet detects that and automatically frees up wallet inputs
from the permanently double-spent wallet transaction. This is great,
that means we only need to manually call `abandontransaction` for
transactions that have been invalidated because one of their parents
has been double-spent.
2024-02-13 18:17:21 +01:00
Bastien Teinturier
b5e83a6092
Add closing test reconnect with 3rd-stage txs (#2820)
We had some cases where channels were staying stuck in the CLOSING state
without going to the CLOSED state in previous versions of eclair where
we published different versions of our 3rd-stage transactions after a
restart and a feerate increase.

This happened in two cases:

- when we published a different version of our claim-main, since we only
  store the latest (it's an `Option`, not a `Seq`) and put a watch on
  this specific `txid` instead of watching the corresponding output
- when we re-published 3rd-stage txs after receiving `CMD_FULFILL_HTLC`
  because we replaced the previous `claim-htlc-delayed` transactions

This was on my backlog for a while, and I wanted to take another look at
it after the splicing implementation. Fortunately, this was fixed as
part of the splicing changes, but it's worth having a test to ensure
that there's no regression from future changes.
2024-02-13 17:31:13 +01:00
Bastien Teinturier
3d8dc88089
Abandon transactions whose ancestors have been double spent (#2818)
When a transaction is directly double-spent, bitcoind is able to
automatically detect it and free up wallet inputs that are used
in double-spent transactions. However, when a transaction becomes
invalid because one of its ancestors is double-spent, bitcoind is
not able to detect it and will keep wallet inputs locked forever.

The only cases where this can happen are:

- splice transactions when a commitment transaction that is not
  based on the latest splice is confirmed
- anchor transactions in the above case, or when a different
  version of the commitment confirms (e.g. remote commit while
  we're trying to CPFP ou local commit)

When we detect that this happened, we abandon the corresponding
transactions, which ensures that we don't end up with unusable
liquidity in our wallet.

We also remove cases where we eagerly abandoned transactions,
which could lead us to double-spend ourselves inadvertently
because the abandoned transaction could still confirm while
we reused its inputs in another transaction (which is a real
issue when using 0-conf).
2024-02-07 15:50:12 +01:00
Bastien Teinturier
5b1c69cc84
Add configurable threshold on maximum anchor fee (#2816)
* Add configurable threshold on maximum anchor fee

We previously bumped up to 5% of our channel balance when no HTLCs were
at risk. For large channels, 5% is an unreasonably high value. In most
cases it doesn't matter, because the transaction confirms before we try
to bump it to unreasonable levels. But if the commitment transaction
was pruned and couldn't be relayed to miners, then eclair would keep
trying to bump until it reached that threshold. We now restrict this to
a value configurable by the node operator. Note that when HTLCs are at
risk, we still bump up to the HTLC amount, which may be higher than the
new configuration parameter: we want that behavior as a scorched earth
strategy against pinning attacks.

* Add feerate upper bound from fee estimator

We add a new limit to the feerate used for fee-bumping, based on the
fastest feerate returned by our fee estimator. It doesn't make sense
to use much higher values, since this feerate should guarantee that
the transaction is included in the next block.
2024-02-05 14:38:07 +01:00
Thomas HUET
aae16cf79f
Trampoline to blinded (#2811)
Allow trampoline to pay a list of blinded paths instead of a node id.
Only the last trampoline hop can target blinded paths, trampoline nodes are still reached with their node id, not with blinded paths.

Co-authored-by: t-bast <bastien@acinq.fr>
2024-01-25 18:24:34 +01:00
Thomas HUET
e66e6d2a14
Trampoline to blinded (types only) (#2813)
Add types needed for trampoline to pay a list of blinded paths instead of a node id.
2024-01-23 09:47:50 +01:00
Thomas HUET
5fb9fef978
Variable size for trampoline onion (#2810)
The size of trampoline onions was fixed at 400 bytes. We remove this limit, allowing larger trampoline onions when necessary.
The size of the trampoline onion is still constrained by the size of the standard onion (1300 bytes).

Co-authored-by: t-bast <bastien@acinq.fr>
2024-01-15 11:09:14 +01:00
Pierre-Marie Padiou
c37df26c7a
Add a funding fee budget (#2808)
When opening an important channel we may be willing to pay a high feerate that we wouldn't want to use when consolidating UTXOs. However because we delegate the transaction creation to bitcoin core, we can sometimes be surprised by funding transactions that are much bigger than expected. This PR protects us from such cases by refusing to open the channel if the transaction fee is too high.

Based on original work from @thomash-acinq.
2024-01-10 17:01:17 +01:00
Bastien Teinturier
3bd3d07369
Send batch_size on commit_sig retransmit (#2809)
If we get disconnected after sending `commit_sig`, we will retransmit
that message when reconnecting if our peer has not received it.

When we have multiple commitments, we need to retransmit one message
per commitment, and include the `batch_size` tlv.

We incorrectly stored `commit_sig` without the `batch_size` tlv in the
next remote commit field, and thus retransmitted without that tlv.
2024-01-10 15:05:40 +01:00
Richard Myers
a9b590365c
Fixes for quiescence back ported from lightning-kmp (#2779)
Fixes some issues we found while porting quiescence to lightning-kmp.
2024-01-10 10:38:58 +01:00
Bastien Teinturier
61f1e1f82e
Relay HTLC failure when inactive revoked commit confirms (#2801)
When an inactive revoked commitment containing outgoing HTLCs
is confirmed, we must consider the outgoing HTLC failed and relay that
failure upstream. Because of the alternative commit tx mechanism,
those inactive revoked commitments match the remote commit,
so we were waiting for tx confirmation before failing back upstream.
2024-01-02 16:19:24 +01:00
Pascal Grange
3a49f5dd43
FIX eclair-cli error code in case of HTTP problem (#2798)
Last command of eclair-cli is a curl piped to jq. In case of an
error with the curl command (for instance, eclair service is not
running) the error code was swallowed by the pipe wich will
return the exit code of the last command of the pipe (here, jq).

Setting `pipefail` ensures that the error code of curl is
preserve in case of HTTP issue.

This can come handy, for instance, to check that eclair is not
ok:

```
if eclair-cli getinfo
then
  echo eclair is answering
else
  echo problem communicating with eclair
fi
```
2024-01-02 10:39:07 +01:00
Thabokani
63a1d77baa
Fix typos in various comments (#2805) 2024-01-02 09:31:57 +01:00
Barry G Becker
e05ed03f2f
Fix some typos in CircularRebalancing documentation (#2804) 2024-01-02 09:13:03 +01:00
Fabrice Drouin
eced7b909a
Update bitcoin-lib (#2800)
bitcoin-lib 0.31 depends on secp256k1-kmp 0.12.0 which fixes a bug when parsing BOLT11 invoices with an invalid recovery id.
2023-12-18 18:04:02 +01:00