Commit 5f28013f authored by obscuren's avatar obscuren

Merge branch 'develop'

parents f0f20500 65c5a20e
...@@ -27,20 +27,22 @@ General command line options ...@@ -27,20 +27,22 @@ General command line options
``` ```
Shared between ethereum and ethereal Shared between ethereum and ethereal
-m Start mining blocks -id Set the custom identifier of the client (shows up on other clients)
-genaddr Generates a new address and private key (destructive action) -port Port on which the server will accept incomming connections
-p Port on which the server will accept incomming connections
-upnp Enable UPnP -upnp Enable UPnP
-x Desired amount of peers -maxpeer Desired amount of peers
-r Start JSON RPC -rpc Start JSON RPC
-dir Data directory used to store configs and databases -dir Data directory used to store configs and databases
-import Import a private key -import Import a private key
-genaddr Generates a new address and private key (destructive action)
-h This -h This
Ethereum only Ethereum only
ethereum [options] [filename] ethereum [options] [filename]
-js Start the JavaScript REPL -js Start the JavaScript REPL
filename Load the given file and interpret as JavaScript filename Load the given file and interpret as JavaScript
-m Start mining blocks
Etheral only Etheral only
-asset_path absolute path to GUI assets directory -asset_path absolute path to GUI assets directory
......
...@@ -8,7 +8,7 @@ import Ethereum 1.0 ...@@ -8,7 +8,7 @@ import Ethereum 1.0
ApplicationWindow { ApplicationWindow {
visible: false visible: false
title: "IceCream" title: "IceCREAM"
minimumWidth: 1280 minimumWidth: 1280
minimumHeight: 900 minimumHeight: 900
width: 1290 width: 1290
...@@ -224,8 +224,8 @@ ApplicationWindow { ...@@ -224,8 +224,8 @@ ApplicationWindow {
} }
function setInstruction(num) { function setInstruction(num) {
asmTableView.selection.clear() //asmTableView.selection.clear()
asmTableView.selection.select(num) //asmTableView.selection.select(num)
} }
function setMem(mem) { function setMem(mem) {
...@@ -255,6 +255,10 @@ ApplicationWindow { ...@@ -255,6 +255,10 @@ ApplicationWindow {
} }
function setLog(msg) { function setLog(msg) {
logModel.append({message: msg}) logModel.insert(0, {message: msg})
}
function clearLog() {
logModel.clear()
} }
} }
...@@ -8,1004 +8,905 @@ import Ethereum 1.0 ...@@ -8,1004 +8,905 @@ import Ethereum 1.0
ApplicationWindow { ApplicationWindow {
id: root id: root
width: 900 property alias miningButtonText: miningButton.text
height: 600
minimumHeight: 300 width: 900
height: 600
title: "Ethereal" minimumHeight: 300
MenuBar { title: "Ethereal"
Menu {
title: "File" MenuBar {
MenuItem { Menu {
text: "Import App" title: "File"
shortcut: "Ctrl+o" MenuItem {
onTriggered: openAppDialog.open() text: "Import App"
} shortcut: "Ctrl+o"
} onTriggered: openAppDialog.open()
}
Menu { }
title: "Tools"
MenuItem { Menu {
text: "Muted" MenuItem {
shortcut: "Ctrl+e" text: "Debugger"
onTriggered: ui.muted("") shortcut: "Ctrl+d"
} onTriggered: ui.startDebugger()
}
MenuItem { }
text: "Debugger"
shortcut: "Ctrl+d" Menu {
onTriggered: ui.startDebugger() title: "Network"
} MenuItem {
} text: "Add Peer"
shortcut: "Ctrl+p"
Menu { onTriggered: {
title: "Network" addPeerWin.visible = true
MenuItem { }
text: "Add Peer" }
shortcut: "Ctrl+p" }
onTriggered: {
addPeerWin.visible = true Menu {
} title: "Help"
} MenuItem {
text: "About"
MenuItem { onTriggered: {
text: "Start" aboutWin.visible = true
onTriggered: ui.connect() }
} }
} }
Menu { }
title: "Help"
MenuItem {
text: "About" property var blockModel: ListModel {
onTriggered: { id: blockModel
aboutWin.visible = true }
}
} function setView(view) {
} networkView.visible = false
historyView.visible = false
} newTxView.visible = false
infoView.visible = false
view.visible = true
property var blockModel: ListModel { //root.title = "Ethereal - " = view.title
id: blockModel }
}
SplitView {
function setView(view) { anchors.fill: parent
networkView.visible = false resizing: false
historyView.visible = false
newTxView.visible = false Rectangle {
infoView.visible = false id: menu
view.visible = true Layout.minimumWidth: 80
//root.title = "Ethereal - " = view.title Layout.maximumWidth: 80
} anchors.bottom: parent.bottom
anchors.top: parent.top
SplitView { //color: "#D9DDE7"
anchors.fill: parent color: "#252525"
resizing: false
ColumnLayout {
Rectangle { y: 50
id: menu anchors.left: parent.left
Layout.minimumWidth: 80 anchors.right: parent.right
Layout.maximumWidth: 80 height: 200
anchors.bottom: parent.bottom Image {
anchors.top: parent.top source: ui.assetPath("tx.png")
//color: "#D9DDE7" anchors.horizontalCenter: parent.horizontalCenter
color: "#252525" MouseArea {
anchors.fill: parent
ColumnLayout { onClicked: {
y: 50 setView(historyView)
anchors.left: parent.left }
anchors.right: parent.right }
height: 200 }
Image { Image {
source: ui.assetPath("tx.png") source: ui.assetPath("new.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
setView(historyView) setView(newTxView)
} }
} }
} }
Image { Image {
source: ui.assetPath("new.png") source: ui.assetPath("net.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
setView(newTxView) setView(networkView)
} }
} }
} }
Image {
source: ui.assetPath("net.png") Image {
anchors.horizontalCenter: parent.horizontalCenter source: ui.assetPath("heart.png")
MouseArea { anchors.horizontalCenter: parent.horizontalCenter
anchors.fill: parent MouseArea {
onClicked: { anchors.fill: parent
setView(networkView) onClicked: {
} setView(infoView)
} }
} }
}
Image { }
source: ui.assetPath("heart.png") }
anchors.horizontalCenter: parent.horizontalCenter
MouseArea { Rectangle {
anchors.fill: parent id: mainView
onClicked: { color: "#00000000"
setView(infoView) anchors.right: parent.right
} anchors.left: menu.right
} anchors.bottom: parent.bottom
} anchors.top: parent.top
}
} property var txModel: ListModel {
id: txModel
Rectangle { }
id: mainView
color: "#00000000" Rectangle {
anchors.right: parent.right id: historyView
anchors.left: menu.right anchors.fill: parent
anchors.bottom: parent.bottom
anchors.top: parent.top property var title: "Transactions"
TableView {
property var txModel: ListModel { id: txTableView
id: txModel anchors.fill: parent
} TableViewColumn{ role: "inout" ; title: "" ; width: 40 }
TableViewColumn{ role: "value" ; title: "Value" ; width: 100 }
Rectangle { TableViewColumn{ role: "address" ; title: "Address" ; width: 430 }
id: historyView TableViewColumn{ role: "contract" ; title: "Contract" ; width: 100 }
anchors.fill: parent
model: txModel
property var title: "Transactions" }
TableView { }
id: txTableView
anchors.fill: parent Rectangle {
TableViewColumn{ role: "inout" ; title: "" ; width: 40 } id: newTxView
TableViewColumn{ role: "value" ; title: "Value" ; width: 100 } property var title: "New transaction"
TableViewColumn{ role: "address" ; title: "Address" ; width: 430 } visible: false
TableViewColumn{ role: "contract" ; title: "Contract" ; width: 100 } anchors.fill: parent
color: "#00000000"
model: txModel /*
} TabView{
} anchors.fill: parent
anchors.rightMargin: 5
Rectangle { anchors.leftMargin: 5
id: newTxView anchors.topMargin: 5
property var title: "New transaction" anchors.bottomMargin: 5
visible: false id: newTransactionTab
anchors.fill: parent Component.onCompleted:{
color: "#00000000" addTab("Simple send", newTransaction)
TabView{ addTab("Contracts", newContract)
anchors.fill: parent }
anchors.rightMargin: 5 }
anchors.leftMargin: 5 */
anchors.topMargin: 5 Component.onCompleted: {
anchors.bottomMargin: 5 newContract.createObject(newTxView)
id: newTransactionTab }
Component.onCompleted:{ }
addTab("Simple send", newTransaction)
addTab("Contracts", newContract) Rectangle {
} id: networkView
} property var title: "Network"
} visible: false
anchors.fill: parent
Rectangle {
id: networkView TableView {
property var title: "Network" id: blockTable
visible: false width: parent.width
anchors.fill: parent anchors.top: parent.top
anchors.bottom: parent.bottom
TableView { TableViewColumn{ role: "number" ; title: "#" ; width: 100 }
id: blockTable TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 }
width: parent.width TableViewColumn{ role: "txAmount" ; title: "Tx amount" ; width: 100 }
anchors.top: parent.top
anchors.bottom: logView.top model: blockModel
TableViewColumn{ role: "number" ; title: "#" ; width: 100 }
TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 } onDoubleClicked: {
TableViewColumn{ role: "txAmount" ; title: "Tx amount" ; width: 100 } popup.visible = true
popup.setDetails(blockModel.get(row))
model: blockModel }
}
onDoubleClicked: {
popup.visible = true }
popup.setDetails(blockModel.get(row))
} Rectangle {
} id: infoView
property var title: "Information"
property var logModel: ListModel { visible: false
id: logModel color: "#00000000"
} anchors.fill: parent
TableView { Label {
id: logView id: addressLabel
width: parent.width text: "Address"
height: 150 anchors {
anchors.bottom: parent.bottom margins: 5
TableViewColumn{ role: "description" ; title: "log" } top: parent.top
left: parent.left
model: logModel }
} }
} TextField {
anchors {
Rectangle { margins: 5
id: infoView left: addressLabel.right
property var title: "Information" top: parent.top
visible: false }
color: "#00000000" text: pub.getKey().address
anchors.fill: parent width: 500
}
Label {
id: addressLabel
text: "Address" property var addressModel: ListModel {
anchors { id: addressModel
margins: 5 }
top: parent.top TableView {
left: parent.left id: addressView
} width: parent.width
} height: 200
TextField { anchors.bottom: logView.top
anchors { TableViewColumn{ role: "name"; title: "name" }
margins: 5 TableViewColumn{ role: "address"; title: "address"; width: 300}
left: addressLabel.right
top: parent.top model: addressModel
} }
text: pub.getKey().address
width: 500
} property var logModel: ListModel {
} id: logModel
}
/* TableView {
signal addPlugin(string name) id: logView
Component { width: parent.width
id: pluginWindow height: 200
Rectangle { anchors.bottom: parent.bottom
anchors.fill: parent TableViewColumn{ role: "description" ; title: "log" }
Label {
id: pluginTitle model: logModel
anchors.centerIn: parent }
text: "Hello world" }
}
Component.onCompleted: setView(this) /*
} signal addPlugin(string name)
} Component {
id: pluginWindow
onAddPlugin: { Rectangle {
var pluginWin = pluginWindow.createObject(mainView) anchors.fill: parent
console.log(pluginWin) Label {
pluginWin.pluginTitle.text = "Test" id: pluginTitle
} anchors.centerIn: parent
*/ text: "Hello world"
} }
} Component.onCompleted: setView(this)
}
FileDialog { }
id: openAppDialog
title: "Open QML Application" onAddPlugin: {
onAccepted: { var pluginWin = pluginWindow.createObject(mainView)
//ui.open(openAppDialog.fileUrl.toString()) console.log(pluginWin)
//ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html"))) pluginWin.pluginTitle.text = "Test"
ui.openHtml(openAppDialog.fileUrl.toString()) }
} */
} }
}
statusBar: StatusBar {
RowLayout { FileDialog {
anchors.fill: parent id: openAppDialog
title: "Open QML Application"
Button { onAccepted: {
property var enabled: true //ui.open(openAppDialog.fileUrl.toString())
id: debuggerWindow //ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html")))
onClicked: { ui.openHtml(openAppDialog.fileUrl.toString())
ui.startDebugger() }
} }
text: "Debugger"
} statusBar: StatusBar {
height: 30
Button { RowLayout {
id: importAppButton Button {
anchors.left: debuggerWindow.right id: miningButton
anchors.leftMargin: 5 onClicked: {
onClicked: openAppDialog.open() eth.toggleMining()
text: "Import App" }
} text: "Start Mining"
}
Label {
anchors.left: importAppButton.right Button {
anchors.leftMargin: 5 property var enabled: true
id: walletValueLabel id: debuggerWindow
} onClicked: {
ui.startDebugger()
Label { }
anchors.right: peerImage.left text: "Debugger"
anchors.rightMargin: 5 }
id: peerLabel
font.pixelSize: 8 Button {
text: "0 / 0" id: importAppButton
} anchors.left: debuggerWindow.right
Image { anchors.leftMargin: 5
id: peerImage onClicked: openAppDialog.open()
anchors.right: parent.right text: "Import App"
width: 10; height: 10 }
source: ui.assetPath("network.png")
} Label {
} anchors.left: importAppButton.right
} anchors.leftMargin: 5
id: walletValueLabel
Window { }
id: popup }
visible: false
property var block Label {
width: root.width y: 7
height: 240 anchors.right: peerImage.left
Component{ anchors.rightMargin: 5
id: blockDetailsDelegate id: peerLabel
Rectangle { font.pixelSize: 8
color: "#252525" text: "0 / 0"
width: popup.width }
height: 200 Image {
Column { y: 7
anchors.leftMargin: 10 id: peerImage
anchors.topMargin: 5 anchors.right: parent.right
anchors.top: parent.top width: 10; height: 10
anchors.left: parent.left source: ui.assetPath("network.png")
Text { text: '<h3>Block details</h3>'; color: "#F2F2F2"} }
Text { text: '<b>Block number:</b> ' + number; color: "#F2F2F2"} }
Text { text: '<b>Hash:</b> ' + hash; color: "#F2F2F2"}
Text { text: '<b>Block found at:</b> ' + prettyTime; color: "#F2F2F2"} Window {
} id: popup
} visible: false
} property var block
ListView { width: root.width
model: singleBlock height: 300
delegate: blockDetailsDelegate Component{
anchors.top: parent.top id: blockDetailsDelegate
height: 70 Rectangle {
anchors.leftMargin: 20 color: "#252525"
id: listViewThing width: popup.width
Layout.maximumHeight: 40 height: 150
} Column {
TableView { anchors.leftMargin: 10
id: txView anchors.topMargin: 5
anchors.top: listViewThing.bottom anchors.top: parent.top
anchors.topMargin: 50 anchors.left: parent.left
width: parent.width Text { text: '<h3>Block details</h3>'; color: "#F2F2F2"}
Text { text: '<b>Block number:</b> ' + number; color: "#F2F2F2"}
TableViewColumn{width: 90; role: "value" ; title: "Value" } Text { text: '<b>Hash:</b> ' + hash; color: "#F2F2F2"}
TableViewColumn{width: 200; role: "hash" ; title: "Hash" } Text { text: '<b>Coinbase:</b> ' + coinbase; color: "#F2F2F2"}
TableViewColumn{width: 200; role: "sender" ; title: "Sender" } Text { text: '<b>Block found at:</b> ' + prettyTime; color: "#F2F2F2"}
TableViewColumn{width: 200;role: "address" ; title: "Receiver" } }
TableViewColumn{width: 60; role: "gas" ; title: "Gas" } }
TableViewColumn{width: 60; role: "gasPrice" ; title: "Gas Price" } }
TableViewColumn{width: 60; role: "isContract" ; title: "Contract" } ListView {
model: singleBlock
model: transactionModel delegate: blockDetailsDelegate
onClicked: { anchors.top: parent.top
var tx = transactionModel.get(row) height: 100
if(tx.data) { anchors.leftMargin: 20
popup.showContractData(tx) id: listViewThing
}else{ Layout.maximumHeight: 40
popup.height = 230 }
} TableView {
} id: txView
} anchors.top: listViewThing.bottom
anchors.topMargin: 50
function showContractData(tx) { width: parent.width
txDetailsDebugButton.tx = tx
if(tx.createsContract) { TableViewColumn{width: 90; role: "value" ; title: "Value" }
contractData.text = tx.data TableViewColumn{width: 200; role: "hash" ; title: "Hash" }
contractLabel.text = "<h4> Transaction created contract " + tx.address + "</h4>" TableViewColumn{width: 200; role: "sender" ; title: "Sender" }
}else{ TableViewColumn{width: 200;role: "address" ; title: "Receiver" }
contractLabel.text = "<h4> Transaction ran contract " + tx.address + "</h4>" TableViewColumn{width: 60; role: "gas" ; title: "Gas" }
contractData.text = tx.rawData TableViewColumn{width: 60; role: "gasPrice" ; title: "Gas Price" }
} TableViewColumn{width: 60; role: "isContract" ; title: "Contract" }
popup.height = 400
} model: transactionModel
onClicked: {
Rectangle { var tx = transactionModel.get(row)
id: txDetails if(tx.data) {
width: popup.width popup.showContractData(tx)
height: 300 }else{
anchors.left: listViewThing.left popup.height = 440
anchors.top: txView.bottom }
Label { }
text: "<h4>Contract data</h4>" }
anchors.top: parent.top
anchors.left: parent.left function showContractData(tx) {
id: contractLabel txDetailsDebugButton.tx = tx
anchors.leftMargin: 10 if(tx.createsContract) {
} contractData.text = tx.data
Button { contractLabel.text = "<h4> Transaction created contract " + tx.address + "</h4>"
property var tx }else{
id: txDetailsDebugButton contractLabel.text = "<h4> Transaction ran contract " + tx.address + "</h4>"
anchors.right: parent.right contractData.text = tx.rawData
anchors.rightMargin: 10 }
anchors.top: parent.top popup.height = 540
anchors.topMargin: 10 }
text: "Debug contract"
onClicked: { Rectangle {
if(tx.createsContract){ id: txDetails
ui.startDbWithCode(tx.rawData) width: popup.width
}else { height: 300
ui.startDbWithContractAndData(tx.address, tx.rawData) anchors.left: listViewThing.left
} anchors.top: txView.bottom
} Label {
} text: "<h4>Contract data</h4>"
TextArea { anchors.top: parent.top
id: contractData anchors.left: parent.left
text: "Contract" id: contractLabel
anchors.top: contractLabel.bottom anchors.leftMargin: 10
anchors.left: parent.left }
anchors.bottom: popup.bottom Button {
wrapMode: Text.Wrap property var tx
width: parent.width - 30 id: txDetailsDebugButton
height: 80 anchors.right: parent.right
anchors.leftMargin: 10 anchors.rightMargin: 10
} anchors.top: parent.top
} anchors.topMargin: 10
property var transactionModel: ListModel { text: "Debug contract"
id: transactionModel onClicked: {
} if(tx.createsContract){
property var singleBlock: ListModel { ui.startDbWithCode(tx.rawData)
id: singleBlock }else {
} ui.startDbWithContractAndData(tx.address, tx.rawData)
function setDetails(block){ }
singleBlock.set(0,block) }
popup.height = 230 }
transactionModel.clear() TextArea {
if(block.txs != undefined){ id: contractData
for(var i = 0; i < block.txs.count; ++i) { text: "Contract"
transactionModel.insert(0, block.txs.get(i)) anchors.top: contractLabel.bottom
} anchors.left: parent.left
if(block.txs.get(0).data){ anchors.bottom: popup.bottom
popup.showContractData(block.txs.get(0)) wrapMode: Text.Wrap
} width: parent.width - 30
} height: 80
txView.forceActiveFocus() anchors.leftMargin: 10
} }
} }
property var transactionModel: ListModel {
Window { id: transactionModel
id: addPeerWin }
visible: false property var singleBlock: ListModel {
minimumWidth: 230 id: singleBlock
maximumWidth: 230 }
maximumHeight: 50 function setDetails(block){
minimumHeight: 50 singleBlock.set(0,block)
popup.height = 300
TextField { transactionModel.clear()
id: addrField if(block.txs != undefined){
anchors.verticalCenter: parent.verticalCenter for(var i = 0; i < block.txs.count; ++i) {
anchors.left: parent.left transactionModel.insert(0, block.txs.get(i))
anchors.leftMargin: 10 }
placeholderText: "address:port" if(block.txs.get(0).data){
onAccepted: { popup.showContractData(block.txs.get(0))
ui.connectToPeer(addrField.text) }
addPeerWin.visible = false }
} txView.forceActiveFocus()
} }
Button { }
anchors.left: addrField.right
anchors.verticalCenter: parent.verticalCenter Window {
anchors.leftMargin: 5 id: addPeerWin
text: "Add" visible: false
onClicked: { minimumWidth: 230
ui.connectToPeer(addrField.text) maximumWidth: 230
addPeerWin.visible = false maximumHeight: 50
} minimumHeight: 50
}
Component.onCompleted: { TextField {
addrField.focus = true id: addrField
} anchors.verticalCenter: parent.verticalCenter
} anchors.left: parent.left
anchors.leftMargin: 10
Window { placeholderText: "address:port"
id: aboutWin onAccepted: {
visible: false ui.connectToPeer(addrField.text)
title: "About" addPeerWin.visible = false
minimumWidth: 350 }
maximumWidth: 350 }
maximumHeight: 200 Button {
minimumHeight: 200 anchors.left: addrField.right
anchors.verticalCenter: parent.verticalCenter
Image { anchors.leftMargin: 5
id: aboutIcon text: "Add"
height: 150 onClicked: {
width: 150 ui.connectToPeer(addrField.text)
fillMode: Image.PreserveAspectFit addPeerWin.visible = false
smooth: true }
source: ui.assetPath("facet.png") }
x: 10 Component.onCompleted: {
y: 10 addrField.focus = true
} }
}
Text {
anchors.left: aboutIcon.right Window {
anchors.leftMargin: 10 id: aboutWin
font.pointSize: 12 visible: false
text: "<h2>Ethereal</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Maran Hidskes<br>" title: "About"
} minimumWidth: 350
maximumWidth: 350
} maximumHeight: 200
minimumHeight: 200
ApplicationWindow {
id: debugWindow Image {
visible: false id: aboutIcon
title: "Debugger" height: 150
minimumWidth: 600 width: 150
minimumHeight: 600 fillMode: Image.PreserveAspectFit
width: 800 smooth: true
height: 600 source: ui.assetPath("facet.png")
x: 10
y: 10
Item { }
id: keyHandler
focus: true Text {
Keys.onPressed: { anchors.left: aboutIcon.right
if (event.key == Qt.Key_Space) { anchors.leftMargin: 10
ui.next() font.pointSize: 12
} text: "<h2>Ethereal</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Maran Hidskes<br>"
} }
} }
SplitView {
anchors.fill: parent function addDebugMessage(message){
property var asmModel: ListModel { debuggerLog.append({value: message})
id: asmModel }
}
TableView { function addAddress(address) {
id: asmTableView addressModel.append({name: address.name, address: address.address})
width: 200 }
TableViewColumn{ role: "value" ; title: "" ; width: 100 } function clearAddress() {
model: asmModel addressModel.clear()
} }
Rectangle { function loadPlugin(name) {
anchors.left: asmTableView.right console.log("Loading plugin" + name)
anchors.right: parent.right mainView.addPlugin(name)
SplitView { }
orientation: Qt.Vertical
anchors.fill: parent function setWalletValue(value) {
walletValueLabel.text = value
TableView { }
property var memModel: ListModel {
id: memModel function addTx(tx, inout) {
} var isContract
height: parent.height/2 if (tx.contract == true){
width: parent.width isContract = "Yes"
TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50} }else{
TableViewColumn{ role: "value" ; title: "Memory" ; width: 750} isContract = "No"
model: memModel }
}
var address;
SplitView { if(inout == "recv") {
orientation: Qt.Horizontal address = tx.sender;
id: debugSplitView } else {
TableView { address = tx.address;
property var debuggerLog: ListModel { }
id: debuggerLog txModel.insert(0, {inout: inout, hash: tx.hash, address: address, value: tx.value, contract: isContract})
} }
TableViewColumn{ role: "value"; title: "Debug messages" }
model: debuggerLog function addBlock(block, initial) {
} var txs = JSON.parse(block.transactions);
TableView { var amount = 0
property var stackModel: ListModel { if(initial == undefined){
id: stackModel initial = false
} }
height: parent.height/2
width: parent.width if(txs != null){
TableViewColumn{ role: "value" ; title: "Stack" ; width: debugSplitView.width } amount = txs.length
model: stackModel }
}
} if(initial){
} blockModel.append({number: block.number, coinbase: block.coinbase, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
} }else{
} blockModel.insert(0, {number: block.number, coinbase: block.coinbase, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
statusBar: StatusBar { }
RowLayout { }
anchors.fill: parent
Button { function addLog(str) {
property var enabled: true if(str.len != 0) {
id: debugNextButton logModel.insert(0, {description: str})
onClicked: { }
ui.next() }
}
text: "Next" function setPeers(text) {
} peerLabel.text = text
} }
} function convertToPretty(unixTs){
} var a = new Date(unixTs*1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
function setAsm(asm) { var year = a.getFullYear();
asmModel.append({asm: asm}) var month = months[a.getMonth()];
} var date = a.getDate();
var hour = a.getHours();
function setInstruction(num) { var min = a.getMinutes();
asmTableView.selection.clear() var sec = a.getSeconds();
asmTableView.selection.select(num-1) var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
} return time;
}
function clearAsm() { // *******************************************
asmModel.clear() // Components
} // *******************************************
function setMem(mem) { // New Contract component
memModel.append({num: mem.num, value: mem.value}) Component {
} id: newContract
function clearMem(){ Column {
memModel.clear() id: mainContractColumn
} anchors.fill: parent
function contractFormReady(){
function setStack(stack) { if(codeView.text.length > 0 && txValue.text.length > 0 && txGas.text.length > 0 && txGasPrice.length > 0) {
stackModel.append({value: stack}) txButton.state = "READY"
} }else{
function addDebugMessage(message){ txButton.state = "NOTREADY"
console.log("WOOP:") }
debuggerLog.append({value: message}) }
} states: [
State{
function clearStack() { name: "ERROR"
stackModel.clear() PropertyChanges { target: txResult; visible:true}
} PropertyChanges { target: codeView; visible:true}
},
function loadPlugin(name) { State {
console.log("Loading plugin" + name) name: "DONE"
mainView.addPlugin(name) PropertyChanges { target: txValue; visible:false}
} PropertyChanges { target: txGas; visible:false}
PropertyChanges { target: txGasPrice; visible:false}
function setWalletValue(value) { PropertyChanges { target: codeView; visible:false}
walletValueLabel.text = value PropertyChanges { target: txButton; visible:false}
} PropertyChanges { target: txDataLabel; visible:false}
PropertyChanges { target: atLabel; visible:false}
function addTx(tx, inout) { PropertyChanges { target: txFuelRecipient; visible:false}
var isContract
if (tx.contract == true){ PropertyChanges { target: txResult; visible:true}
isContract = "Yes" PropertyChanges { target: txOutput; visible:true}
}else{ PropertyChanges { target: newTxButton; visible:true}
isContract = "No" },
} State {
txModel.insert(0, {inout: inout, hash: tx.hash, address: tx.address, value: tx.value, contract: isContract}) name: "SETUP"
} PropertyChanges { target: txValue; visible:true; text: ""}
PropertyChanges { target: txGas; visible:true; text: ""}
function addBlock(block, initial) { PropertyChanges { target: txGasPrice; visible:true; text: ""}
var txs = JSON.parse(block.transactions); PropertyChanges { target: codeView; visible:true; text: ""}
var amount = 0 PropertyChanges { target: txButton; visible:true}
if(initial == undefined){ PropertyChanges { target: txDataLabel; visible:true}
initial = false
} PropertyChanges { target: txResult; visible:false}
PropertyChanges { target: txOutput; visible:false}
if(txs != null){ PropertyChanges { target: newTxButton; visible:false}
amount = txs.length }
} ]
width: 400
if(initial){ spacing: 5
blockModel.append({number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) anchors.left: parent.left
}else{ anchors.top: parent.top
blockModel.insert(0, {number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) anchors.leftMargin: 5
} anchors.topMargin: 5
}
TextField {
function addLog(str) { id: txFuelRecipient
if(str.len != 0) { placeholderText: "Address / Name or empty for contract"
logModel.append({description: str}) //validator: RegExpValidator { regExp: /[a-f0-9]{40}/ }
} width: 400
} }
function setPeers(text) { TextField {
peerLabel.text = text id: txValue
} width: 222
function convertToPretty(unixTs){ placeholderText: "Amount"
var a = new Date(unixTs*1000); validator: RegExpValidator { regExp: /\d*/ }
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; onTextChanged: {
var year = a.getFullYear(); contractFormReady()
var month = months[a.getMonth()]; }
var date = a.getDate(); }
var hour = a.getHours();
var min = a.getMinutes(); RowLayout {
var sec = a.getSeconds(); TextField {
var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ; id: txGas
return time; width: 50
} validator: RegExpValidator { regExp: /\d*/ }
// ******************************************* placeholderText: "Gas"
// Components text: "500"
// ******************************************* /*
onTextChanged: {
// New Contract component contractFormReady()
Component { }
id: newContract */
Column { }
id: mainContractColumn Label {
function contractFormReady(){ id: atLabel
if(codeView.text.length > 0 && txValue.text.length > 0 && txGas.text.length > 0 && txGasPrice.length > 0) { text: "@"
txButton.state = "READY" }
}else{
txButton.state = "NOTREADY" TextField {
} id: txGasPrice
} width: 200
states: [ placeholderText: "Gas price"
State{ text: "1000000"
name: "ERROR" validator: RegExpValidator { regExp: /\d*/ }
PropertyChanges { target: txResult; visible:true} /*
PropertyChanges { target: codeView; visible:true} onTextChanged: {
}, contractFormReady()
State { }
name: "DONE" */
PropertyChanges { target: txValue; visible:false} }
PropertyChanges { target: txGas; visible:false} }
PropertyChanges { target: txGasPrice; visible:false}
PropertyChanges { target: codeView; visible:false} Label {
PropertyChanges { target: txButton; visible:false} id: txDataLabel
PropertyChanges { target: txDataLabel; visible:false} text: "Data"
}
PropertyChanges { target: txResult; visible:true}
PropertyChanges { target: txOutput; visible:true} TextArea {
PropertyChanges { target: newTxButton; visible:true} id: codeView
}, height: 300
State { anchors.topMargin: 5
name: "SETUP" width: 400
PropertyChanges { target: txValue; visible:true; text: ""} onTextChanged: {
PropertyChanges { target: txGas; visible:true; text: ""} contractFormReady()
PropertyChanges { target: txGasPrice; visible:true; text: ""} }
PropertyChanges { target: codeView; visible:true; text: ""} }
PropertyChanges { target: txButton; visible:true}
PropertyChanges { target: txDataLabel; visible:true}
Button {
PropertyChanges { target: txResult; visible:false} id: txButton
PropertyChanges { target: txOutput; visible:false} /* enabled: false */
PropertyChanges { target: newTxButton; visible:false} states: [
} State {
] name: "READY"
width: 400 PropertyChanges { target: txButton; /*enabled: true*/}
spacing: 5 },
anchors.left: parent.left State {
anchors.top: parent.top name: "NOTREADY"
anchors.leftMargin: 5 PropertyChanges { target: txButton; /*enabled:false*/}
anchors.topMargin: 5 }
]
TextField { text: "Send"
id: txValue onClicked: {
width: 200 //this.enabled = false
placeholderText: "Amount" var res = eth.create(txFuelRecipient.text, txValue.text, txGas.text, txGasPrice.text, codeView.text)
validator: RegExpValidator { regExp: /\d*/ } if(res[1]) {
onTextChanged: { txResult.text = "Your contract <b>could not</b> be send over the network:\n<b>"
contractFormReady() txResult.text += res[1].error()
} txResult.text += "</b>"
} mainContractColumn.state = "ERROR"
TextField { } else {
id: txGas txResult.text = "Your transaction has been submitted:\n"
width: 200 txOutput.text = res[0].address
validator: RegExpValidator { regExp: /\d*/ } mainContractColumn.state = "DONE"
placeholderText: "Gas" }
onTextChanged: { }
contractFormReady() }
} Text {
} id: txResult
TextField { visible: false
id: txGasPrice }
width: 200 TextField {
placeholderText: "Gas price" id: txOutput
validator: RegExpValidator { regExp: /\d*/ } visible: false
onTextChanged: { width: 530
contractFormReady() }
} Button {
} id: newTxButton
visible: false
Row { text: "Create a new transaction"
id: rowContract onClicked: {
ExclusiveGroup { id: contractTypeGroup } this.visible = false
RadioButton { txResult.text = ""
id: createContractRadio txOutput.text = ""
text: "Create contract" mainContractColumn.state = "SETUP"
checked: true }
exclusiveGroup: contractTypeGroup }
onClicked: { }
txFuelRecipient.visible = false }
txDataLabel.text = "Contract code"
} // New Transaction component
} Component {
RadioButton { id: newTransaction
id: runContractRadio Column {
text: "Run contract" id: simpleSendColumn
exclusiveGroup: contractTypeGroup states: [
onClicked: { State{
txFuelRecipient.visible = true name: "ERROR"
txDataLabel.text = "Contract arguments" },
} State {
} name: "DONE"
} PropertyChanges { target: txSimpleValue; visible:false}
PropertyChanges { target: txSimpleRecipient; visible:false}
PropertyChanges { target:newSimpleTxButton; visible:false}
Label {
id: txDataLabel PropertyChanges { target: txSimpleResult; visible:true}
text: "Contract code" PropertyChanges { target: txSimpleOutput; visible:true}
} PropertyChanges { target:newSimpleTxButton; visible:true}
},
TextArea { State {
id: codeView name: "SETUP"
height: 300 PropertyChanges { target: txSimpleValue; visible:true; text: ""}
anchors.topMargin: 5 PropertyChanges { target: txSimpleRecipient; visible:true; text: ""}
Layout.fillWidth: true PropertyChanges { target: txSimpleButton; visible:true}
width: parent.width /2 PropertyChanges { target:newSimpleTxButton; visible:false}
onTextChanged: { }
contractFormReady() ]
} spacing: 5
} anchors.leftMargin: 5
anchors.topMargin: 5
TextField { anchors.top: parent.top
id: txFuelRecipient anchors.left: parent.left
placeholderText: "Contract address"
validator: RegExpValidator { regExp: /[a-f0-9]{40}/ } function checkFormState(){
visible: false if(txSimpleRecipient.text.length == 40 && txSimpleValue.text.length > 0) {
width: 530 txSimpleButton.state = "READY"
} }else{
txSimpleButton.state = "NOTREADY"
Button { }
id: txButton }
/* enabled: false */
states: [ TextField {
State { id: txSimpleRecipient
name: "READY" placeholderText: "Recipient address"
PropertyChanges { target: txButton; /*enabled: true*/} Layout.fillWidth: true
}, //validator: RegExpValidator { regExp: /[a-f0-9]{40}/ }
State { width: 530
name: "NOTREADY" onTextChanged: { checkFormState() }
PropertyChanges { target: txButton; /*enabled:false*/} }
} TextField {
] id: txSimpleValue
text: "Send" width: 200
onClicked: { placeholderText: "Amount"
//this.enabled = false anchors.rightMargin: 5
var res = eth.create(txFuelRecipient.text, txValue.text, txGas.text, txGasPrice.text, codeView.text) validator: RegExpValidator { regExp: /\d*/ }
if(res[1]) { onTextChanged: { checkFormState() }
txResult.text = "Your contract <b>could not</b> be send over the network:\n<b>" }
txResult.text += res[1].error() Button {
txResult.text += "</b>" id: txSimpleButton
mainContractColumn.state = "ERROR" /*enabled: false*/
} else { states: [
txResult.text = "Your transaction has been submitted:\n" State {
txOutput.text = res[0].address name: "READY"
mainContractColumn.state = "DONE" PropertyChanges { target: txSimpleButton; /*enabled: true*/}
} },
} State {
} name: "NOTREADY"
Text { PropertyChanges { target: txSimpleButton; /*enabled: false*/}
id: txResult }
visible: false ]
} text: "Send"
TextField { onClicked: {
id: txOutput //this.enabled = false
visible: false var res = eth.transact(txSimpleRecipient.text, txSimpleValue.text, "500", "1000000", "")
width: 530 if(res[1]) {
} txSimpleResult.text = "There has been an error broadcasting your transaction:" + res[1].error()
Button { } else {
id: newTxButton txSimpleResult.text = "Your transaction has been broadcasted over the network.\nYour transaction id is:"
visible: false txSimpleOutput.text = res[0].hash
text: "Create an other contract" this.visible = false
onClicked: { simpleSendColumn.state = "DONE"
this.visible = false }
txResult.text = "" }
txOutput.text = "" }
mainContractColumn.state = "SETUP" Text {
} id: txSimpleResult
} visible: false
Button { }
id: debugButton TextField {
text: "Debug" id: txSimpleOutput
onClicked: { visible: false
var res = ui.debugTx("", txValue.text, txGas.text, txGasPrice.text, codeView.text) width: 530
debugWindow.visible = true }
} Button {
} id: newSimpleTxButton
} visible: false
} text: "Create an other transaction"
onClicked: {
// New Transaction component this.visible = false
Component { simpleSendColumn.state = "SETUP"
id: newTransaction }
Column { }
id: simpleSendColumn }
states: [ }
State{
name: "ERROR"
},
State {
name: "DONE"
PropertyChanges { target: txSimpleValue; visible:false}
PropertyChanges { target: txSimpleRecipient; visible:false}
PropertyChanges { target:newSimpleTxButton; visible:false}
PropertyChanges { target: txSimpleResult; visible:true}
PropertyChanges { target: txSimpleOutput; visible:true}
PropertyChanges { target:newSimpleTxButton; visible:true}
},
State {
name: "SETUP"
PropertyChanges { target: txSimpleValue; visible:true; text: ""}
PropertyChanges { target: txSimpleRecipient; visible:true; text: ""}
PropertyChanges { target: txSimpleButton; visible:true}
PropertyChanges { target:newSimpleTxButton; visible:false}
}
]
spacing: 5
anchors.leftMargin: 5
anchors.topMargin: 5
anchors.top: parent.top
anchors.left: parent.left
function checkFormState(){
if(txSimpleRecipient.text.length == 40 && txSimpleValue.text.length > 0) {
txSimpleButton.state = "READY"
}else{
txSimpleButton.state = "NOTREADY"
}
}
TextField {
id: txSimpleRecipient
placeholderText: "Recipient address"
Layout.fillWidth: true
validator: RegExpValidator { regExp: /[a-f0-9]{40}/ }
width: 530
onTextChanged: { checkFormState() }
}
TextField {
id: txSimpleValue
width: 200
placeholderText: "Amount"
anchors.rightMargin: 5
validator: RegExpValidator { regExp: /\d*/ }
onTextChanged: { checkFormState() }
}
Button {
id: txSimpleButton
/*enabled: false*/
states: [
State {
name: "READY"
PropertyChanges { target: txSimpleButton; /*enabled: true*/}
},
State {
name: "NOTREADY"
PropertyChanges { target: txSimpleButton; /*enabled: false*/}
}
]
text: "Send"
onClicked: {
//this.enabled = false
var res = eth.transact(txSimpleRecipient.text, txSimpleValue.text,"","","")
if(res[1]) {
txSimpleResult.text = "There has been an error broadcasting your transaction:" + res[1].error()
} else {
txSimpleResult.text = "Your transaction has been broadcasted over the network.\nYour transaction id is:"
txSimpleOutput.text = res[0].hash
this.visible = false
simpleSendColumn.state = "DONE"
}
}
}
Text {
id: txSimpleResult
visible: false
}
TextField {
id: txSimpleOutput
visible: false
width: 530
}
Button {
id: newSimpleTxButton
visible: false
text: "Create an other transaction"
onClicked: {
this.visible = false
simpleSendColumn.state = "SETUP"
}
}
}
}
} }
...@@ -5,8 +5,8 @@ import ( ...@@ -5,8 +5,8 @@ import (
) )
var Identifier string var Identifier string
var StartConsole bool
var StartMining bool //var StartMining bool
var StartRpc bool var StartRpc bool
var RpcPort int var RpcPort int
var UseUPnP bool var UseUPnP bool
...@@ -18,25 +18,22 @@ var GenAddr bool ...@@ -18,25 +18,22 @@ var GenAddr bool
var UseSeed bool var UseSeed bool
var ImportKey string var ImportKey string
var ExportKey bool var ExportKey bool
var DataDir string
var AssetPath string var AssetPath string
func Init() { func Init() {
flag.StringVar(&Identifier, "i", "", "Custom client identifier") flag.StringVar(&Identifier, "id", "", "Custom client identifier")
flag.BoolVar(&StartConsole, "c", false, "debug and testing console") flag.StringVar(&OutboundPort, "port", "30303", "listening port")
flag.BoolVar(&StartMining, "m", false, "start dagger mining")
flag.BoolVar(&StartRpc, "r", false, "start rpc server")
flag.BoolVar(&ShowGenesis, "g", false, "prints genesis header and exits")
flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support") flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support")
flag.IntVar(&MaxPeer, "maxpeer", 10, "maximum desired peers")
flag.IntVar(&RpcPort, "rpcport", 8080, "port to start json-rpc server on")
flag.BoolVar(&StartRpc, "rpc", false, "start rpc server")
flag.StringVar(&AssetPath, "asset_path", "", "absolute path to GUI assets directory")
flag.BoolVar(&ShowGenesis, "genesis", false, "prints genesis header and exits")
flag.BoolVar(&UseSeed, "seed", true, "seed peers") flag.BoolVar(&UseSeed, "seed", true, "seed peers")
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
flag.BoolVar(&ExportKey, "export", false, "export private key") flag.BoolVar(&ExportKey, "export", false, "export private key")
flag.IntVar(&RpcPort, "rpcport", 8080, "port to start json-rpc server on")
flag.StringVar(&OutboundPort, "p", "30303", "listening port")
flag.StringVar(&DataDir, "dir", ".ethereal", "ethereum data directory")
flag.StringVar(&ImportKey, "import", "", "imports the given private key (hex)") flag.StringVar(&ImportKey, "import", "", "imports the given private key (hex)")
flag.IntVar(&MaxPeer, "x", 10, "maximum desired peers")
flag.StringVar(&AssetPath, "asset_path", "", "absolute path to GUI assets directory")
flag.Parse() flag.Parse()
} }
...@@ -8,9 +8,11 @@ import ( ...@@ -8,9 +8,11 @@ import (
"github.com/ethereum/go-ethereum/ethereal/ui" "github.com/ethereum/go-ethereum/ethereal/ui"
"github.com/ethereum/go-ethereum/utils" "github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml" "github.com/go-qml/qml"
"github.com/rakyll/globalconf"
"log" "log"
"os" "os"
"os/signal" "os/signal"
"path"
"runtime" "runtime"
) )
...@@ -39,7 +41,16 @@ func main() { ...@@ -39,7 +41,16 @@ func main() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())
ethchain.InitFees() ethchain.InitFees()
ethutil.ReadConfig(DataDir, ethutil.LogFile|ethutil.LogStd, Identifier)
g, err := globalconf.NewWithOptions(&globalconf.Options{
Filename: path.Join(ethutil.ApplicationFolder(".ethereal"), "conf.ini"),
})
if err != nil {
fmt.Println(err)
} else {
g.ParseAll()
}
ethutil.ReadConfig(".ethereal", ethutil.LogFile|ethutil.LogStd, Identifier)
// Instantiated a eth stack // Instantiated a eth stack
ethereum, err := eth.New(eth.CapDefault, UseUPnP) ethereum, err := eth.New(eth.CapDefault, UseUPnP)
...@@ -108,9 +119,11 @@ save these words so you can restore your account later: %s ...@@ -108,9 +119,11 @@ save these words so you can restore your account later: %s
os.Exit(0) os.Exit(0)
} }
if StartMining { /*
utils.DoMining(ethereum) if StartMining {
} utils.DoMining(ethereum)
}
*/
if StartRpc { if StartRpc {
utils.DoRpc(ethereum, RpcPort) utils.DoRpc(ethereum, RpcPort)
......
...@@ -71,6 +71,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data ...@@ -71,6 +71,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
var err error var err error
script := ethutil.StringToByteFunc(scriptStr, func(s string) (ret []byte) { script := ethutil.StringToByteFunc(scriptStr, func(s string) (ret []byte) {
ret, err = ethutil.Compile(s) ret, err = ethutil.Compile(s)
fmt.Printf("%x\n", ret)
return return
}) })
...@@ -82,6 +83,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data ...@@ -82,6 +83,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
dis := ethchain.Disassemble(script) dis := ethchain.Disassemble(script)
self.win.Root().Call("clearAsm") self.win.Root().Call("clearAsm")
self.win.Root().Call("clearLog")
for _, str := range dis { for _, str := range dis {
self.win.Root().Call("setAsm", str) self.win.Root().Call("setAsm", str)
......
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"github.com/ethereum/eth-go/ethdb" "github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethpub" "github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml" "github.com/go-qml/qml"
"math/big" "math/big"
"strings" "strings"
...@@ -66,7 +67,6 @@ func (gui *Gui) Start(assetPath string) { ...@@ -66,7 +67,6 @@ func (gui *Gui) Start(assetPath string) {
}}) }})
ethutil.Config.SetClientString(fmt.Sprintf("/Ethereal v%s", version)) ethutil.Config.SetClientString(fmt.Sprintf("/Ethereal v%s", version))
ethutil.Config.Log.Infoln("[GUI] Starting GUI")
// Create a new QML engine // Create a new QML engine
gui.engine = qml.NewEngine() gui.engine = qml.NewEngine()
context := gui.engine.Context() context := gui.engine.Context()
...@@ -93,12 +93,28 @@ func (gui *Gui) Start(assetPath string) { ...@@ -93,12 +93,28 @@ func (gui *Gui) Start(assetPath string) {
panic(err) panic(err)
} }
ethutil.Config.Log.AddLogSystem(gui)
ethutil.Config.Log.Infoln("[GUI] Starting GUI")
win.Show() win.Show()
win.Wait() win.Wait()
gui.eth.Stop() gui.eth.Stop()
} }
func (gui *Gui) ToggleMining() {
var txt string
if gui.eth.Mining {
utils.StopMining(gui.eth)
txt = "Start mining"
} else {
utils.StartMining(gui.eth)
txt = "Stop mining"
}
gui.win.Root().Set("miningButtonText", txt)
}
func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) { func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
component, err := gui.engine.LoadFile(gui.uiLib.AssetPath("qml/wallet.qml")) component, err := gui.engine.LoadFile(gui.uiLib.AssetPath("qml/wallet.qml"))
if err != nil { if err != nil {
...@@ -107,8 +123,11 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) { ...@@ -107,8 +123,11 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
win := gui.createWindow(component) win := gui.createWindow(component)
go gui.setInitialBlockChain() gui.setInitialBlockChain()
go gui.readPreviousTransactions() gui.loadAddressBook()
gui.readPreviousTransactions()
gui.setPeerInfo()
go gui.update() go gui.update()
return win, nil return win, nil
...@@ -145,6 +164,19 @@ func (gui *Gui) setInitialBlockChain() { ...@@ -145,6 +164,19 @@ func (gui *Gui) setInitialBlockChain() {
} }
} }
type address struct {
Name, Address string
}
var namereg = ethutil.FromHex("bb5f186604d057c1c5240ca2ae0f6430138ac010")
func (gui *Gui) loadAddressBook() {
gui.win.Root().Call("clearAddress")
gui.eth.StateManager().CurrentState().GetStateObject(namereg).State().EachStorage(func(name string, value *ethutil.Value) {
gui.win.Root().Call("addAddress", struct{ Name, Address string }{name, ethutil.Hex(value.Bytes())})
})
}
func (gui *Gui) readPreviousTransactions() { func (gui *Gui) readPreviousTransactions() {
it := gui.txDb.Db().NewIterator(nil, nil) it := gui.txDb.Db().NewIterator(nil, nil)
for it.Next() { for it.Next() {
...@@ -189,10 +221,14 @@ func (gui *Gui) update() { ...@@ -189,10 +221,14 @@ func (gui *Gui) update() {
blockChan := make(chan ethutil.React, 1) blockChan := make(chan ethutil.React, 1)
txChan := make(chan ethutil.React, 1) txChan := make(chan ethutil.React, 1)
objectChan := make(chan ethutil.React, 1)
peerChan := make(chan ethutil.React, 1)
reactor.Subscribe("newBlock", blockChan) reactor.Subscribe("newBlock", blockChan)
reactor.Subscribe("newTx:pre", txChan) reactor.Subscribe("newTx:pre", txChan)
reactor.Subscribe("newTx:post", txChan) reactor.Subscribe("newTx:post", txChan)
reactor.Subscribe("object:"+string(namereg), objectChan)
reactor.Subscribe("peerList", peerChan)
state := gui.eth.StateManager().TransState() state := gui.eth.StateManager().TransState()
...@@ -239,10 +275,18 @@ func (gui *Gui) update() { ...@@ -239,10 +275,18 @@ func (gui *Gui) update() {
state.UpdateStateObject(object) state.UpdateStateObject(object)
} }
case <-objectChan:
gui.loadAddressBook()
case <-peerChan:
gui.setPeerInfo()
} }
} }
} }
func (gui *Gui) setPeerInfo() {
gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
}
// Logging functions that log directly to the GUI interface // Logging functions that log directly to the GUI interface
func (gui *Gui) Println(v ...interface{}) { func (gui *Gui) Println(v ...interface{}) {
str := strings.TrimRight(fmt.Sprintln(v...), "\n") str := strings.TrimRight(fmt.Sprintln(v...), "\n")
......
...@@ -20,7 +20,6 @@ var UseSeed bool ...@@ -20,7 +20,6 @@ var UseSeed bool
var ImportKey string var ImportKey string
var ExportKey bool var ExportKey bool
var LogFile string var LogFile string
var DataDir string
var NonInteractive bool var NonInteractive bool
var StartJsConsole bool var StartJsConsole bool
var InputFile string var InputFile string
...@@ -31,22 +30,21 @@ func Init() { ...@@ -31,22 +30,21 @@ func Init() {
flag.PrintDefaults() flag.PrintDefaults()
} }
flag.StringVar(&Identifier, "i", "", "custom client identifier") flag.StringVar(&Identifier, "id", "", "Custom client identifier")
flag.BoolVar(&StartMining, "m", false, "start dagger mining") flag.StringVar(&OutboundPort, "port", "30303", "listening port")
flag.BoolVar(&ShowGenesis, "g", false, "prints genesis header and exits") flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support")
flag.BoolVar(&StartRpc, "r", false, "start rpc server") flag.IntVar(&MaxPeer, "maxpeer", 10, "maximum desired peers")
flag.IntVar(&RpcPort, "rpcport", 8080, "port to start json-rpc server on") flag.IntVar(&RpcPort, "rpcport", 8080, "port to start json-rpc server on")
flag.BoolVar(&StartRpc, "rpc", false, "start rpc server")
flag.BoolVar(&StartJsConsole, "js", false, "exp")
flag.BoolVar(&StartMining, "mine", false, "start dagger mining")
flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)") flag.BoolVar(&NonInteractive, "y", false, "non-interactive mode (say yes to confirmations)")
flag.BoolVar(&UseUPnP, "upnp", false, "enable UPnP support")
flag.BoolVar(&UseSeed, "seed", true, "seed peers") flag.BoolVar(&UseSeed, "seed", true, "seed peers")
flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key") flag.BoolVar(&GenAddr, "genaddr", false, "create a new priv/pub key")
flag.BoolVar(&ExportKey, "export", false, "export private key") flag.BoolVar(&ExportKey, "export", false, "export private key")
flag.StringVar(&OutboundPort, "p", "30303", "listening port")
flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)") flag.StringVar(&LogFile, "logfile", "", "log file (defaults to standard output)")
flag.StringVar(&DataDir, "dir", ".ethereum", "ethereum data directory")
flag.StringVar(&ImportKey, "import", "", "imports the given private key (hex)") flag.StringVar(&ImportKey, "import", "", "imports the given private key (hex)")
flag.IntVar(&MaxPeer, "x", 10, "maximum desired peers")
flag.BoolVar(&StartJsConsole, "js", false, "exp")
flag.Parse() flag.Parse()
......
...@@ -59,7 +59,7 @@ func main() { ...@@ -59,7 +59,7 @@ func main() {
lt = ethutil.LogFile | ethutil.LogStd lt = ethutil.LogFile | ethutil.LogStd
} }
ethutil.ReadConfig(DataDir, lt, Identifier) ethutil.ReadConfig(".ethereum", lt, Identifier)
logger := ethutil.Config.Log logger := ethutil.Config.Log
......
...@@ -33,8 +33,6 @@ func DoMining(ethereum *eth.Ethereum) { ...@@ -33,8 +33,6 @@ func DoMining(ethereum *eth.Ethereum) {
addr := keyPair.Address() addr := keyPair.Address()
go func() { go func() {
ethutil.Config.Log.Infoln("Miner started")
miner = ethminer.NewDefaultMiner(addr, ethereum) miner = ethminer.NewDefaultMiner(addr, ethereum)
// Give it some time to connect with peers // Give it some time to connect with peers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment