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

1426 commits

Author SHA1 Message Date
Pierre-Marie Padiou
c530b23175
Added simple plugin support (#927)
Using org.clapper:classutil library and a very simple `Plugin` interface.
2019-04-19 18:10:47 +02:00
Pierre-Marie Padiou
f563ca0897
Add channel errors in audit db (#955)
We now keep track of all local/remote channel errors in the audit db.
2019-04-19 16:28:02 +02:00
Andrew Camilleri
ed507334e0 Fix Dockerfile maven binary checksum (#956)
The Maven 3.6.0 SHA256 checksum was invalid and caused the docker build to fail.
2019-04-19 15:53:13 +02:00
Pierre-Marie Padiou
44778a72c9
Set MAX_BUFFERED to 1,000,000 (#948)
Note that this doesn't mean that we will buffer 1M objects in memory:
those are just pointers to (mostly) network announcements that already
exist in our routing table.

Routing table has recently gone over 100K elements (nodes,
announcements, updates) and this causes the connection to be closed when
peer requests a full initial sync.
2019-04-19 14:18:57 +02:00
Pierre-Marie Padiou
84c0fab433
Added a timeout for channel open request (#928)
Until now, if the peer is unresponsive (typically doesn't respond to
`open_channel` or `funding_created`), we waited indefinitely, or until the
connection closed.

It translated to an API timeout for users, and uncertainty about the
state of the channel.

This PR:
- adds an optional `--openTimeoutSeconds` timeout to the `open` endpoint, that will
actively cancel the channel opening if it takes too long before reaching
state `WAIT_FOR_FUNDING_CONFIRMED`.
- makes the `ask` timeout configurable per request with a new `--timeoutSeconds`
- makes the akka http timeout slightly greater than the `ask` timeout

Ask timeout is set to 30s by default.
2019-04-18 18:30:51 +02:00
Fabrice Drouin
6afe28d147
Electrum: do not persist transaction locks (#953)
Locks held on utxos that are used in unpublished funding transactions should not be persisted.
If the app is stopped before the funding transaction has been published the channel is forgotten
and so should be locks on its funding tx utxos.
2019-04-17 19:10:14 +02:00
Pierre-Marie Padiou
9032da5326
Add a proper payments database (#885)
There is no unique identifier for payments in LN protocol. Critically,
we can't use `payment_hash` as a unique id because there is no way to
ensure unicity at the protocol level.

Also, the general case for a "payment" is to be associated to multiple
`update_add_htlc`s, because of automated retries. We also routinely
retry payments, which means that the same `payment_hash` will be
conceptually linked to a list of lists of `update_add_htlc`s.

In order to address this, we introduce a payment id, which uniquely
identifies a payment, as in a set of sequential `update_add_htlc`
managed by a single `PaymentLifecycle` that ends with a `PaymentSent` or
`PaymentFailed` outcome.

We can then query the api using either `payment_id` or `payment_hash`.
The former will return a single payment status, the latter will return a
set of payment statuses, each identified by their `payment_id`.

* Add a payment identifier

* Remove InvalidPaymentHash channel exception

* Remove unused 'close' from paymentsDb

* Introduce sent_payments in PaymentDB, bump db version

* Return the UUID of the ongoing payment in /send API

* Add api to query payments by ID

* Add 'fallbackAddress' in /receive API

* Expose /paymentinfo by paymentHash

* Add id column to audit.sent table, add test for db migration

* Add invoices to payment DB

* Add license header to ExtraDirective.scala

* Respond with HTTP 404 if the corresponding invoice/paymentHash was not found.

* Left-pad numeric bolt11 tagged fields to have a number of bits multiple of five (bech32 encoding).

* Add invoices API

* Remove CheckPayment message

* GUI: consume UUID reply from payment initiator

* API: reply with JSON encoded response if the queried element wasn't found

* Return a payment request object in /receive

* Remove limit of pending payment requests!

* Avoid printing "null" fields when serializing an invoice to json

* Add index on paymentDb.sent_payments.payment_hash

* Order results in descending order in listPaymentRequest
2019-04-16 17:03:21 +02:00
rorp
70d7db7f96 Set max payment attempts from configuration (#931)
With a default to `5`.
2019-04-15 15:19:39 +02:00
araspitzu
3eceb90fa0
Expose the websocket over HTTP GET to work properly with basic auth (#934)
* Expose the websocket over HTTP GET
* Add test for basic auth over websocket endpoint
2019-04-10 11:07:19 +02:00
Fabrice Drouin
a37fd38d65
API: fix fee rate conversion (#936)
Our `open` API calls expects an optional fee rate in satoshi/byte, which is the most widely
used unit, but failed to convert to satoshi/kiloweight which is the standard in LN.
We also check that the converted fee rate cannot go below 253 satoshi/kiloweight.
2019-04-09 11:32:12 +02:00
Pierre-Marie Padiou
fa5d0235cb
Make Electrum tests pass on windows (#932)
There was an obscure Docker error when trying to start an Electrum
server in tests. [1]

It appears that there is a conflict between Docker and Hyper-V on some
range of ports.

A workaround is to just change the port we were using.

[1] https://github.com/docker/for-win/issues/3171
2019-04-04 11:38:11 +02:00
araspitzu
2aa088e0e6 Fix eclair-cli to work with equal sign in arguments (#926)
* Fix eclair cli argument passing

* Modify eclair-cli to work with equals in arguments

* Eclair-cli: show usage when wrong params are received

* Remove deprecated call from eclair-cli help message [ci skip]
2019-04-03 19:19:56 +02:00
araspitzu
3a56ad9133
Send events when HTLCs settle on-chain (#884)
* send events when htlc settle on-chain

* send events when a payment is received/relayed/sent

* send events when a payment is failed

* Add test for websocket

* Use nicer custom type hints when serializing to json (websocket)

* Fix bech32 prefix for regtest

* Separate cases for bech32 testnet and regtest for BOLT11 fallback address
2019-04-03 11:41:08 +02:00
Fabrice Drouin
288aa75305
Electrum: update client name (#930)
* Electrum: use 3.3.4 as client name

* Electrum Pool: more specific message on disconnect

Specify wether we lost connection to our master server or to a backup server.
2019-04-03 10:58:26 +02:00
Andrea
e3f8d9b140
Formatting, remove unused param in comments 2019-04-03 10:29:41 +02:00
Fabrice Drouin
617ccf4d11
Minor API fixes (#929)
Move GetInfoResponse and AuditResponse out of the api package
Fix parameter handling for audit() and networkFees()
2019-04-02 16:23:49 +02:00
Pierre-Marie Padiou
933913de08
Add random delay to rebroadcast (#925)
* add random delay to rebroadcast

* ignore `BadMessage` while disconnected

* ignore `DelayedRebroadcast` while disconnected
2019-04-01 13:31:41 +02:00
Pierre-Marie Padiou
9c37448ebf
Rollback tx if disconnected in WAIT_FOR_FUNDING_SIGNED (#923) 2019-03-30 20:28:54 +01:00
Andrea
1b91609aec
Separate cases for bech32 testnet and regtest for BOLT11 fallback address 2019-03-29 19:02:43 +01:00
Andrea
77eb1de4f3
Merge remote-tracking branch 'origin/extended-api-pm' into extended-api-pm 2019-03-29 19:00:18 +01:00
Andrea
5e476fddc4
Fix bech32 prefix for regtest 2019-03-29 18:59:59 +01:00
Fabrice Drouin
c99026828c
Electrum: fixes and improvements (#924)
* Electrum: Update mainnet servers list

* Electrum: make pool address selection more readable

We connect to a random server we're not already connected to.

* Electrum Tests: increase "wait for ready" test timeout

If was a bit short and sometimes failed on travis.

* Electrum: better parsing of invalid responses

On testnet some Electrum servers are not compliant with the protocole version they advertise
and will return responses formatted with 1.0 rules.
2019-03-29 18:56:00 +01:00
pm47
dd52cdc61f
added tests 2019-03-29 18:16:44 +01:00
araspitzu
9624383f22
cleaner isSentByLocal
Co-Authored-By: pm47 <pm47@users.noreply.github.com>
2019-03-29 18:14:32 +01:00
Pierre-Marie Padiou
14da6d3c23
Update eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala
Co-Authored-By: araspitzu <a.raspitzu@protonmail.com>
2019-03-29 17:26:11 +01:00
Andrea
008b2cad87
re-introduce dropTail strategy for websocket buffer, let the unhandled messages be handled by akka's default 2019-03-29 17:09:10 +01:00
Andrea
09618a8764
Log error with warn level in websocket actor, use backpressure strategy for websocket queue. 2019-03-29 16:57:59 +01:00
Andrea
52b17fe75f
Use nicer custom type hints when serializing to json (websocket) 2019-03-28 17:54:56 +01:00
araspitzu
5bed099206
Upgrade scala library target on travis: 2.11.12 (#922) 2019-03-28 17:25:22 +01:00
Andrea
9a7e2158be
Add test for websocket 2019-03-28 16:07:51 +01:00
Andrea
c8d38871e9
remote println from test, 2019-03-28 15:21:04 +01:00
Andrea
5b423b1571
Remove 'fallbackAddress' from /receive API 2019-03-28 14:54:28 +01:00
Andrea
10bc4ab811
Reorganize specialized formats for the websocket 2019-03-28 14:51:21 +01:00
Andrea
cd703f2d4a
Merge branch 'master' into extended-api-pm 2019-03-28 11:24:12 +01:00
Andrea
c557f70af5
Finish merging master 2019-03-28 11:22:37 +01:00
Andrea
8ec8574d97
Merge branch 'master' into extended-api-pm
# Conflicts:
#	eclair-core/src/main/scala/fr/acinq/eclair/api/Service.scala
#	eclair-core/src/main/scala/fr/acinq/eclair/payment/PaymentEvents.scala
#	eclair-core/src/test/scala/fr/acinq/eclair/api/JsonSerializersSpec.scala
2019-03-28 10:44:24 +01:00
Fabrice Drouin
e2ff5c857b
Set version to 0.3-SNAPSHOT (#920)
We have enough major changes from the last release to justify switching to 0.3
2019-03-28 09:49:17 +01:00
araspitzu
2505e80283
Factor out nodeId API param, rename /channels API param to nodeId. (#919) 2019-03-27 15:49:22 +01:00
araspitzu
fafda93e5b Move the JSON API section of the readme closer to the top (#918)
Also fixed the broken link to old API documentation
2019-03-26 18:29:23 +01:00
araspitzu
a4b94004e4 API: use form data instead of JSON-RPC (#894)
Port the existing API functionalities over a new structure of HTTP endpoints, with the biggest difference being the usage of **named parameters** for the requests (responses are unchanged). RPC methods have become endpoints and the parameters for each are now passed via form-params (clients must use the header "Content-Type" : "multipart/form-data"), this allows for a clearer interpretation of the parameters and results in more elegant parsing code on the server side. It is possible to still use the old API version via a configuration key.

Old API can be used by setting `eclair.api.use-old-api=true`.
2019-03-26 18:10:09 +01:00
araspitzu
89ddc52640 Deal with channels with fees=0 when computing a route (#905)
* Treat channels with fees=0 as if they had feeBase=1msat while we compute a route

* Add test to ensure we build the onion attaching no fees if they were not required by the channel_update
2019-03-26 14:00:15 +01:00
Pierre-Marie Padiou
57e43cc65d
Check WatchSpent in constant time (#916)
This is done with a secondary map that indexes watched utxos.
2019-03-25 18:09:30 +01:00
araspitzu
06b2337ed9
Rework database initialization (#911)
* Initialize the database outside the node param constructor
* Do not create folders during StartupSpec
* Simplify syntax for instantiating test Databases
* Rework parameter passing to database initialization
* Force UTF-8 file encoding on all platform.
2019-03-25 18:04:30 +01:00
Fabrice Drouin
3b7afd92d4
Use bitcoin-lib 0.11 which embeds libsecp256k1 (#907)
* Use bitcoin-lib 0.11, which embeds libsecp256k1

* Unit tests: generate dummy sig from 32 random bytes

We now use a version of bitcoin-lib which embeds JNI bindings for libsecp256k1,
and it will only sign data that is 32 bytes long (in Bitcoin and LN you always
sign data hashes, not the actual data).

* Use maven 3.6.0 and a different mirror

* RoutingSyncSpec: don't create databases at init time

We called nodeParams which created a new in-memory sqlite database everytime we created "fake" routing info
2019-03-25 14:42:06 +01:00
Pierre-Marie Padiou
8ea4bd0468
Don't send updates if no filter has been set (#912)
We mistakenly implemented `Peer.timestampInRange` as opt-out whereas it
should be opt-in.
2019-03-25 14:37:12 +01:00
araspitzu
3fda5ddede Remove unused param 'randomize' from SendPayment command (#910)
Cleanup of the SendPayment command in which there was a leftover field 'randomize' currently replaced by its analogous in the RouteParams.
2019-03-22 14:39:06 +01:00
Fabrice Drouin
32d8a08ad1 Improve unit tests (#908)
* Bitcoin tests: generate 150 blocks instead of 500

We don't need to generate 432 blocks to activate segwit but we still need to have
spendable coins and coinbase maturity is 100 blocks even on regtest.

* Electrum client: test against mainnet Electrum servers

Previous test against testnet servers was flaky because testnet Electrum
servers are unrelable. Here we test against our own server on mainnet (and
2 servers from our list for the pool test).
2019-03-22 13:26:55 +01:00
araspitzu
1c9ac1d62d Ensure the cost function in path-finding is monotonic (#904)
Make sure the cost function in path-finding is monotonic
2019-03-20 10:43:48 +01:00
Fabrice Drouin
4aa7a1ca9f Upgrade to bitcoin 0.17.1 (#826)
Bitcoin Core 0.18 is about to enter RC cycle and should be release soon (initial target was April). It is not compatible with 0.16 (some of the RPC calls that we use have been removed. They're still available in 0.17 but tagged as deprecated). 

With this PR, eclair will be compatible with 0.17 and the upcoming 0.18, but not with 0.16 any more so it will be a breaking change for some of our users. Supporting the last 2 versions is the right option and we should be ready before 0.18 is actually released (its initial target was April).
2019-03-19 14:57:03 +01:00
Pierre-Marie Padiou
cc3395a5bb
Better logic for sending channel_updates (#888)
* don't spam with channel_updates at startup

Previous logic was very simple but naive:
- every time a channel_update changed we would send it out
- we would always make a new channel_update with the disabled flag set
at startup.

In case our node was simply restarted, this resulted in us re-sending a
channel_update with the disabled flag set, then a second one with the
disabled flag unset a few seconds later, for each public channel.

On top of that, this opened way to a bug: if reconnection is very fast,
then the two successive channel_update will have the same timestamp,
causing the router to not send the second one, which means that the
channel would be considered disabled by the network, and excluded from
payments.

The new logic is as follows:
- when we do NORMAL->NORMAL or NORMAL->OFFLINE or OFFLINE->NORMAL, we
send out the new channel_update if it has changed
- in all other case (e.g. WAIT_FOR_INIT_INTERNAL->OFFLINE) we do nothing

As a side effect, if we were connected to a peer, then we shut down
eclair, then the peer goes down, then we restart eclair: we will make a
new channel_update with the disabled flag set but we won't broadcast it.
If someone tries to make a payment to that node, we will return the
new channel_update with disabled flag set (and maybe the payer will then
broadcast that channel_update). So even in that corner case we are good.

* quick reconnection: bump channel_update timestamp

In case of a disconnection-reconnection, we first generate a
channel_update with disabled bit set, then after we reconnect we
generate a second channel_update with disabled bit not set.

If this happens very quickly, then both channel_updates will have the
same timestamp, and the second one will get ignored by the network.

A simple fix is to bump the second timestamp in this case.

* set channel_update refresh timer at reconnection

We only care about this timer when connected anyway. We also cancel it
when disconnecting.

This has several advantages:
- having a static task resulted in unnecessary refresh if the channel
got disconnected/reconnected in between 2 weeks
- better repartition of the channel_update refresh over time because at
startup all channels were generated at the same time causing all refresh
tasks to be synchronized
- less overhead for the scheduler (because we cancel refresh task for
offline channels (minor, but still)
2019-03-18 14:39:29 +01:00