Commit Graph

9881 Commits

Author SHA1 Message Date
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
Joost Jager
f1fbdb1b84
lnwallet/test: remove unused index field 2020-06-17 22:59:14 +02:00
Joost Jager
24e1126776
lnwallet/test: reproduce test vectors in commit and htlc tx test
This commit changes the verification of our code against the spec test
vectors to use a more black box approach. It exercises the channel state
machine via its external interface as much as possible, making this test
more robust. A consequence of this is that the test now runs from the
'root' data from which the test vectors are also derived, meaning that
more code is covered too.

Running from the root data is also a preparation for _producing_ test
vectors for the new anchor commitment format. This will be a matter of
changing the channel type and recording the produced commitment and htlc
txes.

Previously the success transaction was skipped during verification. With
this commit, the proper preimage insertion is carried out, allowing the
success tx to be checked too.
2020-06-17 22:59:12 +02: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
Joost Jager
4e945f6083
lnwallet/test: name test cases 2020-06-15 13:51:07 +02:00
Joost Jager
8b55c10e45
lnwallet/test: name testCase struct 2020-06-15 13:51:05 +02:00
Joost Jager
997bab0343
lnwallet/test: move htlcDesc struct 2020-06-15 13:51:03 +02:00
Joost Jager
c27406b579
lnwallet/test: move test htlcs out of function 2020-06-15 13:51:01 +02:00
Joost Jager
98ec8bf502
lnwallet/test: move test cases out of function 2020-06-15 13:50:59 +02:00
Joost Jager
3b7f084509
lnwallet/test: remove impossible test case
In this test case, the funder cannot pay the commit fee.
2020-06-15 13:50:57 +02:00
Joost Jager
4421894c4c
lnwallet/test: remove zero fee test case
This is currently not supported in lnd.
2020-06-15 13:50:55 +02: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
nsa
85852733af Makefile: add -w to -ldflags to strip DWARF symbols
Compiling with this flag cuts down on the binary size by several
megabytes.
2020-06-09 14:40:48 -04:00
Matheus Degiovani
c76356e7be breacharbiter: fix flaky race condition in test
This fixes a possible race condition during TestBreachSpends that could
cause the test to fail in a flaky way.

The error returned in PublishTransaction (publErr) could be modified by
the main test goroutine before PublishTransaction had a chance to
return, causing the wrong error value to be returned.

This was mostly visible as a flake during TestBreachSpends/all_spends
where adding a one second delay in the old code between the send in
publTx and the call to publMtx.Lock() would cause the last iteration of
the test loop to fail.

This is fixed by moving the lock and locally storing the expected error
value to before the send so that each call to PublishTransaction is
guaranteed to return the correct error value.
2020-06-09 10:40:22 -03:00
Olaoluwa Osuntokun
38b8e54ba7
Merge pull request #4357 from bhandras/invoices_testify
invoices+test: replace DeepEqual + spew dump with testify
2020-06-08 20:37:38 -07:00
Conner Fromknecht
87d1c37e3c
Merge pull request #4356 from wpaulino/sign-key-desc-quirk
signrpc: parse both KeyDescriptor fields for SignOutputRaw requests
2020-06-08 20:16:52 -07:00
Conner Fromknecht
06028ed141
Merge pull request #4358 from matheusdtech/contest-doc
contractcourt/incoming_resolver: Improve comments
2020-06-08 15:12:56 -07:00
yyforyongyu
ac99c0d021 contractcourt: add ChannelStatus in MarkChannelClosed 2020-06-08 17:30:28 +08:00
Matheus Degiovani
a2a2a301ca contractcourt/incoming_resolver: Improve comments
Small nits on a few comments.
2020-06-05 16:52:48 -03:00