Skip to content

Commit c6e7b5f

Browse files
committed
Avoid context cancellation race
In the event that a purchase tickets request context from the ticket autobuyer is cancelled due to the changing sdiff window, addresses and outpoints must still be watched. Not doing so eventually leads to an invalid UTXO set as relevant transactions become missed. There is a small chance that this change may cause a hang during process shutdown. A better solution for this is included in a comment.
1 parent 72eefbe commit c6e7b5f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

wallet/createtx.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,9 +1378,11 @@ func (w *Wallet) purchaseTickets(ctx context.Context, op errors.Op,
13781378
// relevant transactions
13791379
var watchOutPoints []wire.OutPoint
13801380
defer func() {
1381-
if ctx.Err() != nil {
1382-
return
1383-
}
1381+
// Cancellation of the request context should not prevent the
1382+
// watching of addresses and outpoints that need to be watched.
1383+
// A better solution would be to watch for the data first,
1384+
// before publishing transactions.
1385+
ctx := context.TODO()
13841386
_, err := w.watchHDAddrs(ctx, false, n)
13851387
if err != nil {
13861388
log.Errorf("Failed to watch for future addresses after ticket "+

0 commit comments

Comments
 (0)