Commit Graph
100 Commits
Author SHA1 Message Date
Joost Jager ab4da0f53d cnct: define separate broadcast delta for outgoing htlcs
This commits exposes the various parameters around going to chain and
accepting htlcs in a clear way.

In addition to this, it reverts those parameters to what they were
before the merge of commit d107627145.
2019-04-05 11:36:07 +02:00
Joost Jager cf42719c45 lnd+rpcserver: refactor TLS configuration
This commit restructures the creation of various tls related object. It
also fixes a bug where wildcard IP addresses where only instantiated for
the main RPC server and not the WalletUnlocker service.
2019-04-04 14:18:18 -07:00
Joost Jager 6b6dd30aa7 routerrpc: register router sub server logger 2019-03-27 11:44:49 +01:00
Joost JagerandJim Posen cd535b9401 link: increase expiry grace delta
This commit increase the expiry grace delta to a value above the
broadcast delta. This prevents htlcs from being accepted that would
immediately trigger a channel force close.

A correct delta is generated in server.go where there is access to
the broadcast delta and passed via the peer to the links.

Co-authored-by: Jim Posen <jim.posen@gmail.com>
2019-03-26 18:42:00 +01:00
Joost JagerandJim Posen e6fbbaa1dc link: also check expiry grace delta for forwarded htlcs
Previously there was no minimum remaining blocks requirement on
forwarded htlcs, which may cause channel arbitrator to force
close the channel directly after forwarding the htlc.

Co-authored-by: Jim Posen <jim.posen@gmail.com>
2019-03-26 18:41:41 +01:00
Joost Jager 73efc31177 build: add routerrpc tag in itest 2019-03-21 10:25:58 +01:00
Joost Jager 087de7cc4d routerrpc: adapt to changed interfaces of routing subsystem 2019-03-21 10:25:55 +01:00
Joost Jager ec0d241905 lncli: add cltv limit 2019-03-19 10:38:09 +01:00
Joost Jager 06cd64cbbc routing: add cltv limit to payment session 2019-03-19 10:36:51 +01:00
Joost Jager e3bb3d46a2 routing: abstract path finding interface 2019-03-19 10:36:48 +01:00
Joost Jager 6006549ed5 routing: enforce cltv limit in path finding 2019-03-19 10:36:45 +01:00
Joost Jager c5961d4904 routing: only warn for zero cltv delta edges
This condition may be caused by a bug somewhere else in the system.
Expose it here as a warn log line.
2019-03-19 10:36:43 +01:00
Joost Jager f6d67945dc lncli: add settle invoice command 2019-03-15 10:09:26 +01:00
Joost Jager f450929b65 invoicesrpc: add SettleInvoice 2019-03-15 10:09:23 +01:00
Joost Jager 0823c79e4e htlcswitch/test: hodl invoice test 2019-03-15 10:09:20 +01:00
Joost Jager 32f2b047e8 htlcswitch: hodl invoice
This commit modifies the invoice registry to handle invoices for which
the preimage is not known yet (hodl invoices). In that case, the
resolution channel passed in from links and resolvers is stored until we
either learn the preimage or want to cancel the htlc.
2019-03-15 10:09:17 +01:00
Joost Jager 1f41a2abce htlcswitch: abtract invoice from link
This commit detaches signaling the invoice registry that an htlc was
locked in from the actually settling of the htlc.

It is a preparation for hodl invoices.
2019-03-15 10:09:15 +01:00
Joost Jager aeb35d9898 htlcswitch/test: use real invoice registry with temp db as mock
In further commits the behaviour of invoice registry becomes more
intrinsically connected to the link. This commit prepares for that by
allowing link and registry to be tested as a single unit.
2019-03-15 10:09:12 +01:00
Joost Jager e464ed18c7 htlcswitch/test: make unknown hash test independent of mock
In the TestChannelLinkMultiHopUnknownPaymentHash test, a preimage was
modified to trigger an unknown payment hash failure. The way the mock is
implemented, it would take the hash of that modified preimage and store
it. It basically stores a completely different invoice. For this test,
it is just as good to store no invoice at all.
2019-03-15 10:09:09 +01:00
Joost Jager 3b5c2f44c6 invoices: extract invoice decoding from registry
Previously it was difficult to use the invoice registry in unit tests,
because it used zpay32 to decode the invoice. For that to succeed, a
valid signature is required on the payment request.

This commit injects the decode dependency on a different level so that
it is easier to mock.
2019-03-15 10:09:06 +01:00
Joost Jager c23bb5b3f1 htlcswitch: extract settle invoice into method 2019-03-15 10:09:03 +01:00
Joost Jager 22b68e5dc7 lncli: add hold invoice 2019-03-15 10:09:00 +01:00
Joost Jager fcdc8f0e83 lnrpc/invoices: add hold invoice rpc 2019-03-15 10:08:58 +01:00
Joost Jager 19f79613df channeldb: store hold invoice 2019-03-15 10:08:55 +01:00
Joost Jager 8392f6d28f lnrpc/invoicesrpc: remove lnrpc type from add invoice 2019-03-15 10:08:52 +01:00
Joost Jager b9cc165341 lnrpc: move add invoice logic to subserver 2019-03-15 10:08:49 +01:00
Joost Jager 4141773e90 htlcswitch: resolve invoice cancelation race condition
Previously it could happen that an invoice was open at the time of the
LookupInvoice call, the htlc was settled because of that, but when the
SettleInvoice call was made eventually, it would fail because the
invoice was canceled in the mean time. The htlc would then be settled,
but the invoice not marked as such.
2019-03-15 10:08:46 +01:00
Joost Jager eb598ec7a4 htlcswitch: extract exit hop processing to method 2019-03-15 10:08:43 +01:00
Joost Jager 9643b45dbc htlcswitch/test: move preimage cache to server level
In this commit the preimage cache is instantiated on the mock server
level where it belongs. Previously it was a cache shared across all mock
servers.
2019-03-15 10:08:40 +01:00
Joost Jager c4263e7061 lntypes: return a value from constructors
Returning pointers proved inconvenient in almost all cases. This commmit
converts the constructors to returning values.
2019-03-15 10:08:38 +01:00
Joost Jager 449c3d533e contractcourt: add access to full invoice registry from resolvers
Previously a function pointer was passed to chain arbitrator to avoid a
circular dependency. Now that the routetypes package exists, we can pass
the full invoice registry to chain arbitrator.

This is a preparation to be able to use other invoice registry methods
in contract resolvers.
2019-03-15 10:08:35 +01:00
Joost Jager 2be1051fb6 zpay32: move HopHint and DefaultFinalCLTVDelta 2019-03-15 10:08:32 +01:00
Joost Jager 652ebb1652 lnwire: add constructor for FinalExpiryTooSoon failure message 2019-03-15 10:08:29 +01:00
Joost Jager 10a655b6b1 lntypes: add preimage Matches method 2019-03-15 10:08:26 +01:00
Joost Jager 293971cd03 routerrpc: move query routes into sub server
This commit moves the query routes backend logic from the main
rpc server into the sub server. It is another step towards splitting up
the main rpc server code.

In addition to this, a unit test is added to verify rpc parameter
parsing.
2019-03-11 09:56:16 +01:00
Joost Jager 5b6fdbeb6f lncli: fix command line argument parsing for sendpayment
This commit fixes a bug that caused the payment hash to be (re)parsed as
an int representing the final cltv delta.
2019-03-08 10:42:18 +01:00
Joost Jager 6cc82b4a34 routing: add todo describing route cache bug 2019-03-06 15:31:09 +01:00
Joost Jager 6e10c05a82 lnrpc: deprecate QueryRoutes with more than one route
Now that QueryRoutes gained the ability to route from any source node
and takes in edge and node black lists, all pieces are in place to have
users implemented their own k-shortests path algorithm. Or any other algorithm
they might wish to use and currently can't.

This commit marks the num_routes field as deprecated as a preparation
for removing k-shortest for lnd.
2019-03-06 15:31:06 +01:00
Joost Jager c62c9d64da routing: add source parameter to query routes
This commit allows execution of QueryRoutes from any source node.
Previously this was restricted to only the self node.
2019-03-06 15:31:03 +01:00
Joost Jager 7719bc432f routing: take Vertex types as path finding source and target nodes
Currently public keys are represented either as a 33-byte array (Vertex) or as a
btcec.PublicKey struct. The latter isn't useable as index into maps and
cannot be used easily in compares. Therefore the 33-byte array
representation is used predominantly throughout the code base.

This commit converts the argument types of source and target nodes for
path finding to Vertex. Path finding executes no crypto operations and
using Vertex simplifies the code.

Additionally, it prepares for the path finding source parameter to be
exposed over rpc in a follow up commit without requiring conversion back
and forth between Vertex and btcec.PublicKey.
2019-03-06 15:31:00 +01:00
Joost Jager b09adc3219 lnrpc+routing: add edges and nodes restrictions to query routes
This commit allows the execution of QueryRoutes to be controlled using
lists of black-listed edges and nodes. Any path returned will not pass
through the edges and/or nodes on the list.
2019-03-06 15:30:57 +01:00
Joost Jager 4376f3e1bd routing: allow nil maps for ignored edges and nodes
This allows removing a lot of empty map initialization code and makes
the code more readable.
2019-03-06 15:30:54 +01:00
Joost Jager b2b28b49b1 routing: export RestrictParams and EdgeLocator 2019-03-06 15:30:52 +01:00
Joost Jager 4937304732 routing: remove redundant fee limit check in newRoute
This check was a left over from when the fee limit wasn't checked yet in
the path finding algorithm.
2019-03-06 15:30:49 +01:00
Joost Jager f4cc2e235a routing: add todo describing fee limit bug 2019-03-06 15:30:46 +01:00
Joost Jager f23fdf95e7 cnct: fix error returning bug
The wrong error variable was returned, causing a resolution failure to
be interpreted by the channel arbitrator as a success.
2019-02-26 12:56:21 -03:00
Joost Jager 4de9ffdf7b Merge pull request #2679 from joostjager/itest-unkeyed
lnd_test: remove unkeyed field references
2019-02-21 14:36:32 +01:00
Joost Jager d67b1962a8 lnd_test: remove unkeyed field references 2019-02-21 13:47:58 +01:00
Joost Jager f8721ffbca routing: sendPayment broken down into multiple functions 2019-02-11 08:42:41 +01:00
Joost Jager c44d4046c1 Merge pull request #2572 from joostjager/outgoing-chan-selection
routing: add outgoing channel restriction
2019-02-09 11:33:43 +01:00
Joost Jager 7c30a8c493 routing: add outgoing channel restriction 2019-02-08 23:05:56 +01:00
Joost Jager e26dc6ac57 Merge pull request #2601 from Roasbeef/send-to-route-rest-fix
rpc: fix regression in SendToRouteSync payment hash parsing
2019-02-07 10:31:47 +01:00
Joost Jager a8baa23c2e lncli: add cancel invoice command 2019-02-06 07:29:38 +01:00
Joost Jager 077852cd4e htlcswitch/test: test canceled invoice 2019-02-06 07:29:35 +01:00
Joost Jager f80fb286d8 htlcswitch/test: add two hop network 2019-02-06 07:29:32 +01:00
Joost Jager 524d2465e0 htlcswitch/test: extract generic hop network 2019-02-06 07:29:29 +01:00
Joost Jager 9cac0efab7 htlcswitch/test: create preparePayment function 2019-02-06 07:29:26 +01:00
Joost Jager e7907e0e7c htlcswitch/test: add waitForPaymentResult helper function 2019-02-06 07:29:24 +01:00
Joost Jager afd2d69906 htlcswitch/test: convert makePayment into function 2019-02-06 07:29:21 +01:00
Joost Jager 1b87fbfab2 invoices+htlcswitch+lnrpc: cancel invoice 2019-02-06 07:29:18 +01:00
Joost Jager 077e1887fa Merge pull request #2564 from joostjager/move-paymentsession
routing: move payment session to separate file
2019-02-05 08:44:56 +01:00
Joost Jager 17645fefdf lnrpc: deprecate multiple routes sendtoroute 2019-02-04 13:07:30 +01:00
Joost Jager 5a4951affd lnrpc: extract sendtoroute unmarshall to method 2019-02-04 13:06:58 +01:00
Joost Jager b16357116c invoices: add SubscribeSingleInvoice test 2019-02-01 09:47:37 +01:00
Joost Jager 8996a1490d lnrpc: reuse common FileExists function 2019-02-01 09:47:31 +01:00
Joost Jager 70c874be88 invoicesrpc: add SubscribeSingleInvoice rpc 2019-02-01 09:43:17 +01:00
Joost Jager 4c4536a488 lnrpc: move invoice marshall code to package
As a preparation for reusing the marshall code in the invoices sub
server.
2019-02-01 09:43:10 +01:00
Joost Jager acb0162443 invoices: subscribe single invoice 2019-02-01 09:43:03 +01:00
Joost Jager 436dd41c77 channeldb: move idempotency up the call tree
As a preparation for subscribing to single invoices, InvoiceRegistry
needs to become aware of settling a settled invoice.
2019-02-01 09:42:56 +01:00
Joost Jager 2a4c93cdc4 lnrpc: add search path to gen_protos.sh
Without this addition, sub servers cannot import google annotations
in their proto files.
2019-02-01 09:42:48 +01:00
Joost Jager 78cd07570b invoiceregistry: extract dispatch to method 2019-02-01 09:42:42 +01:00
Joost Jager 3545685177 invoicesrpc: create sub server
Sub server implementation is still empty. This is a preparatory
step for adding invoice functionality.
2019-02-01 09:42:35 +01:00
Joost Jager bacd92418a invoices: use lntypes.Hash and lntypes.Preimage
Previously chainhash.Hash was used, which converts to/from string in
reversed format. Payment hashes and preimages are supposed to be
non-reversed.
2019-02-01 09:42:29 +01:00
Joost Jager 18698663c5 lnhash: create Hash and Preimage types
This commit adds new hash and preimage types. These types are
similar to chainhash.Hash, except for that string representations
are not reversed.

The reason for adding dedicated types and not use [32]byte, is to
facilitate logging (%v displays as hex string) and have
standard methods to convert from byte slice and string with a
length check.
2019-02-01 09:42:23 +01:00
Joost Jager ca619bf680 utxonursery: report unconfirmed htlc on commit tx
This commit closes a reporting gap for htlc outputs on the remote
commitment tx. Those are waited out by nursery, but were not reported
before.
2019-02-01 09:36:54 +01:00
Joost Jager 55aee9c703 cnct: expose non-incubating htlcs after channel force close
In this commit we fix a reporting gap that previously existed for htlcs
that were still contested.
2019-02-01 09:36:47 +01:00
Joost Jager e486340106 cnct: use sweeper in commit resolver
Now that the sweeper is available, it isn't necessary anymore for the
commit resolver to craft its own sweep tx. Instead it can offer its
input to the sweeper and wait for the outcome.
2019-02-01 09:20:45 +01:00
Joost Jager 7b94d9adb0 routing: move payment session to separate file 2019-02-01 09:14:54 +01:00
Joost Jager 5c03a0db99 lnrpc: extract setting force close info to method 2019-02-01 09:10:17 +01:00
Joost Jager 288fc6f065 utxonursery: remove unused report fields 2019-02-01 09:10:10 +01:00
Joost Jager 9abe06f3c8 cnct: finish channel arbitrator in StateFullyResolved
Previously the arbitrator wasn't advanced to the final stage after
the last contract resolved.

Also channel arbitrator now does not ignore a log error anymore
unresolved contracts cannot be retrieved.
2019-02-01 09:10:04 +01:00
Joost Jager 9e012ecc93 multi: move Input interface and related code
This commit is a step to split the lnwallet package. It puts the Input
interface and implementations in a separate package along with all their
dependencies from lnwallet.
2019-01-31 13:25:33 +01:00
Joost Jager 667474db75 lnwallet: move code to transactions files 2019-01-31 13:24:39 +01:00
Joost Jager 6ae55168b8 Merge pull request #2486 from joostjager/split-resolvers
cnct: split resolvers in separate files
2019-01-17 08:57:22 +01:00
Joost Jager 4ec3fc3b1a cnct: split resolvers in separate files 2019-01-16 20:03:59 +01:00
Joost Jager 649408003d lnrpc: expose network name in GetInfo
Previously only a testnet boolean was available which
made it impossible to distinguish between regtest and
mainnet.
2019-01-08 00:17:14 +01:00
Joost Jager c1eaf60000 invoices: create package
This commit isolates the invoice registry in a separate package. It is
a preparation for the creation of an invoices sub server.
2019-01-07 23:04:05 +01:00
Joost Jager d151916ae1 lnrpc: deprecate invoice receipt field 2019-01-07 22:05:52 +01:00
Joost Jager 1199f17cd9 lnrpc: report invoice state
Expose the new invoice state field over rpc.
2019-01-04 07:54:14 +01:00
Joost Jager 5515713b88 channeldb: convert settled boolean to state
This commit is a preparation for the addition of new invoice
states. A database migration is not needed because we keep
the same field length and values.
2019-01-04 07:53:55 +01:00
Joost Jager 6c027e2bc9 htlcswitch: remove lnrpc dependency
This commits removes an unwanted dependency that prevents
moving parts of rpcserver to a sub server.
2019-01-03 09:07:56 +01:00
Joost Jager 237f2b6d4b lnrpc: remove ConfirmationUpdate message from close status updates 2019-01-03 09:06:52 +01:00
Joost Jager 4a58ec5b15 utxonursery: fix bound variable bug
A pointer to the loop variable was passed to the waitForSweepConf
goroutine, causing the wrong output to be graduated from
kindergarten.
2018-12-21 09:29:26 +01:00
Joost Jager 347d1545de utxonursery: use mocked sweeper in tests
This commit fixes a test flake caused by a race condition. Using the
real sweeper in the nursery test created too complex concurrent
behaviour to reliably assert on and made the tests difficult to
comprehend.
2018-12-19 14:14:53 +01:00
Joost Jager e29b0f8894 utxonursery: add mock sweeper
This commit adds a simple mock of the sweeper to be able to test
dependents of sweeper in isolation.
2018-12-19 14:09:30 +01:00
Joost Jager 74e9852e3d utxonursery: configure using SweepInput function
As a preparation for mocking sweeper, this commit modifies the
utxonursery config to take a function pointer instead of the full
sweeper struct.
2018-12-19 12:49:19 +01:00
Joost Jager 78aaf8639b lnrpc: remove reference to GOPATH
As go modules allow us to build outside of the GOPATH, we shouldn't look for .proto imports there anymore.
2018-12-18 14:57:26 +01:00
Joost Jager 9e611636ee lnrpc: update github.com/golang/protobuf to v1.2.0
Update is necessary to get protoc to generate files in the right
directory when using modules outside the gopath. The old version of this
dependency did not support paths=source_relative.

This commit also fixes a build error in lnd_test.go because of a
slight difference in generated code.
2018-12-18 14:57:24 +01:00
Joost Jager 6ca52c4ec7 lnrpc/walletrpc: remove unused gen_proto.sh script 2018-12-18 14:56:52 +01:00
Joost Jager 687d4e7725 cnct: add todo comment for sweeper 2018-12-18 10:50:22 +01:00