Commit Graph
11461 Commits
Author SHA1 Message Date
Olaoluwa Osuntokun c0acdd8082 Merge pull request #5036 from halseth/breacharbiter-justice-splitting
[breacharbiter] Split justice tx in case of delayed confirmation.
2021-05-12 13:42:42 -07:00
Olaoluwa Osuntokun 86c5e483b2 Merge pull request #5206 from carlaKC/4987-heightexpirywatcher
invoices: add height based expiry watcher
2021-05-12 13:41:52 -07:00
Olaoluwa Osuntokun 93730088c5 Merge pull request #5256 from guggero/wallet-unlock-file
Auto-unlock wallet from password file
2021-05-12 13:41:30 -07:00
Olaoluwa Osuntokun dc73a23e81 Merge pull request #5253 from cfromknecht/amp-invoice
Support paying AMP invoices via SendPaymentV2
2021-05-12 13:38:42 -07:00
Johan T. Halseth 02268b8912 breacharbiter: fix revoked funds calculation
Since we also must count revoked funds swept from second level revoked
outputs, we move the funds counting into the updateBreachInfo method,
where we already are checking whether the spend is by us or the remote.

We also clean up the logs a bit, to log the incremental sweep of funds
that now can happen.
2021-05-12 12:32:29 +02:00
Johan T. Halseth db0ec12412 breacharbiter: broadcast "splitted" justice tx if spend all not
confirming

In case 4 block passes without our justice tx confirming, we'll "split"
it up, and separately sweep the commitment outs, and HTLC outs.
2021-05-12 12:32:29 +02:00
Johan T. Halseth 2d710154c4 breacharbiter: create split variants of justice tx
We define a new struct justiceTxVariants, which holds three different
justice transactions:

1. The "normal" justice tx that spends all breached outputs
2. A tx that spends only the breached to_local output and to_remote output
   (can be nil if none of these exist)
3. A tx that spends all the breached HTLC outputs (can be nil if no HTLC
   outputs exist)

This will later be used to sweep the time sensitive outputs separately,
in case the normal justice tx doesn't confirm in time.
2021-05-12 12:32:29 +02:00
Johan T. Halseth 783d1f9578 breacharbiter: remove justiceTx finalization
Now that we don't rely on the justice tx TXID anymore, we can remove
finalization of it. Instead we'll recreate the transaction when needed
from the persisted retribution info.
2021-05-12 12:32:29 +02:00
Johan T. Halseth 3be9b74694 breacharbiter: replace justice tx conf check with spend check
Since we want to potentially broadcast multiple versions of the justice
TX, instead of waiting for confirmation of a specific TXID, we instead
wait for the breached outputs to be spent.
2021-05-12 12:32:29 +02:00
Johan T. Halseth c3b2791158 breacharbiter: don't transition to second level if own spend 2021-05-12 12:32:29 +02:00
Johan T. Halseth 0a0b5f89c9 input: create IsHtlcSpendRevoke 2021-05-12 12:32:29 +02:00
Johan T. Halseth e7ee5ad51f breacharbiter_test: extract sweep tx creation into method 2021-05-12 12:32:29 +02:00
Johan T. Halseth a192718807 breacharbiter_test: distinguish spending transactions from justice tx
inputs

Since we want to test more complex combinations of spends of the
breached outputs, we use two maps tracking

1. which transaction will spend the outpoint
2. which outpoints we expect the breacharbiter to include in the justice
   tx

This let us trigger spends of the individual outputs, and depending on
what we want to test check whether the breacharbiter sweeps the expected
outpoints.
2021-05-12 12:32:28 +02:00
Johan T. Halseth 3aa5e650fb lntest/mock: set input index on spend event 2021-05-12 12:32:28 +02:00
Johan T. Halseth a6724c1088 breacharbiter: split waitForSpendEvent
We split the method waitForSpendEvent into two, such that we can reuse
it in case the commitment is spent by various transactions.
2021-05-12 12:32:28 +02:00
Johan T. Halseth bca5839929 breacharbiter: extract countRevokedFunds 2021-05-12 12:32:28 +02:00
carla 74373f26b9 invoices/test: add height expiry watcher tests with registry 2021-05-11 08:47:17 +02:00
carla 8066ff7047 itest/test: assert expired hold invoice updated correctly 2021-05-11 08:45:32 +02:00
carla b7d1ed0cbb itest/test: test hold invoice cancel before force close 2021-05-11 08:45:31 +02:00
carla 85e56dbfb7 invoices/test: add test for hodl invoices 2021-05-11 08:45:30 +02:00
carla 34de5922ed multi: add height-based invoice expiry
This commit adds height-based invoice expiry for hodl invoices
that have active htlcs. This allows us to cancel our intentionally
held htlcs before channels are force closed. We only add this for
hodl invoices because we expect regular invoices to automatically
be resolved.

We still keep hodl invoices in the time-based expiry queue,
because we want to expire open invoices that reach their timeout
before any htlcs are added. Since htlcs are added after the
invoice is created, we add new htlcs as they arrive in the
invoice registry. In this commit, we allow adding of duplicate
entries for an invoice to be added to the expiry queue as each
htlc arrives to keep implementation simple. Our cancellation
logic can already handle the case where an entry is already
canceled, so this is ok.
2021-05-11 08:45:29 +02:00
Olaoluwa Osuntokun d2c25124ed cmd/lncli: add basic AMP support for CLI 2021-05-10 22:02:15 -07:00
Conner Fromknecht ef392dcd0c lntest: add amp invoice test 2021-05-10 22:02:15 -07:00
Conner Fromknecht 4e93c1303c lntest: isolate alice+bob in mppTestContext 2021-05-10 22:02:15 -07:00
Conner Fromknecht 2ecd1de713 config: expose distinct accept-amp flag
This mirrors the accept-keysend flag, but also permits users to
eventually toggle off keysend separately from AMP.
2021-05-10 22:02:15 -07:00
Conner Fromknecht 64d07558d9 lnrpc: set either payHash or setId depending on payreq type 2021-05-10 22:02:14 -07:00
Conner Fromknecht 8c404ade18 routing: allow splitting for AMP or MPP 2021-05-10 22:02:14 -07:00
Conner Fromknecht b0949054e5 invoices: fail HTLCs that target the wrong type of invoice 2021-05-10 22:02:14 -07:00
Conner Fromknecht dba055de2d lntest/amp_test: assert subscribe invoice in sendtoroute_amp 2021-05-10 22:02:14 -07:00
Olaoluwa Osuntokun ba5aaec632 Merge pull request #5266 from wpaulino/import-dry-run
walletrpc: expose dry run support for ImportAccount
2021-05-10 17:19:09 -07:00
Conner Fromknecht 8402e346f5 channeldb/invoice: fail extra HTLC sets immeidately 2021-05-10 16:55:18 -07:00
Conner Fromknecht 70efaa5fe2 invoices: use HTLCSet method with state filter 2021-05-10 16:55:17 -07:00
Conner Fromknecht d93c3298b7 channeldb+invoice: add state filter to HTLCSet 2021-05-10 16:55:17 -07:00
Conner Fromknecht 620e426bc3 lncli: add --amp flag to invoice command 2021-05-10 16:55:17 -07:00
Conner Fromknecht 2be874f340 lnrpc: add IsAmp to Invoice 2021-05-10 16:55:17 -07:00
Conner Fromknecht 541041f4a8 invoicesrpc: add ability to generate AMP invoices 2021-05-10 16:55:17 -07:00
Conner Fromknecht 6a7d3c4b5e lnrpc+rpcserver: thread GenAmpInvoiceFeatures to invoicesrpc 2021-05-10 16:55:17 -07:00
Conner Fromknecht e97da53676 feature: populate SetInvoiceAmp with TlvOpt+PayAddrReq+AmpReq 2021-05-10 16:55:16 -07:00
Conner Fromknecht bbb841bd5f feature/set: add SetInvoiceAmp
AMP invoices need to signal:
 - AMPRequired in order to avoid being paid by older clients that don't
   support it.
 - Can't advertised MPP optional, otherwise older clients will attempt
   to pay the invoice with regular MPP payment.

Hence, the features advertised on AMP invoices are mutually exclusive
from those advertised on MPP. Create a new set to classify the two.
2021-05-10 16:55:16 -07:00
Conner Fromknecht 9020a4d2a5 lnrpc/invoicesrpc: extract paymentHashAndPreimage helper 2021-05-10 16:55:12 -07:00
Olaoluwa Osuntokun 0d3253c410 Merge pull request #5281 from guggero/router-chain-sync
itest flakes: fix multiple issues around router subsystem being out of sync
2021-05-10 13:11:37 -07:00
Oliver Gugger 6c37cae639 lntest+routing: update best height after graph pruning
It seems #5246 introduced a subtle bug that lead to the error "out of
order block: expecting height=1, got height=XXX" some times during
startup. Apparently it can happen that during pruning of the graph tip
some blocks can come in before we start our chain view and the new block
subscription. By querying the chain backend for the best height before
syncing with the graph we ensure that we never miss a block.
2021-05-10 16:46:28 +02:00
Oliver Gugger 8147b270d4 lntest: wait for chain sync in switch test 2021-05-10 16:46:28 +02:00
Oliver Gugger ea4ef204a0 rpcserver: add router synced to synced_to_chain flag
The router has a lot of work to do for each block. So it might be
possible that it isn't yet up to date with the most recent block,
even if the wallet is. This can happen in environments with high CPU
load (such as parallel itests). Since the `synced_to_chain` flag in
the response of this call is used by many wallets (and also our
itests) to make sure everything's up to date, we add the router's
state to it. So the flag will only toggle to true once the router was
also able to catch up.
2021-05-10 16:46:28 +02:00
Oliver Gugger 9f0228b21c router: add SyncedHeight() method
The router subsystem has its own goroutine that receives chain updates
and then does its (quite time consuming) work on each new block. To make
it possible to find out what block the router currently is synced to, we
export its internal best height through a new method.
2021-05-10 16:46:27 +02:00
Johan T. Halseth 6f2f23aae6 Merge pull request #5284 from yuki-js/master
lnrpc: Change State -> state in GetState
2021-05-10 10:41:09 +02:00
yuki-js 241f62fbb6 lnrpc: Change State -> state in GetState
protobuf and rest field's first letter should be lower case
2021-05-09 22:50:10 +00:00
Wilmer Paulino e079a9583c walletrpc: use bytes to represent master key fingerprint
The integer representation is not common and using bytes allows users to
easily confirm whether their master key fingerprint is correct.
2021-05-07 13:07:10 -07:00
Wilmer Paulino f7b130b5ca lncli: add dry run flag for wallet account import command 2021-05-07 13:07:10 -07:00
Wilmer Paulino e180023843 walletrpc: expose dry run support for ImportAccount 2021-05-07 13:06:27 -07:00