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

1482 commits

Author SHA1 Message Date
pm47
a0f3b6075a
fixed tests following b5190666f4 2018-08-15 15:34:01 +02:00
pm47
0c63e32fdd
Merge branch 'master' into android 2018-08-15 14:46:36 +02:00
Pierre-Marie Padiou
82973cdb76
Fixed some logs and added ChannelPersisted event (#674)
* ignore answers to CMD_UPDATE_FEE

* ignore BITCOIN_FUNDING_DEPTHOK in OFFLINE/SYNCING

* ignore BITCOIN_FUNDING_DEEPLYBURIED in OFFLINE/SYNCING

* improvements in eclair-cli:
   - Made default `channel`/`channels` outputs more useful.
   - Added support for timestamp filtering to `audit` and `networkfees`.

* added `ChannelPersisted` event
2018-08-15 14:39:19 +02:00
Pierre-Marie Padiou
952f94c2a8
Send query_short_channel_ids sequentially (#672)
and add a event to follow the synchronization progress.
2018-08-15 14:34:45 +02:00
pm47
b5190666f4
bypassed announcement sigs check 2018-08-15 14:01:37 +02:00
pm47
cd24f38510
fixed compilation error due to json serialization 2018-08-15 14:01:24 +02:00
pm47
cf62dc598b
Merge branch 'master' into android 2018-08-10 12:32:11 +02:00
Pierre-Marie Padiou
24db529d8b
Handle unknown remote commit in recovery logic (#667)
Our recovery logic didn't handle the case were our local commit is
up-to-date, but we don't know their local commit (probably because we
just lost the last state were we sent them a new `commit_sig`).

Also, process all cases in the same `channel_reestablish` handler, like we do
everywhere else.

Moved the sync tests in `Helpers` so that they are more understandable.
2018-08-10 12:27:09 +02:00
Pierre-Marie Padiou
f3676c6497
Get full blocks when looking for spending tx (#666)
* get full blocks when looking for spending tx

With a verbosity of `0`, `getblock` returns the raw serialized
block. It saves us from calling `getrawtransaction` for each transaction
in the block.

Fixes #664.
2018-08-03 12:17:09 +02:00
Pierre-Marie Padiou
6d5ec8c4fa
Fail unsigned outgoing htlcs at CLOSING (#660)
This can happen in an unilateral close scenario, when local commit
"wins" the race to the blockchain, and some outgoing htlcs weren't yet
signed by remote.

This fixes #649.
2018-07-31 16:04:55 +02:00
Pierre-Marie Padiou
75d23cf1b3
Audit: Keep track of sent/received/relayed payments and relay/network fees (#654)
Added a new `AuditDb` which keeps tracks of:
- every single payment (received/sent/relayed)
- every single network fee paid to the miners (funding, closing, and all commit/htlc transactions)

Note that network fees are considered paid when the corresponding tx has reached `min_depth`, it makes sense and allows us to compute the fee in one single place in the `CLOSING` handler. There is an exception for the funding tx, for which we consider the fee paid when the tx has successfully been published to the network. It simplifies the implementation and the tradeoff seems acceptable.

Three new functions have been added to the json-rpc api:
- `audit`: returns all individual payments, with optional filtering on timestamp.
- `networkfees`: returns every single fee paid to the miners, by type (`funding`, `mutual`, `revoked-commit`, etc.) and by channel, with optional filtering on timestamp.
- `channelstats`: maybe the most useful method; it returns a number of information per channel, including the `relayFee` (earned) and the `networkFee` (paid).

The `channels` method now returns details information about channels. It makes it far easier to compute aggregate information about channels using the command line.

Also added a new `ChannelFailed` event that allows e.g. the mobile app to know why a channel got closed.
2018-07-25 16:47:38 +02:00
rorp
924efeabe3 Fix Bitcoin JSON RPC client's rounding errors (#616)
* Fix Bitcoin JSON RPC client's rounding errors

* FundTransactionResponse fee field type is now Satoshi, fix Electrum tests

* BitcoinCoreFeeProvider: rework error handling code
2018-07-24 18:43:35 +02:00
Dominique
818ef7fe1d
set version to 0.2-android-beta9 2018-07-18 20:58:53 +02:00
Dominique
6ce5505f1f
Merge branch 'master' into android 2018-07-18 20:49:11 +02:00
Pierre-Marie Padiou
633deb5c0b
Send an event when an error occurs in a channel (#663)
This allows e.g. the mobile app to know why a channel got closed.
Depending on whether the error is local or remote, a
`Throwable`/`wire.Error` will be attached to the event.
2018-07-18 14:45:12 +02:00
Chris Stewart
fe82641e92 Clean up ExecutionContext/ActorSystem (#652)
This allows for a user of the library to implicitly pass the `ActorSystem` to the eclair node. Although if you are running multiple eclair instances on the same machine you need to make sure the `ActorSystems` that are passed implicitly are unique.
2018-07-16 14:25:20 +02:00
Fabrice Drouin
fef0df7607
Use "unsigned long" comparison for short channel ids (#656) 2018-07-16 12:18:38 +02:00
Dominique
3575fe7998
set version to 0.2-android-beta8 2018-07-16 12:12:49 +02:00
Fabrice Drouin
6d5ed22c4d
Router: prune channel that our peer does not have (#647)
* router: prune channel that our peer does not have

when we receive a reply to a channel query, we check whether channels that we have
but they don't can are stale and can be pruned.

* router: cap the number of channels that we would prune

We limit the number of channels that we will prune to avoid
freezing the app.

* pruning: simplify our process and address change requests

we restore the computation of missing channels that we had before, remove
new `isStale` and `isInRange` method and simplify short channel ids range
check.

* pruning: improve test, don't prune nodes (they are not handled on android)
2018-07-13 17:19:54 +02:00
sstone
4deb67600a
Merge branch 'master' into android 2018-07-13 12:40:44 +02:00
Fabrice Drouin
9f708acf04
Improve initial routing sync (#453)
* Implement new 'routing sync' messages

* add a new feature bit for channel queries

when we receive their init message and check their features:
- if they set `initial_routing_sync` and `channel_range_queries` we do nothing, we should receive a
range query shorly
- if they support channel range queries we send a range query

* Modify query_short_channel_id to ask for a range of ids

And not just a single id

* use `SortedMap` to store channel announcements

* don't send prune channels with channel range queries

* update range queries type to match BOLT PR

* add timestamp-based filters for gossip messages

each peer can speficy a `timestamp range` to filter gossip messages against.

* don't preserve order in `decodeShortChannelIds`

It is not needed and allows us to return a `Set`, which is better suited
to how we use the result.

* channel range queries: handle multi-message responses

Handle case where there are too many short ids to fit in a single message.

* channel range queries: use zlib instead of gzip

but detect when a message was encoded with gzip and reply with gzip in that case.

* router: add more channel range queries logs

* Channel range queries: correctly set firstBlockNum and numberOfBlocks fields

* channel range queries: properly handle case where there is no data

we will just receive on byte (compression format)

* channel range queries: use their compression format to query channels

when we query channels with `query_short_channel_ids`, we now use the same compression
format as in their `repy_channel_range` message. So we should be able to communicate
with peers that have not implemented all compression formats.

* router: make sure that channel ids are sorted

For channel range queries to work properly, channel ids need to be sorted.
It is then much more efficient to use a sorted map in our router state.

* always use `keySet` instead of `keys`

`SortedMap`.`keySet` returns a `SortedSet`, whereas `SortedMap`.`keys`
returns an `Iterable`. This is a critical difference because channel
range queries has requirements on ordering of channel ids.

Using the former allows us to rely on type guarantees instead of on
assumptions that the `Iterable` is sorted in `ChannelRangeQueries`.

There is no cost difference as internally the `Iterator` is actually a
`SortedSet`.

Also, explicitely specified the type instead of relying on comments in
`Router`.

* publish channel update event on router startup

* channel range queries: use uint32 for 4-byte integers (and not int32)

* channel range queries: make sure we send at least one reply to `query_channel_range`

reply to `query_channel_range` messages for which we have no matching channel ids
with a single `reply_channel_range` that contains no channel ids.

* channel range queries: handle `query_channel_range` cleanly

add an explicit test when we have no matching channel ids and send back a reply with an
empty (uncompressed) channel ids payload

* channel range queries: rename GossipTimeRange to GossipTimestampFilter

* channel range queries: add gossip filtering test

* peer: forward all routing messages to the router

and not just channel range queries. this should not break anything and if
it does it would reveal a problem

* peer: add remote node id to messages sent to the router

this will improve logging and debugging and will help if we implement
banning strategies for mis-behaving peers

* router: filter messages with a wrong chainHash more cleanly

* channel range queries: set a "pass-all" timestamp filter

* router: remove useless pattern match

ChannelUpdates are wapped in a PeerRoutingMessage now

* Peer: fit typo in comment

* Peer: optimize our timestamp filter

* Router: use mdc to log remote node id when possible

* fix typos and improve log message formatting

* Peer: rephrase scala doc comment that breaks travis

* Peer: improve timestamp filtering + minor fixes

* Electrum tests: properly stop actor system at the end of the test

* Peer: filter out node announcements against our peer's timestamp

But we don't prune node annoucements for which we don't have a matching
channel in the same "rebroadcast" message
2018-07-12 21:36:57 +02:00
Pierre-Marie Padiou
5ea623ae8c
Relay payments to channel with highest balance (#648)
* relay htlcs to channels with the highest balance

In order to reduce unnecessary back-and-forth in case an outgoing
channel doesn't have enough capacity but another one has, the relayer
can now forward a payment to a different channel that the one specified
in the onion (to the same node of course).

If this preferred channel returns an error, then we will retry to the original
requested channel, this way if it fails again, the sender will always receive 
an error for the channel she requested.
2018-07-09 12:36:11 +02:00
nayuta-gondo
5ad65063a0 Set MIN_CLTV_EXPIRY to 9 as per BOLT 11 (#650) 2018-07-09 11:17:32 +02:00
Pierre-Marie Padiou
86e91f76fc
Added context to logs (#638)
* improved logs on sig sent/received

* put 'sent announcements' log in debug

* added logging of IN/OUT wire messages

* added mdc support to IO classes

* reduced package length to 24 chars in logs
2018-07-02 18:25:19 +02:00
sstone
44bb9a27af
Merge branch 'wip-routing-sync' into android 2018-06-27 16:12:00 +02:00
sstone
34176afb7c
Merge branch 'master' into wip-routing-sync 2018-06-27 14:53:39 +02:00
Fabrice Drouin
923d8661f8
Electrum: add wallet and watcher tests (via Docker) (#592)
* add basic electrum wallet test

our wallet connects to a dockerized electrumx server

* electrum: clean up tests, and add watcher docker tests

* electrum wallet: fix balance computation issue

when different keys produced the exact same confirmed + unconfirmed balances, we
would compute an invalid balance because these duplicates would be pruned.

* electrum: rename wallet test

* electrum: add a specific test with identical outputs

* electrum: change scripthash balance logging level to debug

* electrum: make docker tests run on windows/mac

Our electrumx docker container needs to contains to bitcoind that is running on the host.
On linux we use the host network mode, which is not available on windows/osx
On windows/osx we use host.docker.internal, which is not available on linux. This
requires docker 18.03 or higher.
2018-06-27 14:34:02 +02:00
sstone
a74a62b359
Revert "electrum: make docker tests run on windows/mac"
This reverts commit eecddcb340.
2018-06-27 14:26:00 +02:00
sstone
1743901691
router: remove useless pattern match
ChannelUpdates are wapped in a PeerRoutingMessage now
2018-06-27 14:24:39 +02:00
sstone
eecddcb340
electrum: make docker tests run on windows/mac
Our electrumx docker container needs to contains to bitcoind that
    is running on the host.
    On linux we use the host network mode, which is not available on windows/osx
    On windows/osx we use host.docker.internal, which is not available on linux. This
    requires docker 18.03 or higher.

    electrum: change scripthash balance logging level to debug

    electrum: add a specific test with identical outputs

    electrum: rename wallet test

    electrum wallet: fix balance computation issue

    when different keys produced the exact same confirmed + unconfirmed balances, we
    would compute an invalid balance because these duplicates would be pruned.

    electrum: clean up tests, and add watcher docker tests

    add basic electrum wallet test

    our wallet connects to a dockerized electrumx server
2018-06-26 23:12:48 +02:00
Dominique
2d829d40eb
Can generate payment request with extra routing information (#637)
* `ReceivePayment` now accepts additional routing info, which is useful for nodes that are not announced on the network but still want to receive funds.
2018-06-26 18:35:22 +02:00
rorp
71e50520ec Proper parsing of public-ips config parameter
* Fix scala.NotImplementedError when public-ips config parameter contains invalid values

* more comprehensive validations

* fix unit tests

This fixes #630
2018-06-26 18:15:01 +02:00
sstone
b5f39e5710
Merge remote-tracking branch 'origin/wip-routing-sync' into android 2018-06-26 15:39:02 +02:00
sstone
f7526e8d5b
channel range queries: set a "pass-all" timestamp filter 2018-06-26 14:34:24 +02:00
sstone
9dc5236670
Merge remote-tracking branch 'origin/wip-routing-sync' into android 2018-06-26 14:16:37 +02:00
sstone
96e51ea71a
channel range queries: set a "pass-all" timestamp filter 2018-06-26 13:57:46 +02:00
sstone
47578e2e0f
Merge branch 'wip-routing-sync' into android 2018-06-26 12:33:09 +02:00
sstone
a70c50775d
router: filter messages with a wrong chainHash more cleanly 2018-06-26 12:10:07 +02:00
sstone
e4b5fd8c5d
Merge branch 'wip-routing-sync' into android 2018-06-22 21:40:25 +02:00
sstone
a90dd69de8
peer: add remote node id to messages sent to the router
this will improve logging and debugging and will help if we implement
banning strategies for mis-behaving peers
2018-06-22 15:14:05 +02:00
sstone
50d52b48ed
set version to 0.2-android-beta7 2018-06-21 13:31:51 +02:00
sstone
624fb4d286
Merge branch 'wip-routing-sync' into android 2018-06-21 13:28:44 +02:00
sstone
ea2532cabb
peer: forward all routing messages to the router
and not just channel range queries. this should not break anything and if
it does it would reveal a problem
2018-06-20 17:43:52 +02:00
sstone
1f52577ddc
channel range queries: add gossip filtering test 2018-06-20 17:28:10 +02:00
sstone
d6da9861d2
channel range queries: rename GossipTimeRange to GossipTimestampFilter 2018-06-20 13:31:49 +02:00
sstone
cd6524e25b
set version to 0.2-SNAPSHOT 2018-06-20 09:45:09 +02:00
sstone
8aa51f4e02
set version to 0.2-beta5 2018-06-20 09:21:05 +02:00
Pierre-Marie Padiou
a9348f0774
Check when relay fee is insufficient (#634)
We should return a `FeeInsufficient` error when an incoming htlc doesn't
pay us what we require in our latest `channel_update`.

Note that the spec encourages us to being a bit more lax than that (BOLT
7):

> SHOULD accept HTLCs that pay an older fee, for some reasonable time
after sending channel_update.

>    Note: this allows for any propagation delay.
2018-06-19 16:58:40 +02:00
n1bor
b7b9f4929a Add api call to update channel relay fees (#620)
* add api call to update channel relay fees

* fixed bug in GUI, as channel can had different fees in each direction!

* fire transitions on `TickRefreshChannelUpdate` (fixes #621)

* make router publish `channel_update`s on startup

* (gui) Channel info fees are now options and case where channels have no known fees data is now properly handled.
2018-06-19 14:09:37 +02:00
n1bor
b3731adabd Adding ability to set expiry when creating a new invoice (#632) 2018-06-19 13:13:07 +02:00