1
0
mirror of https://github.com/ACINQ/eclair.git synced 2025-01-19 05:33:59 +01:00
Commit Graph

2195 Commits

Author SHA1 Message Date
Pierre-Marie Padiou
ca71a3c152
Update a few dependencies (#2166)
This updates versions of a few major dependencies: scala, akka, postgres, etc.
2022-02-08 11:37:24 +01:00
Richard Myers
daddee1912
fixup! Convert wiki pages in to files in the docs directory and general docs file cleanups (#2165) (#2167)
- Fixup for #2165, Usage.md should link to ./API.md and not the deprecated wiki
2022-02-07 14:21:08 +01:00
Thomas HUET
9401592382
Typed features (#2164)
Give different types to init features / node announcement features / invoice features.

We now accept more invoices (we would previously reject invoices if they required a feature that we don't support but that we know is irrelevant for invoices).
2022-02-07 09:51:38 +01:00
Richard Myers
553727cb22
Convert wiki pages in to files in the docs directory and general docs file cleanups (#2165)
Created new files for pages that were in the wiki, but not already in the docs directory. Also made following fixes to  README.md and existing files in the docs directory:

* update bolt links to avoid redirect
* link to logging guide from logging section (README.md)
* fixed typo in Backup section and capitalization of Bitcoin Core (README.md)
* Alice does not need trampoline feature enabled (TrampolinePayments.md)
* link to 2021 edition of Trampoline PR (TrampolinePayments.md)
* fixed API examples and removed quotes from password (API.md)
* use --nodeIds for sendtoroute examples (TrampolinePayments.md and MultipartPayments.md)
* update CLI example 3 to use jq (Usage.md)
* fix typo in docs/FAQ.md
* updated Guide.md to point to all pages that are guides
2022-02-06 20:28:50 +01:00
Thomas HUET
fa31d81d0e
Improve postman (#2147)
Makes the code a bit cleaner and fixes a bug where `Postman` could respond with both a failure to send and later a `NoReply` after the timeout in case we were expecting a reply.
2022-02-02 17:45:22 +01:00
Thomas HUET
4307bada51
Refactoring of PaymentRequest (#2144)
Refactoring of `PaymentRequest` to pave the way for bolt12 invoices

`PaymentRequest` is renamed to `Invoice` and is now a trait extended by `Bolt11Invoice` and `Bolt12Invoice`. `Bolt12Invoice` will come in a future PR.

Co-authored-by: t-bast <bastuc@hotmail.fr>
2022-02-02 17:29:15 +01:00
Bastien Teinturier
8a65e35c8f
Don't broadcast commit before funding locked (#2163)
If a channel is force-closed before the funding transaction is confirmed,
broadcasting our local commit can be a problem if the funding
tx is double spent. When that happens, the channel stays stuck in the
closing state trying to publish a commit tx with an invalid input.

If we haven't even seen the funding tx in the mempool, we have no way of
being sure that it was double spent, so we would need to keep trying
forever, which pollutes the logs with publishing errors.

Whenever the funding transaction isn't confirmed and we have nothing
at stake, we now directly go to the closed state without publishing our
commitment. This will be an issue for peers who lost state and rely on
us for dataloss protection, but it's not worth exposing ourselves to that
annoying edge case. Our peers should be able to at least keep state
long enough for the funding tx to confirm or for them to force-close.
2022-02-02 17:28:03 +01:00
Bastien Teinturier
648f93f682
Ignore revoked htlcs after restart (#2161)
When we restart, if a downstream channel is closing with a revoked commit,
we should fail the corresponding htlcs in upstream channels.

Otherwise they will be ignored until they timeout, which will cause the
upstream channel to force-close.
2022-02-02 15:36:45 +01:00
Bastien Teinturier
cc61f121ec
Fix publish loop when funding tx double-spent (#2162)
If a funding tx is double-spent, we can't publish our commit tx. However,
the previous code would retry very regularly in a loop, polluting the logs.

When that happens, we now only retry when a new block is found.
2022-02-02 15:36:22 +01:00
Bastien Teinturier
44510698f7
Back to Dev (#2159) 2022-02-01 10:42:29 +01:00
Bastien Teinturier
a804905c0b
Eclair v0.7.0 release (#2158) 2022-02-01 08:34:50 +01:00
Pierre-Marie Padiou
0333e11c79
Database migration Sqlite->Postgres (#2156)
Add a migration tool and a step-by-step guide for users who want to switch from Sqlite to Postgres.
2022-01-31 12:49:39 +01:00
Pierre-Marie Padiou
1f6a7afd47
Have sqlite also write to jdbc url file (#2153)
Eclair will now refuse to start if the database config is changed from `sqlite` to `postgres` or the opposite.
2022-01-27 16:29:46 +01:00
Pierre-Marie Padiou
ffecd62cc1
Move channel parameters to their own conf section (#2149)
For consistency with existing sections: `router`, `relay`, `peer-connection`, etc.
2022-01-27 15:16:26 +01:00
Pierre-Marie Padiou
57c2cc5df9
Type ChannelFlags instead of using a raw Byte (#2148)
This has the same kind of impact as the typing of `Features`. In particular we can now explicitly set the values in `eclair.conf`:
`eclair.channel.channel-flags.announce-channel=true`. I took the opportunity to move this channel-related config key in its own config section, with the goal that we move the other fields in a follow-up PR.

It also has the nice side effect of providing a pretty json formatting out of the box:
```json
"channelFlags": {
  "announceChannel": true
}
```

The `open` method of the API has been updated: `channelFlags` has been replaced by a new `announceChannel` parameter.
2022-01-25 18:35:32 +01:00
Pierre-Marie Padiou
75ef66e54c
Front: use IMDSv2 to retrieve the instance ip (#2146)
This is used by the built-in AWS Beanstalk package.
2022-01-25 17:23:41 +01:00
Fabrice Drouin
8758d50df2
Update cluster documentation [ci skip] (#2122)
Update cluster documentation
2022-01-24 18:04:25 +01:00
Fabrice Drouin
f3604cffaf
Document onchain wallet backup. (#2143)
Eclair does not include an onchain wallet and instead uses the wallet of the bitcoin node it is connected to.
Users must also backup this wallet.
2022-01-24 16:32:13 +01:00
Bastien Teinturier
d59d4343c8
Improve getsentinfo accuracy (#2142)
The PaymentInitiator now stores all pending payments, where it previously
only stored trampoline payments (for which it handled the retries).

Whenever the DB doesn't contain any pending payment we also ask the
payment initiator whether a payment attempt is being started, which lets
us provide more accurate information with the `sentinfo` RPC.
2022-01-24 11:34:52 +01:00
Bastien Teinturier
2d64187073
More aggressive confirmation target when low on utxos (#2141)
An optimistic schedule for confirmation during force-close scenarios
could in theory help malicious peers starve us of our utxos, making it
hard to fee-bump HTLC transactions in high-fee environments.

If we detect that our safe utxos count is low, we try to get force-close
transactions confirmed as quickly as possible, which will yield a new utxo
that can be used to fund other transactions.
2022-01-24 11:27:45 +01:00
Bastien Teinturier
85f94554c0
Fix error logs formatting in TxPublisher (#2136)
I always forget that `log.error` doesn't use the same formatting as
other log.* methods (it optimizes for showing a Throwable).
2022-01-24 11:01:46 +01:00
Pierre-Marie Padiou
0a37213483
Add randomization on node addresses (#2123)
Instead of always using the last known peer address from the `PeersDb`,
we randomly pick the address from the `PeersDb` and the `NetworkDb`.

We use clearnet or tor addresses depending on the node configuration:
- tor not supported: always use clearnet addresses
- tor supported but not enabled for clearnet addresses: use clearnet
  addresses when available
- tor supported and enabled for clearnet addresses: use tor
  addresses when available
2022-01-21 15:24:43 +01:00
Pierre-Marie Padiou
c180ca2ef1
Postgres: add safety checks at startup (#2140)
When using postgres, at startup we optionnally run a few basic safety
checks, e.g. the number of local channels, how long since the last local
channel update, etc. The goal is to make sure that we are connected to
the correct database instance.
2022-01-21 14:45:16 +01:00
Bastien Teinturier
f8d507bbdd
Send remote address in init (#1973)
This adds the option to report a remote IP address back to a connecting
peer using the `init` message. A node can decide to use that information
to discover a potential update to its public IP address (NAT) and use
that for a `node_announcement` update message containing the new address.

See https://github.com/lightningnetwork/lightning-rfc/pull/917
2022-01-21 12:40:12 +01:00
Pierre-Marie Padiou
2f07b3ec0b
(Minor) Nits (#2139)
* consistency in feature names

Since we're not always following the `option_` prefix from the spec,
let's at least be consistent with ourselves.

* add alternative to `def nodeFees()`
2022-01-21 10:14:50 +01:00
Bastien Teinturier
e2b1b26919
Activate anchor outputs (#2134)
This feature is now ready to be widely deployed.
The transaction format has been tested for a long time
(between Phoenix iOS and our node) and automatic
fee-bumping has been implemented in #2113.
2022-01-19 13:30:55 +01:00
Bastien Teinturier
52a6ee9059
Rename TxPublishLogContext (#2131)
This data class is actually used for more than logging, we also use it to
track the id of a publish request.

We also switch to a different MDC key for transaction publishing instead
of re-using the paymentId one.
2022-01-19 13:24:22 +01:00
Bastien Teinturier
58f9ebc624
Use BlockHeight everywhere (#2129)
We now have this better type to remove ambiguity.
We should use it wherever it makes sense.
There shouldn't be any business logic change in this commit.
2022-01-19 11:31:54 +01:00
Bastien Teinturier
40f7ff4034
Replaceable txs fee bumping (#2113)
* Add deadline information to tx publication

When a channel is force-closed, we tell the `TxPublisher` the block before
which the transaction should be confirmed. Then it will be up to the
`TxPublisher` to set the feerate appropriately and fee-bump whenever
it becomes necessary.

* Evaluate feerate at tx broadcast time

We previously evaluated the feerate when we issued the command to publish
a transaction. However, the transaction may actually be published many
blocks later (especially for HTLC-timeout transactions, for which we may
issue commands long before the timeout has been reached).

We change the command to include the deadline, and evaluate the
feerate to meet that deadline when we're ready to broadcast a valid
transaction.

* Retry conflicting replaceable transactions

We should retry replaceable transactions whenever we find a conflict in
the mempool: as we get closer to the deadline, we will try higher fees.

This ensures we either succeed in replacing the mempool transaction, or
it gets confirmed before the deadline, which is good as well.

In particular, this handles the case where we restart our node. The mempool
conflict can be a transaction that we submitted ourselves, but we've
lost the context in the restart. We want to keep increasing the fees of
that transaction as we get closer to the deadline, so we need this retry
mechanism.

* Regularly bump transaction fees

Once we've published a first version of a replaceable transaction, at every
new block we evaluate whether we should RBF it.

When we choose to RBF, we try to reuse the previous wallet inputs and
simply lower the change amount. When that's not possible, we ask bitcoind
to add more wallet inputs.
2022-01-18 18:50:22 +01:00
Fabrice Drouin
88dffbc28c
Publish docker images (#2130)
Publish docker images for master branch with tag `latest`
2022-01-18 15:17:12 +01:00
Thomas HUET
27e29ecebf
Fix onion message tests by changing the rate limiter (#2132)
We want to be able to send several messages immediately after opening the connection which is not supported by Google's rate limiter that assumes that we had already reached the maximum rate when the rate limiter was created.
We create our own rate limiter that does what we need.
2022-01-18 10:40:47 +01:00
Bastien Teinturier
546ca23984
Activate onion messages (#2133)
* Fix supervisor for MessageRelay actors
* Use optional replyTo instead of replyTo.NoSender
* Activate onion messages
2022-01-17 16:48:50 +01:00
Bastien Teinturier
7f7ee03899
Handle onion creation failures (#2087)
We have a few requirements inside the sphinx code that can make the onion
creation throw exceptions (e.g. onion payloads cannot exceed 1300 bytes).
This usually isn't an issue as our code doesn't generate payloads that
could reach those limits, but the introduction of payment_metadata changes
this: invoices may contain too much data for onion payloads, and we need
to gracefully handle failures.

Note that it has already bitten us when people included many routing hints
in invoices and we were trying to pay with trampoline.
2022-01-11 17:31:15 +01:00
Bastien Teinturier
6e88532d18
Add support for option_payment_metadata (#2063)
* Filter init, node and invoice features

We should explicitly filter features based on where they can be included
(`init`, `node_announcement` or `invoice`) as specified in Bolt 9.

* Add support for sending `payment_metadata`

Whenever we find a payment metadata field in an invoice, we send it in
the onion payload for the final recipient.

* Include `payment_metadata` in all invoices

We include a payment metadata in every invoice we generate. This lets us
see whether our payers support it or not, which is important data to have
before we make it mandatory and use it for storage-less invoices.

See https://github.com/lightning/bolts/pull/912 for reference.
2022-01-10 15:55:43 +01:00
Pierre-Marie Padiou
27579a5786
(Minor) Use sys package instead of System when applicable (#2124)
Use scala's `sys.exit()` instead of java's `System.exit()`, etc.
2022-01-06 18:55:46 +01:00
Thomas HUET
7421098c44
Process replies to onion messages (#2117)
Add a postman that is in charge of sending messages and listens to incoming replies and delivers them to the right actor
2022-01-05 16:37:52 +01:00
Bastien Teinturier
fda3818c6a
Rename raw tx publisher to final tx publisher (#2119)
This makes the distinction between final and replaceable txs more obvious.

Do note that this doesn't mean that final txs cannot be replaced.
Transaction replacement logic may happen outside of the tx publisher
components, which will change the txid and replace the existing attempts.
2022-01-04 14:28:34 +01:00
Pierre-Marie Padiou
1fd6344a5d
Define 9999-12-31 as max value for timestamps (#2118)
This effectively reverts #2112 and implements it differently.

Having a single very conservative max value is simpler and the risk of regression is very low. Also fixed a wrong comment, previous max wasn't `11/04/2262` but a huge value.
2022-01-03 16:00:38 +01:00
Bastien Teinturier
2827be875d
Make ClaimHtlcTx replaceable (#2102)
These transactions are much simpler than HTLC transactions: we don't add
new inputs, we just decrease the output amount and we can unilaterally sign
the updated transaction.
2022-01-03 15:18:51 +01:00
Fabrice Drouin
0b807d257a
Set max timestamp in API call to 9999/12/31 (#2112)
Previous value was 10001950-04-24 09:07:11+00 which is out of range for Postgresql.
9999 seems far away enough for most databases.
2021-12-20 19:54:34 +01:00
Thomas HUET
76936961f9
Fix potential loop in path-finding (#2111)
Use the amount WITHOUT the fees when computing the success probability of routing through an edge.
This fixes a problem where the computed probability could be negative, leading to a shorter path after adding an edge.
2021-12-20 17:00:57 +01:00
Thomas HUET
bf0969a308
Add defenses against looping paths (#2109) 2021-12-17 14:42:59 +01:00
Bastien Teinturier
8afb02ab97
Add payment hash to ClaimHtlcSuccessTx (#2101)
This can be useful to match a preimage to a given claim-htlc-success
transaction without going through the process of re-creating the transaction
from scratch.

We already include the payment hash in htlc-success transactions for that
reason.
2021-12-16 10:24:06 +01:00
Thomas HUET
c370abe5c3
Rate limit onion messages (#2090)
Rate limiting is applied per peer connection in both directions
2021-12-16 10:20:07 +01:00
Bastien Teinturier
ec132810a5
Add nightly build with bitcoind master (#2027)
We should regularly run against bitcoind master, to detect if a change to
bitcoind is affecting us.

This will let us detect changes that may break lightning before bitcoind
releases them, giving us a chance to rectify it.

We really don't want to run this workflow for every pull request or every
merge to master, we instead run it twice per week, which should give
us enough time to detect dangerous changes.
2021-12-15 17:13:57 +01:00
Anton Kumaigorodski
7e7de53d1d
Filter out non-standard channels from channelInfo API (#2107)
This change makes it possible for a non-standard channel to reply
with `CommandFailure` which in turn will be filtered out in `channelsInfo`.

The reason is that currently hosted channels have to return something
to make the whole API call succeed and whatever they return would
break external tools which only expect standard channel formats.
2021-12-15 16:25:25 +01:00
Bastien Teinturier
8ff7dc713a
Avoid default arguments in test helpers (#2108)
A few of our test helper functions started using too many default arguments,
which makes them a bit messy to use in tests, especially when we want to
add new arguments.

We change this to use method overloading instead, which makes it easier to
add new overloads without changes to existing tests.
2021-12-15 15:49:00 +01:00
Thomas HUET
3d88c43b12
Kill idle peers (#2096)
We may create connections to new peers for relaying onion messages but we don't want to keep them open for long.
2021-12-15 14:05:51 +01:00
Bastien Teinturier
576c0f6e39
Increase timeout onion message integration tests (#2106)
In channel tests, we set a 60 seconds timeout on the receiver end,
otherwise we sometimes run into timeout on slow CI machines that run a
lot of tests in parallel.

It makes sense to do the same for onion messages, to help us figure out
whether there is a race condition or it's just the machines that are slow.
2021-12-14 19:20:48 +01:00
Bastien Teinturier
4ebc8b5d6b
Notify node operator on low fee bumping reserve (#2104)
With anchor outputs, we need to keep utxos available for fee bumping.
Having enough on-chain funds to claim HTLCs in case channels force-close
is necessary to guarantee funds safety.

There is no perfect formula to estimate how much we should reserve: it
depends on the feerate when the channels force-close, the number of
impacted HTLCs and their amount.

We use a very rough estimation, to avoid needlessly spamming node operators
while still notifying them when the situation becomes risky.
2021-12-14 16:42:22 +01:00