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

1226 commits

Author SHA1 Message Date
Pierre-Marie Padiou
28037ea8fe
Added more methods in API (#281)
* can use `channelId` or `shortChannelId` in API for methods `channel` and `close`

* can now list channels to a particular `nodeId` in API
2017-12-15 15:05:22 +01:00
pm47
f1afe3f4b7 back to SNAPSHOT 2017-12-14 18:22:39 +01:00
pm47
1155788b5e set version to 0.2-alpha7 2017-12-14 12:28:25 +01:00
Fabrice Drouin
6957de31b5 Implement change in BOLT11 r field (#277)
* update link to bolt11 spec

* BOLT11: implement change in r field
see https://github.com/lightningnetwork/lightning-rfc/pull/317
2017-12-13 15:38:02 +01:00
Pierre-Marie Padiou
c43c009f94
Catch channel errors in relayer (#276)
The `relayer` was missing failures sent by the `channel`, which led to `htlc` lingering without being failed. Sender would see payments stuck in `PENDING` state until they eventually timeout and cause the channel to be unilaterally closed.

This is a regression caused by f47ea72369.

This fixes #264.
2017-12-12 16:12:05 +01:00
Pierre-Marie Padiou
5916dd6a05
Handle corner case when relaying to an unknown channel (#275)
The `relayer` wasn't correctly handling failures from the `register`, which led to `htlc` lingering without being failed. Sender would see payments stuck in `PENDING` state until they eventually timeout and cause the channel to be unilaterally closed.

This is a regression caused by f47ea72369.
2017-12-12 12:30:55 +01:00
Dominique
07f0cbeaab [GUI] Set default unit to milliBTC (#268)
* (gui) Default unit should be milliBTC

* Default unit set to MILLI_BTC

* Added tests to String amount conversion function

* Added BTC unit

* Removed milliSatoshi unit when opening a channel

* Removed redundant dependency and added a unit test
2017-12-11 19:19:55 +01:00
Pierre-Marie Padiou
4acfed364e Reduce default fees (#267)
* set more reasonable defaults for routing fees

* removed useless pluginManagement entry
2017-12-08 16:24:43 +01:00
Nicolas Dorier
d0da3d3899 Docker: can now set configuration and expose datadir, added doc (#256) 2017-12-08 15:36:50 +01:00
Dominique
559779f046 (gui) Units are now set from CoinUtils values (#261)
Fixes #260 where units could mismatch and a string amount would not be parsed
2017-12-07 18:49:03 +01:00
pm47
44f7bd7145 bcak to SNAPSHOT 2017-12-06 19:19:30 +01:00
pm47
3d240f5761 set version 0.2-alpha6 2017-12-06 18:34:40 +01:00
Pierre-Marie Padiou
ffb92831e1 Removed default values for commitid in pom (#258)
This is a regression caused by 0794fb8d5a,
because default values provided for `git.commit.id` `git.commit.id.abbrev`
are not overriden by git-commit-id-plugin plugin.

Instead we specify these variables when doing the docker build.
2017-12-06 16:10:22 +01:00
Dominique
46b2af1c26
Removed 'hsmiths' from electrum testnet servers (#257) 2017-12-06 15:46:59 +01:00
Pierre-Marie Padiou
ee7038c7a6
Rework mutual closing (#247)
* include raw tx when sig check fails

See BOLT 1 recommendation:

"when failure was caused by an invalid signature check:

    SHOULD include the raw, hex-encoded transaction in reply to a
    funding_created, funding_signed, closing_signed, or commitment_signed
    message."

 Also, removed redundant signature check in state
 `WAIT_FOR_FUNDING_SIGNED`.

* enforce closing fee <= commitment fee

In accordance to BOLT 2.

Note that it is safe to consider feerates instead of fees, because
weight(closingTx) < weight(commitTx).

This fixes #243.

* use channel logger in Helpers.scala and Commitment.scala

* handle multiple closing txes

Nothing prevents the counterparty to publish any or several of the closing txes
before the negotiation is finished, we need to handle this case.

This fixes #245.

* added msg+state when chanel failure occurs

* proper handling of invalid closing sig

* removed hardcoded error messages in channel

* return an `error` to sync attemps when in CLOSING

* peer now return an error for unknown channels

* added fee negotiation details in logs

* properly display errors, reject closing fee to high
2017-12-06 13:53:09 +01:00
Pierre-Marie Padiou
f47ea72369
Correctly translates and relay channels errors (#230)
* return `UnknownNextPeer` when next channel is unknown

* correctly relay channels errors (fixes #227)

* keeping `channel_update` in DATA_NORMAL

* moved class `ForwardLocalFail`->`AddHtlcFailed`

* made `AddHtlcFailed` a `ChannelException`

* unannounced channels now return `channel_update` in errors

* use remote `htlc_minimum_msat` in `channel_update`

also set default `htlc-minimum-msat`=`10000`

This fixes #248.

* Announce short channel id when funding depth ok

* added logs to router

* channel do not send `node_announcement` anymore
2017-12-06 13:32:06 +01:00
Nicolas Dorier
0794fb8d5a Docker support with repeatable build (#255)
Dependency to `git` has been removed, we now use `notag` when building without
a git directory.

In order to reliably fetch all dependencies, we do a first blank build
(with no source files), then we copy the sources and do a real commit.

This is a simpler and more robust approach.

Also, fixed the .dockerignore to filter out IDE files.
2017-12-05 17:29:47 +01:00
Pierre-Marie Padiou
5f6987bc1a Add test on signing a single Updatefee with no other updates (#254)
* Added a test on updatefee with no changes

* Fixed test logs: Akka slf4j logger was unset by 71f39a033b

* Closes #242 (can't reproduce)
2017-12-04 18:41:39 +01:00
Dominique
82c5b676e6
Unified cltv expiry type to Long (#253) 2017-12-04 17:37:11 +01:00
Dominique
71f39a033b Moved akka conf to eclair-node application.conf (#252)
Overriding configuration of dependencies must be done at the application level.
2017-12-04 13:31:05 +01:00
pm47
5b2fbb1bb2 re-added the '-no-link-warnings' option
But this time to `scaladoc` compiler.
2017-12-03 20:33:36 +01:00
pm47
1f36e8261e Revert "added '-no-link-warnings' compiler option"
This reverts commit 552fcd3a73.
2017-12-03 18:56:55 +01:00
pm47
552fcd3a73 added '-no-link-warnings' compiler option
This removes warning due to scaladoc, see:
http://www.scala-archive.org/Scaladoc-2-11-quot-throws-tag-quot-cannot-find-any-member-to-link-td4641850.html
2017-12-03 18:35:53 +01:00
pm47
1c7f66bf5b updated plugin versions 2017-12-03 18:05:47 +01:00
pm47
6e37586f9e disabled debug mode in default logback.xml 2017-12-01 18:42:50 +01:00
Dominique
b2c684a0da
Added the maven command to build eclair-node only (#250)
Also favouring `install` instead of `package`
2017-12-01 13:56:01 +01:00
Fabrice Drouin
84a9d73413 Disable dust limit checks on regtest and testnet (#249)
* disable dust limit checks on regtest and testnet

* fundee should also check dust limit they received open_channel (see #236)

* channel state tests: accept optional node parameters
use defaults if not provided
2017-12-01 11:18:16 +01:00
Dominique
44e7c3ba31 Handling optional amount in a Payment Request (#241)
* Enable generation of a payment request without amount

The amount field in a `PaymentRequest` was already optional but eclair
did not permit the generation of such a request.

Added a new `receive` service with no required amount field.

In the GUI, the parsing of the amount field and its conversion to
`MilliSatoshi` are reworked to better handle decimals.

* (gui) Amount's can be overriden when sending a payment request

The amount of a payment request can be changed and it is up to the
receiving node to accept or deny the payment according to its
implementation.

This also enables the user to pay through the GUI a payment request
where the amount has not been set, such as a donation. The amount is still
required!

The description field has also been added in the GUI. It is empty if the
description has not been set.

* (gui) Properly parse amounts from open channel form

* (gui) added optional `lightning:` scheme to payment request
2017-11-30 15:55:29 +01:00
Pierre-Marie Padiou
ffc4172e70
Added more checks on open/accept messages (#240)
We check that channel parameters are compliant with [BOLT 2](https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md) (this fixes #236).

We make sure that the counterparty chooses a decent `dust_limit`
because we want them to be able to publish their commitment, e.g. in a
data loss scenario. We also make sure that our configurable `dust_limit` isn't too low (this
fixes #234).

Also fixed our min `dust_limit` (542->546).

GUI:
* Using funding constants from `Channel`
* Also fixed an issue here `push` amount was compared to the max funding amount
  instead of the actual `funding` amount
2017-11-29 18:18:09 +01:00
Pierre-Marie Padiou
2ef479d38c
Fix concurrent spends with Electrum (#233)
By keeping temporary spending items in history
2017-11-29 17:40:07 +01:00
pm47
2d5d68bf3f a channel being restored is disabled 2017-11-28 13:34:35 +01:00
Pierre-Marie Padiou
ba25821e85 eclair-cli: added payreq desc, fixed method names (#238) 2017-11-27 20:46:17 +01:00
Fabrice Drouin
86133db5f7 Check that all UTXOS are p2sh on testnet (#228)
To avoid malleability issues, ask users to only have p2sh-of-p2wkh outputs.
on testnet, on startup we check that all UTXOs are p2sh (we cannot check that the
p2sh script is a p2wpkh script). It is not needed on regtest since there is no
chance that wallet tx will be malleated.
2017-11-27 18:30:59 +01:00
Pierre-Marie Padiou
40b18aed8b Added bitgo fee provider (#237)
* added bitgo fee provider and set it as default, keeping `earn.com` as fallback.
2017-11-27 18:17:38 +01:00
Pierre-Marie Padiou
8b151eb5c0
Removed bitcoin-core parent-tx hack (#231)
This was a workaround because bitcoin-core could produce malleable funding
transactions.

We now:
1) assume that all existing funds in bitcoin core are in segwit P2S addresses
2) manually create segwit change addresses when we create new transactions

Also disabled unused/unreliable bitcoinj tests
2017-11-27 15:05:25 +01:00
Pierre-Marie Padiou
6304041d77
Use tx-output pubkeyscript as hint for electrum watcher (#232)
* use tx-output pubkeyscript as hint for electrum watcher to detect tx confirmed

* support adding a WatchConfirmed to a tx that has no output
2017-11-27 12:28:44 +01:00
Fabrice Drouin
bf0423c020 Ignore unknown tags when parsing a payment request
This fixes #206.
2017-11-24 11:30:36 +01:00
Fabrice Drouin
4a4640bc86 Bitcoin rpc client: queue requests locally (#223)
use a local queue for outgoing rpc requests. this should be a better solution than
inceasing the number of concurrent requests.
see https://doc.akka.io/docs/akka-http/current/scala/http/client-side/host-level.html#using-the-host-level-api-with-a-queue
for more information.
2017-11-22 14:48:23 +01:00
Pierre-Marie Padiou
bfa3e1c2ca Reformat + optimized imports (#222)
* Reformat + optimized imports

* Fixed unwanted modifications
2017-11-21 20:08:15 +01:00
Pierre-Marie Padiou
df67157119 fix doc for api call connect/open (#220)
Fixes #215.
2017-11-21 19:11:07 +01:00
Pierre-Marie Padiou
875dc04d39
Support for electrumx API (#208)
This is a rework of #184 with numerous improvements and bugfixes.

* re-enabled `WatchSpentBasic`

* fixed several issues in watcher

* fixed pattern matching for INPUT_RECONNECTED event in CLOSING

* reduced logback_colors log level

* connect txes even if they arrive out of order

* wallet: send confidence event as soon as a tx is confirmed

* fixed 5985148f2f and improve events

* added `NewWalletReceiveAddress` event

* cleaned up electrum testnet seeds

* added a test on dumping routing state

* removed WAIT_FOR_FUNDING_PUBLISHED state and clarified funding tx publish assumptions

* wallet: use BIP49 derivation and 24 words mnemonic codes
we use segwit with p2sh-of-p2wkh so we should use BIP49 derivation
instead of BIP44 (same path with m/49'/... instead of m/44'/...)

* added a rollback function to `EclairWallet`

This rollback is called whenever we know we won't publish the funding tx,
so that we tell the wallet to release locks on utxos.

* fundee now checks feerates at `open_channel` reception

* proper handling of electrum connection/disconnection

* moved bitcoinj test to its own package

* make electrum wallet advertise address at startup

* set version to 0.2-SNAPSHOT
2017-11-21 18:12:45 +01:00
Pierre-Marie Padiou
68cbcf74e3
Prune stale network announcements (#219)
See https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md#recommendation-on-pruning-stale-entries.

* send a new `channel_update` every 24h as keepalive

* use case object instead of symbol for ticks

* minor improvements in router init

* prune stale channels

Note that we don't want to prune brand new channels for which we didn't
yet receive a channel update, so we consider stale a channel that:
(1) is older than 2 weeks (2*7*144 = 2016 blocks)
AND
(2) didn't have an update during the last 2 weeks.

Pruning is triggered every day.

Also renamed event `BITCOIN_FUNDING_OTHER_CHANNEL_SPENT` to
`BITCOIN_FUNDING_EXTERNAL_CHANNEL_SPENT`.

* filter out duplicate announcements before checking sig

* changed routing table dump parameters
2017-11-21 16:47:02 +01:00
Pierre-Marie Padiou
1ce7b8791c
Improved fees management (#216)
* main feerate source is now earn.com (21.co) instead of bitpay insight
* if main feerate source is unavailable, we now fallback to default values
* we retrieve feerates for a set of block delays instead of just one
* we now use different block delays depending on transactions:
  - `block_delay`=`1` for txes that compete with others (eg: commitment
    tx, htlc tx, penalty tx)
  - `block_delay`=`6` for other txes (eg: funding tx, closing tx, delayed
    output tx)
2017-11-21 15:59:01 +01:00
Pierre-Marie Padiou
340e00fb6b
Use a separate htlc_key to sign 2nd stage htlc txs (#213)
We previously used the `payment_key` both for our main output, and to sign
the local `htlc_success`/`htlc_timeout` transactions.

With this change we can keep the `payment_privkey` offline, which is far
better from a security point of view because an attacker getting control
of a node wouldn't be able to just publish the current commitment
transaction and get the funds. The attacker would only be able to get our
`htlc_privkey`, which we only use in a 2-of-2 multisig with our
counterparty, so it is useless except if the attacker and the counterparty
are the same person, and even in that case only the pending htlcs would be
at risk.

Note that this implementation is a first step and actually keeps the
payment key to spend our outputs in non-mutual close scenarios.
2017-11-17 15:44:44 +01:00
Pierre-Marie Padiou
fcb5bf2549
Delay announcement_signatures when received early (#217)
* delay `announcement_signatures` in state `WAIT_FOR_FUNDING_LOCKED`
* delay `announcement_signatures` in state `WAIT_FOR_FUNDING_CONFIRMED`
* always re-send our `announcement_signatures` in response to theirs
2017-11-17 14:52:00 +01:00
Pierre-Marie Padiou
dd642c961d
Handle remote error in SYNCING state (#205)
This closes #203.
2017-11-14 18:44:25 +01:00
Pierre-Marie Padiou
eff7a8b986
Better handle big routing table (#194)
* increased tcp send buffer x100

* throttle announcement messages when dumping the table

* set router throttling to chunkSize=10 delay=50ms
2017-11-14 18:44:10 +01:00
Pierre-Marie Padiou
ac64cc285a
Reworked channel closing logic (#204)
When doing an unilateral close (local or remote), we previously weren't
watching htlc outputs to decide whether the commit was finished or not.
This was incorrect because we didn't make sure the htlc-related
transactions had indeed been confirmed on the blockchain, making us
potentially lose money.

This is not trivial, because htlc transactions may be double-spent by the
counterparty, dependending on scenarios (ex: `htlc-timeout` vs
`claim-success`). On top of that, there may be several different kind of
commits in competition at the same time.

With this change, we now:
- put `WatchConfirm` watches on the commitment tx, and on all outputs only
  us control (eg: our main output) ;
- put `WatchSpent` watches on the outputs that may be double spent by the
  counterparty; when such an output is spent, we put a `WatchConfirm` on
  the corresponding transaction and keep track of all outpoints spent ;
- every time a new transaction is confirmed, we find out if there are some
  remaining transactions waiting for confirmation, taking into account the
  fact that some 2nd/3rd-stage txs may never confirm because their input
  has been doublespent.

We also don't rely anymore on dedicated `BITCOIN_CLOSE_DONE`,
`BITCOIN_LOCALCOMMIT_DONE`, ... events.
2017-11-14 18:43:33 +01:00
Pierre-Marie Padiou
f71f3da027
Rework preimage handling (#183)
* properly handle new htlc requests when closing

When in NORMAL state and a `shutdown` message has already been
sent or received, then any subsequent `CMD_ADD_HTLC` fails and
the relayer is notified of the failure.

Same in SHUTDOWN state.

This fixes a possible race condition when a channel just switched
to SHUTDOWN, and the relayer keeps sending it new htlcs before
being notified of the state change.

* renamed Htlc->DirectedHtlc + cleanup

* storing origin of htlcs in the channel state

Currently this information is handled in the relayer, which is not
persisted. As a consequence, if eclair is shut down and there are
pending (signed) incoming htlcs, those will always expire (time out
and fail) even if the corresponding outgoing htlc is fulfilled, because
we lose the lookup table (the relayer's `bindings` map).

Storing the origin in the channel (as opposed to persisting the state
of the relayer) makes sense because we want to store the origin if and
only if an outgoing htlc was successfully sent and signed in a channel.

It is also probably more performant because we only need to do one disk
operation (which we have to do at signing anyway) instead of two
distinct operations.

* removed bindings from relayer

Instead, we rely on the origin stored in the actor state.

* preimages are now persisted and acknowledged

Upon reception of an `UpdateFulfillHtlc`, the relayer forwards it
immediately to the origin channel, *and* it stores the preimage in
a `PreimagesDb`.

When the origin channel has irrevocably committed the fulfill in a
`CommitSig`, it sends an `AckFulfillCmd` back to the relayer, which
will then remove the preimage from its database.

In addition to that, the relayer will re-send all pending fulfills
when it is notified that a channel reaches NORMAL, SHUTDOWN, or
CLOSING state. That way we make sure that the origin channel will
always get the fulfill eventually, even if it currently OFFLINE for
example. This fixes #146.

Also, the relayer now relies on the register to forward messages to
channels based on `channelId` or `shortChannelId`. This simplifies
the relayer but adds one hop when forwarding messages.

* modified `PaymentRelayed` event

Replaced `amountIn` and `feesEarned` by more explicit `amountIn`
and `amountOut`. `feesEarned` are simply the difference.

TODO:
- when local/remote closing a channel, we currently do not wait
for htlc-related transactions, we consider the channel CLOSED when
the commitment transactions has been buried deeply enough; this is
wrong because it wouldn't let us time to extract payment preimages
in certain cases
2017-11-14 17:21:02 +01:00
Dominique
a68a06fd38 Readme: added help for options syntax (#212)
* (README) updated link to release readme
* (README) added a link to HOCON readme for options syntax

This closes #209
2017-11-14 10:56:10 +01:00