1
0
mirror of https://github.com/ACINQ/eclair.git synced 2024-11-20 10:39:19 +01:00
Commit Graph

326 Commits

Author SHA1 Message Date
Pierre-Marie Padiou
a52acdcaf1
Auto probing of local channels (#762)
This is a simple mechanism to test our direct peers by sending fake
small payments to them. A probe is considered successful if the peer
replies with an `UnknownPaymentHash` error.

Probing is configurable and disabled by default.
2019-01-18 14:39:06 +01:00
araspitzu
d5fe47572c Compute k-shortest routes (#813)
We use Yen's algorithm to find the k-shortest (loopless) paths in a graph, and dijkstra as search algo.

We then pick a random route up among the cheapest ones.
2019-01-17 21:15:51 +01:00
Fabrice Drouin
74d454d904
Electrum: improve error handling (#825)
* Electrum: always stop clients when there's an error

We will automatically connect to another server, and it's much cleaner
that restarting right away

* Electrum: improve handling of server errors

* Electrum Pool: don't switch to our current master

In regtest (and probably testnet too) it may seem that our master server went
straight to current height + 2 when blocks are created very quickly, so
check first that the server is not already our master before we switch.
2019-01-17 20:59:06 +01:00
araspitzu
67dc37c525 Impose a max length of 32 bytes on UTF-8 encoded aliases (#828)
Co-Authored-By: araspitzu <a.raspitzu@protonmail.com>
2019-01-17 19:23:08 +01:00
n1bor
6438c65ad9 Add JSON serializer for PaymentRequest (#798)
Also, renamed `checkinvoice` to `parseinvoice`. `checkinvoice` still works but is deprecated.
2019-01-17 15:46:02 +01:00
araspitzu
6d638e9941
Fix findroute documentation (#817)
* Fix the README and help message about the 'findroute' API parameters
2019-01-16 18:35:53 +01:00
Dominique
e3b2992934
Readibility improvements in GUI (#801)
* Improved amounts readability (fixes #542) and added the Bits unit 
denomination in the documentation

* Improved channel panel UI layout

* Added a confirmation dialog when closing a channel, with a short summary 
of the channel to be closed

The balance bar has been shrunk in size so that it should not be mistaken as 
a separator element between channels. The channel's balance, capacity and 
peer node id are now more visible. Also added the short channel id to the 
channel's pane.

fixes #690

* Added node's aggregated balance in the status bar

fixes #775
2019-01-14 16:53:52 +01:00
Pierre-Marie Padiou
10ea7bdc23
Make ping less aggressive (#782)
* send pings only after there is less activity

* make disconnect-on-ping configurable
2019-01-11 19:16:37 +01:00
araspitzu
fd3ff9184e Compute routes backward (#797)
* Support searching backward from the target

* Use the amount+fees with testing for min/max htlc value of edges

* Build the adjacency list graph with incoming edges instead of outgoing

* Make sure we don't find routes longer than the max allowed by the spec

* Remove default amount msat, enhance 'findroute' API

* Optimize tests for ignored edges in Dijkstra

* Enhance test for max route length, fix the length to 20 channels

* Add test for routing to a target that is not in the graph (assisted routes)
2019-01-11 17:20:01 +01:00
araspitzu
83b464cfcc Fix short_channel_id parsing and add RPC API test (#815)
* Correctly parse short channel id

* Add test for RPC APIs

* Put akka.http.version in parent project pom

Co-Authored-By: araspitzu <a.raspitzu@protonmail.com>
2019-01-11 14:59:33 +01:00
Fabrice Drouin
e082d89a3b
Electrum: download, verify and store headers (#776)
* Implement "GetHeaders" RPC call

* Add checkpoints and pow verification

* Don't resolve server address too soon

* Add testnet checkpoints

* Store headers in a sqlite wallet db

* Use 1.4 protocol

Request protocol version 1.4 (this is the default setting in Electrum wallet).
Retrieve and store all headers as binary blobs in bitcoin format.

* Insert headers in batch

* Optimize headers sync and persistence

We assume that there won't be a reorg of more that 2016 blocks (which
could be handled by publishing a new checkpoint) and persist our headers
except for the last 2016 we have received: when we restart, we will ask
our server for at least 2016 headers.

* Persists transactions

Transactions are persisted only when they've been verified (i.e. we've receive
a valid Merkle proof)

* Disable difficulty check on testnet and regtest

On testnet there can be difficulty adjustements even within a re-targeting window.

* Update checkpoints

* Use proper Ping message

`version` can not longer be sent as a ping as we did before.

* Don't ask for Merkle proofs for unconfirmed transactions

* Improve startup time

We now store a new checkpoint and headers up to that checkpoint as soon as our
best chain is 2016 + 500 blocks long

* Properly detect connection loss

* Update electrum mainnet servers list

Using the list from Electrum 3.3.2

* Don't open multiple connection to the same Electrum servers

We want to keep connection to 3 different servers, but when we have less than 3 different
addresses it's pointless to attempt to keep maintain 3 connections.
2019-01-11 14:08:46 +01:00
Pierre-Marie Padiou
52f671384e
Detect broken HTLC links at startup (#757)
If we have stopped eclair while it was forwarding HTLCs, it is possible
that we are in a state were an incoming HTLC
was committed by both sides, but we didn't have time to send
and/or sign the corresponding HTLC to the downstream node.

In that case, if we do nothing, the incoming HTLC will
eventually expire and we won't lose money, but the channel
will get closed, which is a major inconvenience.

This check will detect this and will allow us
to fast-fail HTLCs and thus preserve channels.
2019-01-04 17:34:50 +01:00
araspitzu
75a18e2446 Set a max value of 2016 blocks for to_self_delay (#795)
This will be a hard requirement in BOLT 1.1
2019-01-03 16:59:26 +01:00
Pierre-Marie Padiou
ad31d89e54
Disable local channels below reserve (#763)
The goal is to reduce attempts from other nodes in the network to use
channels that are unbalanced and can't be used to relay payments.

This leaks information about the current balance and is a privacy
tradeoff, particularly in this simplistic implementation. A better way
would be to add some kind of hysteresis in order to prevent trivial
probing of channels.
2019-01-03 14:02:39 +01:00
Pierre-Marie Padiou
9da330478a
Add exclusive locks to channels sqlite db (#781)
* added an exclusive write lock to channels sqlite db

* added close() method in db traits
2019-01-03 11:01:53 +01:00
Pierre-Marie Padiou
8887ac2043
Relay fail message *after* it is cross-signed (#754)
We were previously handling `UpdateFailHtlc` and
`UpdateFailMalformedHtlc` similarly to `UpdateFulfillHtlc`, but that is
wrong:
- a fulfill needs to be propagated as soon as possible, because it
allows us to pull funds from upstream
- a fail needs to be cross-signed downstream (=irrevocably confirmed)
before forwarding it upstream, because it means that we won't
be able to pull funds anymore. In other words we need to be absolutely
sure that the htlc won't be fulfilled downstream if we fail it upstream,
otherwise we risk losing money.

Also added tests.
2019-01-02 16:44:05 +01:00
araspitzu
7f3b101426 Use BOLT specific formatting for short channel id (#793) 2019-01-02 14:40:24 +01:00
araspitzu
255c280bd0 Routing: use custom implementation for the shortest path algorithm and the graph (#779)
* Consider htlc_minimum/maximum_msat when computing a route

* Compare shortChannelIds first as it is less costly than comparing the pubkeys

* Remove export to dot functionality

* Remove dependency jgraph

* Add optimized constructor to build the graph faster

* Use fibonacci heaps from jheaps.org

* Use Set instead of Seq for extraEdges, remove redundant publishing of channel updates

* Use Set for ignored edges
2018-12-20 16:52:42 +01:00
Dominique
be5d188a38
Tweak parameters to optimize ElectrumClient connections (#788)
* use TCP_NODELAY and PooledByteBufAllocator

* added reference to interesting slidedeck
2018-12-20 14:14:23 +01:00
Dominique
a80ff1f6d9 Cleaned up mainnet electrum servers list (#786) 2018-12-18 17:21:28 +01:00
Dominique
521aa8adcd Share NioEventLoopGroup across Electrum clients (#783)
`NioEventLoopGroup` is expensive to create and should be shared with all clients. This also prevents issues when several event loop groups are created and are not shutdown correctly.
2018-12-14 11:44:11 +01:00
Pierre-Marie Padiou
723d0deed2
Optional per-node features in conf (#778)
Allow setting specific `globalfeatures` and `localfeatures` for given nodes.
2018-12-12 16:02:51 +01:00
Anton Kumaigorodski
4573d8a1e0 Make maxHtlcValueInFlight checks directional when sending and receiving HTLCs (#768) 2018-12-12 15:59:31 +01:00
Pierre-Marie Padiou
b5c96f0439
Update connection-level features at reconnection (#765)
Previously we weren't updating them since the channel creation, which
was wrong: both local and remote features may change after a
reconnection.
2018-12-12 15:12:17 +01:00
Pierre-Marie Padiou
ff588b578f
Use netty to connect to Electrum servers (#774)
* replaced akka.io by netty in electrum client and enabled ssl support

* updated docker-testkit to 0.9.8 so that electrum tests pass on windows

* use ssl port on testnet/mainnet

* removed experimental warning on electrum
2018-12-11 18:13:38 +01:00
Pierre-Marie Padiou
99566f525c
Disconnect peer after a timeout when waiting for revocation (#761)
* added a revocation timeout

If a peer doesn't quickly reply to a `commit_sig`, we assume that it is
experiencing technical issues, and we disconnect. This will make pending
(unsigned) `update_add_htlc` to be fast-failed and will hopefully limit
the number of htlc that time out in the network.

By default we wait 20 seconds, configurable with
`eclair.revocation-timeout`.

This fixes #745.
2018-12-07 14:49:51 +01:00
rorp
fadfabfd33 Wait for Router to be initialized at startup (#769) 2018-12-04 15:37:52 +01:00
Pierre-Marie Padiou
1c0e24a909
Watch future remote commit on restore (#766)
We need to put back watches on restart in "future remote commit published" scenarii, otherwise we will never consider the channel closed if we restart before the "claim main output" tx is confirmed. Note that there was no risk of losing funds, but the channel would have lingered forever.
2018-11-23 16:38:07 +01:00
Pierre-Marie Padiou
fa1b2e4c00
Switch sttp backend async-http-client -> okhttp (#764)
Okhttp works better on Android.
2018-11-23 11:58:23 +01:00
Anton Kumaigorodski
65a854caf3 Disconnect peer if it does not reply to pings (#755)
* Also ignore invalid pings
2018-11-20 14:03:46 +01:00
n1bor
738b4fa8e9 Reject received payments where PaymentRequest Expiry Tag time has been exceeded. (#749)
This fixes #748.

Also renamed htlc `expiry` to `cltvExpiry`. This removes confusion between different types of expiries and is how the spec is written.
2018-11-15 14:08:27 +01:00
Jens Schendel
93464aa7fb Updated readme.md and eclair-cli (#750)
* Minor changes. Typos and grammar corrected.

* Added check for curl and hint ift not installed
2018-11-13 17:35:16 +01:00
Pierre-Marie Padiou
2de7c6b07d
Use sttp lib instead of akka-http-client (#720)
Also updated json4s-jackson to 3.6.0
2018-10-25 16:45:27 +02:00
Fabrice Drouin
5141cd7d4d
Use different ZMQ block and tx subscriptions
Fixes #733
2018-10-25 14:28:28 +02:00
Dominique
3a221e7e98
Support for custom Electrum server (#739)
We can now use the `overrideDefaults` parameter in `Setup` to programmatically 
provide a custom electrum address when starting eclair, by setting the 
`eclair.electrum.host` and `eclair.electrum.port` entries in the configuration.

When these entries are set, eclair-core will always try to connect to this server
instead of relying on a random server picked from the preset lists.
2018-10-23 19:07:20 +02:00
Pierre-Marie Padiou
2bdf258c78
Always add 1 block to the finalCltvExpiry (#742)
This fixes #651.
2018-10-23 17:31:22 +02:00
sstone
4e0702a923
set version to 0.2-SNAPSHOT 2018-10-20 21:38:16 +02:00
sstone
52821b8664
set version to 0.2-beta8 2018-10-20 21:34:34 +02:00
Fabrice Drouin
6126ed4b9e
Fix encoding of FinalIncorrectHtlcAmount error message (#740) 2018-10-19 17:58:20 +02:00
Pierre-Marie Padiou
c77c276c77
Add htlcMaximumMsat field to ChannelUpdate message (#738)
* Add `htlcMaximumMsat` field to `ChannelUpdate` message

* added compatibility test with c-lightning
2018-10-19 17:47:13 +02:00
sstone
b0305b0551
set version to 0.2-SNAPSHOT 2018-10-15 17:00:40 +02:00
sstone
c564f51d24
set version to 0.2-beta7 2018-10-15 16:48:13 +02:00
Pierre-Marie Padiou
22b6bfb0ab
Only persist trimmed htlcs (#724)
We persist htlc data in order to be able to claim htlc outputs in
case a revoked tx is published by our counterparty, so only htlcs
above remote's `dust_limit` matter.

Removed the TODO because we need data to be indexed by commit number so
it is ok to write the same htlc data for every commitment it is included
in.
2018-10-15 14:46:51 +02:00
Pierre-Marie Padiou
892770b1ed
Update scalatest and remove junit runner (#728)
* updated to scalatest 3.0.5

* use scalatest runner instead of junit

Output is far more readable, and makes console (incl. travis) reports
actually usable.

Turned off test logs as error reporting is enough to figure out what
happens.

The only downside is that we can't use junit's categories to group
tests, like we did for docker related tests. We	could use nested suites,
but that seems to be overkill so I just removed the categories. Users
will only have the possibility to either skip/run all tests.

* update scala-maven-plugin to 3.4.2

NB: This requires maven 3.5.4, which means that we currently need to
manually install maven on travis.

Also updated Docker java version to 8u181 (8u171 for compiling).
2018-10-11 19:01:41 +02:00
Fabrice Drouin
d490480b7e
Simplify bitcoind version check (#731)
Bitcoind returns version as MMmmrr (major, minor, revision), use an int representation
and compare it to our minimum version target.
2018-10-11 18:54:12 +02:00
sstone
997aceea82
set version back to 0.2-SNAPSHOT 2018-09-26 14:05:57 +02:00
sstone
3fc5da0a7b
set version to 0.2-beta6 2018-09-26 14:04:38 +02:00
Fabrice Drouin
b07bb2a39e
Logging: use a rolling file appender (#721)
* Logging: use a rolling file appender

Use one file per day, keep 90 days of logs with a total maximum size
capped at 5 Gb

* Router: log routing broadcast in debug level only
2018-09-24 20:00:36 +02:00
Pierre-Marie Padiou
f38748c0b6
Fixed regression caused by 7a4f175 (#722)
When updating relay fee in state OFFLINE, the new channel_update must
have the disabled flag on.

This caused tests to be flaky, added necessary checks to always make
them fail in case that kind of regression happens again.
2018-09-24 19:41:27 +02:00
Pierre-Marie Padiou
7a4f175f2f
Handle update relay fee in OFFLINE state (#719)
Previously it was only possible to update relay fee in NORMAL state,
which is not very convenient because most of the time there are always
some channels in OFFLINE state.

This works like the NORMAL case, except that the new `channel_update`
won't be broadcast immediately. It will be sent out next time the
channel goes back to NORMAL, in the same `channel_update` that sets the
`enable` flag to true.

Also added a default handler that properly rejects the
CMD_UPDATE_RELAY_FEE command in all other states.
2018-09-24 13:59:01 +02:00