aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/gui.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-10 21:57:42 +0800
committerobscuren <geffobscura@gmail.com>2014-08-10 21:57:42 +0800
commit51a2087081ec0c8a9d0d739c344929c8494e13b6 (patch)
tree25c81e5b0d75d54a904da33036cda29c36f1f8a8 /ethereal/gui.go
parent4dc5855dfe08bd427e931d03f2c7ae9105688f67 (diff)
downloadgo-tangerine-51a2087081ec0c8a9d0d739c344929c8494e13b6.tar.gz
go-tangerine-51a2087081ec0c8a9d0d739c344929c8494e13b6.tar.zst
go-tangerine-51a2087081ec0c8a9d0d739c344929c8494e13b6.zip
Minor issues
Diffstat (limited to 'ethereal/gui.go')
-rw-r--r--ethereal/gui.go72
1 files changed, 57 insertions, 15 deletions
diff --git a/ethereal/gui.go b/ethereal/gui.go
index 61f7b1099..36e147ba9 100644
--- a/ethereal/gui.go
+++ b/ethereal/gui.go
@@ -13,6 +13,7 @@ import (
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethminer"
+ "github.com/ethereum/eth-go/ethpipe"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
@@ -236,20 +237,54 @@ func (gui *Gui) loadAddressBook() {
}
}
-func (gui *Gui) readPreviousTransactions() {
- it := gui.txDb.Db().NewIterator(nil, nil)
+func (gui *Gui) insertTransaction(window string, tx *ethchain.Transaction) {
+ nameReg := ethpipe.New(gui.eth).World().Config().Get("NameReg")
addr := gui.address()
- for it.Next() {
- tx := ethchain.NewTransactionFromBytes(it.Value())
- var inout string
- if bytes.Compare(tx.Sender(), addr) == 0 {
- inout = "send"
+ var inout string
+ if bytes.Compare(tx.Sender(), addr) == 0 {
+ inout = "send"
+ } else {
+ inout = "recv"
+ }
+
+ var (
+ ptx = ethpub.NewPTx(tx)
+ send = nameReg.Storage(tx.Sender())
+ rec = nameReg.Storage(tx.Recipient)
+ s, r string
+ )
+
+ if tx.CreatesContract() {
+ rec = nameReg.Storage(tx.CreationAddress())
+ }
+
+ if send.Len() != 0 {
+ s = strings.Trim(send.Str(), "\x00")
+ } else {
+ s = ethutil.Bytes2Hex(tx.Sender())
+ }
+ if rec.Len() != 0 {
+ r = strings.Trim(rec.Str(), "\x00")
+ } else {
+ if tx.CreatesContract() {
+ r = ethutil.Bytes2Hex(tx.CreationAddress())
} else {
- inout = "recv"
+ r = ethutil.Bytes2Hex(tx.Recipient)
}
+ }
+ ptx.Sender = s
+ ptx.Address = r
+
+ gui.win.Root().Call("addTx", window, ptx, inout)
+}
- gui.win.Root().Call("addTx", ethpub.NewPTx(tx), inout)
+func (gui *Gui) readPreviousTransactions() {
+ it := gui.txDb.Db().NewIterator(nil, nil)
+ for it.Next() {
+ tx := ethchain.NewTransactionFromBytes(it.Value())
+
+ gui.insertTransaction("post", tx)
}
it.Release()
@@ -322,24 +357,26 @@ func (gui *Gui) update() {
object := state.GetAccount(gui.address())
if bytes.Compare(tx.Sender(), gui.address()) == 0 {
- gui.win.Root().Call("addTx", ethpub.NewPTx(tx), "send")
- gui.txDb.Put(tx.Hash(), tx.RlpEncode())
-
unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
} else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
- gui.win.Root().Call("addTx", ethpub.NewPTx(tx), "recv")
- gui.txDb.Put(tx.Hash(), tx.RlpEncode())
-
unconfirmedFunds.Add(unconfirmedFunds, tx.Value)
}
gui.setWalletValue(object.Balance, unconfirmedFunds)
+
+ gui.insertTransaction("pre", tx)
} else {
object := state.GetAccount(gui.address())
if bytes.Compare(tx.Sender(), gui.address()) == 0 {
object.SubAmount(tx.Value)
+
+ gui.win.Root().Call("addTx", "post", ethpub.NewPTx(tx), "send")
+ gui.txDb.Put(tx.Hash(), tx.RlpEncode())
} else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
object.AddAmount(tx.Value)
+
+ gui.win.Root().Call("addTx", "post", ethpub.NewPTx(tx), "recv")
+ gui.txDb.Put(tx.Hash(), tx.RlpEncode())
}
gui.setWalletValue(object.Balance, nil)
@@ -422,6 +459,11 @@ func (gui *Gui) Create(recipient, value, gas, gasPrice, data string) (*ethpub.PR
return gui.pub.Transact(gui.privateKey(), recipient, value, gas, gasPrice, data)
}
+func (self *Gui) ImportTx(rlpTx string) {
+ tx := ethchain.NewTransactionFromBytes(ethutil.Hex2Bytes(rlpTx))
+ self.eth.TxPool().QueueTransaction(tx)
+}
+
func (gui *Gui) SetCustomIdentifier(customIdentifier string) {
gui.clientIdentity.SetCustomIdentifier(customIdentifier)
gui.config.Save("id", customIdentifier)