Commit Graph

11473 Commits

Author SHA1 Message Date
Olaoluwa Osuntokun
7ab5906093
Merge pull request #5245 from bhandras/kvdb_module
kvdb: make kvdb a top level submodule to allow dependency in other projects
2021-05-13 15:59:20 -07:00
Olaoluwa Osuntokun
3cc9e63bb5
Merge pull request #5293 from Crypt-iQ/prevent_zombie_payments_05122021
multi: validate payment params at RPC layer
2021-05-13 15:48:09 -07:00
Olaoluwa Osuntokun
875a3d9659
Merge pull request #5291 from guggero/psbt-segwit-check
chanfunding: extend PSBT witness input check
2021-05-13 15:46:20 -07:00
eugene
a70d0bef34
multi: validate payment params at RPC layer
With this patch, we'll fail out earlier in the cycle in case of
some wonky parameters, and not leave zombie payments in the router
which currently are not cleaned up.
2021-05-13 17:17:52 -04:00
Oliver Gugger
2d70b46269
chanfunding: extend PSBT witness input check
Fixes #5287.

The PSBT spec is a bit vague when it comes to the WitnessUtxo field of
an input as it's not strictly required for witness inputs. Therefore
Electrum for example does not include the field.
We need to make the SegWit input check a bit more elaborate by looking
at the output script of the UTXO and also the redeem script in case it's
a nested SegWit spend.
2021-05-13 20:42:57 +02:00
Andras Banki-Horvath
fc139d9bb8
kvdb: add ForEachBucket implementation 2021-05-13 10:35:35 +02:00
Olaoluwa Osuntokun
6a2fb316ca
Merge pull request #5274 from halseth/anchors-reserved-value-max
[anchors] cap value reserved for anchor fee bumping
2021-05-12 16:19:57 -07:00
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
Johan T. Halseth
820e77d574
lncfg: make anchor channels by default
This commit again enables anchor channels by default.

During itests we still keep anchors opt-in, as many of the tests rely on
the behaviour of non-anchor channels.
2021-05-11 10:27:54 +02:00
Johan T. Halseth
8e1087d1cd
lwallet: only count public channels towards our reserved value
Since private channels (most likely) won't be used for routing other
than as last hop, they bear a smaller risk that we must quickly force
close them in order to resolve a HTLC up/downstream.

In the case where it actually has to be force to resolve a payment (if
it is the first/last hop on a routed payment), we can assume that the
router will have UTXOs available from the reserved value from the
incoming public channel.
2021-05-11 10:27:54 +02:00
Johan T. Halseth
a0b6a0b00b
lnwallet: cap value reserved for anchor fee bumping
We cap the maximum value we'll reserve for anchor channel fee bumping at
10 times the per-channel amount such that nodes with a high number of
channels don't have to keep around a very large amount for the unlikely
scanario that they all close at the same time.
2021-05-11 10:27:54 +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