Commit Graph
100 Commits
Author SHA1 Message Date
Johan T. Halseth d787e74125 contractcourt/channel_arbitrator: stop block epoch on channel attendant exit 2018-06-21 11:13:46 +01:00
Johan T. Halseth 1c43a0cb36 contractcourt/chain_arbitrator: delete watcher from activeWatchers 2018-06-21 11:13:46 +01:00
Johan T. Halseth b56d922ce2 fundingmanager: properly stop channel on error 2018-06-19 12:48:38 +01:00
Johan T. Halseth 55c8741e42 peer: don't stop nil channel 2018-06-19 12:48:11 +01:00
Johan T. Halseth 327420d854 contractcourt/channel_arbitrator: Cancel block epoch in case of error in Start() 2018-06-19 12:20:30 +01:00
Johan T. Halseth 3bdc968f39 breacharbiter: wait on spend events instead of timeout
This commit handles a racy condition within the breacharbiter's justice
tx procedure. For backends that have no mempool we would check if an
HTLC output was spent and then try broadcasting the justice tx, but this
would fail since we wouldn't detect the spend before it was in a block.
The result was that we would continuously attempt to broadcast the
transaction, effectively ending up in an endless (until the second-level
tx actually comfirmed) loop.

Instead we now register for spend notifications in case broadcasting the
transaction fails, and then wait for any of the notifications to be
sent before trying again.

This is a necessary step to be able to make lnd work well only with
confimed transactions, and was a better solution than introducing
timeouts within the broadcast loop (which complicates integration
tests).
2018-06-15 12:11:13 +02:00
Johan T. Halseth e0560741b4 breacharbiter test: add TestBreachSecondLevelTransfer 2018-06-15 12:11:13 +02:00
Johan T. Halseth 60d9ae02c7 mock: protect mockSpendNotifier map by mutex 2018-06-15 12:11:13 +02:00
Johan T. Halseth 9aa55b164e breacharbiter test: extract common init logic 2018-06-15 12:11:13 +02:00
Johan T. Halseth 0316523bb5 lntest/harness: add pollIntervall to WaitPredicate
This commit adds a poll 20 ms interval to WaitPredicate, similar to what
is done for WaitInvariant. This makes the predicate not being checked
super-rapidly, potentially filling the logs with useless info over the
wait predicate interval.
2018-06-11 15:58:30 +02:00
Johan T. Halseth 5d8aaa94f1 lnd_test: add missing node shutdowns 2018-06-10 10:07:01 +02:00
Johan T. Halseth abe590b752 lnd_test: shutdown nodes using defers
This commit adds the helper method shutdownAndAssert, and makes us shut
down nodes created temporarily during the test cases using defers
instead of at the end of the test. This makes it easier to remember to
shut them down, as it is done right after they are started.
2018-06-10 10:07:00 +02:00
Johan T. Halseth 226b38fed7 lntest/node: add method Name to get a node's name 2018-06-10 10:07:00 +02:00
Johan T. Halseth ac1ab6f516 server: hold mutex shorter during broadcast
We remove the internale broadcastMessage method, and instead handle the
mutex handling within BroadcastMessage. This lets us hold the mutex only
when neccessary.
2018-06-06 12:20:25 +02:00
Johan T. Halseth b8512c3568 server: don't hold mutex while sending to peer
This commit removes the sendToPeer method from the server, and instead
moves the necessary logic into SendToPeer. This let's us make the mutex
acquisition more fine-grained, only holding it while reading from the
peer map. Earlier it was required to be held during the whole call to
sendToPeer, as the method would access the map internally.
2018-06-06 12:20:06 +02:00
Johan T. Halseth 07629e5da1 lnwallet/channel: use FullySynced to check chanSync special case
We check if the channel is FullySynced instead of comparing the local
and remote commit chain heights, as the heights might not be in sync.
Instead we call FullySynced which recently was modified to use compare
the message indexes instead, which is _should_ really be in sync between
the chains.

The test TestChanSyncOweRevocationAndCommitForceTransition is altered to
ensure the two chains at different heights before the test is started, to
trigger the case that would previously fail to resend the commitment
signature.
2018-06-04 15:09:51 +02:00
Johan T. Halseth cdaafc4a23 fundingmanager: hold mutex during ctx cancellation
This commit changes cancelReservationCtx to gold the resMtx from start
to finish. Earlier it would lock at different times only when accessing
the maps, meaning that other goroutines (I'm looking at you
PeerTerminationWatcher) could come in and grab the context in between
locks, possibly leading to a race.
2018-06-01 09:19:01 +02:00
Johan T. Halseth 3d964628f0 fundingmanager test: check that error is sent on timeout 2018-06-01 08:55:07 +02:00
Johan T. Halseth d20cb8e2f6 fundingmanager: send on resCtx.err in failFundingFlow
This commit moves the responsibility of sending a funding error on the
reservation error channel inside failFundingFlow, reducing the places we
need to keep track of sending it.
2018-06-01 08:55:07 +02:00
Johan T. Halseth 9090344329 fundingmanager: simplify handleErrorMsg 2018-06-01 08:55:07 +02:00
Johan T. Halseth 7d38e35cdc fundingmanager: send error directly in CancelPeerReservations
The error channel should never be nil, and it should always be buffered.
Because of this we can send directly on the channel.
2018-06-01 08:55:07 +02:00
Johan T. Halseth b63ee1a410 fundingmanager: fail funding flow on confirmation timeout 2018-06-01 08:55:07 +02:00
Johan T. Halseth ccf9cd47ef fundingmanager: delete empty peer in deleteReservationCtx 2018-06-01 08:55:06 +02:00
Johan T. Halseth 6ee58ec1b0 fundingmanager: don't block on pendingChannels chan send 2018-06-01 08:55:06 +02:00
Johan T. Halseth 08d9edd059 server: increase updateChan buffer to 2 2018-06-01 08:55:06 +02:00
Johan T. Halseth 5ddb154a45 fundingmanager: use non-zero channel ID 2018-06-01 08:55:06 +02:00
Johan T. Halseth d4700640e0 lnwallet/channel test: add TestChannelRestoreCommitHeight
This commit adds a test which will restore a channel from an OpenChannel
struct at various stages of the state transation cycle, ensuring the
HTLC local and remote add heights are restored properly.
2018-05-29 08:35:01 +02:00
Johan T. Halseth cb52151123 lnwallet/channel: set add heights based on the locked in commits
This commit fixes a bug which would cause the add heights of the HTLCs
in the update log to be set wrongly. At times, an add height could be
incorrecly set, leading to the HTLCs not being accounted for correctly
during evaluating the HTLC views. This was caused by the assumption that
if the HTLC was not on the pending remote commit, then it was locked in
on both the local and the remote commit, which is not always true.

Instead of making this assumption, we instead now inspect the three
commits: the local, remote and pending remote; and set the add heights
accordingly. This should ensure that HTLCs are subtracted from the
balances only when they are first added.
2018-05-29 08:35:01 +02:00
Johan T. Halseth 4dfb4547a0 htlcswitch: remove unused Disconnect from Peer interface 2018-05-25 06:58:24 +02:00
Johan T. Halseth f95ae1cdd6 htlcswitch/link: add failed variable to ensure exit 2018-05-25 06:58:24 +02:00
Johan T. Halseth d0b0734e5b lnd_test: add testFailingLink
This commit adds an integration test that checks that in case a channel
counterparty tries to settle an HTLC with the wrong preimage, the
channel is failed and force closed.
2018-05-25 06:58:24 +02:00
Johan T. Halseth 49fd3f34d4 htlcswitch/link: settle with fake preimage if BogusSettle active 2018-05-25 06:58:24 +02:00
Johan T. Halseth 71a1aae417 htlcswitch/hodl: add flag BogusSettle
This commit adds a new hodl flag "BogusSettle" which will be used to
emulate a node trying to settle back an incoming HTLC with a fake
preimage.
2018-05-25 06:58:23 +02:00
Johan T. Halseth 88670175c7 htlcswitch/link_test: add TestChannelLinkFail 2018-05-25 06:58:23 +02:00
Johan T. Halseth 9a47494517 htlcswitch/link_test: extract adding link to switch 2018-05-25 06:58:23 +02:00
Johan T. Halseth 3b2fd32523 peer: populate OnChannelFailure in link config
This commit makes the peer aware of the LinkFailureErrors that can
happen during link operation, and making it start a goroutine to
properly remove the link and force close the channel.
2018-05-25 06:58:23 +02:00
Johan T. Halseth fbec83699c htlcswitch/link: make fail() call OnChannelFailure with LinkFailureError
Adds a new closure OnChannelFailure to the link config, which is called
when the link fails. This function closure should use the given
LinkFailureError to properly force close the channel, send an error to
the peer, and disconnect the peer.
2018-05-25 06:58:23 +02:00
Johan T. Halseth 92afcbe3f4 htlcswitch/linkfailure: define LinkFailureError
This commit introduces a new error type LinkFailureError which is used
to distinguish the different kinds of errors that we can encounter
during link operation. It encapsulates the information necessary to
decide how we should handle the error.
2018-05-25 06:58:18 +02:00
Johan T. Halseth 4836a25c98 peer: move link creation into new method 2018-05-25 06:54:05 +02:00
Johan T. Halseth 1f746c3fda contractcourt/chan_arb: specify that ForceCloseChan removes link from
switch
2018-05-25 06:54:05 +02:00
Johan T. Halseth 5cef2bacde rpcserver: add TODO for removing coop closes from "pending close" channels 2018-05-24 10:29:20 +02:00
Johan T. Halseth 8afc7bf66e contractcourt/chain_arbitrator: add TODO for removing watchForChannelClose 2018-05-24 10:24:31 +02:00
Johan T. Halseth 69a76a808f breacharbiter: add todo for removing IsPending check 2018-05-23 12:11:19 +02:00
Johan T. Halseth 72d9726e7f channeldb/channel: update IsPending godoc
The pending state definitin in ChannelCloseSummary was slightly changed
in such a way that channels that has had their commitment broadcasted
now is no longer considered "pending close". They now instead stay in
the open chan bucket with the ChanStatus "CommitmentBroadcasted" until
their commitment is confirmed. This commit updates the IsPending godoc
to reflect this.
2018-05-23 12:07:35 +02:00
Johan T. Halseth 74205a64fd lnd_test: check for coop closed channel among WaitingClose instead of PendingClosed 2018-05-22 14:30:30 +02:00
Johan T. Halseth 921f02fe22 contractcourt/chain_arbitrator: markChanClosed->notifyChanClosed
We no longer have to mark the channel as fully closed in the database,
as it is done directly in the chainWatcher. Instead, we stop the watcher
and delete it from the set of active watchers.
2018-05-22 14:30:19 +02:00
Johan T. Halseth 0f077fcb54 contractcourt/chain_watcher: mark fully closed in dispatchCoopClose
This commit makes the dispatchCooperativeClose method mark the channel
fully closed directly, without registering for confirmation
notifications first. We can do this as recent changes to the
contractcourt changed the definition of a closed channel in the database
to have had its closing tx confirmed, and we only dispatch the
cooperative close once the transaction has 1 confirmation.

We also rename the markChanClosed method to notifyChanClosed, to more
clearly indicate that the ChainArbitrator no longer has to mark the
channel fully closed in the database.
2018-05-22 14:26:02 +02:00
Johan T. Halseth af14a2fc57 contractcourt/chain_watcher: remove CooperativeCloseCtx
Removes CooperativeCloseCtx and methods.
2018-05-22 14:21:43 +02:00
Johan T. Halseth 21d1cc3fe8 contractcourt/chain_arbitrator: remove BeginCoopChanClose 2018-05-22 12:06:33 +02:00
Johan T. Halseth bb611e065d peer: don't pass closeCtx to chanCloser 2018-05-22 12:06:33 +02:00
Johan T. Halseth 0809880426 chancloser: don't log potential closes to the chainwatcher
This commit stops the chan closer from sending the potential coop close
transactions to the chainwatcher, as this is no longer needed. The
chainwatcher recently was modified to watch for any potential close, and
will because of this handle the close regardless of which one appears in
chain.

When the chancloser broadcast the final close transaction, we mark it as
CommitmentBroadcasted in the database.
2018-05-22 12:05:47 +02:00
Johan T. Halseth 9ddd484524 lnwallet/channel: export method MarkCommitmentBroadcasted 2018-05-22 12:03:35 +02:00
Johan T. Halseth 7cd783d7bb lnwallet/channel: remove unused method DeleteState 2018-05-22 11:51:30 +02:00
Johan T. Halseth 9c7163187b lnwallet/channel: don't restore htlcs uneccessary
This commit removes redundant HTLC restoring. We don't have to restore
outgoing HTLCs from the local commitment, as we _know_ they will always
be added to the remote commitment first. Also, when receiving
Settles/Fails, they will be removed from the local commitment first.
This way we can be sure that outgoing HTLCs found on the local
commitment always will be found on the remote commitment

Similarly we don't have to restore incoming HTLCs from the remote
commitment, as they will be added to the local commitment first.
2018-05-16 21:02:17 +02:00
Johan T. Halseth c1e96e01e6 lnwallet/channel: remove restoreHtlc from pendingRemoteCommit
This commit removes the stage during updateLog restoration where we
would attempt to restore incoming HLTCs from the pendingRemoteCommit, in
addition to update our log and htlc counter to reflect this state. The
reason we can safely remove this is to observe that a pending remote
commit is always created from a commitDiff which only contains updates
made by _us_, and thus only taken from the localUpdateLog. The same can
be said for the counters, when creating a commitDiff we'll always use
the remoteACKedIndex as the index into the remoteUpdateLog, meaning that
all potential updates will already be included in the remote commit that
has been ACKed.
2018-05-16 21:02:17 +02:00
Johan T. Halseth fad7821e45 lnwallet/channel test: add TestChannelRestoreUpdateLogsFailedHTLC
This commit adds a test that runs through a scenario where an HTLC is
added then failed, making sure the update logs are properly restored at
any point during the process.
2018-05-16 21:02:14 +02:00
Johan T. Halseth d69c358dc6 lnwallet/channel_test: add TestChannelRestoreUpdateLogs
This commit adds a test ensuring that the fix applied in the previous
commit works as expected. The test exercises the scenario where the
HTLCs on the local, remote and pending remote commitment differ, and we
attempt to restore the update logs. We now check that in this case the
logs before and after restart are equivalent.
2018-05-16 21:01:32 +02:00
Johan T. Halseth 902e1e77cb lnwallet/channel: init localUpdateLog with index from remoteCommit,
remoteUpdateLog from localCommit

This commit fixes a bug within channel.go that would lead to the
content of the update logs and their indexes getting out of sync during
restores.

The scenario that could occur was that the localUpdateLog was initiated
with a log index taken from the localCommitment. Updates we send (which
are added to the localUpdateLog) will be added to the remote commitment
first. The problem happened when an update was sent and added to the
remote commitment, but not ACKed. Since it was not ACKed, we would not
add it to our local commitment. During a restart/restore we would init
the localUpdateLog with a height too low, such that when going through
the outgoing HTLCs on the remote commitment, we would restore an HTLC at
an index higher than our local log HTLC counter.

The symmetric change is done to the remoteUpdateLog.
2018-05-16 20:53:33 +02:00
Johan T. Halseth ec93bf581d contractcourt test: add TestChannelArbitratorLocalForceDoubleSpend
This commit adds a test for the case where the ChannelArbitrator fails
to broadcast its commitment during a force close because of
ErrDoubleSpend. We test that in this case it will still wait for a
commitment getting confirmed in-chain, then resolve.
2018-05-14 14:21:06 +02:00
Johan T. Halseth 0d435eff68 lnd_test: print predErr instead of generic waitPredicate error 2018-05-09 10:28:00 +02:00
Johan T. Halseth 03d2aa360f lnd_test: fix flake from routing hints for inactive channel
This commit attempts to fix a flake we have seen, where a routing hints
for an inactive channel was unexpectedly added to the invoice. This
happened because of a race between shutting down the endpoint of this
channel (Eve) and creating the invoice. This commit fixes this by moving
the call to AddInvoice with corresponding route hint check inside a
WaitPredicate.
2018-05-09 10:25:08 +02:00
Johan T. Halseth 2313eb2c7b make/testing_flags: delete log files before running itests, print date
This commit makes sure old log files are deleted before running the
integration tests. Previously new logs would be added to the existing
ones, causing a big mess. This was especially messy during flake
hunting, as all logs would be kept.

In addition, we now print the date before every start of the integration
tests, which is useful to see how long they have been running, for
instance in case of a deadlock.
2018-05-09 10:02:30 +02:00
Johan T. Halseth bc22fc9b63 makefile flakehunter: call $(ITEST) directly, print current time
For some reason, starting the integration test using /bin/sh -c would
cause unit tests to also be run. We fix this by just calling $(ITEST).
2018-05-09 09:59:51 +02:00
Johan T. Halseth 854e2a0581 link test: add TestChannelLinkWaitForRevocation
This commit adds a test where we trigger a situation which would
previously make the link think it was never in sync, and potentially
create a lot of empty state updates. This would happen if we were
waiting for a revocation, while still receiving updates from the remote.
Since in this case we could not ACK the updates because of the exhausted
revocation window, our local commitchain would extend, while the remote
chain would stall. When we finally got the revocation the local
commitment height would be far larger than the remote, and FullySynced
would return false from that point on.
2018-05-09 08:47:21 +02:00
Johan T. Halseth db254c1258 link test: add TestChannelLinkNoMoreUpdates
This commit adds a new test that makes sure we don't try to send
commitments for states where there are now new updates. Before the
recent change to FullySynced we would do this in this test scenario, as
the local an remote commitment heights would differ.

The test makes the local commitment chain extend by 1 vs the remote,
which would earlier trigger another state update, and checks taht no
such state update is made.
2018-05-09 08:47:21 +02:00
Johan T. Halseth 71228a6b06 lnwallet/channel: don't use commit height to determine FullySynced
This commit removes a faulty check we did to determine if the channel
commitments were fully synced. We assumed that if out local commitment
chain had a height higher than the remote, then we would have state
updates present in our chain but not in theirs, and owed a commitment.
However, there were cases where this wasn't true, and we would send a
new commitment even though we had no new updates to sign. This is a
protocol violation.

Now we don't longer check the heights to determine if we are fully
synced. A consequence of this is that we also need to check if we have
any pending fee updates that are nopt yet signed, as those are
considered non-empty updates.
2018-05-09 08:47:21 +02:00
Johan T. Halseth f26ec38a74 channeldb: return ErrNoPendingCommit in case of no channel bucket 2018-05-08 13:41:52 +02:00
Johan T. Halseth 9324bf7b1d lnwallet/channel: return error in case of htlc index mismatch
This commit make us return an error in case a restored HTLC from a
pending remote commit has an index that is different from our local
update log index. It is appended with the assumption that these indexes
are the same, and if they are not we cannot really continue.
2018-05-08 13:41:52 +02:00
Johan T. Halseth 7e1f2a7dc3 lnwallet/channel: remove unused arguments 2018-05-08 13:41:52 +02:00
Johan T. Halseth aa1c2cdf81 lnwallet/channel: add more info in case of crash
This commit adds a call to panic in case the HTLC we are looking for is
not found in the update log. It _should_ always be there, but we have
seen crashes resulting from it not being found. Since it will crash with
a nil pointer dereference below, we instead call panic giving us a bit
more information to work with.
2018-05-08 13:41:52 +02:00
Johan T. Halseth 1d676b77e1 lnwallet/channel: log pending remote commit during restore 2018-05-08 13:41:51 +02:00
Johan T. Halseth 1d172428c4 lnwallet/channel: return missing errors
This commit corrects a few cases where we would encounter errors, but
return nil by mistake.
2018-05-08 13:41:51 +02:00
Johan T. Halseth 690992043b breacharbiter_test: add double handoff event 2018-05-02 08:43:32 +02:00
Johan T. Halseth e9eab3f79f server: reliably hand off breach from the ChainArbitrator to the breachArb
This commit make the server populate the ChainArbitrator's
ContractBreach method, by a method that will reliably handoff the breach
event ot the breachArbiter. The server will now forward the breach event
to the breachArbiter, and only let the closure return a non-nil error
when the breachArbiter ACKs this event.
2018-05-02 08:43:32 +02:00
Johan T. Halseth 08f1a3689d peer: don't pass bool to SubscribeChannelEvents 2018-05-02 08:43:32 +02:00
Johan T. Halseth f06797ab00 contractcourt/chain_arbitrator: make breachArbiter handoff a function closure
This commit adds the new function closure option ContractBreach to the
ChainArbitrator config, a closure that is again used by the ChainWatcher
to reliably handoff a breach event to the breachArbiter.
2018-05-02 08:43:31 +02:00
Johan T. Halseth 3fdc04dff0 contractcourt/chain_watcher: make breachArbiter handoff a function closure
This commit changes how the ChainWatcher notifies the breachArbiter
about a channel breach. Instead of assuming the breachArbiter is among
the clients subscibing to channel events, it will call a new method
contractBreach(), and assume the breachArbiter has reliably gotten the
breach info when this method returns with a non-nil error.

Since the breachArbiter was the only sybsystem having a sync chain
subsciption, we also remove the (now) unused syncDispatch option.
2018-05-02 08:43:31 +02:00
Johan T. Halseth a6f0dd72ac contractcourt/chain_arbitrator: use chainWatcherConfig 2018-05-02 08:43:31 +02:00
Johan T. Halseth 0697510884 contractcourt/chain_watcher: create chainWatcherConfig 2018-05-02 08:43:31 +02:00
Johan T. Halseth 7c945b42fe fundingmanager_test: remove ArbiterChan 2018-05-02 08:43:31 +02:00
Johan T. Halseth cdf60b5f9d lnd: remove ArbiterChan 2018-05-02 08:43:31 +02:00
Johan T. Halseth c3f0e608ec fundingmanager: remove ArbiterChan 2018-05-02 08:43:31 +02:00
Johan T. Halseth 409ab08c36 rpcserver: remove send to settledContracts 2018-05-02 08:43:30 +02:00
Johan T. Halseth 55ac8735b6 breacharbiter_test: use ContractBreaches channel 2018-05-02 08:43:30 +02:00
Johan T. Halseth b9970aec47 breacharbiter: receive breaches to ACK on separate channel
This commit changes how the breachArbiter gets notified about channel
breaches. Previously it would need to SubscribeToChannelEvents to get
get notified if any breach happened, now we send all seen breaches on a
new channel ContractBreaches.

By having the breachArbiter subscribe to channel events, we risked
events getting lost when we were either starting up or shutting down,
since events could happen before we had been able to subscribe, or right
after we had cancelled our subscription.

Now it is the server's responsibility to reliably forward events from
the ChainArbitrator to the breachArbiter, and forward the ACK the
breachArbiter responds with. This makes sure that the messages aren't
lost in the event of starting up or shutting down, since the connection
between the subsystems now are static.

A result of this change is that the internals of the breachArbiter can
be simplified significantly, as we will get all channel breaches
forwarded on one channel. This lets us get rid of the observer
goroutines, and we spin up goroutines handling the channel breaches only
when they happen.
2018-05-02 08:43:30 +02:00
Johan T. Halseth 79341fc63e contractcourt/chain_watcher: move log message
This move the log message "channel marked pending-closed" to the point
where the channel actually has been marked pending closed, instead of
before the database transaction has been done.
2018-05-02 08:43:30 +02:00
Johan T. Halseth 7e397067f6 contractcourt/chainwatcher: remove close observer for loop
This commit removes the for loop in the closeObserver, as it wasn't
serving any purpose. After receiving a spend notification we would
return, breaking out of the loop. When getting a quit signal we would
also return, making the loop only do one iteration in any case.
2018-05-02 08:43:30 +02:00
Johan T. Halseth 23f67ef009 lnd_test: remove racy block generation
This commit removes the mining of a block within the integration tests,
that would lead to a flake during runs. The reason was that the sweeoing
transaction was actually broadcast already at this point, and this block
was mined with the assumption that it wasn't. However, test would pass
more often than not because the UTXO nursery would be working on
graduating new heights, whcih is a bit slow, so in most cases the block
would be mined before it had broadcast the sweeping transaction.

By removing this block we ensure that the sweeping transaction will be
found for sure in the waitForTxInMempool call below.
2018-04-27 10:01:05 +02:00
Johan T. Halseth 4320421110 contractcourt/chain_watcher: don't delete syncDispatch clients on Cancel()
This commit makes clients subscribing to channel events that are marked
"sync dispatch" _not_ being deleted from the list of clients when they
call Cancel(). Instead a go routine will be launched that will send an
error on every read of the ProcessACK channel.

This fixes a race in handing off the breach info while lnd was shutting
down. The breach arbiter could end up being shut down (and calling
Cancel()) before while the ChainWatcher was in the process of
dispatching a breach. Since the breach arbiter no longer was among the
registered clients at this point, the ChainWatcher would assume the
breach was handed off successfully, and mark the channel as pending
closed. When lnd now was restarted, the breach arbiter would not know
about the breach, and the ChainWatcher wouldn't attempt to re-dispatch,
as it was already marked as pending closed.
2018-04-25 09:37:26 +02:00
Johan T. Halseth 8d5a33e349 lnd_test: modify tests to work with on-chain spend registrations
This commit modifies the integration tests to work with the recent
 changes to the ChannelArbitrator, where it will only act on commitments
 that has been confirmed. Main changes involving when to look for
 transactions in the mempool and in blocks, and using the new RPC for
 getting channels in the "waiting close" phase when they are waiting for
 the commitment to confirm.
2018-04-25 09:37:26 +02:00
Johan T. Halseth 028d1b7e26 lnd_test: add more relevant info to error messages 2018-04-25 09:37:26 +02:00
Johan T. Halseth ddf62bbeea contractcourt/channel_arbitrator: remove unused transationTrigger 2018-04-25 09:37:25 +02:00
Johan T. Halseth 97977c8a06 rpcserver: add channels waiting for commitment confirmation to pending channels response 2018-04-25 09:37:25 +02:00
Johan T. Halseth 8b670d783a lnrpc: add WaitingCloseChannel to PendingChannelResponse 2018-04-25 09:37:25 +02:00
Johan T. Halseth 5cdc7550b5 htlcswitch: use FetchAllOpenChannels
This commit changes from using FetchAllChannels to FetchAllOpenChannels,
making the check for whether a channel is pending unnecessary.
2018-04-25 09:37:25 +02:00
Johan T. Halseth 0735b8e0b7 channeldb: add method for fetching channels waiting for closing tx
This commit adds a new method FetchWaitingCloseChannels to the database,
used for fetching OpenChannels that have a ChanStatus != Default. These
are channels that are borked, or have had a commitment broadcasted, and
is now waiting for it to confirm.

The fetchChannels method is rewritten to return channels exclusively
based on wheter they are pending or waitingClose.
2018-04-25 09:37:25 +02:00
Johan T. Halseth b2949bd728 contractcourt/channel_arbitrator test: add unit tests
This commit adds MVP unit tests for the following scenarios in the
ChannelArbitrator:
1) A cooperative close is confirmed.
2) A remote force close is confirmed.
3) A local force close is requested and confirmed.
4) A local force close is requested, but a remote force close gets
confirmed.
2018-04-25 09:37:25 +02:00
Johan T. Halseth 84f06959f3 contractcourt/chain_arbitrator: remove CloseChannel method from ChannelArbitrator config 2018-04-25 09:37:25 +02:00
Johan T. Halseth 5f1da5b5f4 contractcourt/channel_arbitrator: remove unused CloseChannel method from config 2018-04-25 09:37:24 +02:00
Johan T. Halseth bd4e717971 peer: don't load channels that have had commitment broadcasted 2018-04-25 09:37:24 +02:00