Commit Graph

9835 Commits

Author SHA1 Message Date
Jasper Rädisch
20b42ce261 cmd/lncli: add fwdinghistory support for relative times
- introduces new parser in `cmd/lncli/arg_parse.go`
- converts start_time and end_time flags to strings
- adds default value for end_time
2020-06-23 15:58:23 -07:00
Conner Fromknecht
03b20cabd2
Merge pull request #4275 from cfromknecht/invoices-ntfn-order
invoices: ensure ntfns are sent in the same order
2020-06-22 12:15:07 -07:00
Joost Jager
8f2a2fc5da
Merge pull request #4018 from breez/intercept-forward-htlc
Intercept forward htlc
2020-06-22 10:18:14 +02:00
Olaoluwa Osuntokun
acc698a699
Merge pull request #4379 from Roasbeef/scb-union-bug-fix
chanbackup: always combine with on-disk state when swapping, refuse to start w/ invalid files
2020-06-18 18:49:28 -07:00
Conner Fromknecht
60a6f2ddd1
Merge pull request #4391 from matheusdtech/lnwire-zero-sid
lnwire: fix decoding for initial zero sid
2020-06-18 17:21:43 -07:00
Conner Fromknecht
47cf144170
invoices: ensure ntfns are sent in the same order
SettleHodlInvoice and CancelInvoice both notifyClients after
notifyHodlSubscribers. This commit changes UpdateInvoice to follow the
same pattern so that we are consistent.
2020-06-18 16:28:13 -07:00
Conner Fromknecht
f5581eb04a
Merge pull request #4370 from wpaulino/no-graph-restored-channels
channeldb: remove graph insertion of restored channels
2020-06-18 16:17:56 -07:00
Wilmer Paulino
8c79359247
Merge pull request #4395 from bmancini55/reply-channel-range-query
discovery: prevent endBlock overflow in replyChanRangeQuery
2020-06-18 15:19:52 -07:00
Wilmer Paulino
d808ec0d17
itest: add sync error to whitelist 2020-06-18 14:51:45 -07:00
Wilmer Paulino
d23be59f53
channeldb: remove graph insertion of restored channels
This was initially done as there were a few assertions throughout the
codebase requiring a channel's policy to be known. Now that these have
been addressed, we no longer need to store restored channels in the
graph, as their policies where incomplete anyway.
2020-06-18 14:51:44 -07:00
Brian Mancini
28931390ff discovery: prevent endBlock overflow in replyChanRangeQuery
Modifies syncer.replyChanRangeQuery method to use the LastBlockHeight
method on the query. LastBlockHeight safely calculates the ending
block height and prevents an overflow of start_block + num_blocks.

Prior to this change, query messages that had a start_block +
num_blocks that overflows uint32_max would return zero results in the
reply message.

Tests are added to fix the bug and ensure proper start and end values
are supplied to the channel graph filter.
2020-06-18 16:48:09 -04:00
Conner Fromknecht
5eb798a23e
Merge pull request #4365 from Crypt-iQ/chancloser_pkg_0609
lnwallet/chancloser: cooperative channel closure pkg
2020-06-18 13:38:41 -07:00
Matheus Degiovani
44555a70ed lnwire: fix decoding for initial zero sid
This fixes a decoding error when the list of short channel ids within a
QueryShortChanIDs message started with a zero sid.

BOLT-0007 specifies that lists of short channel ids should be sorted in
ascending order. Previously, this was checked within lnwire by comparing
two consecutive sids in the list, starting at the empty (zero) sid.

This meant that a list that started with a zero sid couldn't be decoded
since the first element would _not_ be greater than the last one
(namely: also zero).

Given that one can only check for ordering starting at the second
element, we add a check to ensure the proper behavior.

A unit test is also added to ensure no future regressions on this
behavior.
2020-06-18 14:04:39 -03:00
Roei Erez
7b56268f70 rpc: implement RPC htlc interceptor.
In this commit we add the ability to intercept forwarded htlc packets
straight from the RPC layer. The RPC layer handles a bidrectional stream
that comminucates to the client the intercepted packets and handles its
response by coordinating with the interceptable switch.
2020-06-18 15:20:07 +03:00
Roei Erez
0f50d8b2ed htlcswitch: introducing interceptable switch.
In this commit we implement a wrapper arround the switch, called
InterceptableSwitch. This kind of wrapper behaves like a proxy which
intercepts forwarded packets and allows an external interceptor to
signal if it is interested to hold this forward and resolve it
manually later or let the switch execute its default behavior.
This infrastructure allows the RPC layer to expose interceptor
registration API to the user and by that enable the implementation
of custom routing behavior.
2020-06-18 15:12:50 +03:00
Roei Erez
1a6701122c htlcswitch: change ForwardPackets to return error
As part of the preparation to the switch interceptor feature, this
function is changed  to return error instead of error channel that
is closed automatically.
Returning an error channel has become complex to maintain and
implement when adding more asynchronous flows to the switch.
The change doesn't affect the current behavior which logs the
errors as before.
2020-06-18 12:48:21 +03:00
Olaoluwa Osuntokun
496e29d02e
chanbackup: refuse to start the SubSwapper if we can't read the SCB file
In this commit, we add an additional defense against starting up with an
invalid SCB state. With this commit, we'll now fail to start up if we're
unable to update or read the existing SCB state from disk. This will
prevent an lnd node from starting up with an invalid SCB file, an SCB
file it can't decrypt, or an SCB left over from another node.
2020-06-17 17:44:57 -07:00
Olaoluwa Osuntokun
fc65c9b2cc
chanbackup: always combine new backup data w/ on-disk state
In this commit, we fix a bug that could possibly cause a user's on disk
back up file to be wiped out, if they ever started _another_ lnd node
with different channel state. To remedy this, before we swap out the
channel state with what's on disk, we'll first read out the contents of
the on-disk SCB file and _combine_ that with what we have in memory.

Fixes #4377
2020-06-17 17:44:52 -07:00
Conner Fromknecht
87880c0d56
Merge pull request #4141 from guggero/rest-api-improvements
REST saga 3/3: REST API for subservers, websocket for streaming responses
2020-06-17 10:30:29 -07:00
Oliver Gugger
1cda467701
lnrpc: explain how to use map types in REST 2020-06-17 08:35:52 +02:00
Oliver Gugger
e73c9218d7
itest: add REST API tests 2020-06-17 08:35:51 +02:00
Anthony Ronning
a76e752f3b
config+lnd+rpcserver: add CORS origin config for REST 2020-06-17 08:34:55 +02:00
Oliver Gugger
6250ed1cf1
lnrpc: add WebSocket proxy 2020-06-17 08:34:54 +02:00
nsa
2d68a64a5b chancloser: new package for cooperative channel closure
Introduces a new chancloser package which exposes a ChanCloser
struct that handles the cooperative channel closure negotiation
and is meant to replace chancloser.go in the lnd package. Updates
all references to chancloser.go to instead use chancloser package.
2020-06-16 20:34:44 -04:00
nsa
8528ec4568 lnd: modifying comments in chancloser.go 2020-06-16 20:34:44 -04:00
Olaoluwa Osuntokun
ed93c16e51
Merge pull request #4033 from Roasbeef/go1.14
build: update travis to build against go 1.14
2020-06-16 16:25:34 -07:00
Joost Jager
4a7cefdab3
Merge pull request #4264 from joostjager/itest-err-detector-doc
doc: describe usage of log levels
2020-06-16 16:33:50 +02:00
Olaoluwa Osuntokun
25f6d51b45
build: update Github Actions to use Go 1.14.4 2020-06-15 17:51:22 -07:00
Olaoluwa Osuntokun
7261b064db
build: update to walletdb v1.3.3 and wtxmgr v1.2.0 2020-06-15 17:51:20 -07:00
Olaoluwa Osuntokun
870b64a5bd
build: update travis to build against go 1.14 2020-06-15 17:51:19 -07:00
Olaoluwa Osuntokun
3c48cab227
Merge pull request #4366 from wpaulino/bitcoind-20-compat
Support bitcoind v0.20
2020-06-15 17:45:35 -07:00
Olaoluwa Osuntokun
103c59a488
Merge pull request #4262 from Crypt-iQ/strip_dwarf_0507
Makefile: add -w to -ldflags to strip DWARF symbols
2020-06-15 10:42:44 -07:00
Olaoluwa Osuntokun
1cce50d3b7
Merge pull request #4345 from matheusdtech/brar-flake
breacharbiter: fix flaky race condition in test
2020-06-15 10:41:44 -07:00
Conner Fromknecht
d688ea2124
Merge pull request #4369 from wpaulino/coin-select-lock-sync
rpc: acquire global coin select lock in related RPCs
2020-06-15 10:06:43 -07:00
Wilmer Paulino
2a5b66ec00
lnwallet: note requirement of global coin selection lock 2020-06-12 11:22:30 -07:00
Wilmer Paulino
c2f1fe26c1
rpc: acquire global coin select lock in related RPCs
This ensures proper coin selection synchronization between lnd and users
of the RPC to avoid potential double spend errors.
2020-06-12 11:22:29 -07:00
Wilmer Paulino
9d9e54f83e
btcwallet: ensure output isn't locked by in-memory impl in LeaseOutput
The current implementation of LeaseOutput already checked whether the
output had already been leased by the persisted implementation, but not
the in-memory one used by lnd internally. Without this check, we could
potentially end up with a double spend error if lnd acquired the UTXO
internally before the LeaseOutput call.
2020-06-12 11:22:28 -07:00
Wilmer Paulino
6e8021f858
scripts: bump bitcoind version to 0.20 2020-06-12 10:46:20 -07:00
Wilmer Paulino
d49c6fba87
build: update btcwallet dependency for bitcoind v0.20 compat 2020-06-12 10:46:16 -07:00
Joost Jager
d1e049fa68 docs: describe log levels 2020-06-12 11:22:35 +02:00
Olaoluwa Osuntokun
9b8d51231c
Merge pull request #4355 from wpaulino/txnotifier-cancel-conf-cleanup
chainntnfs: remove queued confirmation notification in CancelConf
2020-06-11 18:13:44 -07:00
nsa
ec2d999371 chancloser+peer: export negotiationHeight, channel, and error 2020-06-11 15:49:23 -04:00
Wilmer Paulino
69b8a356b2
chainntnfs: remove queued confirmation notification in CancelConf
This addresses a panic when a notification is canceled after its been
detected as included in a block and before its confirmation notification
is dispatched.
2020-06-10 13:45:45 -07:00
Conner Fromknecht
d47d17b5d4
Merge pull request #4261 from carlaKC/4164-indexpayments
channeldb: Index payments by sequence number
2020-06-10 08:11:45 -07:00
carla
ab594ea57b
channeldb: update QueryPayments to use sequence nr index and paginator
Use the new paginatior strcut for payments. Add some tests which will
specifically test cases on and around the missing index we force in our
test to ensure that we properly handle this case. We also add a sanity
check in the test that checks that we can query when we have no
payments.
2020-06-10 12:55:05 +02:00
carla
38624e8612
channeldb: add fetchPaymentWithSequenceNumber lookup and test
With our new index of sequence number to index, it is possible for
more than one sequence number to point to the same hash because legacy
lnd allowed duplicate payments under the same hash. We now store these
payments in a nested bucket within the payments database. To allow
lookup of the correct payment from an index, we require matching of the
payment hash and sequence number.
2020-06-10 12:55:03 +02:00
carla
eea871b583
channeldb: add a paginator struct to process generic pagination
We now use the same method of pagination for invoices and payments.
Rather than duplicate logic across calls, we add a pagnator struct
which can have query specific logic plugged into it. This commit also
addresses an existing issue where a reverse query for invoices with an
offset larger than our last offset would not return any invoices. We
update this behaviour to act more like c.Seek and just start from the
last entry. This behaviour change is covered by a unit test that
previously checked for the lack of invoices.
2020-06-10 12:49:48 +02:00
carla
f4933c67fd
channeldb: add test case for index offset greater than index
In our current invoice pagination logic, we would not return any
invoices if our offset index was more than 1 off our last index and we
were paginating backwards. This commit adds a test case for this
behaviour before fixing it in the next commit.
2020-06-10 12:49:13 +02:00
carla
c8d11285f3
channeldb: index payments by sequence number
Add an entry to a payments index bucket which maps sequence number
to payment hash when we initiate payments. This allows for more
efficient paginated queries. We create the top level bucket in its
own migration so that we do not need to create it on the fly.

When we retry payments and provide them with a new sequence number, we
delete the index for their existing payment so that we do not have an
index that points to a non-existent payment.

If we delete a payment, we also delete its index entry. This prevents
us from looking up entries from indexes to payments that do not exist.
2020-06-10 12:49:06 +02:00
carla
6c4a1f4f99
channeldb: update TestQueryPayments to cover duplicate payments
Update our current tests to include lookup of duplicate payments. We
do so in preparation for changing our lookup to be based on a new
payments index. We add an append duplicate function which will add a
duplicate payment with the minimum information required to successfully
read it from disk in tests.
2020-06-10 12:34:27 +02:00