good morning!!!!

Skip to content
Snippets Groups Projects
Commit 51a20870 authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

Minor issues

parent 4dc5855d
Branches
Tags
No related merge requests found
...@@ -14,7 +14,7 @@ h1 { ...@@ -14,7 +14,7 @@ h1 {
</head> </head>
<body> <body>
<h1>Ethereum</h1> <h1>... Ethereum ...</h1>
<!-- ĐΞV --!> <!-- ĐΞV --!>
</body> </body>
</html> </html>
......
function handleMessage(message) {
console.log("[onMessageReceived]: ", message.data)
// TODO move to messaging.js
var data = JSON.parse(message.data)
try {
switch(data.call) {
case "getCoinBase":
postData(data._seed, eth.getCoinBase())
break
case "getIsListening":
postData(data._seed, eth.getIsListening())
break
case "getIsMining":
postData(data._seed, eth.getIsMining())
break
case "getPeerCount":
postData(data._seed, eth.getPeerCount())
break
case "getTxCountAt":
require(1)
postData(data._seed, eth.getTxCountAt(data.args[0]))
break
case "getBlockByNumber":
var block = eth.getBlock(data.args[0])
postData(data._seed, block)
break
case "getBlockByHash":
var block = eth.getBlock(data.args[0])
postData(data._seed, block)
break
case "transact":
require(5)
var tx = eth.transact(data.args[0], data.args[1], data.args[2],data.args[3],data.args[4],data.args[5])
postData(data._seed, tx)
break
case "create":
postData(data._seed, null)
break
case "getStorage":
require(2);
var stateObject = eth.getStateObject(data.args[0])
var storage = stateObject.getStorage(data.args[1])
postData(data._seed, storage)
break
case "getStateKeyVals":
require(1);
var stateObject = eth.getStateObject(data.args[0]).stateKeyVal(true)
postData(data._seed,stateObject)
break
case "getTransactionsFor":
require(1);
var txs = eth.getTransactionsFor(data.args[0], true)
postData(data._seed, txs)
break
case "getBalance":
require(1);
postData(data._seed, eth.getStateObject(data.args[0]).value());
break
case "getKey":
var key = eth.getKey().privateKey;
postData(data._seed, key)
break
case "watch":
require(1)
eth.watch(data.args[0], data.args[1]);
break
case "disconnect":
require(1)
postData(data._seed, null)
break;
case "set":
console.log("'Set' has been depcrecated")
/*
for(var key in data.args) {
if(webview.hasOwnProperty(key)) {
window[key] = data.args[key];
}
}
*/
break;
case "getSecretToAddress":
require(1)
postData(data._seed, eth.secretToAddress(data.args[0]))
break;
case "debug":
console.log(data.args[0]);
break;
}
} catch(e) {
console.log(data.call + ": " + e)
postData(data._seed, null);
}
}
function postData(seed, data) {
webview.experimental.postMessage(JSON.stringify({data: data, _seed: seed}))
}
...@@ -56,6 +56,13 @@ ApplicationWindow { ...@@ -56,6 +56,13 @@ ApplicationWindow {
shortcut: "Ctrl+d" shortcut: "Ctrl+d"
onTriggered: ui.startDebugger() onTriggered: ui.startDebugger()
} }
MenuItem {
text: "Import Tx"
onTriggered: {
txImportDialog.visible = true
}
}
} }
Menu { Menu {
...@@ -98,6 +105,7 @@ ApplicationWindow { ...@@ -98,6 +105,7 @@ ApplicationWindow {
historyView.visible = false historyView.visible = false
newTxView.visible = false newTxView.visible = false
infoView.visible = false infoView.visible = false
pendingTxView.visible = false
view.visible = true view.visible = true
//root.title = "Ethereal - " = view.title //root.title = "Ethereal - " = view.title
} }
...@@ -161,6 +169,17 @@ ApplicationWindow { ...@@ -161,6 +169,17 @@ ApplicationWindow {
} }
} }
} }
Image {
source: "../tx.png"
anchors.horizontalCenter: parent.horizontalCenter
MouseArea {
anchors.fill: parent
onClicked: {
setView(pendingTxView)
}
}
}
} }
} }
...@@ -365,6 +384,28 @@ ApplicationWindow { ...@@ -365,6 +384,28 @@ ApplicationWindow {
} }
} }
Rectangle {
anchors.fill: parent
visible: false
id: pendingTxView
property var title: "Pending Transactions"
property var pendingTxModel: ListModel {
id: pendingTxModel
}
TableView {
id: pendingTxTableView
anchors.fill: parent
TableViewColumn{ role: "value" ; title: "Value" ; width: 100 }
TableViewColumn{ role: "from" ; title: "sender" ; width: 230 }
TableViewColumn{ role: "to" ; title: "Reciever" ; width: 230 }
TableViewColumn{ role: "contract" ; title: "Contract" ; width: 100 }
model: pendingTxModel
}
}
/* /*
signal addPlugin(string name) signal addPlugin(string name)
Component { Component {
...@@ -500,6 +541,36 @@ ApplicationWindow { ...@@ -500,6 +541,36 @@ ApplicationWindow {
} }
} }
Window {
id: txImportDialog
minimumWidth: 270
maximumWidth: 270
maximumHeight: 50
minimumHeight: 50
TextField {
id: txImportField
width: 170
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 10
onAccepted: {
}
}
Button {
anchors.left: txImportField.right
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 5
text: "Import"
onClicked: {
eth.importTx(txImportField.text)
txImportField.visible = false
}
}
Component.onCompleted: {
addrField.focus = true
}
}
Window { Window {
id: popup id: popup
visible: false visible: false
...@@ -719,7 +790,7 @@ ApplicationWindow { ...@@ -719,7 +790,7 @@ ApplicationWindow {
walletValueLabel.text = value walletValueLabel.text = value
} }
function addTx(tx, inout) { function addTx(type, tx, inout) {
var isContract var isContract
if (tx.contract == true){ if (tx.contract == true){
isContract = "Yes" isContract = "Yes"
...@@ -727,13 +798,19 @@ ApplicationWindow { ...@@ -727,13 +798,19 @@ ApplicationWindow {
isContract = "No" isContract = "No"
} }
if(type == "post") {
var address; var address;
if(inout == "recv") { if(inout == "recv") {
address = tx.sender; address = tx.sender;
} else { } else {
address = tx.address; address = tx.address;
} }
txModel.insert(0, {inout: inout, hash: tx.hash, address: address, value: tx.value, contract: isContract}) txModel.insert(0, {inout: inout, hash: tx.hash, address: address, value: tx.value, contract: isContract})
} else if(type == "pre") {
pendingTxModel.insert(0, {hash: tx.hash, to: tx.address, from: tx.sender, value: tx.value, contract: isContract})
}
} }
function addBlock(block, initial) { function addBlock(block, initial) {
......
...@@ -13,6 +13,7 @@ import ( ...@@ -13,6 +13,7 @@ import (
"github.com/ethereum/eth-go/ethdb" "github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethlog" "github.com/ethereum/eth-go/ethlog"
"github.com/ethereum/eth-go/ethminer" "github.com/ethereum/eth-go/ethminer"
"github.com/ethereum/eth-go/ethpipe"
"github.com/ethereum/eth-go/ethpub" "github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact" "github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethutil"
...@@ -236,11 +237,9 @@ func (gui *Gui) loadAddressBook() { ...@@ -236,11 +237,9 @@ func (gui *Gui) loadAddressBook() {
} }
} }
func (gui *Gui) readPreviousTransactions() { func (gui *Gui) insertTransaction(window string, tx *ethchain.Transaction) {
it := gui.txDb.Db().NewIterator(nil, nil) nameReg := ethpipe.New(gui.eth).World().Config().Get("NameReg")
addr := gui.address() addr := gui.address()
for it.Next() {
tx := ethchain.NewTransactionFromBytes(it.Value())
var inout string var inout string
if bytes.Compare(tx.Sender(), addr) == 0 { if bytes.Compare(tx.Sender(), addr) == 0 {
...@@ -249,7 +248,43 @@ func (gui *Gui) readPreviousTransactions() { ...@@ -249,7 +248,43 @@ func (gui *Gui) readPreviousTransactions() {
inout = "recv" inout = "recv"
} }
gui.win.Root().Call("addTx", ethpub.NewPTx(tx), inout) 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 {
r = ethutil.Bytes2Hex(tx.Recipient)
}
}
ptx.Sender = s
ptx.Address = r
gui.win.Root().Call("addTx", window, ptx, 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() it.Release()
...@@ -322,24 +357,26 @@ func (gui *Gui) update() { ...@@ -322,24 +357,26 @@ func (gui *Gui) update() {
object := state.GetAccount(gui.address()) object := state.GetAccount(gui.address())
if bytes.Compare(tx.Sender(), gui.address()) == 0 { 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) unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
} else if bytes.Compare(tx.Recipient, gui.address()) == 0 { } 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) unconfirmedFunds.Add(unconfirmedFunds, tx.Value)
} }
gui.setWalletValue(object.Balance, unconfirmedFunds) gui.setWalletValue(object.Balance, unconfirmedFunds)
gui.insertTransaction("pre", tx)
} else { } else {
object := state.GetAccount(gui.address()) object := state.GetAccount(gui.address())
if bytes.Compare(tx.Sender(), gui.address()) == 0 { if bytes.Compare(tx.Sender(), gui.address()) == 0 {
object.SubAmount(tx.Value) 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 { } else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
object.AddAmount(tx.Value) 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) gui.setWalletValue(object.Balance, nil)
...@@ -422,6 +459,11 @@ func (gui *Gui) Create(recipient, value, gas, gasPrice, data string) (*ethpub.PR ...@@ -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) 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) { func (gui *Gui) SetCustomIdentifier(customIdentifier string) {
gui.clientIdentity.SetCustomIdentifier(customIdentifier) gui.clientIdentity.SetCustomIdentifier(customIdentifier)
gui.config.Save("id", customIdentifier) gui.config.Save("id", customIdentifier)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment