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

164 Commits

Author SHA1 Message Date
Pierre-Marie Padiou
b061ea5efc Fixed bug in ignored channel computation (#472)
Also, renamed `getBlacklistedChannels` to `getIgnoredUpdates` and added
test.
2018-03-02 18:49:51 +01:00
Pierre-Marie Padiou
f0a877c78b Use bitgo API v2 to get network fees (#473)
Supports mainnet/testnet fees according to the configured chain.
2018-03-02 18:49:27 +01:00
Pierre-Marie Padiou
bb1d0e96cf added check on to_self_delay parameter (#470) 2018-03-02 11:25:03 +01:00
Fabrice Drouin
24dadff625 Improve key management (#372)
* generate all channel keys and secrets from the node key and channel number

* use a key manager
the key manager does not export private keys or secrets.
It exports public keys, and points, and provide methods to sign
transaction.
There is just one exception: it does export revocation secrets, since
we need to send them back when we receive a commitment signature.

* key management: cache private keys and public keys

* add key manager to node parameters

* create an interface for key manager
and an implementation which keeps private keys locally

* generate a new BIP32 key path for each new channel

When we create a new channel we generate a new random BIP32 key path
with 128 bits of entropy
2018-03-01 20:37:39 +01:00
Pierre-Marie Padiou
42fb9a90c1
Reworked routing algorithm (#461)
* use a `DirectedWeightedPseudograph`

Because we want a directed graph with multiple weighted edges between two
vertices, and loops allowed.

See discussion in [1] for more details.

* take node fee into account when finding route

Fees vary depending on the amount we want to send, so as a simplification
we use a default `DEFAULT_AMOUNT_MSAT`=`10000000` to compute edges weight.

This fixes #310.

* reuse the same graph for all payments

In `findRoute`, if we have specific updates to add/remove, we don't mutate
the main graph and create a copy instead.


[1]
http://jgrapht-users.107614.n3.nabble.com/Difference-between-a-directed-multigraph-and-a-directed-pseudograph-td4024788.html
2018-03-01 19:42:23 +01:00
Pierre-Marie Padiou
85592de0e5
Proper management of expiry-related errors (#469)
Make `Commitment` return `ExpiryTooSmall` and `ExpiryTooBig` when
appropriate, and don't do the check in the `Relayer`.

Be more restrictive when sending HTLCs, so that counterparty doesn't
close the channel when a block just appeared and there is temporarily a
1-block discrepancy between two peers.

Proper management of `FinalExpiryTooSoon` in the payment handler.

On top of that, added more tests and simplified some.
2018-03-01 18:48:54 +01:00
Pierre-Marie Padiou
203288c415
Rebroadcast only valid channel_update, always attach channel_announcements (#464) 2018-03-01 17:57:52 +01:00
Pierre-Marie Padiou
d510d08190 Publish a ChannelSignatureSent for each outgoing commitment sig (#467) 2018-03-01 13:53:14 +01:00
Pierre-Marie Padiou
8d387cee90 PaymentSucceeded adds fee in amountMsat, and contains paymentHash (#466) 2018-02-28 17:26:28 +01:00
Pierre-Marie Padiou
43128636ce Improvements & fixes (#459)
* moved CoinUtils to eclair-core to expose conversion methods

Parsing and converting string amount to BtcAmount objects, and
displaying BtcAmount as well formatted string is a common use case.
Methods that were developed for the gui module should be exposed from
eclair-core so that they can be reused elsewhere.

* increased timeouts in integration tests

* have bitcoin wallet and watcher use a separate client

* return more information on channel opening

* removed `storedChannels` from `Peer` constructor

1) so that they can be garbage-collected
2) that was a memory leak because closed channel would stay forever

* OpenChannel now accepts a feerate param for the funding Tx

User should be able to override the fee rate of the funding tx that he
sends when he opens a channel. This custom fee is entered as a fee rate
in satoshi per byte, and converted to a fee rate per kw.

The default value of this fee rate does not change, and still aims for
the funding tx to be included in a block within the next 6 blocks,
estimation which is made through the FeeProvider class.

* reworked payment events

and made sure we send events even when `PaymentLifecycle` disappeared, e.g.
when we restart right after having sent a payment.
2018-02-27 19:36:56 +01:00
Dominique
288dec3c00
Add detailed message to remote failures (#431)
A `FailureMessage` should include a detailed description. A `transformForUser` 
static method is also added to streamline the list of failures associated to a 
`PaymentFailure`.

In the GUI, the payment notification shows a message for each failed attempts
2018-02-27 17:28:46 +01:00
Pierre-Marie Padiou
3b5355bbf2
Prune on initial_routing_sync (#455)
* announcements are pruned before they are sent for `initial_routing_sync` (this was removed by #422)
* is now considered stale a channel that is older than 2 weeks and hasn't any `channel_update` younger than two weeks (again, before #422 we were more lax because of pre-validation pruning)
* pruning was rewritten without use of very expensive `exists` function
* we don't prune anymore on startup
* removed `ThrottleForwarder` and `WriteAckSender`, and handle both TCP read/write backpressure at the `TransportHandler` level, which is much more efficient (e.g. we don't serialize/encrypt outgoing data if OS buffer is already full, which saves RAM and CPU)
* added a simple priority management that reduces priority of routing announcements so that they don't block channel messages on `initial_routing_sync`
2018-02-26 15:22:44 +01:00
Pierre-Marie Padiou
7aca967e91
Better closing tx management (#423)
* call `doPublish` in `handleMutualClose`

That's more consistent with other closing scenarii, and we weren't
putting a `WatchConfirmed` in case of unexpected closing tx.

* store the unsigned closing tx along with sent `closing_signed`

So that we can identify txes based on txid when they are published,
instead of on their (malleable) signature.

* don't log publish error when tx is already in blockchain

* store the last signed closing tx during negotiation

And use it instead of our local commitment if channel fails before end of
negotiation.

* fixed `SYNCING`->`NEGOTIATING` transition

There were three bugs:
(1) we weren't re-sending our `shutdown`
(2) we were re-sending all previous `closing_signed` instead of restarting
  the negotiation
(3) there was even a bug in (2) since
1aee6e8c21

On top of that, had to implement changes as per
https://github.com/lightningnetwork/lightning-rfc/pull/36.

Note that this is unfinished, as there is a corner case where fundee
reuses previous `closing_signed` to compute its next closing fee, even if
it was just disconnected for possibly a long time and network fees have
changed a lot in the meantime.

* watch for closing tx published in `OFFLINE` and `SYNCING`

* added a tx json serializer

* use a separate list for each attempted negotiation

This allow us to properly handle restarting a negotiation after a
reconnect.
2018-02-26 13:23:04 +01:00
Anton Kumaigorodski
a065ae757f Added support for data loss protection option (#410)
* This is based on the `option-data-loss-protect` feature defined in BOLT 9.

* At reconnection, when the counterparty proves us that our commitment is outdated, we politely ask them to publish their commitment. This is done by adding a new state `WAIT_FOR_REMOTE_PUBLISH_FUTURE_COMMITMENT`, and introducing a new "future" remote commitment type, in addition to existing "current" and "next".

* Slightly changed the signature of `Helpers`.`claimRemoteCommitMainOutput` so that current/next/future commitments are all handled the same way.

* Made sure that we never publish our local commitment when we know it is outdated, as it would be a cheating attempt and would result in a total loss of funds.

* Support both optional/required modes for option `option_data_loss_protect`
2018-02-23 15:46:05 +01:00
Pierre-Marie Padiou
226aeb56d8
Minor fixes (#452)
* removed unused `WAITING_FOR_VALIDATION` state

* unwatch connection when peer is dequeued from `initial_routing_sync` waitlist

* Updated testnet electrum servers list

* Added error log in supervisor when throwable is caught

The default error logging does not log the stack.

* filter updates in one pass

* filter stale channels in one pass

* added `strategy` to supervisor logs

* add the downstream htlc to `Forward*` messages
2018-02-20 18:02:28 +01:00
Pierre-Marie Padiou
6b837ecbae
Better data structures (#451)
* make `listPeers` return a `Map`

* use `Seq` instead of `List` in db trait, and implement using `Queue`s
Append is a O(1) in `Queue` and O(n) in `List`.

* use a `Map` to store unacked incoming messages

* used `Vector` instead of `List` in decryption
2018-02-20 16:42:06 +01:00
Dominique
8684fb238b Removed BitcoinJ watcher (#447)
Added guava dependency which was previously bundled with bitcoinj.
2018-02-20 14:26:38 +01:00
pm47
1b247ae613 back to SNAPSHOT 2018-02-16 18:10:35 +01:00
pm47
0beca13b23 set version to 0.2-alpha10 2018-02-16 17:28:01 +01:00
Pierre-Marie Padiou
82803cab1d
Ignore 'tx already in block chain' errors when publishing a tx (#441)
And set more reasonable log levels in `ZmqWatcher`.
2018-02-16 17:22:03 +01:00
Pierre-Marie Padiou
57e4f54d3e
Improved queuing of initial_routing_sync requests (#440)
We now use a queue instead of relying on a scheduler that re-send the request.

Also, better management of dead connection, they get cleaned up and removed from the queue.
2018-02-16 17:01:39 +01:00
Pierre-Marie Padiou
b91e90783f
Replaced LoggingFSM -> FSM (#439)
And changed akka default log level from `DEBUG` to `INFO`.
2018-02-16 16:51:10 +01:00
Pierre-Marie Padiou
1aea66457a
Explicitely ack all relayed messages (#390)
In order to gracefully handle cases when the counterparty goes online while we are in
the middle of processing payments, we need to explicitely ack all
`fulfill`/`fail`/`fail_malformed` messages.

We previously only acked `fulfill` messages.

Also, we now fail timed out htlcs at the right time, which is:
- for dust htlcs, when the commitment tx reaches `min_depth`
- for non-dust htlcs, when the htlc-timeout or claim-htlc-timeout tx
  reaches `min_depth`

Moved preimage extraction to `Helper` file.

This fixes #376, #377 and #378.
2018-02-16 16:42:08 +01:00
Pierre-Marie Padiou
f3b746643d
Use TCP pull mode (#422)
We now use [akka tcp pull mode](https://doc.akka.io/docs/akka/2.5.3/scala/io-tcp.html#read-back-pressure-with-pull-mode) for both incoming and outgoing connections.

In combination with setting a relatively low value for `akka.io.tcp.max-received-message-size`, this results in less RAM consumption, in particular when validating a whole routing table.

Also improved the router:
- Removed the grouping of `channel_announcement` because batching is done lower in the stack, in the bitcoin json-rpc client. Channels are now validated as they arrive.
- Keep track of all origin peers for every announcement (instead of the first one), in order not to send back the same announcements to peers.
- Better choice of data structures, which increases constant time operation (but don't completely eliminate less efficient access)
- Reworked management of private/not-yet-announced channels
2018-02-16 15:49:34 +01:00
n1bor
17acf77a65 Persisted channel capacity an added fees and capacity to Channel GUI (#416)
* (gui) added channel fees (base and proportional) and capacity to the list 
of channels in network

* (gui) fixed issues with gui being updated from wrong threads

* channel capacity is now saved in network DB along with the tx id when
a channel is discovered. `ChannelDiscovered` now contains the capacity.

A compatibility check for the network DB is added in startup. This check is
separated from the node DB check because a network DB check failure is
less severe and the network DB file can be safely removed with no impact
on the node.
2018-02-12 17:28:21 +01:00
Dominique
0416784f08 TCPException message error should be defined (#401)
* TCPException sets a message when extending RuntimeException

If no message was set for the exception, a 'null' message was displayed to
the user when TCPException is thrown. Instead, we now display the exception class name.

This fixes #399.
2018-02-12 15:33:29 +01:00
Pierre-Marie Padiou
468bb5ebfb
Don't send duplicate INPUT_RECONNECTED to channels (#430) 2018-02-12 15:05:34 +01:00
Pierre-Marie Padiou
32d634c7f7
Batch requests to bitcoind json-rpc api (#429)
* added a batching client for bitcoind jsonrpc api

* convert json-rpc errors to exceptions in batching client
2018-02-07 16:58:11 +01:00
Pierre-Marie Padiou
b75962a57f
Store channel funding txid with announcements db (#421)
* store channel funding txid in network db

* directly load announcements from disk without re-validating them all

* use dedicated sqlite file for network announcements db

* re-send `ChannelDiscovered` and `NodeDiscovered` on startup

Also removed unused `ChannelDiscovered`.`capacity` field.

This should fix #415.
2018-02-06 18:18:47 +01:00
Dominique
6719c2d8f1
Added an optional seed to Setup (#424)
If this seed is not provided, it is generated and stored in a seed.dat file.
The electrum watcher uses this seed for its key.
2018-02-01 22:04:51 +01:00
practicalswift
7a6fa8a619 Fix typos (#417) 2018-01-29 18:42:07 +01:00
pm47
56ef710f06 back to SNAPSHOT 2018-01-23 19:11:06 +01:00
pm47
951bcc4750 set version to 0.2-alpha9 2018-01-23 15:29:21 +01:00
Dominique
af7d7b164a Various GUI Improvements (#396)
* (gui) Added funding tx id to channel panel

fixes #335

* (gui) close channel button hidden when CLOSING or CLOSED

fixes #332

* (gui) User can define a preferred display unit

On startup FxApp reads the configuration from `eclair.conf` and sets
a unit to which all the amounts in the UI must be converted.

This unit is a CoinUnit object. Only `sat`, `mbtc` and `btc` are accepted.
`msat` is not accepted because it's an internal accounting unit which
should be invisible to the user. Default unit is `btc`

The gui does not expose any ui feature to update this unit at runtime.

* (gui) Notification message wraps and can now be copied

Notification message should be readable especially when an error occurs.
The message can be copied for easier issue reporting.

* Payment attempts is limited to 1

* (gui) consistent order in status bar contextual actions

* (gui) fixed unit parsing

* (gui) added menu shortcuts

fixes #347

* Revert "Payment attempts is limited to 1"

This reverts commit 1f4168aacb.

* (gui) BtcAmount are convertible to raw big decimal without loss

Fix issue where the decimal part of a BtcAmount could be lost.
Millisatoshi is now accepted as a user preferred unit.

* Set a minimum htlc amount of 1 mSat by default

By default, the node configuration should be permissive and accept low
value payments. It is up to the node admin to set up a restrictive
configuration if he needs it.

* (gui) port in node uri is optional

* (gui) added reactive errors in open channel window

* (gui) format max pr amount to user preferred unit

* (gui) Payment Request QR should be uppercased

see #375

* (gui) added a conf for the gui module

* Added eclair.gui.unit option in README
2018-01-23 15:25:53 +01:00
Pierre-Marie Padiou
c86163cc81
Always check maxAttempts counter when receiving unparseable errors (#391)
We previously only checked this counter when receiving parseable failures
(of type `ErrorPacket`).

This would lead to infinite payment loop in certain cases.

This fixes #355.
2018-01-22 19:05:01 +01:00
Anton Kumaigorodski
f1191bf325 Make payment request expiry configurable (#341)
* Make payment request expiry configurable

* Add payment request expiry to test constants

* Remove outdated unpaid requests from LocalPaymentHandler

* Add max allowed number of pending requests

* Update request pruning code in LocalPaymentHandler, replace def with lazy val in PaymentRequest

* Make payment handler return an error when we are over `max-pending-payment-requests`
2018-01-22 16:55:58 +01:00
Dominique
aa90f94304
Include payment preimage in PaymentSent event (#374)
Payment preimage is important for the sender of the payment as it proves
that he actually paid the request. It must then be available from the
`PaymentSent` event.

(gui) Payment preimage column is added to the 'payments sent' table in Activity tab
2018-01-22 16:10:17 +01:00
Benoît Verret
1db673a631 Add getinfo to API help (#383) 2018-01-21 11:41:06 +01:00
Benoît Verret
c1f6102515 Make eclair-cli executable (#382) 2018-01-20 23:37:21 +01:00
Benoît Verret
d56ad99200 Indicate that wallet mode is needed before exiting (#368) 2018-01-16 16:34:09 +01:00
Benoît Verret
2804e8a919 Remove api.user (#370)
It is not verified in the code.
2018-01-15 21:21:54 +01:00
Dominique
6142d92cc1
Handle ipv6 addresses (#367)
* NodeURI can now handle ipv6 addresses

The address field in `NodeURI` is now a `HostAndPort` object. The reasoning is that `InetSocketAddress` is a network object and should not be directly used in an utility object. Using `HostAndPort` makes for a more readable and less bug prone code.

This especially helps with the parsing of ipv6 addresses which is more complex than ipv4. It also avoids a early lookup when the `NodeURI` object is created.

Deserialization to `NodeURI` now defaults to port 9735 if the port could not be found in the string.

fixes #343
fixes #346
2018-01-11 20:32:29 +01:00
Pierre-Marie Padiou
a1d69af597
Fixed eclair-cli (#354)
* reworked eclair-cli

* API is disabled by default, disabled CORS and require basic auth password

* better error handling

* Fixed latest version in README

* Increased connection timeout to 15s in electrum client test

* Rgb in NodeAnnouncement is now a Color object

Makes the color field more practical to handle and enable finer
serialization with a more readable code.

allnodes command in api now exports a list with node announcements.

* Added api call to list all the channels updates

This call can also filter the channels for a given nodeId

This fixes #344.
2018-01-11 19:23:17 +01:00
Pierre-Marie Padiou
a00fd96ca6
Fix memory leak and reduce overall memory usage (#365)
* added logs

* more efficient logging

* added huge bitcoin jsonrpc queue

* only publish/watch txes if needed when restarting in `CLOSING` state

* limit number of parallel routing state dump

* added a supervision strategy to authenticator hierarchy

* only forward Rebroadcast to connected peers

* rework management of `origins` in router

* explicitely close sqlite prepared statements

* fixed pruning logic

* send instead of forward announcement to router

* store txes that have reached `mindepth` in `CLOSING` state

* add a minimum 10s delay between two reconnection attempts

otherwise, this would frequently cause 2 successful parallel connections

* don't trigger a `NewBlock` event when receiving a new `WatchConfirmed`

Instead, just check this particular watch

* TransportHandler: fix typo when logging received data that has a bad prefix

* better handling of connection errors

* kill WriteAckSender when connection dies, don't send connection errors when auto connecting

* streamlined io actors

* handle parallel connections in peer

This fixes #357.
2018-01-11 13:09:16 +01:00
Fabrice Drouin
065de8bb5c Fix encoding of failure messages (#366)
* Fix encoding of failure messages (fixes #363)
When a failure message includes a channel update field, this field must be encoded as:
[ len | channel update] and we did not include the len field.

* add `ExpiryTooFar` failure message
2018-01-11 12:08:46 +01:00
pm47
74faad53e8 back to SNAPSHOT 2017-12-23 19:26:54 +01:00
pm47
8edb2a478c set version to 0.2-alpha8 2017-12-23 18:37:00 +01:00
Pierre-Marie Padiou
a3bdf52a2f
Improve logs (#320)
* always print `shortChannelId` in hex

* fixed logs in `ThrottleForwarder`

* logs the `paymentHash` when relaying an htlc

* don't print all channel data when restoring a channel

* added logs to relayer

* reduced log level in Peer

* cleaned up switchboard logs

* fixed `id`/`channelId` mixup in relayer logs

* slight changes in log levels

* do not log as warning when tx generation is simply skipped

* streamlined relayer logs

* improved router logs

* don't display errors when witness can't be parsed

* don't log connection errors as warnings

* reduce amount of logs in case of local known error

* removed reconnection message to deadletter

* try a cleaner way of displaying channel errors

* put some reconnection-related logs from info to debug

* peer: ignore `Rebroadcast` messages in `INITIALIZING`

* less verbose exception logging in channel

* display friendlier close type

* reduced default log level to INFO
2017-12-22 23:32:34 +01:00
Pierre-Marie Padiou
fe5416d2df Reworked peer management (#316)
* reworked peer management

- connection and channel opening are now separated, simplified
  `switchboard`

- use a single authenticator for both incoming and outgoing connections

- `peers` api call now returns current state and channel count

* fixed last commit

* fixed last merge

* added inetsocketaddress serializer
2017-12-22 23:06:35 +01:00
Pierre-Marie Padiou
c868d0bdc8 Pre-validation announcements pruning (#323)
* forget about channels older than 3 days and prune every minute

* Revert "forget about channels older than 3 days and prune every minute"

This reverts commit 347e01b5c18208f162b31663d383d5b7de36eea7.

* added pruning pre-validation

* don't pre-prune channels that don't have channel_update, but don't validate them either

* removed println

* removed useless handler

* cleanup announcement db at startup

* simplified pruning logic and re-enabled tests

* fix `getStaleChannels`

* fixed integration tests
2017-12-22 22:18:17 +01:00