sweepbatcher: fix spawning condition "unattached" spend notifiers

Previously, when handling a sweep we assumed that if a sweep status
was completed, the parent batch was also finished. However, since the
batch confirmation status depends on three on-chain confirmations, it
is possible that a spend notifier was started for a sweep of an active
batch. The notifier would fetch the parent batch from the database, but
because we incorrectly assumed that  the parent was confirmed (when it
was not), the DB call would fail with a 'no rows returned' error.
This failure would cause the sweep to fail and the sweep batcher to
stop, resulting in a permanent failure state.
This commit is contained in:
Andras Banki-Horvath 2024-07-11 11:23:02 +02:00
parent 2024791e15
commit 6a4ef3683a
No known key found for this signature in database
GPG key ID: 80E5375C094198D8
4 changed files with 21 additions and 22 deletions

View file

@ -102,10 +102,6 @@ JOIN
sweeps ON sweep_batches.id = sweeps.batch_id
WHERE
sweeps.swap_hash = $1
AND
sweeps.completed = TRUE
AND
sweep_batches.confirmed = TRUE
`
func (q *Queries) GetParentBatch(ctx context.Context, swapHash []byte) (SweepBatch, error) {

View file

@ -73,11 +73,7 @@ FROM
JOIN
sweeps ON sweep_batches.id = sweeps.batch_id
WHERE
sweeps.swap_hash = $1
AND
sweeps.completed = TRUE
AND
sweep_batches.confirmed = TRUE;
sweeps.swap_hash = $1;
-- name: GetBatchSweptAmount :one
SELECT