From 0dcd36bf593ae10ff5fa146f4819f1d3c616e55f Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 10 Mar 2018 16:02:06 -0800 Subject: [PATCH] wallet: only remove conflicting unmined transactions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- wallet/wallet.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wallet/wallet.go b/wallet/wallet.go index 0c762b8..1e2c03f 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -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