From 0bccf1c3cd9576724cbd387922997ebd6bbcf898 Mon Sep 17 00:00:00 2001
From: Maran <maran.hidskes@gmail.com>
Date: Wed, 21 May 2014 11:45:19 +0200
Subject: Wait with mining until up to date

---
 utils/cmd.go | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/utils/cmd.go b/utils/cmd.go
index f163575da..28597194f 100644
--- a/utils/cmd.go
+++ b/utils/cmd.go
@@ -34,11 +34,10 @@ func DoMining(ethereum *eth.Ethereum) {
 		// Give it some time to connect with peers
 		time.Sleep(3 * time.Second)
 
-		/*
-			for ethereum.IsUpToDate() == false {
-				time.Sleep(5 * time.Second)
-			}
-		*/
+		for ethereum.IsUpToDate() == false {
+			time.Sleep(5 * time.Second)
+		}
+
 		ethutil.Config.Log.Infoln("Miner started")
 
 		miner := ethminer.NewDefaultMiner(addr, ethereum)
-- 
cgit v1.2.3


From 6b115659ca3f5879f27c45723ef567b67133bc93 Mon Sep 17 00:00:00 2001
From: Maran <maran.hidskes@gmail.com>
Date: Thu, 22 May 2014 10:27:21 +0200
Subject: Hide inspector by default

---
 ethereal/assets/qml/webapp.qml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml
index f00b04599..d3cffeeca 100644
--- a/ethereal/assets/qml/webapp.qml
+++ b/ethereal/assets/qml/webapp.qml
@@ -188,7 +188,7 @@ ApplicationWindow {
 
 		WebView {
 			id: inspector
-			visible:true
+			visible: false
 			url: webview.experimental.remoteInspectorUrl
 			anchors {
 				left: root.left
-- 
cgit v1.2.3


From 5fc6ee6a4acd1db22a38abb4cff5e5196bf1538e Mon Sep 17 00:00:00 2001
From: Maran <maran.hidskes@gmail.com>
Date: Mon, 26 May 2014 17:07:20 +0200
Subject: Implemented simple block/tx explorer

---
 ethereal/assets/qml/wallet.qml | 139 +++++++++++++++++++++++++++++++++++++----
 ethereal/ui/gui.go             |  20 +++---
 2 files changed, 139 insertions(+), 20 deletions(-)

diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index 7a6750f63..8903fb14f 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -65,6 +65,7 @@ ApplicationWindow {
 	}
 
 	function setView(view) {
+		console.log("Setting view")
 		networkView.visible = false
 		historyView.visible = false
 		newTxView.visible = false
@@ -203,16 +204,14 @@ ApplicationWindow {
 					anchors.bottom: logView.top
 					TableViewColumn{ role: "number" ; title: "#" ; width: 100 }
 					TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 }
+					TableViewColumn{ role: "txAmount" ; title: "Tx amount" ; width: 100 }
 
 					model: blockModel
 
-					/*
-					 onDoubleClicked: {
-						 popup.visible = true
-						 popup.block = eth.getBlock(blockModel.get(row).hash)
-						 popup.hashLabel.text = popup.block.hash
-					 }
-					 */
+					onDoubleClicked: {
+						popup.visible = true
+						popup.setDetails(blockModel.get(row))
+					}
 				}
 
 				property var logModel: ListModel {
@@ -340,10 +339,107 @@ ApplicationWindow {
 		id: popup
 		visible: false
 		property var block
-		Label {
-			id: hashLabel
-			anchors.horizontalCenter: parent.horizontalCenter
-			anchors.verticalCenter: parent.verticalCenter
+		width: 800
+		height: 230
+		x: root.x
+		y: root.y + root.height
+		Component{
+			id: blockDetailsDelegate
+			Rectangle {
+				color: "#252525"
+				width: popup.width
+				height: 200
+				Column {
+					anchors.leftMargin: 10
+					anchors.topMargin: 5
+					anchors.top: parent.top
+					anchors.left: parent.left
+					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"}
+				}
+		}
+	}
+		ListView {
+			model: singleBlock
+			delegate: blockDetailsDelegate
+			anchors.top: parent.top
+			height: 70
+			anchors.leftMargin: 20
+			id: listViewThing
+			Layout.maximumHeight: 40
+		}
+		TableView {
+			id: txView
+			anchors.top: listViewThing.bottom
+			anchors.topMargin: 50
+			width: parent.width
+
+			TableViewColumn{width: 90; role: "value" ; title: "Value" }
+			TableViewColumn{width: 200; role: "hash" ; title: "Hash" }
+			TableViewColumn{width: 200; role: "sender" ; title: "Sender" }
+			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" }
+
+			model: transactionModel
+			onClicked: {
+				var tx = transactionModel.get(row)
+				if(tx.data) {
+					popup.showContractData(tx.data)
+				}else{
+					popup.height = 230
+				}
+			}
+		}
+		function showContractData(data) {
+			contractData.text = data
+			popup.height = 400
+		}
+		Rectangle {
+			width: popup.width
+			height: 200
+			anchors.left: listViewThing.left
+			anchors.top: txView.bottom
+			Label {
+				text: "<h4>Contract data</h4>"
+				anchors.top: parent.top
+				anchors.left: parent.left
+				id: contractLabel
+				anchors.leftMargin: 10
+			}
+			TextArea {
+				id: contractData
+				text: "Contract"
+				anchors.top: contractLabel.bottom
+				anchors.left: parent.left
+				wrapMode: Text.Wrap
+				width: parent.width - 30
+				height: 80
+				anchors.leftMargin: 10
+			}
+		}
+		property var transactionModel: ListModel {
+			id: transactionModel
+		}
+		property var singleBlock: ListModel {
+			id: singleBlock
+		}
+		function setDetails(block){
+			singleBlock.set(0,block)
+			popup.height = 230
+			transactionModel.clear()
+			if(block.txs != undefined){
+				for(var i = 0; i < block.txs.count; ++i) {
+					transactionModel.insert(0, block.txs.get(i))
+				}
+				if(block.txs.get(0).data){
+					popup.showContractData(block.txs.get(0).data)
+				}
+			}
+			txView.forceActiveFocus()
 		}
 	}
 
@@ -474,7 +570,7 @@ ApplicationWindow {
               }
               height: parent.height/2
               width: parent.width
-              TableViewColumn{ role: "value" ; title: "Stack" ; width: parent.width }
+              TableViewColumn{ role: "value" ; title: "Stack"}
               model: stackModel
             }
           }
@@ -535,7 +631,12 @@ ApplicationWindow {
 	}
 
 	function addBlock(block) {
-		blockModel.insert(0, {number: block.number, hash: block.hash})
+		var objtt = JSON.parse(block.transactions);
+		var amount = 0
+		if(objtt != null){
+			amount = objtt.length
+		}
+		blockModel.insert(0, {number: block.number, hash: block.hash, txs: objtt, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
 	}
 
 	function addLog(str) {
@@ -547,4 +648,16 @@ ApplicationWindow {
 	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'];
+		var year = a.getFullYear();
+		var month = months[a.getMonth()];
+		var date = a.getDate();
+		var hour = a.getHours();
+		var min = a.getMinutes();
+		var sec = a.getSeconds();
+		var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
+		return time;
+	}
 }
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 8d6796ddb..794786d97 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -136,14 +136,20 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window {
 
 	return gui.win
 }
-
-func (gui *Gui) setInitialBlockChain() {
-	// Load previous 10 blocks
-	chain := gui.eth.BlockChain().GetChain(gui.eth.BlockChain().CurrentBlock.Hash(), 10)
-	for _, block := range chain {
-		gui.processBlock(block)
+func (gui *Gui) recursiveAdd(sBlk []byte) {
+	blk := gui.eth.BlockChain().GetBlock(sBlk)
+	if blk != nil {
+		//ethutil.Config.Log.Infoln("Adding block", blk)
+		gui.processBlock(blk)
+		gui.recursiveAdd(blk.PrevHash)
+		return
+	} else {
+		//ethutil.Config.Log.Debugln("At Genesis, added all blocks to GUI")
 	}
-
+	return
+}
+func (gui *Gui) setInitialBlockChain() {
+	gui.recursiveAdd(gui.eth.BlockChain().LastBlockHash)
 }
 
 func (gui *Gui) readPreviousTransactions() {
-- 
cgit v1.2.3


From f7eb4e587f83e4472e3d214076ba0c28102daefd Mon Sep 17 00:00:00 2001
From: Maran <maran.hidskes@gmail.com>
Date: Mon, 26 May 2014 17:18:34 +0200
Subject: Remove extra log statement

---
 ethereal/assets/qml/wallet.qml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index 8903fb14f..81ad7ef24 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -65,7 +65,6 @@ ApplicationWindow {
 	}
 
 	function setView(view) {
-		console.log("Setting view")
 		networkView.visible = false
 		historyView.visible = false
 		newTxView.visible = false
-- 
cgit v1.2.3


From d694e00a3340a36c39872950bb7a2404e9686c18 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Mon, 26 May 2014 21:11:38 +0200
Subject: Fixed debugger

---
 ethereal/assets/qml/wallet.qml             | 75 ++++++++++++++++++------------
 ethereal/assets/samplecoin/samplecoin.html |  2 +-
 ethereal/ui/gui.go                         |  2 +-
 ethereal/ui/ui_lib.go                      | 32 +++++++------
 4 files changed, 64 insertions(+), 47 deletions(-)

diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index f23f182f3..f42cf3b1b 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -409,7 +409,7 @@ ApplicationWindow {
 
 	}
 
-	Window {
+	ApplicationWindow {
 		id: debugWindow
 		visible: false
 		title: "Debugger"
@@ -447,36 +447,49 @@ ApplicationWindow {
 					orientation: Qt.Vertical
 					anchors.fill: parent
 
-          TableView {
-            property var memModel: ListModel {
-              id: memModel
-            }
-            height: parent.height/2
-            width: parent.width
-            TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50}
-            TableViewColumn{ role: "value" ; title: "Memory" ; width: 750}
-            model: memModel
-          }
-
-          SplitView {
-            orientation: Qt.Horizontal
-            TableView {
-              property var debuggerLog: ListModel {
-                id: debuggerLog
-              }
-              TableViewColumn{ role: "value"; title: "Debug messages" }
-              model: debuggerLog
-            }
-            TableView {
-              property var stackModel: ListModel {
-                id: stackModel
-              }
-              height: parent.height/2
-              width: parent.width
-              TableViewColumn{ role: "value" ; title: "Stack" ; width: parent.width }
-              model: stackModel
-            }
-          }
+					TableView {
+						property var memModel: ListModel {
+							id: memModel
+						}
+						height: parent.height/2
+						width: parent.width
+						TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50}
+						TableViewColumn{ role: "value" ; title: "Memory" ; width: 750}
+						model: memModel
+					}
+
+					SplitView {
+						orientation: Qt.Horizontal
+						TableView {
+							property var debuggerLog: ListModel {
+								id: debuggerLog
+							}
+							TableViewColumn{ role: "value"; title: "Debug messages" }
+							model: debuggerLog
+						}
+						TableView {
+							property var stackModel: ListModel {
+								id: stackModel
+							}
+							height: parent.height/2
+							width: parent.width
+							TableViewColumn{ role: "value" ; title: "Stack" ; width: parent.width }
+							model: stackModel
+						}
+					}
+				}
+			}
+		}
+		statusBar: StatusBar {
+			RowLayout {
+				anchors.fill: parent
+				Button {
+					property var enabled: true
+					id: debugNextButton
+					onClicked: {
+						ui.next()
+					}
+					text: "Next"
 				}
 			}
 		}
diff --git a/ethereal/assets/samplecoin/samplecoin.html b/ethereal/assets/samplecoin/samplecoin.html
index 3892141cd..e780aefb4 100644
--- a/ethereal/assets/samplecoin/samplecoin.html
+++ b/ethereal/assets/samplecoin/samplecoin.html
@@ -9,7 +9,7 @@
 
 <script type="text/javascript">
 
-var jefcoinAddr = "fc0a9436890478bb9b1c6ed7455c2535366f4a99"
+var jefcoinAddr = "518546ffa883dcc838a64bc2dabada0fd64af459"
 var mAddr = ""
 
 function createTransaction() {
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 8d6796ddb..1018d77ac 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -130,7 +130,7 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window {
 	gui.win = win
 	gui.uiLib.win = win
 
-	db := &Debugger{gui.win, make(chan bool)}
+	db := &Debugger{gui.win, make(chan bool), true}
 	gui.lib.Db = db
 	gui.uiLib.Db = db
 
diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go
index 1c88b0181..51fa26a88 100644
--- a/ethereal/ui/ui_lib.go
+++ b/ethereal/ui/ui_lib.go
@@ -6,9 +6,7 @@ import (
 	"github.com/ethereum/eth-go"
 	"github.com/ethereum/eth-go/ethchain"
 	"github.com/ethereum/eth-go/ethutil"
-	"github.com/ethereum/go-ethereum/utils"
 	"github.com/go-qml/qml"
-	"github.com/obscuren/mutan"
 	"os"
 	"path"
 	"path/filepath"
@@ -121,27 +119,28 @@ func DefaultAssetPath() string {
 func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) {
 	state := ui.eth.BlockChain().CurrentBlock.State()
 
-	mainInput, _ := mutan.PreParse(data)
-	callerScript, err := utils.Compile(mainInput)
+	script, err := ethutil.Compile(data)
 	if err != nil {
 		ethutil.Config.Log.Debugln(err)
 
 		return
 	}
 
-	dis := ethchain.Disassemble(callerScript)
+	dis := ethchain.Disassemble(script)
 	ui.win.Root().Call("clearAsm")
 
 	for _, str := range dis {
 		ui.win.Root().Call("setAsm", str)
 	}
-	callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), nil)
-
 	// Contract addr as test address
 	keyPair := ethutil.GetKeyRing().Get(0)
+	callerTx :=
+		ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), script)
+	callerTx.Sign(keyPair.PrivateKey)
+
 	account := ui.eth.StateManager().TransState().GetStateObject(keyPair.Address())
-	c := ethchain.MakeContract(callerTx, state)
-	callerClosure := ethchain.NewClosure(account, c, c.Script(), state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))
+	contract := ethchain.MakeContract(callerTx, state)
+	callerClosure := ethchain.NewClosure(account, contract, contract.Init(), state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))
 
 	block := ui.eth.BlockChain().CurrentBlock
 	vm := ethchain.NewVm(state, ui.eth.StateManager(), ethchain.RuntimeVars{
@@ -151,23 +150,28 @@ func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string)
 		Coinbase:    block.Coinbase,
 		Time:        block.Time,
 		Diff:        block.Difficulty,
-		TxData:      nil,
 	})
 
+	ui.Db.done = false
 	go func() {
-		callerClosure.Call(vm, nil, ui.Db.halting)
+		callerClosure.Call(vm, contract.Init(), ui.Db.halting)
 
 		state.Reset()
+
+		ui.Db.done = true
 	}()
 }
 
 func (ui *UiLib) Next() {
-	ui.Db.Next()
+	if !ui.Db.done {
+		ui.Db.Next()
+	}
 }
 
 type Debugger struct {
-	win *qml.Window
-	N   chan bool
+	win  *qml.Window
+	N    chan bool
+	done bool
 }
 
 func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack) {
-- 
cgit v1.2.3


From 47a58b40cd4ba764c9823448687307bb4a80c697 Mon Sep 17 00:00:00 2001
From: Maran <maran.hidskes@gmail.com>
Date: Tue, 27 May 2014 10:29:39 +0200
Subject: Removed recursive function for loop

---
 ethereal/assets/qml/wallet.qml |  8 ++++----
 ethereal/ui/gui.go             | 15 ++++-----------
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index f318ad173..b467982c4 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -643,12 +643,12 @@ ApplicationWindow {
 	}
 
 	function addBlock(block) {
-		var objtt = JSON.parse(block.transactions);
+		var txs = JSON.parse(block.transactions);
 		var amount = 0
-		if(objtt != null){
-			amount = objtt.length
+		if(txs != null){
+			amount = txs.length
 		}
-		blockModel.insert(0, {number: block.number, hash: block.hash, txs: objtt, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
+		blockModel.insert(0, {number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
 	}
 
 	function addLog(str) {
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 64c739c15..7577de1fa 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -136,20 +136,13 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window {
 
 	return gui.win
 }
-func (gui *Gui) recursiveAdd(sBlk []byte) {
+func (gui *Gui) setInitialBlockChain() {
+	sBlk := gui.eth.BlockChain().LastBlockHash
 	blk := gui.eth.BlockChain().GetBlock(sBlk)
-	if blk != nil {
-		//ethutil.Config.Log.Infoln("Adding block", blk)
+	for ; blk != nil; blk = gui.eth.BlockChain().GetBlock(sBlk) {
+		sBlk = blk.PrevHash
 		gui.processBlock(blk)
-		gui.recursiveAdd(blk.PrevHash)
-		return
-	} else {
-		//ethutil.Config.Log.Debugln("At Genesis, added all blocks to GUI")
 	}
-	return
-}
-func (gui *Gui) setInitialBlockChain() {
-	gui.recursiveAdd(gui.eth.BlockChain().LastBlockHash)
 }
 
 func (gui *Gui) readPreviousTransactions() {
-- 
cgit v1.2.3


From 07204f129e277fb5f63f080d6a146e28603f872e Mon Sep 17 00:00:00 2001
From: Maran <maran.hidskes@gmail.com>
Date: Tue, 27 May 2014 10:38:51 +0200
Subject: Increase size for asm

---
 ethereal/assets/qml/wallet.qml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index b467982c4..911422f91 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -339,7 +339,7 @@ ApplicationWindow {
 		visible: false
 		property var block
 		width: 800
-		height: 230
+		height: 280
 		x: root.x
 		y: root.y + root.height
 		Component{
@@ -399,7 +399,7 @@ ApplicationWindow {
 		}
 		Rectangle {
 			width: popup.width
-			height: 200
+			height: 300
 			anchors.left: listViewThing.left
 			anchors.top: txView.bottom
 			Label {
-- 
cgit v1.2.3


From 4fd267a7785ea06014f38f9be4e8e380c7f1cb1e Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Tue, 27 May 2014 10:42:37 +0200
Subject: Sep debugger from main

---
 ethereal/assets/debugger/debugger.qml | 114 ++++++++++++++++++++++++++++++++++
 ethereal/assets/qml/wallet.qml        |  14 ++++-
 ethereal/ui/debugger.go               |  86 +++++++++++++++++++++++++
 ethereal/ui/ui_lib.go                 |  14 +++--
 4 files changed, 222 insertions(+), 6 deletions(-)
 create mode 100644 ethereal/assets/debugger/debugger.qml
 create mode 100644 ethereal/ui/debugger.go

diff --git a/ethereal/assets/debugger/debugger.qml b/ethereal/assets/debugger/debugger.qml
new file mode 100644
index 000000000..b7d954e73
--- /dev/null
+++ b/ethereal/assets/debugger/debugger.qml
@@ -0,0 +1,114 @@
+import QtQuick 2.0
+import QtQuick.Controls 1.0;
+import QtQuick.Layouts 1.0;
+import QtQuick.Dialogs 1.0;
+import QtQuick.Window 2.1;
+import QtQuick.Controls.Styles 1.1
+import Ethereum 1.0
+
+ApplicationWindow {
+	id: debugWindow
+	visible: false
+	title: "Debugger"
+	minimumWidth: 600
+	minimumHeight: 600
+	width: 800
+	height: 600
+
+	SplitView {
+		anchors.fill: parent
+		property var asmModel: ListModel {
+			id: asmModel
+		}
+		TableView {
+			id: asmTableView
+			width: 200
+			TableViewColumn{ role: "value" ; title: "" ; width: 100 }
+			model: asmModel
+		}
+
+		Rectangle {
+			anchors.left: asmTableView.right
+			anchors.right: parent.right
+			SplitView {
+				orientation: Qt.Vertical
+				anchors.fill: parent
+
+				TableView {
+					property var memModel: ListModel {
+						id: memModel
+					}
+					height: parent.height/2
+					width: parent.width
+					TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50}
+					TableViewColumn{ role: "value" ; title: "Memory" ; width: 750}
+					model: memModel
+				}
+
+				SplitView {
+					orientation: Qt.Horizontal
+					TableView {
+						property var debuggerLog: ListModel {
+							id: debuggerLog
+						}
+						TableViewColumn{ role: "value"; title: "Debug messages" }
+						model: debuggerLog
+					}
+					TableView {
+						property var stackModel: ListModel {
+							id: stackModel
+						}
+						height: parent.height/2
+						width: parent.width
+						TableViewColumn{ role: "value" ; title: "Stack" ; width: 200 }
+						model: stackModel
+					}
+				}
+			}
+		}
+	}
+	statusBar: StatusBar {
+		RowLayout {
+			anchors.fill: parent
+			Button {
+				property var enabled: true
+				id: debugNextButton
+				onClicked: {
+					//db.next()
+				}
+				text: "Next"
+			}
+		}
+	}
+
+	function setAsm(asm) {
+		asmModel.append({asm: asm})
+	}
+
+	function setInstruction(num) {
+		asmTableView.selection.clear()
+		asmTableView.selection.select(num-1)
+	}
+
+	function clearAsm() {
+		asmModel.clear()
+	}
+
+	function setMem(mem) {
+		memModel.append({num: mem.num, value: mem.value})
+	}
+	function clearMem(){
+		memModel.clear()
+	}
+
+	function setStack(stack) {
+		stackModel.append({value: stack})
+	}
+	function addDebugMessage(message){
+		debuggerLog.append({value: message})
+	}
+
+	function clearStack() {
+		stackModel.clear()
+	}
+}
diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index f42cf3b1b..40de8624e 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -294,6 +294,7 @@ ApplicationWindow {
 	statusBar: StatusBar {
 		RowLayout {
 			anchors.fill: parent
+			/*
 			Button {
 				property var enabled: true
 				id: connectButton
@@ -304,10 +305,19 @@ ApplicationWindow {
 				}
 				text: "Connect"
 			}
+			*/
+			Button {
+				property var enabled: true
+				id: debuggerWindow
+				onClicked: {
+					ui.startDebugger()
+				}
+				text: "Debugger"
+			}
 
 			Button {
 				id: importAppButton
-				anchors.left: connectButton.right
+				anchors.left: debuggerWindow.right
 				anchors.leftMargin: 5
 				onClicked: openAppDialog.open()
 				text: "Import App"
@@ -473,7 +483,7 @@ ApplicationWindow {
 							}
 							height: parent.height/2
 							width: parent.width
-							TableViewColumn{ role: "value" ; title: "Stack" ; width: parent.width }
+							TableViewColumn{ role: "value" ; title: "Stack" ; width: 300 }
 							model: stackModel
 						}
 					}
diff --git a/ethereal/ui/debugger.go b/ethereal/ui/debugger.go
new file mode 100644
index 000000000..4debc05b2
--- /dev/null
+++ b/ethereal/ui/debugger.go
@@ -0,0 +1,86 @@
+package ethui
+
+import (
+	"fmt"
+	"github.com/ethereum/eth-go/ethchain"
+	"github.com/ethereum/eth-go/ethutil"
+	"github.com/go-qml/qml"
+)
+
+type DebuggerWindow struct {
+	win    *qml.Window
+	engine *qml.Engine
+	lib    *UiLib
+	Db     *Debugger
+}
+
+func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
+	engine := qml.NewEngine()
+	component, err := engine.LoadFile(lib.AssetPath("debugger/debugger.qml"))
+	if err != nil {
+		fmt.Println(err)
+
+		return nil
+	}
+
+	win := component.CreateWindow(nil)
+	db := &Debugger{win, make(chan bool), true}
+
+	return &DebuggerWindow{engine: engine, win: win, lib: lib, Db: db}
+}
+
+func (self *DebuggerWindow) Show() {
+	go func() {
+		self.win.Show()
+		self.win.Wait()
+	}()
+}
+
+func (self *DebuggerWindow) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) {
+	state := self.lib.eth.BlockChain().CurrentBlock.State()
+
+	script, err := ethutil.Compile(data)
+	if err != nil {
+		ethutil.Config.Log.Debugln(err)
+
+		return
+	}
+
+	dis := ethchain.Disassemble(script)
+	self.lib.win.Root().Call("clearAsm")
+
+	for _, str := range dis {
+		self.lib.win.Root().Call("setAsm", str)
+	}
+	// Contract addr as test address
+	keyPair := ethutil.GetKeyRing().Get(0)
+	callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), script)
+	callerTx.Sign(keyPair.PrivateKey)
+
+	account := self.lib.eth.StateManager().TransState().GetStateObject(keyPair.Address())
+	contract := ethchain.MakeContract(callerTx, state)
+	callerClosure := ethchain.NewClosure(account, contract, contract.Init(), state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))
+
+	block := self.lib.eth.BlockChain().CurrentBlock
+	vm := ethchain.NewVm(state, self.lib.eth.StateManager(), ethchain.RuntimeVars{
+		Origin:      account.Address(),
+		BlockNumber: block.BlockInfo().Number,
+		PrevHash:    block.PrevHash,
+		Coinbase:    block.Coinbase,
+		Time:        block.Time,
+		Diff:        block.Difficulty,
+	})
+
+	self.Db.done = false
+	go func() {
+		callerClosure.Call(vm, contract.Init(), self.Db.halting)
+
+		state.Reset()
+
+		self.Db.done = true
+	}()
+}
+
+func (self *DebuggerWindow) Next() {
+	self.Db.Next()
+}
diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go
index 51fa26a88..c3f9f52e6 100644
--- a/ethereal/ui/ui_lib.go
+++ b/ethereal/ui/ui_lib.go
@@ -90,6 +90,12 @@ func (ui *UiLib) AssetPath(p string) string {
 	return path.Join(ui.assetPath, p)
 }
 
+func (self *UiLib) StartDebugger() {
+	dbWindow := NewDebuggerWindow(self)
+
+	dbWindow.Show()
+}
+
 func DefaultAssetPath() string {
 	var base string
 	// If the current working directory is the go-ethereum dir
@@ -163,9 +169,7 @@ func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string)
 }
 
 func (ui *UiLib) Next() {
-	if !ui.Db.done {
-		ui.Db.Next()
-	}
+	ui.Db.Next()
 }
 
 type Debugger struct {
@@ -200,5 +204,7 @@ out:
 }
 
 func (d *Debugger) Next() {
-	d.N <- true
+	if !d.done {
+		d.N <- true
+	}
 }
-- 
cgit v1.2.3


From 1ab865a994758cef8a6bf75a3cc263f16a97d847 Mon Sep 17 00:00:00 2001
From: Maran <maran.hidskes@gmail.com>
Date: Tue, 27 May 2014 11:49:42 +0200
Subject: Adding new blocks on broadcast

---
 ethereal/assets/qml/wallet.qml | 13 +++++++++++--
 ethereal/ui/gui.go             |  7 ++++---
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index 911422f91..e59e85ab3 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -642,13 +642,22 @@ ApplicationWindow {
 		txModel.insert(0, {inout: inout, hash: tx.hash, address: tx.address, value: tx.value, contract: isContract})
 	}
 
-	function addBlock(block) {
+	function addBlock(block, initial) {
 		var txs = JSON.parse(block.transactions);
 		var amount = 0
+		if(initial == undefined){
+			initial = false
+		}
+
 		if(txs != null){
 			amount = txs.length
 		}
-		blockModel.insert(0, {number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
+
+		if(initial){
+			blockModel.append({number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
+		}else{
+			blockModel.insert(0, {number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
+		}
 	}
 
 	function addLog(str) {
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 7577de1fa..18e13d985 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -141,7 +141,7 @@ func (gui *Gui) setInitialBlockChain() {
 	blk := gui.eth.BlockChain().GetBlock(sBlk)
 	for ; blk != nil; blk = gui.eth.BlockChain().GetBlock(sBlk) {
 		sBlk = blk.PrevHash
-		gui.processBlock(blk)
+		gui.processBlock(blk, true)
 	}
 }
 
@@ -163,8 +163,8 @@ func (gui *Gui) readPreviousTransactions() {
 	it.Release()
 }
 
-func (gui *Gui) processBlock(block *ethchain.Block) {
-	gui.win.Root().Call("addBlock", ethpub.NewPBlock(block))
+func (gui *Gui) processBlock(block *ethchain.Block, initial bool) {
+	gui.win.Root().Call("addBlock", ethpub.NewPBlock(block), initial)
 }
 
 func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) {
@@ -203,6 +203,7 @@ func (gui *Gui) update() {
 		select {
 		case b := <-blockChan:
 			block := b.Resource.(*ethchain.Block)
+			gui.processBlock(block, false)
 			if bytes.Compare(block.Coinbase, gui.addr) == 0 {
 				gui.setWalletValue(gui.eth.StateManager().CurrentState().GetAccount(gui.addr).Amount, nil)
 			}
-- 
cgit v1.2.3


From 6fe42f007c6f4816de88a2c4aad10754036d41b8 Mon Sep 17 00:00:00 2001
From: Maran <maran.hidskes@gmail.com>
Date: Tue, 27 May 2014 12:46:02 +0200
Subject: Uhm what

---
 ethereal/assets/qml/wallet.qml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index e59e85ab3..0c0c977c1 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -556,6 +556,7 @@ ApplicationWindow {
 
 					SplitView {
 						orientation: Qt.Horizontal
+						id: debugSplitView
 						TableView {
 							property var debuggerLog: ListModel {
 								id: debuggerLog
@@ -569,7 +570,7 @@ ApplicationWindow {
 							}
 							height: parent.height/2
 							width: parent.width
-							TableViewColumn{ role: "value" ; title: "Stack" ; width: parent.width }
+							TableViewColumn{ role: "value" ; title: "Stack" ; width: debugSplitView.width }
 							model: stackModel
 						}
 					}
-- 
cgit v1.2.3


From d0b31e203053f3f176e61719d877dcaa04169bb3 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Tue, 27 May 2014 13:09:47 +0200
Subject: New debugger

---
 ethereal/assets/debugger/debugger.qml | 310 ++++++++++++++++++++++------------
 ethereal/ui/debugger.go               |  55 +++++-
 ethereal/ui/ui_lib.go                 |  38 -----
 3 files changed, 258 insertions(+), 145 deletions(-)

diff --git a/ethereal/assets/debugger/debugger.qml b/ethereal/assets/debugger/debugger.qml
index b7d954e73..07a78411b 100644
--- a/ethereal/assets/debugger/debugger.qml
+++ b/ethereal/assets/debugger/debugger.qml
@@ -7,108 +7,210 @@ import QtQuick.Controls.Styles 1.1
 import Ethereum 1.0
 
 ApplicationWindow {
-	id: debugWindow
-	visible: false
-	title: "Debugger"
-	minimumWidth: 600
-	minimumHeight: 600
-	width: 800
-	height: 600
-
-	SplitView {
-		anchors.fill: parent
-		property var asmModel: ListModel {
-			id: asmModel
-		}
-		TableView {
-			id: asmTableView
-			width: 200
-			TableViewColumn{ role: "value" ; title: "" ; width: 100 }
-			model: asmModel
-		}
-
-		Rectangle {
-			anchors.left: asmTableView.right
-			anchors.right: parent.right
-			SplitView {
-				orientation: Qt.Vertical
-				anchors.fill: parent
-
-				TableView {
-					property var memModel: ListModel {
-						id: memModel
-					}
-					height: parent.height/2
-					width: parent.width
-					TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50}
-					TableViewColumn{ role: "value" ; title: "Memory" ; width: 750}
-					model: memModel
-				}
-
-				SplitView {
-					orientation: Qt.Horizontal
-					TableView {
-						property var debuggerLog: ListModel {
-							id: debuggerLog
-						}
-						TableViewColumn{ role: "value"; title: "Debug messages" }
-						model: debuggerLog
-					}
-					TableView {
-						property var stackModel: ListModel {
-							id: stackModel
-						}
-						height: parent.height/2
-						width: parent.width
-						TableViewColumn{ role: "value" ; title: "Stack" ; width: 200 }
-						model: stackModel
-					}
-				}
-			}
-		}
-	}
-	statusBar: StatusBar {
-		RowLayout {
-			anchors.fill: parent
-			Button {
-				property var enabled: true
-				id: debugNextButton
-				onClicked: {
-					//db.next()
-				}
-				text: "Next"
-			}
-		}
-	}
-
-	function setAsm(asm) {
-		asmModel.append({asm: asm})
-	}
-
-	function setInstruction(num) {
-		asmTableView.selection.clear()
-		asmTableView.selection.select(num-1)
-	}
-
-	function clearAsm() {
-		asmModel.clear()
-	}
-
-	function setMem(mem) {
-		memModel.append({num: mem.num, value: mem.value})
-	}
-	function clearMem(){
-		memModel.clear()
-	}
-
-	function setStack(stack) {
-		stackModel.append({value: stack})
-	}
-	function addDebugMessage(message){
-		debuggerLog.append({value: message})
-	}
-
-	function clearStack() {
-		stackModel.clear()
-	}
+    visible: false
+    title: "Debugger"
+    minimumWidth: 1280
+    minimumHeight: 900
+    width: 1290
+    height: 900
+
+    SplitView {
+        anchors.fill: parent
+        property var asmModel: ListModel {
+            id: asmModel
+        }
+        TableView {
+            id: asmTableView
+            width: 200
+            TableViewColumn{ role: "value" ; title: "" ; width: 100 }
+            model: asmModel
+        }
+
+        Rectangle {
+            color: "#00000000"
+            anchors.left: asmTableView.right
+            anchors.right: parent.right
+            SplitView {
+                orientation: Qt.Vertical
+                anchors.fill: parent
+
+                Rectangle {
+                    color: "#00000000"
+                    height: 500
+                    anchors.left: parent.left
+                    anchors.right: parent.right
+
+                    TextArea {
+                        id: codeEditor
+                        anchors.top: parent.top
+                        anchors.bottom: parent.bottom
+                        anchors.left: parent.left
+                        anchors.right: settings.left
+                    }
+
+                    Column {
+                        id: settings
+                        spacing: 5
+                        width: 300
+                        height: parent.height
+                        anchors.right: parent.right
+                        anchors.top: parent.top
+                        anchors.bottom: parent.bottom
+
+                        Label {
+                            text: "Data"
+                        }
+                        TextArea {
+                            anchors.left: parent.left
+                            anchors.right: parent.right
+                            height: 150
+                        }
+
+                        Label {
+                            text: "Amount"
+                        }
+                        TextField {
+                            id: txValue
+                            width: 200
+                            placeholderText: "Amount"
+                            validator: RegExpValidator { regExp: /\d*/ }
+                        }
+                        Label {
+                            text: "Amount of gas"
+                        }
+                        TextField {
+                            id: txGas
+                            width: 200
+                            validator: RegExpValidator { regExp: /\d*/ }
+                            text: "10000"
+                            placeholderText: "Gas"
+                        }
+                        Label {
+                            text: "Gas price"
+                        }
+                        TextField {
+                            id: txGasPrice
+                            width: 200
+                            placeholderText: "Gas price"
+                            text: "1000000000000"
+                            validator: RegExpValidator { regExp: /\d*/ }
+                        }
+                    }
+                }
+
+                SplitView {
+                    orientation: Qt.Vertical
+                    id: inspectorPane
+                    height: 500
+
+                    SplitView {
+                        orientation: Qt.Horizontal
+                        height: 300
+
+                        TableView {
+                            id: stackTableView
+                            property var stackModel: ListModel {
+                                id: stackModel
+                            }
+                            height: parent.height
+                            width: 300
+                            TableViewColumn{ role: "value" ; title: "Stack" ; width: 200 }
+                            model: stackModel
+                        }
+
+                        TableView {
+                            id: memoryTableView
+                            property var memModel: ListModel {
+                                id: memModel
+                            }
+                            height: parent.height
+                            width: parent.width - stackTableView.width
+                            TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50}
+                            TableViewColumn{ role: "value" ; title: "Memory" ; width: 750}
+                            model: memModel
+                        }
+                    }
+
+                    SplitView {
+                        height: 300
+                        TableView {
+                            id: storageTableView
+                            property var memModel: ListModel {
+                                id: storageModel
+                            }
+                            height: parent.height
+                            width: parent.width - stackTableView.width
+                            TableViewColumn{ id: key ; role: "key" ; title: "#" ; width: storageTableView.width / 2}
+                            TableViewColumn{ role: "value" ; title: "value" ; width:  storageTableView.width / 2}
+                            model: storageModel
+                        }
+                    }
+                }
+            }
+        }
+    }
+    statusBar: StatusBar {
+        RowLayout {
+            spacing: 5
+            anchors.fill: parent
+
+            Button {
+                property var enabled: true
+                id: debugStart
+                onClicked: {
+                    dbg.debug(txValue.text, txGas.text, txGasPrice.text, codeEditor.text)
+                }
+                text: "Debug"
+            }
+
+            Button {
+                property var enabled: true
+                id: debugNextButton
+                onClicked: {
+                    dbg.next()
+                }
+                text: "Next"
+            }
+        }
+    }
+
+    function setAsm(asm) {
+        console.log("set asm", asm)
+        asmModel.append({asm: asm})
+    }
+
+    function setInstruction(num) {
+        asmTableView.selection.clear()
+        asmTableView.selection.select(num-1)
+    }
+
+    function clearAsm() {
+        asmModel.clear()
+    }
+
+    function setMem(mem) {
+        memModel.append({num: mem.num, value: mem.value})
+    }
+    function clearMem(){
+        memModel.clear()
+    }
+
+    function setStack(stack) {
+        stackModel.append({value: stack})
+    }
+    function addDebugMessage(message){
+        debuggerLog.append({value: message})
+    }
+
+    function clearStack() {
+        stackModel.clear()
+    }
+
+    function clearStorage() {
+        storageModel.clear()
+    }
+
+    function setStorage(storage) {
+        storageModel.append({key: storage.key, value: storage.value})
+    }
 }
diff --git a/ethereal/ui/debugger.go b/ethereal/ui/debugger.go
index 4debc05b2..ce2d73b9a 100644
--- a/ethereal/ui/debugger.go
+++ b/ethereal/ui/debugger.go
@@ -30,13 +30,16 @@ func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
 }
 
 func (self *DebuggerWindow) Show() {
+	context := self.engine.Context()
+	context.SetVar("dbg", self)
+
 	go func() {
 		self.win.Show()
 		self.win.Wait()
 	}()
 }
 
-func (self *DebuggerWindow) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) {
+func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
 	state := self.lib.eth.BlockChain().CurrentBlock.State()
 
 	script, err := ethutil.Compile(data)
@@ -50,14 +53,14 @@ func (self *DebuggerWindow) DebugTx(recipient, valueStr, gasStr, gasPriceStr, da
 	self.lib.win.Root().Call("clearAsm")
 
 	for _, str := range dis {
-		self.lib.win.Root().Call("setAsm", str)
+		self.win.Root().Call("setAsm", str)
 	}
 	// Contract addr as test address
 	keyPair := ethutil.GetKeyRing().Get(0)
 	callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), script)
 	callerTx.Sign(keyPair.PrivateKey)
 
-	account := self.lib.eth.StateManager().TransState().GetStateObject(keyPair.Address())
+	account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
 	contract := ethchain.MakeContract(callerTx, state)
 	callerClosure := ethchain.NewClosure(account, contract, contract.Init(), state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))
 
@@ -84,3 +87,49 @@ func (self *DebuggerWindow) DebugTx(recipient, valueStr, gasStr, gasPriceStr, da
 func (self *DebuggerWindow) Next() {
 	self.Db.Next()
 }
+
+type Debugger struct {
+	win  *qml.Window
+	N    chan bool
+	done bool
+}
+
+type storeVal struct {
+	Key, Value string
+}
+
+func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) {
+	d.win.Root().Call("setInstruction", pc)
+	d.win.Root().Call("clearMem")
+	d.win.Root().Call("clearStack")
+	d.win.Root().Call("clearStorage")
+
+	addr := 0
+	for i := 0; i+32 <= mem.Len(); i += 32 {
+		d.win.Root().Call("setMem", memAddr{fmt.Sprintf("%03d", addr), fmt.Sprintf("% x", mem.Data()[i:i+32])})
+		addr++
+	}
+
+	for _, val := range stack.Data() {
+		d.win.Root().Call("setStack", val.String())
+	}
+
+	stateObject.State().EachStorage(func(key string, node *ethutil.Value) {
+		d.win.Root().Call("setStorage", storeVal{fmt.Sprintf("% x", key), fmt.Sprintf("% x", node.Str())})
+	})
+
+out:
+	for {
+		select {
+		case <-d.N:
+			break out
+		default:
+		}
+	}
+}
+
+func (d *Debugger) Next() {
+	if !d.done {
+		d.N <- true
+	}
+}
diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go
index c3f9f52e6..998392525 100644
--- a/ethereal/ui/ui_lib.go
+++ b/ethereal/ui/ui_lib.go
@@ -2,7 +2,6 @@ package ethui
 
 import (
 	"bitbucket.org/kardianos/osext"
-	"fmt"
 	"github.com/ethereum/eth-go"
 	"github.com/ethereum/eth-go/ethchain"
 	"github.com/ethereum/eth-go/ethutil"
@@ -171,40 +170,3 @@ func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string)
 func (ui *UiLib) Next() {
 	ui.Db.Next()
 }
-
-type Debugger struct {
-	win  *qml.Window
-	N    chan bool
-	done bool
-}
-
-func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack) {
-	d.win.Root().Call("setInstruction", pc)
-	d.win.Root().Call("clearMem")
-	d.win.Root().Call("clearStack")
-
-	addr := 0
-	for i := 0; i+32 <= mem.Len(); i += 32 {
-		d.win.Root().Call("setMem", memAddr{fmt.Sprintf("%03d", addr), fmt.Sprintf("% x", mem.Data()[i:i+32])})
-		addr++
-	}
-
-	for _, val := range stack.Data() {
-		d.win.Root().Call("setStack", val.String())
-	}
-
-out:
-	for {
-		select {
-		case <-d.N:
-			break out
-		default:
-		}
-	}
-}
-
-func (d *Debugger) Next() {
-	if !d.done {
-		d.N <- true
-	}
-}
-- 
cgit v1.2.3


From 47417506c377dd0848739473fa14a51708b6a034 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Tue, 27 May 2014 13:28:11 +0200
Subject: New debugger implemented

---
 ethereal/assets/debugger/debugger.qml |  9 ++++-----
 ethereal/assets/qml/wallet.qml        |  8 --------
 ethereal/ui/debugger.go               | 24 ++++++++++++++++++++----
 ethereal/ui/gui.go                    |  2 +-
 4 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/ethereal/assets/debugger/debugger.qml b/ethereal/assets/debugger/debugger.qml
index 07a78411b..bf69b4254 100644
--- a/ethereal/assets/debugger/debugger.qml
+++ b/ethereal/assets/debugger/debugger.qml
@@ -175,19 +175,18 @@ ApplicationWindow {
     }
 
     function setAsm(asm) {
-        console.log("set asm", asm)
         asmModel.append({asm: asm})
     }
 
+    function clearAsm() {
+        asmModel.clear()
+    }
+
     function setInstruction(num) {
         asmTableView.selection.clear()
         asmTableView.selection.select(num-1)
     }
 
-    function clearAsm() {
-        asmModel.clear()
-    }
-
     function setMem(mem) {
         memModel.append({num: mem.num, value: mem.value})
     }
diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index 40de8624e..4aa22dddc 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -306,14 +306,6 @@ ApplicationWindow {
 				text: "Connect"
 			}
 			*/
-			Button {
-				property var enabled: true
-				id: debuggerWindow
-				onClicked: {
-					ui.startDebugger()
-				}
-				text: "Debugger"
-			}
 
 			Button {
 				id: importAppButton
diff --git a/ethereal/ui/debugger.go b/ethereal/ui/debugger.go
index ce2d73b9a..817c0b08f 100644
--- a/ethereal/ui/debugger.go
+++ b/ethereal/ui/debugger.go
@@ -24,7 +24,7 @@ func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
 	}
 
 	win := component.CreateWindow(nil)
-	db := &Debugger{win, make(chan bool), true}
+	db := &Debugger{win, make(chan bool), make(chan bool), true}
 
 	return &DebuggerWindow{engine: engine, win: win, lib: lib, Db: db}
 }
@@ -40,8 +40,18 @@ func (self *DebuggerWindow) Show() {
 }
 
 func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
+	if !self.Db.done {
+		self.Db.Q <- true
+	}
+
 	state := self.lib.eth.BlockChain().CurrentBlock.State()
 
+	defer func() {
+		if r := recover(); r != nil {
+			fmt.Println(r)
+		}
+	}()
+
 	script, err := ethutil.Compile(data)
 	if err != nil {
 		ethutil.Config.Log.Debugln(err)
@@ -50,7 +60,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
 	}
 
 	dis := ethchain.Disassemble(script)
-	self.lib.win.Root().Call("clearAsm")
+	self.win.Root().Call("clearAsm")
 
 	for _, str := range dis {
 		self.win.Root().Call("setAsm", str)
@@ -91,6 +101,7 @@ func (self *DebuggerWindow) Next() {
 type Debugger struct {
 	win  *qml.Window
 	N    chan bool
+	Q    chan bool
 	done bool
 }
 
@@ -98,7 +109,7 @@ type storeVal struct {
 	Key, Value string
 }
 
-func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) {
+func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) bool {
 	d.win.Root().Call("setInstruction", pc)
 	d.win.Root().Call("clearMem")
 	d.win.Root().Call("clearStack")
@@ -123,9 +134,14 @@ out:
 		select {
 		case <-d.N:
 			break out
-		default:
+		case <-d.Q:
+			d.done = true
+
+			return false
 		}
 	}
+
+	return true
 }
 
 func (d *Debugger) Next() {
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 1018d77ac..ca6da5c49 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -130,7 +130,7 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window {
 	gui.win = win
 	gui.uiLib.win = win
 
-	db := &Debugger{gui.win, make(chan bool), true}
+	db := &Debugger{gui.win, make(chan bool), make(chan bool), true}
 	gui.lib.Db = db
 	gui.uiLib.Db = db
 
-- 
cgit v1.2.3


From a0f73c2703aacab189c5cf26a5c95e156039eb9e Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Tue, 27 May 2014 16:09:04 +0200
Subject: Minor fixes and improvements to the ui

---
 ethereal/assets/debugger/debugger.qml |  12 ++++++------
 ethereal/assets/heart.png             | Bin 0 -> 4277 bytes
 ethereal/assets/qml/wallet.qml        |  21 ++++-----------------
 ethereal/ui/debugger.go               |  34 ++++++++++++++++++++++++++++++----
 4 files changed, 40 insertions(+), 27 deletions(-)
 create mode 100644 ethereal/assets/heart.png

diff --git a/ethereal/assets/debugger/debugger.qml b/ethereal/assets/debugger/debugger.qml
index bf69b4254..9ea131d7d 100644
--- a/ethereal/assets/debugger/debugger.qml
+++ b/ethereal/assets/debugger/debugger.qml
@@ -8,7 +8,7 @@ import Ethereum 1.0
 
 ApplicationWindow {
     visible: false
-    title: "Debugger"
+    title: "IceCream"
     minimumWidth: 1280
     minimumHeight: 900
     width: 1290
@@ -58,9 +58,10 @@ ApplicationWindow {
                         anchors.bottom: parent.bottom
 
                         Label {
-                            text: "Data"
+                            text: "Arbitrary data"
                         }
                         TextArea {
+                            id: rawDataField
                             anchors.left: parent.left
                             anchors.right: parent.right
                             height: 150
@@ -105,7 +106,7 @@ ApplicationWindow {
 
                     SplitView {
                         orientation: Qt.Horizontal
-                        height: 300
+                        height: 250
 
                         TableView {
                             id: stackTableView
@@ -149,16 +150,15 @@ ApplicationWindow {
             }
         }
     }
-    statusBar: StatusBar {
+    toolBar: ToolBar {
         RowLayout {
             spacing: 5
-            anchors.fill: parent
 
             Button {
                 property var enabled: true
                 id: debugStart
                 onClicked: {
-                    dbg.debug(txValue.text, txGas.text, txGasPrice.text, codeEditor.text)
+                    dbg.debug(txValue.text, txGas.text, txGasPrice.text, codeEditor.text, rawDataField.text)
                 }
                 text: "Debug"
             }
diff --git a/ethereal/assets/heart.png b/ethereal/assets/heart.png
new file mode 100644
index 000000000..3c874ab7f
Binary files /dev/null and b/ethereal/assets/heart.png differ
diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index 3063bb10d..5e0904a20 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -123,7 +123,7 @@ ApplicationWindow {
 				}
 
 				Image {
-					source: ui.assetPath("net.png")
+					source: ui.assetPath("heart.png")
 					anchors.horizontalCenter: parent.horizontalCenter
 					MouseArea {
 						anchors.fill: parent
@@ -284,27 +284,14 @@ ApplicationWindow {
 		title: "Open QML Application"
 		onAccepted: {
 			//ui.open(openAppDialog.fileUrl.toString())
-      //ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html")))
-      ui.openHtml(openAppDialog.fileUrl.toString())
-
+			//ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html")))
+			ui.openHtml(openAppDialog.fileUrl.toString())
 		}
 	}
 
 	statusBar: StatusBar {
 		RowLayout {
 			anchors.fill: parent
-			/*
-			Button {
-				property var enabled: true
-				id: connectButton
-				onClicked: {
-					if(this.enabled) {
-						ui.connect(this)
-					}
-				}
-				text: "Connect"
-			}
-			*/
 
 			Button {
 				property var enabled: true
@@ -369,8 +356,8 @@ ApplicationWindow {
 					Text { text: '<b>Hash:</b> ' + hash; color: "#F2F2F2"}
 					Text { text: '<b>Block found at:</b> ' + prettyTime; color: "#F2F2F2"}
 				}
+			}
 		}
-	}
 		ListView {
 			model: singleBlock
 			delegate: blockDetailsDelegate
diff --git a/ethereal/ui/debugger.go b/ethereal/ui/debugger.go
index 817c0b08f..8b27c2fe5 100644
--- a/ethereal/ui/debugger.go
+++ b/ethereal/ui/debugger.go
@@ -5,6 +5,8 @@ import (
 	"github.com/ethereum/eth-go/ethchain"
 	"github.com/ethereum/eth-go/ethutil"
 	"github.com/go-qml/qml"
+	"math/big"
+	"strings"
 )
 
 type DebuggerWindow struct {
@@ -39,11 +41,35 @@ func (self *DebuggerWindow) Show() {
 	}()
 }
 
-func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
+func formatData(data string) []byte {
+	if len(data) == 0 {
+		return nil
+	}
+	// Simple stupid
+	d := new(big.Int)
+	if data[0:1] == "\"" && data[len(data)-1:] == "\"" {
+		d.SetBytes([]byte(data[1 : len(data)-1]))
+	} else if data[:2] == "0x" {
+		d.SetBytes(ethutil.FromHex(data[2:]))
+	} else {
+		d.SetString(data, 0)
+	}
+
+	return ethutil.BigToBytes(d, 256)
+}
+
+func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, dataStr string) {
 	if !self.Db.done {
 		self.Db.Q <- true
 	}
 
+	dataSlice := strings.Split(dataStr, "\n")
+	var data []byte
+	for _, dataItem := range dataSlice {
+		d := formatData(dataItem)
+		data = append(data, d...)
+	}
+
 	state := self.lib.eth.BlockChain().CurrentBlock.State()
 
 	defer func() {
@@ -52,7 +78,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
 		}
 	}()
 
-	script, err := ethutil.Compile(data)
+	script, err := ethutil.Compile(scriptStr)
 	if err != nil {
 		ethutil.Config.Log.Debugln(err)
 
@@ -72,7 +98,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
 
 	account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
 	contract := ethchain.MakeContract(callerTx, state)
-	callerClosure := ethchain.NewClosure(account, contract, contract.Init(), state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))
+	callerClosure := ethchain.NewClosure(account, contract, script, state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))
 
 	block := self.lib.eth.BlockChain().CurrentBlock
 	vm := ethchain.NewVm(state, self.lib.eth.StateManager(), ethchain.RuntimeVars{
@@ -86,7 +112,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
 
 	self.Db.done = false
 	go func() {
-		callerClosure.Call(vm, contract.Init(), self.Db.halting)
+		callerClosure.Call(vm, data, self.Db.halting)
 
 		state.Reset()
 
-- 
cgit v1.2.3


From 34b861c19c02947503a175f7b2be6c880a007d11 Mon Sep 17 00:00:00 2001
From: obscuren <geffobscura@gmail.com>
Date: Tue, 27 May 2014 16:10:15 +0200
Subject: bump

---
 README.md          | 2 +-
 ethereal/ui/gui.go | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 6c19be9aa..a47ce7e25 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Ethereum
 
 Ethereum Go Client © 2014 Jeffrey Wilcke.
 
-Current state: Proof of Concept 5.0 RC9.
+Current state: Proof of Concept 5.0 RC10.
 
 For the development package please see the [eth-go package](https://github.com/ethereum/eth-go).
 
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index b49fafac1..63ab028ab 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -54,7 +54,7 @@ func New(ethereum *eth.Ethereum) *Gui {
 }
 
 func (gui *Gui) Start(assetPath string) {
-	const version = "0.5.0 RC9"
+	const version = "0.5.0 RC10"
 
 	defer gui.txDb.Close()
 
-- 
cgit v1.2.3