Commit Graph

27 Commits

Author SHA1 Message Date
Rusty Russell 12b30ab4fc jsonrpc: register base on linkage.
Other than being neater (no more global list to edit!), this lets the
new daemon and old daemon have their own separate routines.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-04 14:08:15 +10:30
Christian Decker 570003235e gossip: Fixing minor issues
Thanks @rustyrussell for the review ^^
2017-01-03 15:08:05 +10:30
Christian Decker 0ed23c46a9 gossip: Implemented routing table sync with newly connected peers 2017-01-03 15:08:05 +10:30
Christian Decker e54c0adced gossip: Do not consider half-open connections for routes
Connections are in a half-open state after receiving the
`channel_announcement` and before the `channel_update` makes them
usable, so we need to ignore channels that are not yet fully open.
2017-01-03 15:08:05 +10:30
Christian Decker 57d5ae96a4 routing: Added channel_id and directions to connections
The gossip protocol spec refers to channels by their `channel_id` and
a direction. Furthermore, inbetween the `channel_announcement` and the
`channel_update` for either direction, the channel direction is in an
undefined state and cannot be used, so added the `half_add_connection`
function and an `active` flag to differentiate usable connections from
unusable ones.
2017-01-03 15:08:05 +10:30
Rusty Russell a4fdaab5b3 Use global secp256k1_ctx instead of passing it around.
If I'd known how large this patch would be (though trivial), I'd
have done it in parts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-12-02 18:12:58 +10:30
Rusty Russell 5adaf46b19 Merge remote-tracking branch 'origin/pr/65'
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-05 13:48:16 +10:30
Rusty Russell b40c4ae766 json_getroute: don't leak.
Allocate the route off the current command, not dstate.  And in the
case where the route is somehow not via a peer, don't leak memory.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-04 11:17:04 +10:30
Rusty Russell fa402aac31 routing: fix hash of pubkeys.
Found by PVS Studio.

Reported-by: Jon Griffiths <jgriffiths@blockstream.io>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-01 21:33:06 +10:30
Christian Decker f9a4af62e3 irc: Added alias handling for node announcements
Aliases seem to be popular among users wanting to show off their node,
so let's add them :-)
2016-10-28 16:47:01 +02:00
Christian Decker a97d301155 routing: Refuse self-route
Fixes #50. Was causing a segfault because it was creating an empty route
and was trying to extract the first hop as next hop. Routes through self
can still be created manually, but `sendpay` would still refuse to act
on them due to the missing self-link.
2016-10-23 11:57:50 +02:00
Rusty Russell d47d19ef2b Merge remote-tracking branch 'origin/pr/44'
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-17 12:31:19 +10:30
Christian Decker 594eb8109c jsonrpc: Added 'getnodes' to list known nodes.
getnodes returns an object containing a single array of 'nodes'. Each
element contains the node's ID, its hostname and its port. If
unknown (because we haven't seen a node announcement yet) then the port
is 0 and the hostname is null.
2016-10-02 14:52:24 +02:00
Christian Decker b2126375e0 irc: Add contact information to nodes
The routing table now includes hostnames and ports for the node as well
as a helper to add/update the nodes we learn about.
2016-10-02 14:30:25 +02:00
Christian Decker 8e2abfcc70 jsonrpc: Added 'getchannels' RPC method.
'getchannels' returns a 'channels' array containing an object for each
known channel. Each channel object represents one direction of a
bidirectional channel, with a from and a to node ID along with the fees
for that direction. This matched the internal storage of channels and
allows unbalanced fees for each direction.
2016-10-02 12:22:28 +02:00
Rusty Russell ea41386ed3 daemon: rename all the low-level commands to dev-
Rename the structs to match (and remove dev-echo).

This makes it clear that they're not the normal API.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:49 +09:30
Rusty Russell ca80fc0286 getroute: add a risk factor.
We need some way to reflect the tradeoff between the possible delay if
a payment gets stuck, and the fees charged by nodes.  This adds a risk
factor which reflects the probability that a node goes down, and the
cost associated with losing access to our funds for a given time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:48 +09:30
Rusty Russell 79b5663db7 routing: don't coredump on routes to neighbors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 13:47:33 +09:30
Rusty Russell 7bebfe265c pay: remove route when a payment fails partway.
It's a bit harsh, but I'm assuming they'll get refreshed eventually.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-31 16:10:17 +09:30
Christian Decker 754616c45a routing: Fix for single hop routes segfaulting.
The first hop is being stripped from computed routes, however the
first channel of the route is being used to get our peer address. This
results in segfaults if the route is just one hop, i.e., has no first
channel to get the peer's address from. Fixed by simply using an
existing pointer to our peer.
2016-08-26 15:39:35 +09:30
Rusty Russell 830a65de46 daemon: --add-route option.
This allows hardcoded routes in the config file, which is required until
we get route advertisements.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-18 14:25:14 +09:30
Rusty Russell 5f368f1c95 peer: save/load results in database.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-18 14:25:14 +09:30
Rusty Russell 87da9634bc routing: use ids, not nodes in interface.
Turns out to be more convenient.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-18 14:25:13 +09:30
Rusty Russell a613d8d1fb peer: make id a pointer, NULL until we know peer's ID.
Much better than undefined, and testing for NULL is better than
testing for STATE_INIT.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 12:00:17 +09:30
Rusty Russell f4f0c1aa18 daemon: add dev-routefail command.
We're about to change the code so that if it can't route, it will fail
the HTLC.  The current low-level tests will hate this, so have a dev switch
to turn that off.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 12:00:17 +09:30
Rusty Russell b1ac490bea daemon: add-route RPC command.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 12:00:17 +09:30
Rusty Russell 26a03acfd0 daemon: routing infrastructure.
Simple routing topology, and ability to ask about the cheapest route.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-07-01 12:00:17 +09:30