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
bb72347a
Commit
bb72347a
authored
Apr 23, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fixes and sample coin "improvements"
parent
43f1214f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
108 additions
and
23 deletions
+108
-23
ethereum.js
ethereal/assets/ethereum.js
+12
-0
icon.png
ethereal/assets/icon.png
+0
-0
webapp.qml
ethereal/assets/qml/webapp.qml
+20
-3
test.html
ethereal/assets/test.html
+37
-17
ethereum.go
ethereal/ethereum.go
+1
-1
gui.go
ethereal/ui/gui.go
+13
-1
library.go
ethereal/ui/library.go
+24
-0
ui_lib.go
ethereal/ui/ui_lib.go
+1
-1
No files found.
ethereal/assets/ethereum.js
View file @
bb72347a
...
@@ -5,6 +5,10 @@ function postData(data, cb) {
...
@@ -5,6 +5,10 @@ function postData(data, cb) {
eth
.
_callbacks
[
data
.
_seed
]
=
cb
;
eth
.
_callbacks
[
data
.
_seed
]
=
cb
;
}
}
if
(
data
.
args
===
undefined
)
{
data
.
args
=
[]
}
navigator
.
qt
.
postMessage
(
JSON
.
stringify
(
data
));
navigator
.
qt
.
postMessage
(
JSON
.
stringify
(
data
));
}
}
...
@@ -34,6 +38,14 @@ window.eth = {
...
@@ -34,6 +38,14 @@ window.eth = {
createTx
:
function
(
recipient
,
value
,
gas
,
gasPrice
,
data
,
cb
)
{
createTx
:
function
(
recipient
,
value
,
gas
,
gasPrice
,
data
,
cb
)
{
postData
({
call
:
"createTx"
,
args
:
[
recipient
,
value
,
gas
,
gasPrice
,
data
]},
cb
)
postData
({
call
:
"createTx"
,
args
:
[
recipient
,
value
,
gas
,
gasPrice
,
data
]},
cb
)
},
},
getStorage
:
function
(
address
,
storageAddress
,
cb
)
{
postData
({
call
:
"getStorage"
,
args
:
[
address
,
storageAddress
]},
cb
)
},
getKey
:
function
(
cb
)
{
postData
({
call
:
"getKey"
},
cb
)
},
}
}
window
.
eth
.
_callbacks
=
{}
window
.
eth
.
_callbacks
=
{}
...
...
ethereal/assets/icon.png
0 → 100644
View file @
bb72347a
84.7 KB
ethereal/assets/qml/webapp.qml
View file @
bb72347a
...
@@ -25,12 +25,15 @@ ApplicationWindow {
...
@@ -25,12 +25,15 @@ ApplicationWindow {
WebView
{
WebView
{
objectName
:
"webView"
objectName
:
"webView"
id
:
webview
id
:
webview
anchors.fill
:
parent
/*
anchors {
anchors {
left: parent.left
left: parent.left
right: parent.right
right: parent.right
bottom: sizeGrip.top
bottom: sizeGrip.top
top: parent.top
top: parent.top
}
}
*/
onTitleChanged
:
{
window
.
title
=
title
}
onTitleChanged
:
{
window
.
title
=
title
}
experimental.preferences.javascriptEnabled
:
true
experimental.preferences.javascriptEnabled
:
true
...
@@ -38,7 +41,7 @@ ApplicationWindow {
...
@@ -38,7 +41,7 @@ ApplicationWindow {
experimental.preferences.developerExtrasEnabled
:
true
experimental.preferences.developerExtrasEnabled
:
true
experimental.userScripts
:
[
ui
.
assetPath
(
"ethereum.js"
)]
experimental.userScripts
:
[
ui
.
assetPath
(
"ethereum.js"
)]
experimental.onMessageReceived
:
{
experimental.onMessageReceived
:
{
console
.
log
(
"[onMessageReceived]: "
,
message
.
data
)
//
console.log("[onMessageReceived]: ", message.data)
var
data
=
JSON
.
parse
(
message
.
data
)
var
data
=
JSON
.
parse
(
message
.
data
)
switch
(
data
.
call
)
{
switch
(
data
.
call
)
{
...
@@ -57,6 +60,20 @@ ApplicationWindow {
...
@@ -57,6 +60,20 @@ ApplicationWindow {
var
tx
=
eth
.
createTx
(
data
.
args
[
0
],
data
.
args
[
1
],
data
.
args
[
2
],
data
.
args
[
3
],
data
.
args
[
4
])
var
tx
=
eth
.
createTx
(
data
.
args
[
0
],
data
.
args
[
1
],
data
.
args
[
2
],
data
.
args
[
3
],
data
.
args
[
4
])
postData
(
data
.
_seed
,
tx
)
postData
(
data
.
_seed
,
tx
)
}
}
break
case
"getStorage"
:
if
(
data
.
args
.
length
<
2
)
{
postData
(
data
.
_seed
,
null
)
}
else
{
var
stateObject
=
eth
.
getStateObject
(
data
.
args
[
0
])
var
storage
=
stateObject
.
getStorage
(
data
.
args
[
1
])
postData
(
data
.
_seed
,
storage
)
}
break
case
"getKey"
:
var
keys
=
eth
.
getKey
()
postData
(
data
.
_seed
,
keys
)
break
}
}
}
}
function
postData
(
seed
,
data
)
{
function
postData
(
seed
,
data
)
{
...
@@ -67,7 +84,7 @@ ApplicationWindow {
...
@@ -67,7 +84,7 @@ ApplicationWindow {
Rectangle
{
Rectangle
{
id
:
sizeGrip
id
:
sizeGrip
color
:
"gray"
color
:
"gray"
visible
:
tru
e
visible
:
fals
e
height
:
10
height
:
10
anchors
{
anchors
{
left
:
root
.
left
left
:
root
.
left
...
@@ -86,7 +103,7 @@ ApplicationWindow {
...
@@ -86,7 +103,7 @@ ApplicationWindow {
WebView
{
WebView
{
id
:
inspector
id
:
inspector
visible
:
tru
e
visible
:
fals
e
url
:
webview
.
experimental
.
remoteInspectorUrl
url
:
webview
.
experimental
.
remoteInspectorUrl
anchors
{
anchors
{
left
:
root
.
left
left
:
root
.
left
...
...
ethereal/assets/test.html
View file @
bb72347a
<html>
<html>
<head>
<head>
<title>
jeffcoin
</title>
<title>
jeffcoin
</title>
<body>
<h1>
Jeff Coin
</h1>
<img
src=
"file:///Users/jeffrey/Desktop/iconnew.png"
>
<div
id=
"transactions"
>
<input
id=
"addr"
type=
"text"
placeholder=
"Receiver address"
></input><br>
<input
id=
"amount"
type=
"text"
placeholder=
"Amount"
></input><br>
<button
onclick=
"createTransaction();"
>
Send Tx
</button>
</div>
<div><button
onclick=
"test();"
>
Tests
</button></div>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
var
jefcoinAddr
=
"3dff537f51350239abc95c76a5864aa605259e7d"
function
createTransaction
()
{
function
createTransaction
()
{
debug
(
"test"
)
var
addr
=
document
.
querySelector
(
"#addr"
).
value
;
var
addr
=
document
.
querySelector
(
"#addr"
).
value
;
var
amount
=
document
.
querySelector
(
"#amount"
).
value
;
var
amount
=
document
.
querySelector
(
"#amount"
).
value
;
eth
.
createTx
(
addr
,
amount
,
"100"
,
"250"
,
""
,
function
(
tx
)
{
var
data
=
"0x"
+
addr
+
"
\n
"
+
amount
eth
.
createTx
(
jefcoinAddr
,
0
,
"10000000"
,
"250"
,
data
,
function
(
tx
)
{
debug
(
"received tx hash:"
,
tx
)
debug
(
"received tx hash:"
,
tx
)
})
})
}
}
// Any test related actions here please
// Any test related actions here please
function
tests
()
{
function
tests
()
{
eth
.
getBlock
(
1
,
function
(
block
)
{
eth
.
getKey
(
function
(
keys
)
{
debug
(
"queried block:"
,
block
)
debug
(
keys
)
})
}
function
init
()
{
eth
.
getKey
(
function
(
key
)
{
eth
.
getStorage
(
jefcoinAddr
,
key
,
function
(
storage
)
{
debug
(
"Currently in storage: "
,
storage
);
document
.
querySelector
(
"#currentAmount"
).
innerHTML
=
"Amount: "
+
storage
;
})
})
})
}
}
</script>
</script>
<style
type=
"text/css"
>
input
[
type
=
"text"
]
{
width
:
300px
;
}
</style>
</head>
<body
onload=
"init();"
>
<h1>
Jeff Coin
</h1>
<img
src=
"icon.png"
>
<div
id=
"currentAmount"
></div>
<div
id=
"transactions"
>
<input
id=
"addr"
type=
"text"
placeholder=
"Receiver address"
></input><br>
<input
id=
"amount"
type=
"text"
placeholder=
"Amount"
></input><br>
<button
onclick=
"createTransaction();"
>
Send Tx
</button>
</div>
<div><button
onclick=
"tests();"
>
Tests
</button></div>
<div
id=
"debug"
style=
"border: 1px solid block"
></div>
<div
id=
"debug"
style=
"border: 1px solid block"
></div>
...
...
ethereal/ethereum.go
View file @
bb72347a
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"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/
niemeyer
/qml"
"github.com/
go-qml
/qml"
"log"
"log"
"os"
"os"
"os/signal"
"os/signal"
...
...
ethereal/ui/gui.go
View file @
bb72347a
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/
niemeyer
/qml"
"github.com/
go-qml
/qml"
"math/big"
"math/big"
"strings"
"strings"
)
)
...
@@ -24,6 +24,18 @@ type Tx struct {
...
@@ -24,6 +24,18 @@ type Tx struct {
Contract
bool
Contract
bool
}
}
type
Key
struct
{
Address
string
}
type
KeyRing
struct
{
Keys
[]
interface
{}
}
func
NewKeyRing
(
keys
[]
interface
{})
*
KeyRing
{
return
&
KeyRing
{
Keys
:
keys
}
}
func
NewTxFromTransaction
(
tx
*
ethchain
.
Transaction
)
*
Tx
{
func
NewTxFromTransaction
(
tx
*
ethchain
.
Transaction
)
*
Tx
{
hash
:=
hex
.
EncodeToString
(
tx
.
Hash
())
hash
:=
hex
.
EncodeToString
(
tx
.
Hash
())
sender
:=
hex
.
EncodeToString
(
tx
.
Recipient
)
sender
:=
hex
.
EncodeToString
(
tx
.
Recipient
)
...
...
ethereal/ui/library.go
View file @
bb72347a
...
@@ -10,6 +10,20 @@ import (
...
@@ -10,6 +10,20 @@ import (
"strings"
"strings"
)
)
type
Contract
struct
{
object
*
ethchain
.
StateObject
}
func
NewContract
(
object
*
ethchain
.
StateObject
)
*
Contract
{
return
&
Contract
{
object
:
object
}
}
func
(
c
*
Contract
)
GetStorage
(
address
string
)
string
{
val
:=
c
.
object
.
GetMem
(
ethutil
.
Big
(
"0x"
+
address
))
return
val
.
BigInt
()
.
String
()
}
type
EthLib
struct
{
type
EthLib
struct
{
stateManager
*
ethchain
.
StateManager
stateManager
*
ethchain
.
StateManager
blockChain
*
ethchain
.
BlockChain
blockChain
*
ethchain
.
BlockChain
...
@@ -43,6 +57,16 @@ func (lib *EthLib) CreateAndSetPrivKey() (string, string, string, string) {
...
@@ -43,6 +57,16 @@ func (lib *EthLib) CreateAndSetPrivKey() (string, string, string, string) {
return
mnemonicString
,
fmt
.
Sprintf
(
"%x"
,
pair
.
Address
()),
fmt
.
Sprintf
(
"%x"
,
prv
),
fmt
.
Sprintf
(
"%x"
,
pub
)
return
mnemonicString
,
fmt
.
Sprintf
(
"%x"
,
pair
.
Address
()),
fmt
.
Sprintf
(
"%x"
,
prv
),
fmt
.
Sprintf
(
"%x"
,
pub
)
}
}
func
(
lib
*
EthLib
)
GetKey
()
string
{
return
ethutil
.
Hex
(
ethutil
.
Config
.
Db
.
GetKeys
()[
0
]
.
Address
())
}
func
(
lib
*
EthLib
)
GetStateObject
(
address
string
)
*
Contract
{
stateObject
:=
lib
.
stateManager
.
ProcState
()
.
GetContract
(
ethutil
.
FromHex
(
address
))
return
NewContract
(
stateObject
)
}
func
(
lib
*
EthLib
)
CreateTx
(
recipient
,
valueStr
,
gasStr
,
gasPriceStr
,
dataStr
string
)
(
string
,
error
)
{
func
(
lib
*
EthLib
)
CreateTx
(
recipient
,
valueStr
,
gasStr
,
gasPriceStr
,
dataStr
string
)
(
string
,
error
)
{
var
hash
[]
byte
var
hash
[]
byte
var
contractCreation
bool
var
contractCreation
bool
...
...
ethereal/ui/ui_lib.go
View file @
bb72347a
...
@@ -7,7 +7,7 @@ import (
...
@@ -7,7 +7,7 @@ import (
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/go-ethereum/utils"
"github.com/ethereum/go-ethereum/utils"
"github.com/
niemeyer
/qml"
"github.com/
go-qml
/qml"
"os"
"os"
"path"
"path"
"path/filepath"
"path/filepath"
...
...
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