Commit Graph

350 Commits

Author SHA1 Message Date
eugene
c7cbacc35b multi: move mockChainIO, mockNotifier to lntest/mock 2020-08-31 19:41:09 -04:00
eugene
49d8f04197 multi: migrate instances of mockSigner to the mock package
This commit moves all localized instances of mock implementations of
the Signer interface to the lntest/mock package. This allows us to
remove a lot of code and have it housed under a single interface in
many cases.
2020-08-28 15:43:51 -04:00
yyforyongyu
acc0ec13e1
trivial: remove unused print 2020-08-28 17:09:39 +08:00
Conner Fromknecht
fd3f7ca6c8
Merge pull request #4434 from carlaKC/labels-general
multi: add labels to lnd native transactions
2020-08-20 12:58:04 -07:00
yyforyongyu
57f7115437
trivial: typo fix 2020-08-13 07:33:52 +08:00
carla
2a614cc596
multi: add labels to lnd native transactions
Follow up labelling of external transactions with labels for the
transaction types we create within lnd. Since these labels will live
a life of string matching, a version number and rigid format is added
so that string matching is less painful. We start out with channel ID,
where available, and a transaction "type". External labels, added in a
previous PR, are not updated to this new versioned label because they
are not lnd-initiated transactions. Label matching can check this case,
then check for a version number.
2020-07-29 13:46:07 +02:00
carla
d8a4b37c0e
contractcourt: persist commit sweep resolutions 2020-07-07 19:49:58 +02:00
carla
d0ec872ef3
contractcourt: store htlc timeout sweeps 2020-07-07 19:49:57 +02:00
carla
a38dc256fd
contractcourt: persist remote outgoing htlc claim outcome on disk
When a remote peer claims one of our outgoing htlcs on chain, we do
not care whether they claimed with multiple stages. We simply store
the claim outgome then forget the resolver.
2020-07-07 19:49:56 +02:00
carla
03b76ad9a4
contractcourt: save htlc success resolvers, including first stage
Checkpoint our htlc claims with on chain reasolutions, including our
first stage success tx where required.
2020-07-07 19:49:55 +02:00
carla
eb07f89090
contractcourt/test: add test context for success resolver 2020-07-07 19:49:54 +02:00
carla
cf739f3f87
contractcourt: persist timed out incoming htlc resolver reports
Incoming htlcs that are timed out or failed (invalid htlc or invoice
condition not met), save a single on chain resolution because we don't
need to take any actions on them ourselves (we don't need to worry
about 2 stage claims since this is the success path for our peer).
2020-07-07 19:49:54 +02:00
carla
f5b20b7429
contractcourt: store anchor resolutions on disk 2020-07-07 19:49:53 +02:00
carla
0a01d5d17c
contractcourt: add resolver report function to ContractReport
Our current set of reports contain much of the information we will
need to persist contract resolutions. We add a function to create
resolver reports from our exiting set of resolutions.
2020-07-07 19:49:52 +02:00
carla
fa46db9c48
multi: add resolver reports to Checkpoint
To allow us to write the outcome of our resolver to disk, we add
optional resolver reports to the CheckPoint function. Variadic params
are used because some checkpoints may have no reports (when the resolver
is not yet complete) and some may have two (in the case of a two stage
resolution).
2020-07-07 19:49:51 +02:00
carla
8c8f857f60
contractcourt: add PutResolverReport function to chanArb config 2020-07-07 19:49:50 +02:00
Olaoluwa Osuntokun
1de7e30cd1
Merge pull request #4361 from yyforyongyu/add-channel-status
contractcourt: add ChannelStatus in MarkChannelClosed
2020-06-23 16:23:30 -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
Joost Jager
d416ed59ea
multi: add explicit hodl invoice flag to invoice
Previously it wasn't possible to store a preimage in the invoice
database and signal that a payment should not be settled right away. The
only way to hold a payment was to insert the magic UnknownPreimage value
in the invoice database. This commit introduces a distinct flag to
signal that an invoice is a hold invoice and thereby allows the preimage
to be present in the database already.

Preparation for (key send) hodl invoices for which we already know the
preimage.
2020-06-02 07:34:23 +02:00
Conner Fromknecht
455ddfebdb
multi: rename: ReadBucket to RBucket 2020-05-26 18:21:08 -07:00
Conner Fromknecht
d0d2ca403d
multi: rename ReadTx to RTx 2020-05-26 18:20:37 -07:00
carla
75370ce6b4
multi: update WalletController PublishTransaction to include label
Add label parameter to PublishTransaction in WalletController
interface. A labels package is added to store generic labels that are
used for the different types of transactions that are published by lnd.

To keep commit size down, the two endpoints that require a label
parameter be passed down have a todo added, which will be removed in
subsequent commits.
2020-05-19 13:30:00 +02:00
Olaoluwa Osuntokun
280bf8d26c
Merge pull request #4226 from breez/fix-chainrpc-crash
Fix crash when ChainNotifier is being accessed too early.
2020-05-15 16:17:40 -07:00
Matheus Degiovani
43b9318b2d contractcourt/commit_sweep_resolver: reduce log msg to warn 2020-05-12 07:46:14 -03:00
Matheus Degiovani
9ed14a50a4 contractcourt: switch to table based testCommitSweepResolverDelay
This improves readability since both instances of the test are very
similar.
2020-05-12 07:46:14 -03:00
Matheus Degiovani
2110bfa40b contractcourt: test sweep of locally breached commit tx
This adds a test to the commit sweeper resolver to ensure it behaves
properly if the local node breaches a channel.

In this situation the remote party is expected to sweep the breached
output to itself and therefore the local party won't be able to recover
any funds.
2020-05-12 07:46:14 -03:00
Matheus Degiovani
d71a4ee033 contractcourt+itest: fix lingering pending channel after breach
This fixes an issue where the contract court could leave a completely
swept commit tx unresolved if it was swept by the remote party.

This could happen if (our) commit tx just published was actually a
previously revoked state, in which case the remote party would claim the
funds via a justice transaction.

This manifested itself in the testRevokedCloseRetribution integration
test where at the end of the test Bob was left with a pending channel
that never resolved itself.
2020-05-12 07:46:14 -03:00
Roei Erez
ae2c37e043 Ensure chain notifier is started before accessed.
The use case comes from the RPC layer that is ready before the
chain notifier which is used in the sub server.
2020-04-30 12:54:33 +03:00
Andras Banki-Horvath
ccf6e2a393 contractcourt: remove redundant return 2020-04-24 19:15:08 +02:00
Conner Fromknecht
0f94b8dc62
multi: return input.Signature from SignOutputRaw 2020-04-10 14:27:35 -07:00
Conner Fromknecht
978ff82f1f
contractcourt/chain_watchter: fix broken log stmts 2020-04-03 15:29:18 -07:00
Olaoluwa Osuntokun
9b39692bb2
contractcourt: add additional logging of commitments at play
In this commit, we add some additional logging of the commitments at
play when we detect a channel closure on-chain. This should help to
debug things more in the future as we don't log the full commitments
anywhere.  We also now also print the type of commitment as well, as a
follow up from the recent anchor outputs work. In the near future, as we
implement a dynamic commitments update protocol, always logging the
commitment type as well will likely be useful for debugging purposes.
2020-04-02 16:46:33 -07:00
Joost Jager
8b7bde7200
cnct: log txid for force close 2020-03-27 07:42:01 +01:00
Olaoluwa Osuntokun
320101d054
contractcourt: convert to use new kvdb abstraction 2020-03-18 19:34:52 -07:00
Joost Jager
ab451f634e
cnct+lnrpc: report anchor resolution 2020-03-18 12:27:03 +01:00
Joost Jager
ea397c9d6e
cnct: resolve anchors post-confirmation
Sweeping anchors and being able to bump the fee was already added in a
previous commit. This commit extends anchor sweeping with an anchor
resolver object that becomes active after the commitment tx confirms.
At that point, the anchors do not serve the purpose of getting the
commitment tranaction confirmed anymore. It is however still possible to
reclaim some of their value if using a low fee rate.
2020-03-18 12:27:01 +01:00
Joost Jager
d84b596f55
cnct: do not ignore resolver reports after resolution
Preparation for anchor resolver. The recovered anchor amount should
still be included in the pending channel report even after it has been
resolved.

This also fixes an existing bug that in some cases caused the recovered
amount from an htlc resolver not to be included in the total.
2020-03-18 12:26:59 +01:00
Joost Jager
07a39b1ebf
cnct: do not persist stateless resolvers
Preparation for the anchor resolver which does not have persistent
state.
2020-03-18 12:26:57 +01:00
Joost Jager
d2b6472843
cnct: pre-confirmation anchor sweep
Start anchor sweep attempts immediately after the commitment transaction
has been published. This makes the anchor known to the sweeper and
allows the user to bump the fee on it to get their commitment
transaction confirmed in case the fee committed too is insufficient for
timely confirmation.
2020-03-18 12:26:55 +01:00
Joost Jager
e8e99c6533
cnct: simplify channel arbitrator state logging 2020-03-17 16:25:39 +01:00
Joost Jager
3b517390d8
cnct+sweeper: give contract court access to relay fee
Relay fee is needed later to sweep anchors at the minimum fee rate.
2020-03-17 16:25:37 +01:00
Joost Jager
dd77d9263e
cnct: persist anchor resolutions 2020-03-17 16:25:33 +01:00
Joost Jager
7f3d4e7d49
cnct: create channel interface for arbitrator
Allows unit testing of the channel arbitrator with fewer dependencies.
This is a preparation for the addition of anchor sweeping.
2020-03-17 16:25:31 +01:00
Joost Jager
c0b1b3be14
cnct: always set trigger height to close height
Prior to this change, the trigger height for closed channels was set to
the current best block height. As this height is in some cases used as a
height hint, the spend may have been missed.
2020-03-17 16:25:29 +01:00
Joost Jager
30fc03d84d
lnwallet/test: pass in test channel type 2020-03-17 14:19:33 +01:00
Johan T. Halseth
92af2342da
lnwallet+nursery+input: set sequence=1 for direct HTLC spends 2020-03-09 12:59:33 +01:00
Johan T. Halseth
bddd3e128c
lnwallet: make second level sigs using sighash single|anyonecanpay 2020-03-09 12:59:33 +01:00
Johan T. Halseth
1f28bd8086
contractcourt/commit_sweep_resolver: set sweep witness type based on witness script
We use the fact that we can tell whether the commit is local or remote
by inspecting the witness script. We cannot use the maturity delay
anymore, as we can have delayed to_remote outputs also now.

Co-authored-by: Joost Jager <joost.jager@gmail.com>
2020-03-09 12:10:59 +01:00
Johan T. Halseth
af68ff1640
lnwallet: add anchor commitmenttype
With this commitment type, we'll add extra anchor outputs to the
commitment transaction if the anchor channel type is active.
2020-03-09 12:10:59 +01:00