Commit Graph

951 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun 4e53cf8b49
lnwallet: correct error message in txn subscription test 2017-01-07 21:20:47 -08:00
bryanvu 35cf21733d chainntnfs: exit notifyBlockEpochs upon shutdown
On restarts, notifyBlockEpochs would intermittently attempt to send new
block epoch notifications to clients that had already been shut down,
causing a “send on closed channel” error. This change exits
notifyBlockEpochs upon shutdown so as to prevent this.
2017-01-07 19:39:01 -08:00
bryanvu 24a99ade66 test: remove concurrent payment sends from testMultiHopPayments
testMultiHopPayments was failing intermittently due to a lack of
thread-safety in the gRPC stream. This commit takes payment sending out
of goroutines so that they execute serially.
2017-01-07 19:39:01 -08:00
Alex 89c772aac3 README: fix some typos 2017-01-05 16:42:43 -08:00
Alex e91c1b8136 docs: add installation instructions 2017-01-05 16:42:43 -08:00
Olaoluwa Osuntokun d7b36c6f31
build: update glide dependancies since roasbeef/btcsuite upstream merge 2017-01-05 14:08:43 -08:00
Olaoluwa Osuntokun 3741ae1d4c
lnd: fix lingering connmgr import 2017-01-05 14:08:36 -08:00
Olaoluwa Osuntokun 594dc1b163
lnd: switch to the version of the connmgr in roasbeef's fork 2017-01-05 13:58:11 -08:00
Olaoluwa Osuntokun 5affed38fc
multi: update btcsuite API's to latest upstream changes
This commit makes a large number of minor changes concerning API usage
within the deamon to match the latest version on the upstream btcsuite
libraries.

The major changes are the switch from wire.ShaHash to chainhash.Hash,
and that wire.NewMsgTx() now takes a paramter indicating the version of
the transaction to be created.
2017-01-05 13:56:34 -08:00
Olaoluwa Osuntokun 5d37c1d9e7
uspv: remove package as it's no longer actively used within the project 2017-01-05 13:27:14 -08:00
Olaoluwa Osuntokun 798b0b9c9f
utxonursery: minor post-merge formatting clean ups
This commit implements so minor changes in formatting: character column
limits, error returning, scoped, errors. The aforementioned changes are
a bit of minor clean up after the merge of the latest PR in order to
ensure the new code in the file conforms to the code style in the rest
of the project.
2017-01-05 13:25:55 -08:00
Olaoluwa Osuntokun beb6303e2f
breacharbiter: only log if we have any active channels
This commit modifies the contractObserver slightly to along log if we
have any active channels, which avoids a meaningless log message.
2017-01-05 13:21:47 -08:00
Olaoluwa Osuntokun 5957725975
lnwallet: mine enough blocks to activate CSV+segwit in reservation tests 2017-01-05 13:20:37 -08:00
Olaoluwa Osuntokun fb3bc04d65
test: mine enough blocks to active CSV+segwit in integration tests
As we’re switching to a more up to date btcd branch that properly
guards the activation of the soft-forks we rely on, we’ll also need to
ensure the two soft-forks have activated.
2017-01-05 13:18:37 -08:00
Olaoluwa Osuntokun ad76899a57
config+test: use default port for RPC server if one isn't specified
This commit alters the configuration parsing a bit along with the
documentation to expect the RPCHost configuration paramter to also have
the target port specified. If the port isn’t included, then the default
btcd RPC port for that chain is used.

Additionally, within the integration testing framework, when creating
the lnd nodes, we now use the configuration from the btcd harness to
set the proper RPC host.
2017-01-05 13:18:26 -08:00
Olaoluwa Osuntokun 8fe5c09e21
lnd: remove support for the now obsolete SegNet4 2017-01-05 13:08:15 -08:00
bryanvu aa04f82a15 utxonursery: added persistence to transaction output states
Moved transaction states from in-memory maps to persistent BoltDB
buckets. This allows channel force closes to operate reliably if the
daemon is shut down and restarted at any point during the forced
channel closure process.
2017-01-03 16:23:07 -08:00
bryanvu 90ed23e6aa chainntnfs: fixed off-by-one in attemptHistoricalDispatch 2017-01-03 16:23:07 -08:00
bryanvu def39799c5 chainntnfs: handling for potential deadlocks during system shutdown
If the lnd daemon is shut down while multiple subsystems are attempting
to register for notifications, the blocking of those chain notifier
registrations may cause the daemon shutdown to deadlock. The additions
in this commit allow the registration functions to return errors rather
than potentially deadlock when the chain notifier is shut down.
2017-01-03 16:23:07 -08:00
Olaoluwa Osuntokun b991cd3d78
multi: allow force channel closures while not connected to peer
This commit adds a much needed feature to the daemon, namely the
ability to force close a channel while the source daemon doesn’t have
an active connection to the counter party. Previously this wasn’t
possible as ALL channel closures were routed through the htlcSwitch
which is only able to trigger a channel closure if the peer is online.

To remedy this, if the closure type is “force” then, we now handle the
channel closure and related RPC streaming updates from the call handler
site of the RPC itself. As a result, there are now only two htlcSwitch
channel closure types: breach, and regular. The logic that’s now in the
rpcSever should likely be refactored into a distinct sub-system, but
getting the initial functionality in is important.

Finally, the channel breach integration test has been modified to skip
connection the peers before attempting the forceful channel closure of
a revoked state as the remote peer no longer needs to be online.
2017-01-03 16:04:47 -08:00
Olaoluwa Osuntokun 57c0f8f005
test: add short sleep before channel assert to account for gossip propagation
This commit adds a short sleep before a channel assertion in the
`testMaxPendingChannels` test. This sleep serves to give the nodes
enough time to propagate the new channel announcement over the
authenticated gossip system. Without this sleep, the call may be issued
in a state wherein only half of the channel announcement has fully
propagated.
2017-01-02 15:47:02 -08:00
Olaoluwa Osuntokun 9b50df704c
cmd/lncli: accept zpay32 requests in sendpayment command 2017-01-02 15:46:54 -08:00
Olaoluwa Osuntokun 5a9be3f812
cmd/lncli: display zpay32 request in addinvoice response 2017-01-02 15:37:16 -08:00
Olaoluwa Osuntokun 19bf044bdb rpcserver: accept+parse encoded zpay32 requests in SendPayment 2017-01-02 15:36:15 -08:00
Olaoluwa Osuntokun 5d655ea332
rpcserver: disallow zero valued invoices 2017-01-02 15:35:28 -08:00
Olaoluwa Osuntokun fce366894d
rpcserver: return an encoded payment request in AddInvoice
This commit modifies the generated response to an “AddInvoice” RPC by
including an encoded payment request in the response. This change gives
callers a new atomic piece of information that they can present to the
payee, to allow completion of the payment in a seamless manner.
2017-01-02 15:34:53 -08:00
Olaoluwa Osuntokun ca84c620ea
lnrpc: return encoded payReq in AddInvoice, accept payReq's in SendPayment 2017-01-02 15:31:44 -08:00
Olaoluwa Osuntokun bd0cf51581
zpay32: create new package for encoding/decoding payment requests
This commit adds a new package “zpay32”: which is used within the
daemon to encode/decode payment requests. A payment request currently
consists of: the public key of the payee, the payment hash to use, and
finally the amount to send over the network. The encoded payment
request consists of the mentioned fields concatenated to each other, a
cc32 checksum is added, then the blob is finally encoded using zbas32.
I call the resulting scheme “zpay32”.

A number of extensions may be explored in future commits including
adding a version byte, adding “hint” routing information,
cryptographically signed receipts and more,
2017-01-02 15:17:58 -08:00
Olaoluwa Osuntokun d2e712c19d glide: update build dependancies 2016-12-30 16:44:51 -08:00
Olaoluwa Osuntokun 82815b703e
rpcserver: refactor logic for ListPayments/DeleteAllPayments
This commit slightly refactors the logic for the new outgoing payment
related RPC’s to more closely match the style of the rest of the
codebase. Additionally the tests have been updated to reflect the
changes to the protos of the new RPC’s.
2016-12-30 16:42:10 -08:00
Olaoluwa Osuntokun 480fd8d03f
lnrpc: rename r_hash to payment_hash in Payment message 2016-12-30 16:38:54 -08:00
Olaoluwa Osuntokun 630afbdc93
channeldb: don't return error from HasChannelEdge if single edge doesn't exist
This commit modifies the error propagating behavior within the
HasChannelEdge struct. Rather than exiting the function early when a
single edge isn’t found, we instead continue to also possibly retrieve
the second directional edge.

With this change, we avoid a potential infinite gossiping loop in the
routing package that would result if we’d seen one edge but not the
other. In this case the timestamps returned for *both* edges would
always be zero, causing the daemon to always accept and rebroadcast the
announcement putting all other connected lnd’s into the same loop.
2016-12-30 16:35:30 -08:00
Olaoluwa Osuntokun f7510cf1fc
channeldb: modify new payments module to match project code-style
This commit modifies the new payment module within the database to
match the coding style of the rest of the package and the project as a
hole. Additionally, a few fields have been renamed, and the extra
timestamp added to the OutgoingPayment struct has been removed as
there’s already a CreationTime field within the Invoice struct that’s
embedded within the OutgoingPayment struct.
2016-12-30 16:32:25 -08:00
Olaoluwa Osuntokun 276c384455
breacharbiter: fix double channel close panic bug
This commit fixes s bug in the breachArbiter which was introduced
during the change that added the live channel hand off from an active
peer. Rather than closing the settle channel of the _older_
breachObserver, the settle channel of the newer beachObserver was being
closed. This would result in a panic once the channel itself was
actually settled as the channel would be closed again.

To fix this bug, we now properly close the channel of the old settle
signal instead of the new one.
2016-12-30 16:30:11 -08:00
Olaoluwa Osuntokun 0585ed93be
lnwallet: use in-memory height within channel's closeObserver
This commit partially rectifies a quick hack that was previously thrown
in to address an issue discovered due to possible state inconsistencies
between an active channel object and the daemon’s breachAbrbiter.

A prior commit has modified the interaction between the peer and the
breachArbiter to eliminate the state in consistency. Therefore, we no
longer need to access the database to ensure that we’re observing the
latest channel state in order to correctly make a decision about
whether a broadcast commitment transaction is a breach or not.
2016-12-27 16:45:10 -08:00
Olaoluwa Osuntokun 3e1c98f2f7
breacharbiter: accept handoff for live channel on peer connect
This commit modifies the interaction between the breachArbiter and the
peer struct such that the breachArbiter _always_ has the latest version
of a contract.

Prior to this commit once we connected out to a peer which we had an
active contract with and the breachArbiter was watching, we’d have two
copies of the channel in memory, instead of just a single one. This was
wasteful and caused some duplicated log messages due to two instances
of the channel being active.
2016-12-27 16:45:05 -08:00
Olaoluwa Osuntokun 507a4eb5cc
cmd/lncli: add support for the net channel graph related commands
This commit adds support for the newly added channel graph related
commands: describegraph, getchaninfo, getnodeinfo, queryroute, and
finally getnetworkinfo.
2016-12-27 16:45:02 -08:00
Olaoluwa Osuntokun 367be2d385
lncli: remove deprecated shell command
This commit removes the shell command as it’s now deprecated since it
was never fully implemented.
2016-12-27 16:45:00 -08:00
Olaoluwa Osuntokun 2651541139
test: update integration tests to use DescribeGraph 2016-12-27 16:44:58 -08:00
Olaoluwa Osuntokun d70f03435b
cmd/lncli: implement parsing+dispatching for the new describegraph call 2016-12-27 16:44:55 -08:00
Olaoluwa Osuntokun 1210640e87
rpcserver: implement new set of network/routing RPC's 2016-12-27 16:44:53 -08:00
Olaoluwa Osuntokun ea6f6d6069
rpcserver: modify SendPayment to use new routing pkg API 2016-12-27 16:44:50 -08:00
Olaoluwa Osuntokun abfef02df2
rpcserver: include channelID in ListChannels response 2016-12-27 16:44:48 -08:00
Olaoluwa Osuntokun f9f840feb6
lnrpc: recompile protos 2016-12-27 16:44:45 -08:00
Olaoluwa Osuntokun d299be9785
lnrpc: add a new set of network related RPC's based off new routing package
This commit adds a number of new RPC’s which allow users to query data
that’s now exposed as part of the new routing package: DescribeGraph,
GetChanInfo, GetNodeInfo, QueryRoute, GetNetworkInfo, and SetAlias.

As a result the former ShowRoutingTable command has been removed as the
underlying graph representation has changed.
2016-12-27 16:44:43 -08:00
Olaoluwa Osuntokun 950d87fd78
lnrpc: add the network channel ID to the ListChannels RPC response 2016-12-27 16:44:40 -08:00
Olaoluwa Osuntokun c965eda29e
lnd: fully integrate the ChannelRouter of the new routing package
This commit fully integrates the ChannelRouter of the new routing
package into the main lnd daemon.

A number of changes have been made to properly support the new
authenticated gossiping scheme.

Two new messages have been added to the server which allow outside
services to: send a message to all peers possible excluding one, and
send a series of messages to a single peer. These two new capabilities
are used by the ChannelRouter to gossip new accepted announcements and
also to synchronize graph state with a new peer on initial connect.

The switch no longer needs a pointer to the routing state machine as it
no longer needs to report when channels closed since the channel
closures will be detected by the ChannelRouter during graph pruning
when a new block comes in.

Finally, the funding manager now crafts the proper authenticated
announcement to send to the ChannelRouter once a new channel has bene
fully confirmed. As a place holder we have fake signatures everywhere
since we don’t properly store the funding keys and haven’t yet adapted
the Signer interface (or create a new one) that abstracts out the
process of signing a generic interface.
2016-12-27 16:44:31 -08:00
Olaoluwa Osuntokun 473f298524
lnwallet/btcwallet: fix bug in GetUtxo for BlockChainIO implementation
This commit fixes an unnoticed bug within btcwallet’s implementation of
the BlockChainIO interface, specifically the GetUtxo method. In order
to maintain compatibility with Bitcoin Core’s gettxout method, btcd
doesn’t return an error if the targeted output is actually spent.

We weren’t properly detecting this, but we do now by creating a new
error which is returned in the case of a nil error but a nil return
value.
2016-12-27 16:44:27 -08:00
Olaoluwa Osuntokun 98471256fa
lnwire: modify fundingOpen to include channel ID rather than SPV proof
This commit modifies the SingleFundingOpen message to include the
compact channel ID of the finalized transaction rather than a “fake”
SPV proof. This change is a stop-gap which allows us to implement
portions of BOLT07 without yet fully implementing all parts of BOLT[02,
03].
2016-12-27 16:44:25 -08:00
Olaoluwa Osuntokun e327ffe954
routing: rewrite package to conform to BOLT07 and factor in fees+timelocks
This commit overhauls the routing package significantly to simplify the
code, conform to the rest of the coding style within the package, and
observe the new authenticated gossiping scheme outlined in BOLT07.

As a major step towards a more realistic path finding algorithm, fees
are properly calculated and observed during path finding. If a path has
sufficient capacity _before_ fees are applied, but afterwards the
finalized route would exceed the capacity of a single link, the route
is marked as invalid.

Currently a naive weighting algorithm is used which only factors in the
time-lock delta at each hop, thereby optimizing for the lowest time
lock. Fee calculation also isn’t finalized since we aren’t yet using
milli-satoshi throughout the daemon. The final TODO item within the PR
is to properly perform a multi-path search and rank the results based
on a summation heuristic rather than just return the first (out of
many) route found.

On the server side, once nodes are initially connected to the daemon,
our routing table will be synced with the peer’s using a naive “just
send everything scheme” to hold us over until I spec out some a
efficient graph reconciliation protocol. Additionally, the routing
table is now pruned by the channel router itself once new blocks arrive
rather than depending on peers to tell us when a channel flaps or is
closed.

Finally, the validation of peer announcements aren’t yet fully
implemented as they’ll be implemented within the pending discovery
package that was blocking on the completion of this package. Most off
the routing message processing will be moved out of this package and
into the discovery package where full validation will be carried out.
2016-12-27 16:44:22 -08:00