wallet: only remove conflicting unmined transactions

In this commit, we fix a bug introduced in an earlier commit. Before
this commit, we would *always* remove an unmined transaction if it
failed to be accepted by the network upon restart. Instead, we should
only remove transaction that are actually due to us trying to spend an
output that’s already spent, or an orphan transaction.
This commit is contained in:
Olaoluwa Osuntokun 2018-03-10 16:02:06 -08:00
parent 1d50b92bdc
commit 0dcd36bf59

View file

@ -11,6 +11,7 @@ import (
"errors"
"fmt"
"sort"
"strings"
"sync"
"time"
@ -2115,6 +2116,21 @@ func (w *Wallet) resendUnminedTxs() {
log.Debugf("Could not resend transaction %v: %v",
tx.TxHash(), err)
// We'll only stop broadcasting transactions if we
// detect that the output has already been fully spent,
// is an orphan, or is conflicting with another
// transaction.
switch {
case strings.Contains(err.Error(), "spent"):
case strings.Contains(err.Error(), "orphan"):
case strings.Contains(err.Error(), "conflict"):
default:
continue
}
// As the transaction was rejected, we'll attempt to
// remove the unmined transaction all together.
// Otherwise, we'll keep attempting to rebroadcast