Commit Graph

7792 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
f5d1785ab2
channeldb: factor out LinkNode serialization+db write into new func 2016-10-26 14:36:38 -07:00
Olaoluwa Osuntokun
b853be7b9a
channeldb: ignore duplicate addresses in LinkNode.AddAdress 2016-10-26 14:32:49 -07:00
Olaoluwa Osuntokun
bde47f6ebb
lnrpc: returns the node's pubkey instead of lighting_id in ListPeers 2016-10-26 14:31:48 -07:00
Olaoluwa Osuntokun
caa620a6de
build: update travis to build against go 1.7.3 2016-10-26 14:28:51 -07:00
Olaoluwa Osuntokun
290ea7ba5d
lnd: update peer+fundingManager due to channeldb field rename 2016-10-25 16:44:18 -07:00
Olaoluwa Osuntokun
e1d9d9c8d2
lnwallet: update to adhere to new channeldb API change
This commit modifies the lnwallet code and related tests in order to
adhere to the recent field-name change to channeldb.OpenChannel.
Instead of having the field ‘TheirLNID’ which is the sha256 of the
node’s public key, we now instead use the public key directly in all
contexts.
2016-10-25 16:41:22 -07:00
Olaoluwa Osuntokun
cb328e65c4
channeldb: switch to using a full public key to identity channel->node
This commit slightly modifies the existing structure of the channeldb
scheme to replace the former concept of a “nodeID” with simply the
compressed public key of the remote node. This change paves the way for
adding useful indexes mapping a node to all it’s active channels and
the other way around.

Additionally, the current channeldb code was written before it was
agreed by many of those implementing Lightning that a node’s ID will
simply be its compressed public key.
2016-10-25 16:11:30 -07:00
Olaoluwa Osuntokun
d109bd9298
channeldb: add bucket for storing p2p counterparty meta-data
This commit adds a new bucket to the database which is dedicated to
storing data pertaining to p2p related reachability for direct channel
counter parties. The data stored in this new bucket can be used within
heuristics when deciding to unilaterally close a channel due to
inactivity. Additionally, all known reachable IP addresses for a
particular LinkNode are to be stored and updated within the database in
order to facilitate the establishment of persistent connections to
direct channel counter parties.
2016-10-25 16:06:32 -07:00
Olaoluwa Osuntokun
d181aad8e2
test: use *testing.T directly outside of test execution 2016-10-23 20:04:05 -07:00
Olaoluwa Osuntokun
a7b7f4f272
test: fix double close channel bug by removing wait in lightningNode.stop()
This commit fixes a panic bug caused by two calls to a process’
cmd.Wait() method. If two nodes incurred a fatal error as soon as they
were created, then both the goroutine detected to recovering the stderr
data and the defer statement would case a double channel close due to
the simultaneous calls to Wait().
2016-10-23 19:27:32 -07:00
Olaoluwa Osuntokun
517255fdb1
test: rename CT to harnessTest, ensure all RPC's get distinct timeouts
This commit slightly modifies the existing CT struct in order to
maintain consistency with code-style. As a result of the name change,
all references have also been renamed from `ct` to `t`.

The Error and Errorf methods have been removed in favor of forcing
everything to be reported via `Fatalf`. Additionally a new method
(ProcessErrors) has been introduced to the networkHarness class in
order to encapsulate the underlying channel.
2016-10-23 19:27:24 -07:00
Olaoluwa Osuntokun
5d6b8e49a3
lnwallet: disallow creating a funding reservation with zero total satoshis 2016-10-23 19:27:20 -07:00
Olaoluwa Osuntokun
e6394a0862
routing: fix bug introduced during switch to pubkeys in routing table
This commit fixes a bug which was introduced when the routing table was
switched over to store full pub keys rather then public key hashes. The
switch was change was required in order to properly support onion
routing within the daemon. During the change the source node vertex
when receiving a message wasn’t converted to use public keys instead of
pubkeyhashes. As a result, nodes would be blind to any topology related
updates sent by its neighbors.

This commit fixes the bug by setting the source node of the received
message to the serialized public key rather than the pubkeyhash.
2016-10-23 18:38:44 -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
Olaoluwa Osuntokun
3cf7ec2a51 Merge pull request #36 from AndrewSamokhvalov/single-pending-channel
Only allow a single pending channel per-peer #32
2016-10-22 15:34:53 -07:00
Andrey Samokhvalov
7196c4bb1c fundingmanager: add max pending channel check 2016-10-22 02:15:35 +03:00
Andrey Samokhvalov
19d8abade8 config: add --pendingchannel lnd flag 2016-10-22 02:11:18 +03:00
Andrey Samokhvalov
e6f45a948e testing: add CT (Custom Testing) structure; create uniq point for 'lnd process errors' and 'test panic/failed errors' handling 2016-10-22 02:11:12 +03:00
Andrey Samokhvalov
b0525cf478 wire: add PendingID in ErrorGeneric 2016-10-22 01:48:23 +03:00
Andrey Samokhvalov
14c6770b76 general: fix typos 2016-10-22 01:48:05 +03:00
Olaoluwa Osuntokun
fd163ccf9d
build: add aead/chacha20 and aead/poly1305 to the glide files
The two new dependancies are needed for the new brontide package which
implements the p2p encryption+auth.
2016-10-17 19:45:40 -07:00
Olaoluwa Osuntokun
ab97d9693f
brontide: an authenticated key agreement protocol in three acts
This commit introduces Brontide: an authenticated key agreement
protocol in three acts. Brontide is the successor to lndc within lnd,
and ultimately within the greater Lighting Network. Brontide uses the
Noise_XK handshake for initial key agreement, then implements an AEAD
scheme which encrypts+authenticates both packets, and the lengths of
the packets on the wire. The initial authentication handshake preserves
the responder’s identity by never transmitting it to the initiator and
performing mutual authentication via an incremental Triple-DH based on
ECDH of secp256k1 and an HKDF which uses SHA-256.

Bronzed isn’t yet integrated within the wider daemon yet. Full
integration will land in a future pull request.
2016-10-17 19:41:29 -07:00
andrew.shvv
56ab64ecab test: add basic test for multi-channel opening+closing 2016-10-16 21:36:43 -07:00
John Newbery
72ed6bfdc4 README: fix typo in build instructions 2016-10-16 15:39:21 -07:00
Olaoluwa Osuntokun
180d0aeb96
htlcswitch: fix link deletion bug with multiple open channels
This commit fixes a bug in the htlcSwitch’s logic to unregister links
after a peer has signaled that a channel has been closed. This bug
would arise when multiple channels were opened with a single peer, and
any of the channels were attempted to be closed. The cause of the bug
was that the slice reference within the map wasn’t previously updated
with the re-slicing to truncate the (duplicated, unneeded) element from
the slice. By updating the map’s reference directly, we fix this
behavior.

The safe handling of adding/removing links/interfaces between the
htlcSwitch’s two goroutines has sprawled a bit, and can be hard to
follow due to the map usage. In the future this section of the code
will be cleaned up and the redundant indexes removed.
2016-10-16 15:37:50 -07:00
andrew.shvv
e515710a7d multi: use witnessScript everywhere instead of redeemScript
This commit consists of a mass variable renaming to call the pkScript being executed for segwit outputs the `witnessScript` instead of `redeemScript`. The latter naming convention is generally considered to be reserved for the context of BIP 16 execution. With segwit to be deployed soon, we should be using the correct terminology uniformly through the codebase. 

In addition some minor typos throughout the codebase has been fixed.
2016-10-15 16:02:09 -07:00
Olaoluwa Osuntokun
e038491f8a
lnd: fix build error for go 1.6.3, use experimental context import
This commit fixes a build error for go 1.6.3. Before go 1.7, the
context package was under the experimental go packages, therefore to
maintain compatibility across our currently supported versions, we must
use the ‘/x/net’ import path.
2016-10-15 15:35:35 -07:00
Olaoluwa Osuntokun
79e7862525
test: add integration tests for invoice settle/add notifications 2016-10-15 14:46:12 -07:00
Olaoluwa Osuntokun
7b953c9c61
rpcserver: add REST workarounds, implement new RPC calls
This commit adds a few workarounds in order to concurrently support the
REST proxy as well as the regular gRPC interface. Additionally,
concrete support for the following RPC calls has been added:
GetTransactions, SubscriptTransactions, SubscribeInvoices, and
NewWitnessAddress.
2016-10-15 14:42:25 -07:00
Olaoluwa Osuntokun
566cd86a1d
lnrpc: add cursory REST support to the RPC server
This commit adds a REST interface to the existing gRPC server by
employing a simple http proxy auto-generated from the existing protobuf
files. Currently full-support for any streaming RPC’s are currently
untested. In addition to auto-generating a REST proxy server, a
swagger.json is also generated which allows for gRPC-like native
objects with higher-level clients, and also for auto-generated
documentation.

Due to limitations with accepting raw byte strings as parameters, some
RPC’s have been modified to take both raw-bytes and string arguments.
Additionally a new RPC has been added ‘NewWitnessAddress’ since the
proxy doesn’t currently support enum-based arguments.

Currently the proxy server is embedded within the daemon as an active
HTTP server, however we may want to package the proxy server as a
separate binary in the future. Similarly, we may want to add additional
configuration information which controls the optional inclusion of the
REST proxy.

Atm, just like the current gRPC interface, the REST API is fully
unauthenticated. Before moving to an initial alpha release after making
the necessary changes to meet the spec drafted in Milan, authentication
of the RPC interfaces will be addressed.
2016-10-15 14:39:00 -07:00
Olaoluwa Osuntokun
bea555e61d
lnwallet: add tests for SubscribeTransactions and ListTransactionDetails 2016-10-15 14:12:23 -07:00
Olaoluwa Osuntokun
628224a5ee
lnwallet/btcwallet: concretely implement the new TransactionSubscription interface
This commit returns the BtcWallet wrapper struct back to conformance to
the WalletController interface by adding support for
SubscribeTransactions.

The implementation of the lnwallet.TransactionSubscription consists
simply of a proxy goroutine which forwards notifications from the
wallet’s internal NotificaitonServer.
2016-10-15 14:11:25 -07:00
Olaoluwa Osuntokun
2eb1936cce
lnwallet: extend the WalletController with a new txn pub/sub client
This commit adds a new simple interface related to the WalletController
which allows for subscribing to new notifications as transactions
relevant to the wallet are seen on at the network and/or mined. The
TransactionSubscription interface will prove useful for building higher
level UI’s on-top of the daemon which update the presentation layer in
response to received notifications.
2016-10-15 14:07:24 -07:00
Olaoluwa Osuntokun
617716ce9a
lnwallet/btcwallet: implement ListTransactionDetails
This commit implements the new ListTransactionDetails method within
btcwallet’s concrete implementation of the WalletController interface.
Both mined and unmined transactions are currently returned via the same
method. Unmined transactions are indicated by their lack of an
inclusion block hash and lack of confirmations.
2016-10-14 20:16:00 -07:00
Olaoluwa Osuntokun
78cfcc28b7
lnwallet: add method to list relevant txns to WalletController interface 2016-10-14 20:14:15 -07:00
Olaoluwa Osuntokun
cfd9f8f6f0
invoices: add subscription to invoice updates
This commit adds the ability for clients within the daemon to register
for notifications that are dispatched once invoices are settled, or new
invoices are added. Such notifications can prove useful when
synchronizing higher level primitives, or implementing workflow within
desktop/mobile UI’s.
2016-10-14 19:49:04 -07:00
Olaoluwa Osuntokun
3247a160c5
channeldb: remove obsolete idKey methods 2016-10-13 17:31:47 -07:00
Olaoluwa Osuntokun
85b2b52a5f
lnwallet: add concrete type for coin selection fail during funding workflow 2016-09-26 12:18:03 -07:00
Olaoluwa Osuntokun
6c51bc7cee
test: block with a timeout within SendCoins ensuring proper balance after send 2016-09-26 11:54:19 -07:00
Olaoluwa Osuntokun
0013b804c0
lnwallet: display target+current amount when coin selection fails for funding txns 2016-09-26 11:52:56 -07:00
Olaoluwa Osuntokun
2ed510d1d9
test: eliminate panics on RPC call errors 2016-09-26 10:52:33 -07:00
Olaoluwa Osuntokun
80d38d6bbc
test: add network test case for repeated multi-hop invoice payments 2016-09-26 10:42:02 -07:00
Olaoluwa Osuntokun
bf0945a6bf
test: add test case for a simple one-hop invoice scenario 2016-09-26 10:41:05 -07:00
Olaoluwa Osuntokun
cfdf3f3ab5
peer: send any pending HTLC settles when the commit timer ticks
This commit adds an additional clause to the update of the current
commitment state each time the commitTimer ticks. We now additional
check to see if we have any active HTLC’s to settle, triggering a state
update if so.

This case is needed due to the possibility of desynchronization across
commitment transactions. As an example if any HTLC adds are sent after
the remote node receives our ack-sig, then they may remain uncommitted
within our local commitment chain. The addition of this check solves
the issue by ensuring convergence towards a symmetric commitment state.
2016-09-26 10:39:52 -07:00
Olaoluwa Osuntokun
f1d0b75b9d
routing: purge closed channels from the routing table
This commit properly removes any/all closed channels from the routing
table. In the current implementation individual links (channels)
between nodes are treated sparely from the PoV of the routing table. In
the future, this behavior should be modified such that, the routing
table views all the links between nodes as a single channel. Such a
change will simplify the task of path finding as the links can simply
be viewed as a channel with the sum of their capacities. The link layer
(htlcSwitch) will handle the details of fragmentation on a local basis.
2016-09-26 10:35:16 -07:00
Olaoluwa Osuntokun
9bb917cd2a
test: add methods for connecting nodes, funding the wallet of nodes 2016-09-26 10:31:23 -07:00
Olaoluwa Osuntokun
50e7cbe3be
test: add ability to add additional nodes to the test network 2016-09-26 10:30:29 -07:00
Olaoluwa Osuntokun
d9c0e6653f
test: extract the identity pubkey of running lnd nodes into the lightningNode struct 2016-09-26 10:29:21 -07:00
Olaoluwa Osuntokun
301a9fea38
cmd/lncli: implementing parsing+display for list channels 2016-09-25 20:05:06 -07:00