@@ -408,7 +408,8 @@ func (gui *Gui) update() {
408408 eth.ChainSyncEvent {},
409409 eth.PeerListEvent {},
410410 ethchain.NewBlockEvent {},
411- ethchain.TxEvent {},
411+ ethchain.TxPreEvent {},
412+ ethchain.TxPostEvent {},
412413 ethminer.Event {},
413414 )
414415
@@ -430,40 +431,38 @@ func (gui *Gui) update() {
430431 gui .setWalletValue (gui .eth .StateManager ().CurrentState ().GetAccount (gui .address ()).Balance (), nil )
431432 }
432433
433- case ethchain.TxEvent :
434+ case ethchain.TxPreEvent :
434435 tx := ev .Tx
435- if ev .Type == ethchain .TxPre {
436- object := state .GetAccount (gui .address ())
436+ object := state .GetAccount (gui .address ())
437437
438- if bytes .Compare (tx .Sender (), gui .address ()) == 0 {
439- unconfirmedFunds .Sub (unconfirmedFunds , tx .Value )
440- } else if bytes .Compare (tx .Recipient , gui .address ()) == 0 {
441- unconfirmedFunds .Add (unconfirmedFunds , tx .Value )
442- }
443-
444- gui .setWalletValue (object .Balance (), unconfirmedFunds )
445-
446- gui .insertTransaction ("pre" , tx )
438+ if bytes .Compare (tx .Sender (), gui .address ()) == 0 {
439+ unconfirmedFunds .Sub (unconfirmedFunds , tx .Value )
440+ } else if bytes .Compare (tx .Recipient , gui .address ()) == 0 {
441+ unconfirmedFunds .Add (unconfirmedFunds , tx .Value )
442+ }
447443
448- } else if ev .Type == ethchain .TxPost {
449- object := state .GetAccount (gui .address ())
450- if bytes .Compare (tx .Sender (), gui .address ()) == 0 {
451- object .SubAmount (tx .Value )
444+ gui .setWalletValue (object .Balance (), unconfirmedFunds )
445+ gui .insertTransaction ("pre" , tx )
452446
453- //gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "send")
454- gui .txDb .Put (tx .Hash (), tx .RlpEncode ())
455- } else if bytes .Compare (tx .Recipient , gui .address ()) == 0 {
456- object .AddAmount (tx .Value )
447+ case ethchain.TxPostEvent :
448+ tx := ev .Tx
449+ object := state .GetAccount (gui .address ())
457450
458- //gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "recv")
459- gui .txDb .Put (tx .Hash (), tx .RlpEncode ())
460- }
451+ if bytes .Compare (tx .Sender (), gui .address ()) == 0 {
452+ object .SubAmount (tx .Value )
461453
462- gui .setWalletValue (object .Balance (), nil )
454+ //gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "send")
455+ gui .txDb .Put (tx .Hash (), tx .RlpEncode ())
456+ } else if bytes .Compare (tx .Recipient , gui .address ()) == 0 {
457+ object .AddAmount (tx .Value )
463458
464- state .UpdateStateObject (object )
459+ //gui.getObjectByName("transactionView").Call("addTx", ethpipe.NewJSTx(tx), "recv")
460+ gui .txDb .Put (tx .Hash (), tx .RlpEncode ())
465461 }
466462
463+ gui .setWalletValue (object .Balance (), nil )
464+ state .UpdateStateObject (object )
465+
467466 // case object:
468467 // gui.loadAddressBook()
469468
0 commit comments