Commit Graph

30 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun 494fcec874
breacharbiter: introduce new sub-system to watch for breaches
This commit introduces a new sub-system into the daemon whose job it is
to vigilantly watch for any potential channel breaches throughout the
up-time of the daemon. The logic which was moved from the utxoNursery
in a prior commit now resides within the breachArbiter.

Upon start-up the breachArbiter will query the database for all active
channels, launching a goroutine for each channel in order to be able to
take action if a channel breach is detected. The breachArbiter is also
responsible for notifying the htlcSwitch about channel breaches in
order to black-list the breached linked during any multi-hop forwarding
decisions.
2016-11-28 19:44:09 -08:00
BitfuryLightning 327768f4ad routing: Move tools inside lnd. Refactor and delete unneeded stuff
Use [33]byte for graph vertex representation.
Delete unneeded stuff:
1. DeepEqual for graph comparison
2. EdgePath
3. 2-thread BFS
4. Table transfer messages and neighborhood radius
5. Beacons

Refactor:
1. Change ID to Vertex
2. Test use table driven approach
3. Add comments
4. Make graph internal representation private
5. Use wire.OutPoint as  EdgeId
6. Decouple routing messages from routing implementation
7. Delete Async methods
8. Delete unneeded channels and priority buffer from manager
9. Delete unneeded interfaces in internal graph realisation
10. Renamed ID to Vertex
2016-11-23 20:37:43 -06:00
Andrey Samokhvalov 5b9e4ae61e general: fix typos, rename variables, add comments 2016-11-23 20:02:29 -06:00
Olaoluwa Osuntokun 22074eb737
lnwallet: integrate obfuscated state hints into funding workflow
This commit finalizes the implementation of #58 by integrating passing
around the obfuscate state hints into the funding workflow of the
wallet, and also the daemon’s funding manager.

In order to amend the tests, the functions to set and receive the state
hints are now publicly exported.
2016-11-16 12:54:39 -08:00
Olaoluwa Osuntokun 4fe23a8b3e
lnd: switch over to using brontide for p2p connections
This commit modifies the existing p2p connection authentication and
encryption scheme to now use the newly designed ‘brontide’
authenticated key agreement scheme for all connections.

Additionally, within the daemon lnwire.NetAddress is now used within
all peers which encapsulates host information, a node’s identity public
key relevant services, and supported bitcoin nets.
2016-10-27 19:49:17 -07:00
Olaoluwa Osuntokun 81f7efe1e0
lnwallet+funding: include node net address in reservation workflow
This commit modifies the existing channel reservation workflow slightly
to thread through the IP address that we were able to reach the node
at, or the one which the node reached us via. Additionally, rather than
using OpenChannel.FullSync() at the end of the reservation workflow, we
now use OpenChannel.FullSyncWithAddr() in order to create the
relationship in the database between the channel, and the p2p node we
created the channel with.

All tests, as well as a portion of the fundingManager have been updated
accordingly,
2016-10-26 14:56:58 -07:00
Olaoluwa Osuntokun 290ea7ba5d
lnd: update peer+fundingManager due to channeldb field rename 2016-10-25 16:44:18 -07:00
Olaoluwa Osuntokun bb7f41933f
funding: exit if pending channel doesn't exist for max pending error 2016-10-23 18:37:50 -07:00
Olaoluwa Osuntokun afae7aad2a
lnwire: add concrete error type to ErrorGeneric 2016-10-23 13:41:23 -07:00
Andrey Samokhvalov 7196c4bb1c fundingmanager: add max pending channel check 2016-10-22 02:15:35 +03:00
Andrey Samokhvalov 14c6770b76 general: fix typos 2016-10-22 01:48:05 +03:00
Olaoluwa Osuntokun 9bd5105ae5
cmd/lncli: avoid unnecessarily re-encoding graph vertexes in routing table 2016-09-21 19:48:42 -07:00
Olaoluwa Osuntokun 5ebaf9d1e7
routing: vertexes are now serialized pub keys instead of pubkey hashes 2016-09-21 19:48:35 -07:00
andrew.shvv 2788dbeaa8 Add RPC to show current total available channel capacity #29 (#35)
This commit adds a new RPC command: `channelbalance` which returns the
sum of all available channel capacity across all open channels. The
total balance is currently returned in units of `satoshis`. Additionally
the `networkHarness` has been modified slightly to allow specifying the
additional "extra" command line parameters when creating the initial
seed nodes. Minor refactoring within the integration tests has been
undertaken in order to increase code re-use across tests.

Closes #29.
2016-09-15 12:00:56 -07:00
Olaoluwa Osuntokun 49ce1040d4
lnwallet: adopt simple fee structure for commitment transactions
This commit modifies the prior funding workflow to account for fees
when creating the funding output. As a stop gap, the current fee for
the commitment transaction is now hard-coded at 5k satoshis. Once the
fee models are in place this should instead be some high multiple of
the current “average” fee rate within the network, continuing, the
proper fee should be adjusted from the commitment transaction has
outputs are added/removed.
2016-09-12 19:08:01 -07:00
Olaoluwa Osuntokun 0d871dabb3
lnd: modify the daemon's initialization to use new wallet API's 2016-09-08 12:26:07 -07:00
BitfuryLightning 2bcff188e8 lncli: Add graphical output of routing table
LIGHT-131, LIGHT-140, LIGHT-138
`lncli showroutingtable` may output routing table as image.
Use graphviz for graph rendering.
Add explicit version dependency for tools. Add error checking.
2016-09-06 20:06:51 -04:00
BitfuryLightning d8bceb16f9 routing: Fix bugs with not sending routing messages
LIGHT-138, LIGHT-141. Due to some issues in sending/receiving parts of lnd,
messages with zero length are not sent. So added some mock content to
NeighborAck. Moved sender/receiver from routing message to wrap message
which contains lnwire routing message.
2016-09-06 20:01:21 -04:00
Olaoluwa Osuntokun 832fd248cd
lnd: add async updates for [open|close]channel RPC's
This commit modifies the internal workflow for opening or closing a
channel in order to create a path in which RPC clients can receive
updates. Updates are now communicated via channels from the goroutines
spawned by the RPC server to process the request, and the sub-system
within the daemon that actually executes the request.

With this change clients can now receive updates that the request is
pending (final message has been sent to the target client), or that the
request has been completed. Confirmation related updates have not yet
been implemented as that will require some changes to the ChainNotifier
interface.
2016-08-30 16:53:07 -07:00
Olaoluwa Osuntokun 4bc315d061
lnd: minor clean up with comments + go fmt after latest PR merge 2016-08-11 11:56:03 -07:00
BitfuryLightning f8c851769f multi: initial integration of routing module
This commit integrates BitFury's current routing functionality into lnd. The
primary ochestration point for the routing sub-system in the routingMgr. The
routingMgr manages all persistent and volatile state related to routing within
the network.

Newly opened channels, either when the initiator or responder are inserted into
the routing table once the channel is fully open. Once new links are inserted
the routingMgr can then perform path selection in order to locate an "optimal"
path to a target destination.
2016-08-11 11:20:27 -07:00
Olaoluwa Osuntokun 979b43a3b8
lnd: add log ticker to htlcSwitch, log metrics before forwarding
This commit adds a ticker which attempts to print the total volume
sent/recv over the last 10 seconds if any updates took place during
that interval.

Additionally, when selecting a link to forward an htlcPacket insert a
break after selection in order to properly terminate the loop.
2016-07-21 16:21:33 -07:00
Olaoluwa Osuntokun a56ab46e97
lnd: properly switch RPC port with target net change
With this commit, support for changing the target network (testnet,
simnet, etc) has been finalized. Previously a command line option was
present to swap networks, but the RPC port wouldn’t automatically be
updated to reflect the network.
2016-07-13 18:37:59 -07:00
Olaoluwa Osuntokun 98fae7f329
lnd: properly disconnect peer and clean up resources after critical errors 2016-07-13 16:40:07 -07:00
Olaoluwa Osuntokun 9b29fa3a52
lnd: use channel barriers to synchronize on-chain events and a peer's readHandler 2016-07-12 17:38:14 -07:00
Olaoluwa Osuntokun 07166fe88b
lnd: implement pendingchannels RPC
This commit implements the “pendingchannels” RPC within the rpcserver.
This RPC allows callers to receive details concerning the current
pending channels associated with the daemon. Pending channels are those
waiting for additional confirmations before they can be considered
opened/closed.

At the time of this commit, only open channels are shown. A future
commit will also add the confirmation updates, along with information
for close channels.
2016-07-07 15:33:58 -07:00
Olaoluwa Osuntokun c5cc96a524
lnd: implement the getinfo RPC call 2016-07-05 18:57:14 -07:00
Olaoluwa Osuntokun 927db9cfd5
lnd: update the FundingManager to new revoke key funding workflow 2016-06-30 12:15:06 -07:00
Olaoluwa Osuntokun 1188fd2bf6
lnd: implement open+close channel workflow in daemon
This commit adds the necessary plumbing within the server, peer, and
rpcServer to handle opening and cooperatively closing a channel with a
remote peer.

Many new data structures have been added to the peer in order to allow
it to efficiently manage opening+.losing new/existing lightning
channels. Additional documentation has been added to several methods
within the peer struct, with some minor renaming along with way. The
peer has also gained a dedicated goroutine whose job it is to manage
any requests pertaining to opening, or closing any channels with the
remote peer.

The messages have been added to lnrpc define the requests and responses
to channel open+close messages. Additional channel logic has been added
between the rpcServer, peer, and server in order to properly manage the
necessary synchronization.
2016-06-21 13:14:05 -07:00
Olaoluwa Osuntokun 31e5466692
lnd: introduce the fundingManager
This commit introduces the fundingManger which is used as a bridge
between the wallet’s internal ‘ChannelReservation’ workflow, and the
wire protocol’s funding messages.

 The funding manger is responsible for progressing the workflow, and
communicating any errors generated during the workflow back to the
source peer.
2016-06-21 13:13:49 -07:00