Commit Graph

220 Commits

Author SHA1 Message Date
Johan T. Halseth
8a79bbf383 server: return error from sendPeerMessages
This commit adds a return error to sendPeerMessages,
making it possible to observe if a message sent to
a peer fails or succeeds.
2017-12-19 13:01:59 -06:00
nsa
9fcb845bd2 server: use private parameter when opening channel 2017-12-17 18:35:34 -08:00
Conner Fromknecht
9713cd81fc
server: reorder short-circuit in peer termination watcher
This commit reorders logic in the peer termination
watcher such that we short circuit earlier if we
already have pending persistent connection requests.
Before, the debug statement may have indicated that
a reconnection was being attempted, even though it
may have exited before submitting the request to
the connection manager.
2017-12-13 15:21:57 -08:00
Olaoluwa Osuntokun
1121b0c48b
server+funding: fix bug where funding tx could have zero fees attached
In this commit, we fix an existing bug that would cause funding
transaction to be broadcast without any fees attached at all. This is
only an issue if the fee rate reported is extremely so, as can happen
on testnet. In this case, when we went to scale down to sat/weight, we
would return a value of zero due to integer division. If we went via
the EstimateFeePerWeight call directly, then it would've been detected.
However, we accept the fee/byte from the user directly on the command
line this wasn't being done.

To fix this, we'll now manually set the fee to a sane value, if it
returns a value that can't properly be scaled to fee/weight.
2017-12-12 17:47:39 -08:00
Olaoluwa Osuntokun
c57eda4c6d
server: set default color for self NodeAnnouncements 2017-12-02 18:38:20 -08:00
Olaoluwa Osuntokun
724adb158c
server: lookup DNS seeds directly by active chain's genesis hash
In this commit, we fix a bug that would cause the DNS seeds to be
*always* active regardless of which chain+network we were on. Before we
would look up the network in the reverseChainMap. However, if we were
on regtest or testate, then it would still (incorrectly) resolve to a
valid hash.

To remedy this, we now directly use the genesis hash of the current
active chain.
2017-12-02 18:05:52 -08:00
Olaoluwa Osuntokun
87840f215b
server: disable network bootstrapping for regtest 2017-11-30 22:07:06 -08:00
Olaoluwa Osuntokun
c986e52da7
funding+server: ensure we cancel all reservations when a peer disconnects
In this commit, we fix an existing issue that could at times cause an
inconsistent view between the set of total coins, and the set of segwit
coins in the wallet of the node. This could be caused by initiating a
funding flow, but then the funding negotiation breaking down somewhere
along the lines. In this case, us or the other peer will disconnect.
When we initiate funding flows, we lock coins exclusively, to ensure
that concurrent funding flows don’t end up double spending the same
coin. Before this commit, we wouldn’t ever unlock those coins. As a
result, our view of available coins would be skewed.

The walletbalance call would show all the coins, but when adding the
—witness_only flag, some coins would be missing, or gone all together.
This is because the former call actually scans the txstore and manually
tallies the amount of available coins, while the latter looks at the
sent of available outputs, which is filtered based on which coins are
locked.

To remedy this, we now ensure that when a peer disconnects, we wipe all
existing reservations which will return any locked outputs to the set
of available outputs for funding flows.
2017-11-26 14:08:53 -06:00
Olaoluwa Osuntokun
ad364ae9a1
chains+server: if not in simnet mode, use BtcdFeeEstimator 2017-11-23 23:10:12 -06:00
Olaoluwa Osuntokun
3c4a6f42fa
server: update OpenChannel to properly pass in custom funding fee 2017-11-23 23:10:09 -06:00
Conner Fromknecht
2b74a6549f
server: instantiate utxon with NurseryConfig 2017-11-16 16:16:04 -08:00
Laura Cressman
ed6ad22e85 config+server+networktest: make trickleDelay configurable
Add option to set trickleDelay for AuthenticatedGossiper in
command line, with default value of 300 milliseconds. Pass this
value to newServer, which uses it when creating a new instance of
AuthenticatedGossiper. Also set this value to 300 milliseconds when
creating nodes in integration tests.
2017-11-15 16:50:19 -08:00
Olaoluwa Osuntokun
d894917458
server: add new shouldRequestGraphSync method to gate third feature bit
In this commit, we add a new method shouldRequestGraphSync which the
server will use in order to determine if we should request a full
channel graph sync from a newly connected remote peer. Atm, we’ll only
request a full sync iff, we have less than two peers. This is only the
initial basic logic, as we’ll later extend this to be more
comprehensive.

With this change, we’ll no longer be blasted by full channel graph
dumps for _each_ new connection after we deem that we’ve been
sufficiently bootstrapped to the network.
2017-10-18 15:18:13 -07:00
Olaoluwa Osuntokun
56d4c15914
peer: add localFeatures as parameter to newPeer
In this commit we add the set of local features advertised as a
parameter to the newPeer function. With this change, the server will be
able to programmatically determine _which_ bits should be set on a
connection basis, rather than re-using the same global set of bits for
each peer.
2017-10-18 15:16:09 -07:00
Jim Posen
ee49cdd103 server: Respect the initial_routing_sync feature bit.
Only synchronize routing info with peer if they request it by setting
the appropriate local feature bit.
2017-10-17 22:47:20 -07:00
Jim Posen
9fd77a6e40 multi: Update lnd to use new feature vector API. 2017-10-17 22:47:20 -07:00
Olaoluwa Osuntokun
61be23dc31
htlcswitch+server: add new field SelfKey to htlcswitch.Config
This commit adds a new field to the switch’s Config, namely the public
key of the backing lightning node. This field will soon be used to
return more detailed errors messages back to the ChannelRouter itself.
2017-10-16 18:39:17 -07:00
Olaoluwa Osuntokun
9b0b945a3d
Revert "server: BroadcastMessage will no longer block until completion"
This reverts commit 6db90ef09ab974df0ff09aeaf75a3d80414d4f50.

The root cause was fixed by commit
f4e7c36c80e8e2be9edb78b3b317c69d28d6d78f. As a result, this commit is no
longer needed.
2017-10-16 14:54:30 -07:00
Olaoluwa Osuntokun
7300452225
Revert "server: make sendToPeer async"
This reverts commit b7704e2de3dc96a4aebc2f47908a8f9def1da7f6.

The root issue was fixed by commit
f4e7c36c80e8e2be9edb78b3b317c69d28d6d78f. As a result, this commit is no
longer needed.
2017-10-16 14:53:24 -07:00
Olaoluwa Osuntokun
b7704e2de3
server: make sendToPeer async
This commit removes another case of unnecessary blockage, by modifying
the sendToPeer method to be fully asynchronous. From the PoV of the
callers that utilize this method currently, there’s no reason to block
until the completion of this method. Additionally, as the graph grows
larger without more intelligent the number of messages sent during
initial dump will start to be prohibitive to waiting for full
completion before proceeding.
2017-10-14 17:07:08 -07:00
Olaoluwa Osuntokun
6db90ef09a
server: BroadcastMessage will no longer block until completion
In this commit, we make the BroadcastMessage method on the server more
asynchronous by abandoning the two wait groups that it used for
synchronization. It has been observed that a circular waiting loop
between the AuthenticatedGossiper and a peer’s readHandler can cause
the system to dead lock.

By removing this unnecessary synchronization, we avoid the deadlock
case and allow the gossiper itself to no longer block in this scenario.
2017-10-14 16:04:06 -07:00
Conner Fromknecht
7aa64d58da server: improves readibility of peer connection logic 2017-10-13 16:12:31 -07:00
Conner Fromknecht
96ff63d219 server: fixes race condition during unexpected peer disconnect 2017-10-13 16:12:31 -07:00
Olaoluwa Osuntokun
63838f5764
peer+server: use new sphinx package and htlcswitch package type names 2017-10-10 22:19:21 -07:00
Olaoluwa Osuntokun
e5c303375b
server: in peerBootstrapper check for enough conns before attempting backoff
In this commit we modify the main loop within the peerBootstrapper
slightly to check for a sufficient amount of connections, _before_
checking to see if we need to back off the main loop. With this, we
avoid unnecessarily backing off unless an actual error occurs.
2017-10-10 22:19:13 -07:00
Olaoluwa Osuntokun
3b7855e449
routing: implement 2-week zombie channel pruning
This commit implements 2-week zombie channel pruning. This means that
every GraphPruneInterval (currently set to one hour), we’ll scan the
channel graph, marking any channels which haven’t had *both* edges
updated in 2 weeks as a “zombie”. During the second pass, all “zombie”
channel are removed from the channel graph all together.

Adding this functionality means we’ll ensure that we maintain a
“healthy” network view, which will cut down on the number of failed
HTLC routing attempts, and also reflect an active portion of the graph.
2017-10-04 20:46:09 -07:00
Brandon
3907ae65c2 routing+discovery: implement 2-week network view pruning 2017-10-04 20:40:21 -07:00
Olaoluwa Osuntokun
32508344db
server: use Debugf instead of Debug for logging in peerBootstrapper 2017-10-04 16:58:57 -07:00
Olaoluwa Osuntokun
c8226b1393
server: fix logging statement in peerBootstrapper
This commit fixes an incorrect logging statement within the
peerBootstrapper goroutine. We we’re using a Debug method previously
when we should’ve been using Debugf in order to properly pass the
logging statement through.
2017-10-04 14:52:54 -07:00
John Griffith
54c4fc4559 htlcswitch+server: pass onion error to ChannelRouter 2017-10-02 22:12:50 -07:00
Johan T. Halseth
4b4c431d67
server: add NotifyWhenOnline method.
This commit adds a listener queue for each peer, that can be used
to queue listeners that will be notified when the targetted peer
eventually comes online.
2017-10-02 13:29:51 +02:00
Olaoluwa Osuntokun
bd63e048d8
server: remove stray logging debugging statement from peerBootstrapper 2017-09-25 11:06:47 -07:00
Conner Fromknecht
e32d3024ae
server: instantiate breacharbiter using BreachConfig 2017-09-19 19:18:20 -07:00
Olaoluwa Osuntokun
8a208ae3cd
server: disable bootstrapping for simnet mode by default 2017-09-12 22:13:52 +02:00
Olaoluwa Osuntokun
fe0a7b6a09
multi: fix linter errors 2017-09-03 17:05:11 -07:00
Olaoluwa Osuntokun
1196c2e254
server: introduce new peerBootstrapper goroutine to seed initial conns
This commit adds a new primary goroutine to the server struct:
peerBootstrapper. If peer boostrapping isn’t disabled in the config,
this new goroutine will be launched to attempt to establish a set of
initial connections for a new node. The logic is pretty straight
forward: first a set of initial connections is attempted, if after our
first epoch, we don’t have enough connections yet, then we’ll attempt
to query for an additional set. In each iteration, if we haven’t been
successful, then we increase our exponential backoff in order to not
spam any of our bootstrapping sources.
2017-09-03 16:58:21 -07:00
Olaoluwa Osuntokun
2eb718e177
server: populate gossiper with chainhash of active chain 2017-09-03 16:41:43 -07:00
Olaoluwa Osuntokun
c09713ebd1
peer+server: rename discoverSrv to authGossiper 2017-08-22 00:53:25 -07:00
Olaoluwa Osuntokun
01b0ddf1c5
lnd+rpc: update RPC responses to convert mSAT to SAT 2017-08-22 00:52:56 -07:00
Olaoluwa Osuntokun
c4e43dbaa2
server: avoid nil pointer deference within OutboundPeerConnected 2017-08-15 17:49:35 -07:00
Olaoluwa Osuntokun
472d9967e5
server: fix some minor style deviations in new server code 2017-08-10 21:20:54 -07:00
Olaoluwa Osuntokun
bee7ed7758
server: re-introduce the quit channel to the server
This commit re-introduces the quit channel to the server as an upcoming
addition needs to synchronize its shutdown with the lifetime of the
server.
2017-08-10 21:19:00 -07:00
Olaoluwa Osuntokun
947544753f
server: use %x (hex encoding) when logging peer's pub key 2017-08-10 21:17:07 -07:00
Conner Fromknecht
91d6b0492e server: refactors w/ single mutex and sync disconnect
This commit alters the synchronization patterns used in the server
  such that the internal state is protected by a single mutex.  Overall,
  this simplifies the ability to reason about the behavior and
  manipulation of the internal state, which has resolved a few of flakes
  related to race conditions that were observed before hand.

  Invoking DisconnectPeer is now fully synchronous, and waits until
  the provided peer's peerTerminationWatcher has exited before
  returning.  Currently this is done by tracking the watcher using the
  peer's WaitGroup, and locking until the peer has shutdown.

  The server's API has also been refactored such that all public methods
  are safe for concurrent use. Therefore, other subsystems should be
  sure to make use of these endpoints to avoid corrupting the internal
  state.
2017-08-10 16:14:01 -07:00
Johan T. Halseth
c497a63f14 server: return copy of current node announcement instead of ref 2017-08-08 12:29:27 -07:00
Olaoluwa Osuntokun
d38b4471c2
server: if a fresh announcement is requested, ensure seqno increases 2017-08-07 16:31:20 -07:00
Olaoluwa Osuntokun
43b736225b
multi: add new method to generate fresh node announcments 2017-08-04 18:32:33 -07:00
Olaoluwa Osuntokun
d39410cc01
rpc: wrap canceling a breach watch in a select case 2017-08-03 16:40:15 -07:00
Olaoluwa Osuntokun
c2aafe7e51
server: add a method to query if the server has started
This commit adds a new utility method to the server struct itself. This
method will allow callers to query the state of the server in order to
decide if the server has been started or not. This can be useful
elsewhere in the project as we start to decouple the lifetime of
certain sub-systems from others.
2017-08-02 20:56:34 -07:00
Johan T. Halseth
ebbe6d7a10 server: set HaveNodeAnnouncement=true for self LightningNode 2017-08-02 15:58:58 -07:00
Olaoluwa Osuntokun
07212588fc
funding: update funding workflow to adhere to BOLT-0002
This commit updates the main single-funder funding workflow within the
fundingManager (initiated via the rpcserver or by a message from a
connected peer) to fully adhere to the funding protocol outlined in
BOLT-0002.

The major changes are as follows:
  * All messages modified to use the new funding messages in BOLT-0002.
  * The initiator of a funding workflow no longer decides how many
confirmations must elapse before the channel can be considered open.
  * Rather than each side specifying their desired CSV delay, both
sides now specify the CSV delay for the _other_ party.
2017-07-30 17:51:57 -07:00
Olaoluwa Osuntokun
34bb0ec36f
server: within peerTerminationWatcher exit early if daemon is exiting 2017-07-30 17:51:41 -07:00
Olaoluwa Osuntokun
a04fa76a4c
lnwire+htlcswitch: minor grammatical, formatting fixes after error PR 2017-07-14 20:08:37 -07:00
Andrey Samokhvalov
79b8d26b1a htlcswitch+router+server: handle payment error topology updates
In previous commits we have intoduced the onion errors. Some of this
errors include lnwire.ChannelUpdate message. In order to change
topology accordingly to the received error, from nodes where failure
have occured, we have to propogate the update to the router subsystem.
2017-07-14 19:08:04 -07:00
Andrey Samokhvalov
6bbb7cbfc3 lnd: hook up encrypted onion error scaffolding
In this commit daemon have been changed to set the proper hooks in the
channel link and switch subsystems so that they could send and receive
encrypted onion errors.
2017-07-14 19:08:04 -07:00
Andrey Samokhvalov
ef73062c14 peer+server+htlcswitch: add reason to disconnnect function
In order to recognize exact reason of the disconnect the additional
field have been added in the disconnect function.
2017-07-14 19:08:04 -07:00
Olaoluwa Osuntokun
11f7a227ab
server: update to latest htlcswitch API changes 2017-06-17 00:10:22 +02:00
Olaoluwa Osuntokun
aec8c8dc77
lnd: decouple rpcServer from server, wait till chain synced before starting server
This commit overhauls the way that lnd is created with the goal of
ensuring the chain backends are fully synced up before the daemon
itself starts. The rpcServer has been slightly decoupled from the
server itself s.t we can start the rpcServer independently of the
server. This is required as we’ll now wait (unless we’re in simnet
mode) for the chain to fully sync up before we even _start_ any of the
server’s goroutines.
2017-06-05 19:22:12 -07:00
Olaoluwa Osuntokun
fb4121ba6c
server: Peers method now grabs data directly with read mutex
This commit modifies the Peers method on the server such that a caller
is able to query this method without the main serger goroutines
started. This is a small component in a larger change which will let us
start the RPC server independently of the server.
2017-06-05 19:15:22 -07:00
Olaoluwa Osuntokun
25dc294cf0
server: all references to primary interfaces are now through chainControl 2017-06-05 18:53:37 -07:00
Andrey Samokhvalov
c4955258f1 htlcswicth: start use htlcswitch and channel link inside lnd
In current commit big shift have been made in direction of unit testable
payments scenarios. Previosly two additional structures have been added
which had been spreaded in the lnd package before, and now we apply
them in the lnd itself:

1. ChannelLink - is an interface which represents the subsystem for
managing the incoming htlc requests, applying the changes to the
channel, and also propagating/forwarding it to htlc switch.

2. Switch - is a central messaging bus for all incoming/outgoing htlc's.
The goal of the switch is forward the incoming/outgoing htlc messages
from one channel to another, and also propagate the settle/fail htlc
messages back to original requester.

With this abtractions the folowing schema becomes nearly complete:

abstraction
    ^
    |
    | - - - - - - - - - - - - Lightning - - - - - - - - - - - - -
    |
    | (Switch)		        (Switch)		  (Switch)
    |  Alice <-- channel link --> Bob <-- channel link --> Carol
    |
    | - - - - - - - - - - - - - TCP - - - - - - - - - - - - - - -
    |
    |  (Peer) 		        (Peer)	                  (Peer)
    |  Alice <----- tcp conn --> Bob <---- tcp conn -----> Carol
2017-05-31 11:06:08 -07:00
Olaoluwa Osuntokun
75858a604a
lnd: use a single instance of a FeeEstimator daemon-wide 2017-05-16 19:11:49 -07:00
bryanvu
abe2e502d5 lnwallet: add FeeEstimator interface, StaticFeeEstimator implementation
This commit adds the FeeEstimator interface, which can be used for
future fee calculation implementations. Currently, there is only the
StaticFeeEstimator implementation, which returns the same fee rate for
any transaction.
2017-05-15 20:26:11 -07:00
Olaoluwa Osuntokun
5fe3a5631d
server: eliminate possible initial connection churn by ignoring duplicate inbound conns
This commit fixes a bug that was introduced when the connection
handling was re-worked to properly handle the case of concurrent
connections being made. In certain cases after a successful initial
connection, a peer’s stray goroutine would still attempt to establish a
second outbound connection even though a connection had already been
established. This was properly handled by the connecting peer, but not
he receiving peer. This commit adds the additional logic to the
receiving peer to ensure that we properly handle this case.
2017-05-11 15:21:02 -07:00
Olaoluwa Osuntokun
a75439f56b
lnd: properly initialize ChannelRouter with FilteredChainView 2017-05-11 15:20:57 -07:00
Andrey Samokhvalov
8e4199ee92 discovery+server: make waiting proofs persistent
In this commit waiting proofs array have been replaced with persistant
boltd storage which removes the possibility for the half proof to be
lost during half proof exchange.
2017-05-05 17:02:49 -07:00
Olaoluwa Osuntokun
6429962d27
rpc: modify DisconnectPeer implementation to do all validation within rpcServer
This commit modifies the implementation of the new DisconnectPeer RPC
in the following ways:
   * all validation has moved from the server to the rpcserver
   * rather than iterating over _all_ channels, we now only check the
     peer’s channels
   * the disconnectPeerMsg now has a public key object
      * this allows us to also verify that the user submitted a valid
        pub key string
   * we now check if a peer was persistent when disconnecting so we can
     remove them from the persistent peer map
2017-05-05 16:02:20 -07:00
Olaoluwa Osuntokun
98adeb6657
server: properly add user initiated persistent conns to persistentPeers map
This commit fixes a prior bug wherein if a user connected to a peer
using the —perm command, then once the peer was disconnected, we
wouldn’t automatically connect to them.
2017-05-05 15:57:14 -07:00
afederigo
cf605c81ab lnd: add server calls for disconnecting peers
Issue: 139

This commit contains client-side and server-side functionality
for disconnecting peers. rpc-client calls server side method and sends
message with pubKey.
2017-05-05 14:24:25 -07:00
Olaoluwa Osuntokun
f335250512
server: fix regression in handling persistent connection requesrts
This commit fixes a bug that was introduced when the concurrent
connection handling logic was re-written: if we don’t properly add the
persistent outbound connection to the persistent conn reqs map. The fix
is easy: add the pending conn req to the proper map.
2017-05-04 17:40:49 -07:00
Olaoluwa Osuntokun
e1152148b7
server: only attempt to reconnect to peer if connection not pending
This commit fixes a bug that would possibly result in tens of goroutine
beaching launched in an attempt to persistently connect to a peer. This
bug has been fixed by ensuring that we’ll only launch a new pending
connection attempt if we don’t already have one pending.
2017-05-04 17:39:08 -07:00
Olaoluwa Osuntokun
4cb76071a2
server+peer: re-write persistent connection handling
The prior methods we employed to handle persistent connections could
result in the following situation: both peers come up, and
_concurrently_ establish connection to each other. With the prior
logic, at this point, both connections would be terminated as each peer
would go to kill the connection of the other peer. In order to resolve
this issue in this commit, we’ve re-written the way we handle
persistent connections.

The eliminate the issue described above, in the case of concurrent peer
connection, we now use a deterministic method to decide _which_
connection should be closed. The following rule governs which
connection should be closed: the connection of the peer with the
“smaller” public key should be closed. With this rule we now avoid the
issue described above.

Additionally, each peer now gains a peerTerminationWatcher which waits
until a peer has been disconnected, and then cleans up all resources
allocated to the peer, notifies relevant sub-systems of its demise, and
finally handles re-connecting to the peer if it's persistent. This
replaces the goroutine that was spawned in the old version of
peer.Disconnect().
2017-04-23 19:58:03 -07:00
Olaoluwa Osuntokun
fe3c90362e
server: move establishment of persistent connections to Start() 2017-04-23 19:21:35 -07:00
Olaoluwa Osuntokun
920fcf3392
lnwire: modify newAlias to no longer return an error 2017-04-19 14:59:22 -07:00
Olaoluwa Osuntokun
d74d3fa0f3
server: initialize temp chan ID seed, add new FindChannel func for fundingMgr 2017-04-16 15:40:01 -07:00
Olaoluwa Osuntokun
7ac50b060e
rpc: re-write GetNetworkInfo implementation to use single db transaction
This commit re-writes the GetNetworkInfo implenetaiton to use a single
database transaction. We’re now able to do this due to the recent
change in the API for the ChannelGraph struct and it’s related objects.
The recent change allows the passed callback to accept a db
transaction, with this, the callback is now able to issue another
traversal routine _within_ the prior one.
2017-04-14 13:18:02 -07:00
Olaoluwa Osuntokun
eb37dba3f6
funding: modify fundingManager config to use SignMessage for ann's
This commit modifies the fundingManager config to use the a SignMesage
function rather than two distinct functions for singing one half the
channel announcement proofs. This change unifies the signing of
messages under a single abstraction: the MessageSigner interface.
2017-04-14 11:17:48 -07:00
Olaoluwa Osuntokun
d93e3e6fbe
server: assume default port if one not present for --externalip 2017-04-13 14:41:58 -07:00
Olaoluwa Osuntokun
a22ba92630
server: eliminate possibly deadlock, peerConnected now async
This commit eliminates a possible deadlock (or repeated peer connection
failures) that can arise due to the [inbound|outbound]PeerConnected
methods holding the peer mutex too long. We now alleviate this
concurrency issue by calling s.peerConnected in an asynchronous manner.
This is safe as all operations within the method are themselves
goroutine-safe.
2017-04-11 22:02:06 -07:00
Olaoluwa Osuntokun
ca053e5273
multi: minor coding style and comment clean ups post-discovery merge
This commit implements some minor coding style, commenting and naming
clean up after the recent major discovery service was merged into the
codebase.

Highlights of the naming changes:
* fundingManager.SendToDiscovery -> SendAnnouncement
* discovery.Discovery -> discovery.AuthenticatedGossiper

The rest of the changes consist primary of grammar fixes and proper
column wrapping.
2017-04-01 20:14:05 +02:00
Andrey Samokhvalov
d4055d7830 discovery+funding: add validation of the announcement messages
Add validation functions and include validation checks in the
annoncement process function.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
fbf766e3c6 discovery+funding: add 'AnnounceSignature' proof exchange
Add the interaction between nodes of announce signature messages, which
will allow us to exhcnage the half channel announcemen proofs later.
2017-03-29 19:49:05 -07:00
Andrey Samokhvalov
4c52b6e6a4 lnd: replace 'routing' with 'discovery' package
Add usage of the 'discovery' package in the lnd, now discovery service
will be handle all lnwire announcement messages and send them to the
remote party.
2017-03-29 19:49:05 -07:00
Olaoluwa Osuntokun
0e96d273d9
peer: enforce strict timeout on opening handshake
This commit modifies the logic around the opening p2p handshake to
enforce a strict timeout around the receipt of the responding init
message. Before this commit, it was possible for the daemon and certain
RPC calls to deadlock as if a peer connected, but didn’t respond with
an init msg, then we’d be sitting there waiting for them to respond.
With this commit, we’ll now time out, kill the connection and then
possible attempt to re-connect if the connection was persistent.
2017-03-29 19:00:40 -07:00
Olaoluwa Osuntokun
afe77853b7
server+lnwire: pre-allocate address slices 2017-03-29 19:00:31 -07:00
bryanvu
c9c2848427 server: user NodeAnnouncement addresses and ports for reconnect
Use addresses and ports from NodeAnnouncement messages for reconnection
attempts. For those nodes that don't explicitly report IP addresses, use
the IP address from previous connections connection request along with
the default peer port number.
2017-03-29 12:03:43 -07:00
bryanvu
085b7333cb lnwire: add support for Features in NodeAnnouncement
Add support for Features in NodeAnnouncment according to spec.
2017-03-29 12:03:43 -07:00
bryanvu
3087bec4db connmgr: for nodes with multiple addresses, attempt to connect to each
address.
2017-03-29 12:03:43 -07:00
bryanvu
654c5ea61a config: added support, tests for --externalip config option
Minor change to server.go to add ExternalIPs to
channeldb.LightningNode. Also, added a test that utilizes this
functionality and exercises multiple addresses in NodeAnnouncement.
2017-03-29 12:03:43 -07:00
bryanvu
9ffac9eae1 lnwire: update NodeAnnouncement to handle multiple addresses
This commit modifies address handling in the NodeAnnouncement struct,
switching from net.TCPAddr to []net.Addr. This enables more flexible
address handling with multiple types and multiple addresses for each
node. This commit addresses the first part of issue #131 .
2017-03-29 12:03:43 -07:00
Olaoluwa Osuntokun
ec52c49b6c
lnd+lnwallet+glide: replace last lingering instances of fastsha256 2017-03-16 19:40:29 -07:00
andrew.shvv
35813ad939 server: fix panic when error occures on peer intialization (#163)
If an error occurs during, peer initialization then 'p' is nil. This 
may cause a panic while accessing the peer's member 
variables.

To avoid such panics, we now omit the call to `p.Disconnect` 
and also directly access the `connmgr.ConReq` variable if it's 
non-nil.
2017-03-16 12:37:36 -07:00
Olaoluwa Osuntokun
f217093c00
multi: replace usage of fastsha256 with crypto/sha256
This commit removes all instances of the fastsha256 library and
replaces it with the sha256 library in the standard library. This
change should see a number of performance improvements as the standard
library has highly optimized assembly instructions with use vectorized
instructions as the platform supports.
2017-03-15 18:56:41 -07:00
Olaoluwa Osuntokun
5cc0765b63
funding: rename ProcessRoutingMessage to SendToRouter
This commit renames routing processing method in the funding mangers
config from ProcessRoutingMessage to SendToRouter and also modifies the
signature to only require the message itself and not the server’s
identity public key.
2017-02-24 16:31:57 -08:00
bryanvu
eb490b8833 lnwire: add FundingLocked message
When the funding transaction has been confirmed, the FundingLocked
message is sent by the peers to each other so that the existence of the
newly funded channel can be announced to the network.

This commit also removes the SingleFundingOpenProof message.
2017-02-24 11:37:33 -08:00
bryanvu
e549a3f0ed fundingmanager: move final funding steps from wallet to funding manager.
Once a channel funding process has advanced to the point of broadcasting
the funding transaction, the state of the channel should be persisted
so that the nodes can disconnect or go down without having to wait for the
funding transaction to be confirmed on the blockchain.

Previously, the finalization of the funding process was handled by a
combination of the funding manager, the peer and the wallet, but if
the remote peer is no longer online or no longer connected, this flow
will no longer work. This commit moves all funding steps following
the transaction broadcast into the funding manager, which is available
as long as the daemon is running.
2017-02-24 11:37:33 -08:00
Olaoluwa Osuntokun
e910b12d33
lnd: fix issues reported by golint+govet
github.com/lightningnetwork/lnd  master ✗

                                           0m ◒
▶ golint
htlcswitch.go:292:4: should replace numUpdates += 1 with numUpdates++
htlcswitch.go:554:6: var onionId should be onionID
htlcswitch.go:629:7: var onionId should be onionID
lnd_test.go:133:1: context.Context should be the first parameter of a
function
lnd_test.go:177:1: context.Context should be the first parameter of a
function
networktest.go:84:2: struct field nodeId should be nodeID
peer.go:1704:16: should omit 2nd value from range; this loop is
equivalent to `for invoice := range ...`
rpcserver.go:57:6: func newRpcServer should be newRPCServer

github.com/lightningnetwork/lnd  master ✗

                                        9m ⚑ ◒  ⍉
▶ go vet
features.go:12: github.com/lightningnetwork/lnd/lnwire.Feature
composite literal uses unkeyed fields
fundingmanager.go:380: no formatting directive in Errorf call
exit status 1
2017-02-22 14:58:37 -08:00
Olaoluwa Osuntokun
2636e654be
funding: ensure reservation contexts are remove in the case of workflow error 2017-02-22 14:51:45 -08:00
Andrey Samokhvalov
4c4ce93730 peer: fix panic during peer connection 2017-02-22 14:50:48 -08:00
bryanvu
b21bd351e8 fundingmanager: change funding messages to use server.sendToPeer
Previously, during the channel funding process, peers sent wire
messages using peer.queueMsg. By switching to server.sendToPeer, the
fundingManager is more resilient to network connection issues or system
restarts during the funding process. With server.sendToPeer, if a peer
gets disconnected, the daemon can attempt to reconnect and continue the
process using the peer’s public key ID.
2017-02-21 19:21:19 -08:00