Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
3e8b27c9
Commit
3e8b27c9
authored
Feb 21, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP library, sample app
parent
95a48cea
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
140 additions
and
24 deletions
+140
-24
test_app.qml
test_app.qml
+35
-0
gui.go
ui/gui.go
+25
-3
library.go
ui/library.go
+42
-0
wallet.qml
wallet.qml
+38
-21
No files found.
test_app.qml
0 → 100644
View file @
3e8b27c9
import
QtQuick
2.0
import
QtQuick
.
Controls
1.0
;
import
QtQuick
.
Layouts
1.0
;
import
GoExtensions
1.0
ApplicationWindow
{
minimumWidth
:
500
maximumWidth
:
500
maximumHeight
:
100
minimumHeight
:
100
title
:
"Ethereum Dice"
TextField
{
id
:
textField
anchors.verticalCenter
:
parent
.
verticalCenter
anchors.horizontalCenter
:
parent
.
horizontalCenter
placeholderText
:
"Amount"
}
Label
{
id
:
txHash
anchors.bottom
:
textField
.
top
anchors.bottomMargin
:
5
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
Button
{
anchors.top
:
textField
.
bottom
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.topMargin
:
5
text
:
"Place bet"
onClicked
:
{
txHash
.
text
=
eth
.
createTx
(
"e6716f9544a56c530d868e4bfbacb172315bdead"
,
parseInt
(
textField
.
text
))
}
}
}
ui/gui.go
View file @
3e8b27c9
...
@@ -17,10 +17,15 @@ type Gui struct {
...
@@ -17,10 +17,15 @@ type Gui struct {
engine
*
qml
.
Engine
engine
*
qml
.
Engine
component
*
qml
.
Common
component
*
qml
.
Common
eth
*
eth
.
Ethereum
eth
*
eth
.
Ethereum
// The Ethereum library
lib
*
EthLib
}
}
func
New
(
ethereum
*
eth
.
Ethereum
)
*
Gui
{
func
New
(
ethereum
*
eth
.
Ethereum
)
*
Gui
{
return
&
Gui
{
eth
:
ethereum
}
lib
:=
&
EthLib
{
blockManager
:
ethereum
.
BlockManager
,
blockChain
:
ethereum
.
BlockManager
.
BlockChain
(),
txPool
:
ethereum
.
TxPool
}
return
&
Gui
{
eth
:
ethereum
,
lib
:
lib
}
}
}
type
Block
struct
{
type
Block
struct
{
...
@@ -48,10 +53,10 @@ func (ui *Gui) Start() {
...
@@ -48,10 +53,10 @@ func (ui *Gui) Start() {
}
}
ui
.
win
=
component
.
CreateWindow
(
nil
)
ui
.
win
=
component
.
CreateWindow
(
nil
)
root
:=
ui
.
win
.
Root
()
context
:=
ui
.
engine
.
Context
()
context
:=
ui
.
engine
.
Context
()
context
.
SetVar
(
"tester"
,
&
Tester
{
root
:
root
})
context
.
SetVar
(
"eth"
,
ui
.
lib
)
context
.
SetVar
(
"ui"
,
&
UiLib
{
engine
:
ui
.
engine
})
ui
.
eth
.
BlockManager
.
SecondaryBlockProcessor
=
ui
ui
.
eth
.
BlockManager
.
SecondaryBlockProcessor
=
ui
...
@@ -82,6 +87,23 @@ func (ui *Gui) updatePeers() {
...
@@ -82,6 +87,23 @@ func (ui *Gui) updatePeers() {
}
}
}
}
type
UiLib
struct
{
engine
*
qml
.
Engine
}
func
(
ui
*
UiLib
)
Open
(
path
string
)
{
component
,
err
:=
ui
.
engine
.
LoadFile
(
path
[
7
:
])
if
err
!=
nil
{
ethutil
.
Config
.
Log
.
Debugln
(
err
)
}
win
:=
component
.
CreateWindow
(
nil
)
go
func
()
{
win
.
Show
()
win
.
Wait
()
}()
}
type
Tester
struct
{
type
Tester
struct
{
root
qml
.
Object
root
qml
.
Object
}
}
...
...
ui/library.go
0 → 100644
View file @
3e8b27c9
package
ethui
import
(
"encoding/hex"
"fmt"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"math/big"
)
type
EthLib
struct
{
blockManager
*
ethchain
.
BlockManager
blockChain
*
ethchain
.
BlockChain
txPool
*
ethchain
.
TxPool
}
func
(
lib
*
EthLib
)
CreateTx
(
receiver
string
,
amount
uint64
)
string
{
hash
,
err
:=
hex
.
DecodeString
(
receiver
)
if
err
!=
nil
{
return
err
.
Error
()
}
tx
:=
ethchain
.
NewTransaction
(
hash
,
big
.
NewInt
(
int64
(
amount
)),
[]
string
{
""
})
data
,
_
:=
ethutil
.
Config
.
Db
.
Get
([]
byte
(
"KeyRing"
))
keyRing
:=
ethutil
.
NewValueFromBytes
(
data
)
tx
.
Sign
(
keyRing
.
Get
(
0
)
.
Bytes
())
lib
.
txPool
.
QueueTransaction
(
tx
)
return
ethutil
.
Hex
(
tx
.
Hash
())
}
func
(
lib
*
EthLib
)
GetBlock
(
hexHash
string
)
*
Block
{
hash
,
err
:=
hex
.
DecodeString
(
hexHash
)
if
err
!=
nil
{
return
nil
}
block
:=
lib
.
blockChain
.
GetBlock
(
hash
)
fmt
.
Println
(
block
)
return
&
Block
{
Number
:
int
(
block
.
BlockInfo
()
.
Number
),
Hash
:
ethutil
.
Hex
(
block
.
Hash
())}
}
wallet.qml
View file @
3e8b27c9
import
QtQuick
2.0
import
QtQuick
2.0
import
QtQuick
.
Controls
1.0
;
import
QtQuick
.
Controls
1.0
;
import
QtQuick
.
Layouts
1.0
;
import
QtQuick
.
Layouts
1.0
;
import
QtQuick
.
Dialogs
1.0
;
import
GoExtensions
1.0
import
GoExtensions
1.0
ApplicationWindow
{
ApplicationWindow
{
...
@@ -12,6 +13,7 @@ ApplicationWindow {
...
@@ -12,6 +13,7 @@ ApplicationWindow {
title
:
"Ethereal"
title
:
"Ethereal"
toolBar
:
ToolBar
{
toolBar
:
ToolBar
{
id
:
mainToolbar
id
:
mainToolbar
...
@@ -19,7 +21,7 @@ ApplicationWindow {
...
@@ -19,7 +21,7 @@ ApplicationWindow {
width
:
parent
.
width
width
:
parent
.
width
Button
{
Button
{
text
:
"Send"
text
:
"Send"
onClicked
:
tester
.
compile
(
codeView
)
onClicked
:
console
.
log
(
"SEND"
)
}
}
TextField
{
TextField
{
...
@@ -66,12 +68,28 @@ ApplicationWindow {
...
@@ -66,12 +68,28 @@ ApplicationWindow {
TableViewColumn
{
role
:
"hash"
;
title
:
"Hash"
;
width
:
560
}
TableViewColumn
{
role
:
"hash"
;
title
:
"Hash"
;
width
:
560
}
model
:
blockModel
model
:
blockModel
onDoubleClicked
:
{
console
.
log
(
eth
.
getBlock
(
blockModel
.
get
(
row
).
hash
))
}
}
}
FileDialog
{
id
:
openAppDialog
title
:
"Open QML Application"
onAccepted
:
{
ui
.
open
(
openAppDialog
.
fileUrl
.
toString
())
}
}
statusBar
:
StatusBar
{
statusBar
:
StatusBar
{
RowLayout
{
RowLayout
{
anchors.fill
:
parent
anchors.fill
:
parent
Button
{
onClicked
:
openAppDialog
.
open
()
text
:
"Import App"
}
Label
{
text
:
"0.0.1"
}
Label
{
text
:
"0.0.1"
}
Label
{
Label
{
anchors.right
:
peerImage
.
left
anchors.right
:
peerImage
.
left
...
@@ -80,7 +98,6 @@ ApplicationWindow {
...
@@ -80,7 +98,6 @@ ApplicationWindow {
font.pixelSize
:
8
font.pixelSize
:
8
text
:
"0 / 0"
text
:
"0 / 0"
}
}
Image
{
Image
{
id
:
peerImage
id
:
peerImage
anchors.right
:
parent
.
right
anchors.right
:
parent
.
right
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment