From da7828f336cb323c78810d2963f8353787c03077 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Wed, 30 Apr 2014 17:13:12 +0200
Subject: [PATCH] Fixed tx nonce

---
 ethereal/ui/gui.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 8ec09459b..c821fa824 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -146,17 +146,20 @@ func (ui *Gui) update() {
 	account := ui.eth.StateManager().GetAddrState(ui.addr).Object
 	unconfirmedFunds := new(big.Int)
 	ui.win.Root().Call("setWalletValue", fmt.Sprintf("%v", ethutil.CurrencyToString(account.Amount)))
+
+	addrState := ui.eth.StateManager().GetAddrState(ui.addr)
+
 	for {
 		select {
 		case txMsg := <-txChan:
 			tx := txMsg.Tx
 
 			if txMsg.Type == ethchain.TxPre {
-				if bytes.Compare(tx.Sender(), ui.addr) == 0 {
+				if bytes.Compare(tx.Sender(), ui.addr) == 0 && addrState.Nonce <= tx.Nonce {
 					ui.win.Root().Call("addTx", NewQTx(tx))
 					ui.txDb.Put(tx.Hash(), tx.RlpEncode())
 
-					ui.eth.StateManager().GetAddrState(ui.addr).Nonce += 1
+					addrState.Nonce += 1
 					unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
 				} else if bytes.Compare(tx.Recipient, ui.addr) == 0 {
 					ui.win.Root().Call("addTx", NewQTx(tx))
-- 
GitLab