1
0
Fork 0
mirror of https://github.com/ACINQ/eclair.git synced 2025-03-14 11:58:19 +01:00
Commit graph

1670 commits

Author SHA1 Message Date
pm47
3d864c2d59
Merge branch 'master' into android 2019-02-19 11:08:43 +01:00
Fabrice Drouin
c0af665990 Electrum fixes and improvements (#873)
* Electrum: don't ask for merkle proofs for unconfirmed txs

* Electrum: clear status when we get disconnected and still have pending history transactions

When we get disconnected and have script hashes for which we still have pending connections,
clear the script hash status. When we reconnect we will ask for its history again, this way we
won't miss anything. Since we rotate keys it should not result in heavy traffic (script hashes have
few history items).

* Electrum: represent and persist block heights as 32 bits signed ints

Int.MaxValue is about 40,000 years of block which should be enough, and it will fix the encoding
problem users on testnet when there's a reorg and one of their txs has a height of -1.

Side-note: changing the wallet codec can be done easily: if we cannot read and decode persisted data
we just start with an empty wallet and retrieve all wallet data from electrum servers, and once it's
ready it will be encoded with the new codec and saved.

* Electrum persistence: include a version number

It provides a clean way, when upgrading the app, of choosing whether to keep the same version and start from the
last persisted wallet (if the persistence format has not been changed or is compatible with the old one), or to
change the version and force starting from an empty wallet and downloading all wallet items from Electrum servers.

* ElectrumClient: remove useless buffer
2019-02-19 11:06:36 +01:00
Pierre-Marie Padiou
aeb4360464
Fixed computation of available balance (#868)
There was a unit mismatch. Added a test.
2019-02-18 18:48:01 +01:00
sstone
040c93225a
Merge branch 'master' into android 2019-02-15 17:10:09 +01:00
Pierre-Marie Padiou
7ae083ae29
Faster gui startup (#863)
The GUI took a very long time to startup because nodes and channels were
stored in javafx `ObervableList` which doesn't allow random access. We
can't easily use `ObservableMap` because `TableView` do not support
them.

As a workaround, created an `IndexedObservableList` which keeps track of
indices in `ObservableList` so that we can still have fast random
access.

Also, now grouping announcements in `NetworkEvent` instead of sending
them one by one.
2019-02-14 15:01:19 +01:00
dpad85
e2b814cf4d
Back to development version 2019-02-14 12:15:54 +01:00
dpad85
5394f0716b
Release v0.2-android-beta16
This is the version used by eclair-mobile v0.3.19 (code 35).
2019-02-14 12:12:41 +01:00
dpad85
12412c5565
Actively clean the routing table in payment lifecycle
On android there are some cases where we are not aware that a local public
channel as in fact been closed. If this happens we will tell the router to
forget about it.

If the channel is in fact still alive, we will get it again via network
announcements anyway.
2019-02-14 11:58:17 +01:00
pm47
3ab935c468
don't verify public keys loaded from network.db 2019-02-12 21:26:51 +01:00
pm47
0fa5c0eda3
Merge branch 'master' into android 2019-02-12 20:38:26 +01:00
Pierre-Marie Padiou
57a9e6ed86
Support all-uppercase payment requests (#862) 2019-02-12 20:37:53 +01:00
pm47
9fac6e42a9
added electrum background checker 2019-02-12 19:40:25 +01:00
pm47
a86da82bb6
Merge branch 'master' into android 2019-02-12 17:36:33 +01:00
araspitzu
efa42f5967 Make sure the path-finding algorithm can't use a channel twice in a route (#857)
* Make sure the path-finding algo can't go backward when searching
2019-02-12 15:49:19 +00:00
Pierre-Marie Padiou
e0e958320d
Using bitcoin-lib 0.9.19 (#861) 2019-02-12 16:15:32 +01:00
araspitzu
94c1c36252 Fix discrepancy between config keys (#860) 2019-02-12 10:39:23 +00:00
pm47
8879fe4360
Merge branch 'master' into android 2019-02-11 19:56:51 +01:00
Pierre-Marie Padiou
884812ade0
Reimplemented BOLT 11 with scodec (#856) 2019-02-11 19:45:56 +01:00
araspitzu
4291bef88d Parametric route search (#844)
* Enable searching for routes with size/CLTV/fee limits

* Expose the RouteParams in RouteRequest

* Expose the RouteParams in SendPayment

* Rename DEFAULT_ROUTE_MAX_LENGTH

* If we couldn't find a route on the first attempt, retry relaxing the restriction on the route size

* Avoid returning an empty path, collapse the route not found cases into one

* When retrying to search for a route, relax 'maxCltv'

* Move the default params for route searching in the conf, refactor together router params into a config class

* Remove max-payment-fee in favor of router.search-max-fee-pct

* Group search params configurations into a block

* Rename config keys for router path-finding
2019-02-11 17:30:04 +00:00
pm47
6c7b5ea21a
Merge branch 'master' into android 2019-02-08 16:38:38 +01:00
Dominique
b29874ea70 Increased max-to-local-delay-blocks to 2016 (#853)
Max CLTV of 2016 agreed in 2018 Adelaide's meeting for 1.1 specs.
2019-02-08 15:11:21 +01:00
Pierre-Marie Padiou
fe48e5540c
Stop disconnected peer when it has no channels (#840)
When we are disconnected and we don't have any channel with that peer,
we can stop it and remove its address from db.

We also need to handle the case where we are in `DISCONNECTED` or
`INITIALIZING` state and we are notified that the last channel we had
with that peer just got closed.

Note that this opens a race condition in the switchboard, if we receive
an incoming connection from that same peer right after we stopped it,
and before the switchboard received the `Terminated` event. If that
happens, then `Peer.Connect` or `Peer.OpenChannel` will timeout. We
could also have the switchboard listens to deadletter events, but that
seems a bit over the top.

Also, removed switchboard's map of peers. Instead, we use the actor's 
children list, and access peers using the recommended `child()` method.
Now the 'peers request only returns an `Iterable` instead of a `Map`. This 
removes the need to watch child actors, and thus removes the race
condition when peers were stopped. As a trade-off, peer lookup is now
in O(log(N)) instead of O(1) (with N being the number of peers), but this
seems acceptable.
2019-02-08 13:29:46 +01:00
Fabrice Drouin
9f6d07ae44 Improve Electrum start-up time (#848)
Persist a partial view of our wallet to enable faster startup time.

Users will be able to create transactions as soon as we've checked that we're connected to a "good" electrum server. In the unlikely event where they were able to create and try to publish a transaction during the few seconds it took to finish syncing and their utxo was spent (because they were trying to use an unconfirmed utxo that got double spent, or if they spent their utxo themselves from another wallet initialized with the same seed  while his one was offline), publishing the tx will fail. 

* Electrum: persist wallet state

Wallet state is persisted and reloaded on startup.

* Electrum wallet: fix handling of headers chunk

When we receive a tx that is older than our checkpoints, we download and check
the header chunk that it's in, check it and connect it to our chain.

* Electrum: advertise wallet transactions

Send notifications for all wallet transactions once we're connected and synced

* Electrum: add timestamp to wallet events

Add an optional timestamp to TransactionReceived and TransactionConfidenceChanged, which is the timestamp of the block the tx was confirmed in (if any).

* Electrum client: use a Close message

This will fix concurrency issues where handlers are called when the actor
is already stopped.
2019-02-08 11:28:38 +01:00
Dominique
267037a937
Add balance and channel lifecycle events to the audit db (#827)
Note that balance events are logged at most once every 30s, and only when
the balance actually changes (e.g. won't log if a payment is failed).

Also, only send `AvailableBalanceChanged` when needed.

We were sending this event everytime we sent a `commit_sig`, which is
incorrect because our balance doesn't change if, say, we are signing an
incoming htlc.

Note that we only send this event in `NORMAL` state, not in `SHUTDOWN`
state, because the balance is not really _available_ in the latter.
2019-02-08 10:41:09 +01:00
rorp
808bf14d20 Support for Tor onion services (#736)
This includes support for hosting onion services, and connecting to them, which are two separate things:
- Opening an onion service implie interacting with the tor daemon controller, which requires authentication. We support both `SAFECOOKIE` and `HASHEDPASSWORD` authentication mechanisms, with a default to `SAFECOOKIE`. We support v2 and v3 services, with a default to v3 as recommended by the tor project.
- Connecting to onion services requires tunnelling through tor's local SOCKS5 proxy.

Incoming and outgoing tor connections are thus separate matters that needs to be configured independently. A specific documentation has been added to guide users through these steps.

Big thanks to @rorp for doing the heavy lifting on all this!
2019-02-08 10:18:59 +01:00
araspitzu
968961248e
Allow to disable route randomization via configuration (#851)
* Allow to enable/disable the route randomization feature from the configuration

* Move router related configuration keys in router block.
2019-02-05 17:35:47 +01:00
araspitzu
3165f5dc36
(Router) Always select direct channel if there is one to the target (#850)
During route searching, bypass the route randomization to always select the direct channel if there is one to the target.
2019-02-05 14:00:31 +01:00
Pierre-Marie Padiou
1da0017311
Proper handling of gossiped channels being spent (#838)
While it makes sense to exclude from the routing table channels for
which there is a spending tx in the mempool, we shouldn't blame our
peers for considering the channel still opened if the spending tx hasn't
yet been confirmed.

Also, reworked `ValidateResult` with better types. It appears that the
`NonexistingChannel` error wasn't really useful (a malicious peer would
probably point to an existing funding tx, so there is no real difference
between "txid not found" and "invalid script"), so it was replaced by
`InvalidAnnouncement` error which is a more serious offense (punished
by a disconnection, and probably a ban when we implement that sort of
things).
2019-01-31 16:03:01 +01:00
pm47
79a8ff4717
set default to-remote-delay-blocks to 2016 blocks
This allows the device to be offline for two weeks without risking to be
cheated on.

NB: 2016 is the max possible value since BOLT 1.1
2019-01-30 15:24:22 +01:00
araspitzu
4db9c8daf7 Optional route randomization (#842)
* Make route randomization optional (enabled by default), option is exposed in SendPayment/RouteRequest

* Fix non deterministic behavior in IntegrationTest
2019-01-30 15:21:22 +01:00
pm47
1de64c7ea7
re-enabled htlc data persistence 2019-01-30 14:07:36 +01:00
pm47
fac6707e3e
merged from master 2019-01-30 13:27:18 +01:00
pm47
6b1cca59c6
moved zmq to origin package 2019-01-30 13:07:06 +01:00
Pierre-Marie Padiou
7ff694c711
Ignore reconnections requests to the same peer with the same address (#835)
* ignore reconnections requests to the same address

* don't wait 1s before connecting on restart
2019-01-29 18:38:41 +01:00
rorp
a91cd631e8 Replace initialization futures Future[Boolean] by Future[Done] (#836)
Fixes #772.
2019-01-29 10:25:11 +01:00
Pierre-Marie Padiou
3954e39bf8
Set timestamp filter lower bound to current time (#837)
We previously assumed that the `gossip_timestamp_filter` only applied to
future messages, so we set `first_timestamp` to 0 in order to have a
pass-all filter.

But BOLT 7 actually says that the remote peer:
> SHOULD send all gossip messages whose timestamp is greater or equal to
first_timestamp, and less than first_timestamp plus timestamp_range

Which means that the way our filter was set, the remote peer would dump
the entire routing table on us.

By setting `first_timestamp` to the current time, we achieve what we
want. The synchronization of older messages is done by sending a
`query_channel_range` and then one or several `query_short_channel_ids`.
2019-01-28 15:58:35 +01:00
sstone
0631d11923 Remove akka-http dependency 2019-01-25 14:50:55 +01:00
sstone
a7ad4de72d Merge branch 'master' into android 2019-01-24 11:01:59 +01:00
pm47
a331a69406
Merge branch 'master' into audit-extended 2019-01-24 10:25:39 +01:00
Fabrice Drouin
629cb22192
ChannelSelectionSpec: use akka.event.NoLogging (#834)
akka.http.impl.util.DefaultNoLogging is not available in akka 2.3 which we use on Android.
2019-01-23 21:18:48 +01:00
araspitzu
3953bc400e Fix flaky test in IntegrationSpec (#832) 2019-01-22 17:49:11 +01:00
pm47
e7415a2a7c
Merge branch 'master' into audit-extended 2019-01-22 10:52:08 +01:00
Pierre-Marie Padiou
3aa5754490
Relay to channel with lowest possible balance (#784)
* relay to channel with lowest possible balance

Our current channel selection is very simplistic: we relay to the
channel with the largest balance. As time goes by, this leads to all
channels having the same balance.

A better strategy is to relay to the channel which has the smallest
balance but has enough to process the payment. This way we save larger
channels for larger payments, and also on average channels get depleted
one after the other.

* added tests...

...and found bugs!

Note that there is something fishy in BOLT 4, filed a PR:
https://github.com/lightningnetwork/lightning-rfc/pull/538

Also, first try of softwaremill's quicklens lib (in scope test for now)

* minor: fixed typo (h/t @btcontract)
2019-01-21 22:08:58 +01:00
pm47
3279226902
Merge branch 'relay-to-smaller-channel' into audit-extended 2019-01-21 19:14:47 +01:00
sstone
3f72b441d8
Set version to 0.2-SNAPSHOT 2019-01-18 20:15:04 +01:00
sstone
eb0e45a8b1
set version to 0.2-beta9 2019-01-18 19:01:59 +01:00
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
rorp
17e01c4bcf Update bash auto-completion file (#811) 2019-01-18 13:45:33 +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