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

1418 commits

Author SHA1 Message Date
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
Fabrice Drouin
5519d0aa6a Minor fixes (dependencies, unit tests) (#901)
Use bitcoin-lib v0.10 which has finally been synced to maven central.
Fix transactions unit test (the check in the test was using the whole locktime and not
the last 24 bits).
2019-03-15 12:54:33 +01:00
Pierre-Marie Padiou
b681cfca47
Replace BinaryData by scodec.bits.ByteVector (#896)
See https://github.com/ACINQ/bitcoin-lib/pull/31.

We still have to use `Array[Byte]` for low-level cryptographic primitives, and `akka.util.ByteBuffer` for tcp connections. In order to reduce unnecessary copies, we used `ByteVector.view(...)` as much as possible.

Took the opportunity to do a project-wide optimize imports. We might as well do it now since pretty much all files have been touched already.

NB: temporarily use bitcoin-lib 0.10.1-SNAPSHOT because maven central is very slow and we can't access the recently release 0.10 for now.
2019-03-14 12:43:28 +01:00
araspitzu
889e86a908
Move the param 'randomize' from RouteRequest to RouteParams (#895)
* Move the param 'randomize' from RouteRequest to RouteParams
2019-03-13 18:58:55 +01:00
Pierre-Marie Padiou
2712e30504
Better error logs for socks5 proxy (#893) 2019-03-12 13:37:27 +01:00
Fabrice Drouin
abba9f77ec NetworkDb: remove stale channels in batch (#886)
Add methods to delete channels and tags channels as pruned in batch which is much
more efficient in sqlite.

* Network db: minor changes in unit tests

Test pruning a few 1000s channels at once.

* NetworkDb API: use Iterators and not Seq

It's more consistent with our code base.
2019-03-12 13:34:40 +01:00
pm47
85df143c64
send events when htlc settle on-chain
This is a simpler alternative to #867, with the following limitations:
- no `OnChainRefundsDb` and associated API calls
- `PaymentSettlingOnChain` event will be sent exactly once per payment
and have less information
- we don't touch `HtlcTimeoutTx`
- use json4s type hints instead of manual attributes to case classes
2019-03-07 11:07:43 +01:00
Pierre-Marie Padiou
70397962b6
Clean channels with unexisting funding tx (#714)
There are several separate but related changes in this PR:

(a) Fast close on scenarii where we have nothing at stake (instead of going to `CLOSING` state). The previous process was not only slower (we had to wait for confirmations), but it never resolved when the funding tx hadn't been confirmed. Note that there is still an edge case where the funding tx never gets confirmed, we are fundee and we have something at stake (`push_msat` > 0).

(b) When *fundee*: after a timeout (5 days), if the funding tx hasn't reached `min_depth`, we cancel the channel.

(c) When *funder*: there is no timeout on the funding tx: however on restart, if we detect that our funding tx was doublespent, then we cancel the channel. Just because there is a doublespend doesn't mean that something malicious is going on: e.g. fee was to low, the tx was eventually removed from mempools and we just spent the inputs on something else).

Commits:

* set proper channelid in logs on restore

* fast close if we have nothing at stake

* added fundingTx and timestamp to DATA_WAIT_FOR_FUNDING_CONFIRMED

Also added migration codecs and tests

* implemented funding timeout for fundee

After a given delay, fundee will consider that the funding tx will never
confirm and cancels the channel.

Note that this doesn't apply to the funder, because our implementation
guarantees that we have sent out a funding tx, and the only way to be
sure that it will never be confirmed is that we double spend it. We just
can't rely on a timeout if we want to be safe.

* Electrum: detect if a wallet transaction has been double-spent

If it's in the mempool, or if it's been confirmed, then it's not double spent.
If it's not confirmed and not the mempool, we check if we have a transaction in
our wallet that sspends one of the inputs of our tx. If we find one, then it's been
double spent.
This will work with our funding txs, but not with their funding txs.

* fix regression with dataloss protection

The fast close causes a regression with dataloss protection, because
if we have nothing at stake we won't publish anything in case of
error (even if our peer asks us to).

This fixes #854.
2019-03-06 11:10:40 +01:00
Pierre-Marie Padiou
f9ead30b5c
Set default to-remote-delay-blocks to 720 (#879)
It sounds like a more reasonable default value, 144 was too short.

Keep using 144 blocks for our integration tests.
2019-02-25 18:00:17 +01:00