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
f1da6f05
Commit
f1da6f05
authored
May 02, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed samplecoin
parent
ee04c6ff
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
29 deletions
+42
-29
ethereum.js
ethereal/assets/ethereum.js
+2
-3
webapp.qml
ethereal/assets/qml/webapp.qml
+1
-0
samplecoin.html
ethereal/assets/samplecoin/samplecoin.html
+15
-13
ethereum.go
utils/ethereum.go
+15
-12
types.go
utils/types.go
+9
-1
No files found.
ethereal/assets/ethereum.js
View file @
f1da6f05
...
@@ -19,8 +19,7 @@ window.eth = {
...
@@ -19,8 +19,7 @@ window.eth = {
// Create transaction
// Create transaction
//
//
// Creates a transaction with the current account
// Transact between two state objects
// If no recipient is set, the Ethereum API will see it as a contract creation
transact
:
function
(
sec
,
recipient
,
value
,
gas
,
gasPrice
,
data
,
cb
)
{
transact
:
function
(
sec
,
recipient
,
value
,
gas
,
gasPrice
,
data
,
cb
)
{
postData
({
call
:
"transact"
,
args
:
[
sec
,
recipient
,
value
,
gas
,
gasPrice
,
data
]},
cb
);
postData
({
call
:
"transact"
,
args
:
[
sec
,
recipient
,
value
,
gas
,
gasPrice
,
data
]},
cb
);
},
},
...
@@ -202,7 +201,7 @@ String.prototype.unbin = function() {
...
@@ -202,7 +201,7 @@ String.prototype.unbin = function() {
String
.
prototype
.
hex2bin
=
function
()
{
String
.
prototype
.
hex2bin
=
function
()
{
bytes
=
[]
bytes
=
[]
for
(
var
i
=
2
;
i
<
this
.
length
-
1
;
i
+=
2
){
for
(
var
i
=
2
;
i
<
this
.
length
-
1
;
i
+=
2
)
{
bytes
.
push
(
parseInt
(
this
.
substr
(
i
,
2
),
16
));
bytes
.
push
(
parseInt
(
this
.
substr
(
i
,
2
),
16
));
}
}
...
...
ethereal/assets/qml/webapp.qml
View file @
f1da6f05
...
@@ -60,6 +60,7 @@ ApplicationWindow {
...
@@ -60,6 +60,7 @@ ApplicationWindow {
var
tx
=
eth
.
transact
(
data
.
args
[
0
],
data
.
args
[
1
],
data
.
args
[
2
],
data
.
args
[
3
],
data
.
args
[
4
],
data
.
args
[
5
])
var
tx
=
eth
.
transact
(
data
.
args
[
0
],
data
.
args
[
1
],
data
.
args
[
2
],
data
.
args
[
3
],
data
.
args
[
4
],
data
.
args
[
5
])
postData
(
data
.
_seed
,
tx
)
postData
(
data
.
_seed
,
tx
)
break
break
case
"create"
:
case
"create"
:
postData
(
data
.
_seed
,
null
)
postData
(
data
.
_seed
,
null
)
...
...
ethereal/assets/samplecoin/samplecoin.html
View file @
f1da6f05
...
@@ -9,13 +9,14 @@
...
@@ -9,13 +9,14 @@
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
var
jefcoinAddr
=
"3dff537f51350239abc95c76a5864aa605259e7d"
var
jefcoinAddr
=
"3dff537f51350239abc95c76a5864aa605259e7d"
var
mAddr
=
""
function
createTransaction
()
{
function
createTransaction
()
{
var
addr
=
document
.
querySelector
(
"#addr"
).
value
;
var
addr
=
document
.
querySelector
(
"#addr"
).
value
;
var
amount
=
document
.
querySelector
(
"#amount"
).
value
;
var
amount
=
document
.
querySelector
(
"#amount"
).
value
;
var
data
=
"0x"
+
addr
+
"
\n
"
+
amount
var
data
=
((
"0x"
+
addr
).
pad
(
32
)
+
amount
.
pad
(
32
)).
unbin
()
eth
.
transact
(
""
,
jefcoinAddr
,
0
,
"10000000"
,
"250"
,
data
,
function
(
tx
)
{
eth
.
transact
(
mAddr
,
jefcoinAddr
,
0
,
"10000000"
,
"250"
,
data
,
function
(
tx
)
{
debug
(
"received tx hash:"
,
tx
)
debug
(
"received tx hash:"
,
tx
)
})
})
}
}
...
@@ -23,13 +24,15 @@ function createTransaction() {
...
@@ -23,13 +24,15 @@ function createTransaction() {
function
init
()
{
function
init
()
{
eth
.
set
({
width
:
500
})
eth
.
set
({
width
:
500
})
eth
.
getKey
(
function
(
key
)
{
eth
.
getKey
(
function
(
keyPair
)
{
eth
.
getStorageAt
(
jefcoinAddr
,
key
,
function
(
storage
)
{
mAddr
=
keyPair
.
privateKey
;
eth
.
getStorageAt
(
jefcoinAddr
,
keyPair
.
address
,
function
(
storage
)
{
document
.
querySelector
(
"#current-amount"
).
innerHTML
=
storage
;
document
.
querySelector
(
"#current-amount"
).
innerHTML
=
storage
;
});
});
eth
.
watch
(
jefcoinAddr
,
function
(
stateObject
)
{
eth
.
watch
(
jefcoinAddr
,
function
(
stateObject
)
{
eth
.
getStorageAt
(
jefcoinAddr
,
key
,
function
(
storage
)
{
eth
.
getStorageAt
(
jefcoinAddr
,
key
Pair
.
address
,
function
(
storage
)
{
document
.
querySelector
(
"#current-amount"
).
innerHTML
=
storage
;
document
.
querySelector
(
"#current-amount"
).
innerHTML
=
storage
;
});
});
});
});
...
@@ -50,19 +53,18 @@ function init() {
...
@@ -50,19 +53,18 @@ function init() {
<div>
Amount:
<strong
id=
"current-amount"
></strong></div>
<div>
Amount:
<strong
id=
"current-amount"
></strong></div>
<div
id=
"transactions"
>
<div
id=
"transactions"
>
<form
role=
"form"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<input
id=
"addr"
class=
"form-control"
type=
"text"
placeholder=
"Receiver address"
></input><br>
<input
id=
"addr"
class=
"form-control"
type=
"text"
placeholder=
"Receiver address"
></input><br>
<input
id=
"amount"
class=
"form-control"
type=
"text"
placeholder=
"Amount"
></input><br>
<input
id=
"amount"
class=
"form-control"
type=
"text"
placeholder=
"Amount"
></input><br>
</div>
</div>
<button
class=
"btn btn-default"
onclick=
"createTransaction();"
>
Send Tx
</button>
<button
class=
"btn btn-default"
onclick=
"createTransaction();"
>
Send Tx
</button>
</div>
</div>
</div>
</div>
<div
id=
"debug"
style=
"border: 1px solid block"
></div>
</div>
</div>
<div
id=
"debug"
style=
"border: 1px solid black; min-height: 30px;"
></div>
</body>
</body>
</html>
</html>
utils/ethereum.go
View file @
f1da6f05
package
utils
package
utils
import
(
import
(
"fmt"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethutil"
...
@@ -28,8 +29,13 @@ func (lib *PEthereum) GetBlock(hexHash string) *PBlock {
...
@@ -28,8 +29,13 @@ func (lib *PEthereum) GetBlock(hexHash string) *PBlock {
return
&
PBlock
{
Number
:
int
(
block
.
BlockInfo
()
.
Number
),
Hash
:
ethutil
.
Hex
(
block
.
Hash
())}
return
&
PBlock
{
Number
:
int
(
block
.
BlockInfo
()
.
Number
),
Hash
:
ethutil
.
Hex
(
block
.
Hash
())}
}
}
func
(
lib
*
PEthereum
)
GetKey
()
string
{
func
(
lib
*
PEthereum
)
GetKey
()
*
PKey
{
return
ethutil
.
Hex
(
ethutil
.
Config
.
Db
.
GetKeys
()[
0
]
.
Address
())
keyPair
,
err
:=
ethchain
.
NewKeyPairFromSec
(
ethutil
.
Config
.
Db
.
GetKeys
()[
0
]
.
PrivateKey
)
if
err
!=
nil
{
return
nil
}
return
NewPKey
(
keyPair
)
}
}
func
(
lib
*
PEthereum
)
GetStateObject
(
address
string
)
*
PStateObject
{
func
(
lib
*
PEthereum
)
GetStateObject
(
address
string
)
*
PStateObject
{
...
@@ -59,7 +65,7 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in
...
@@ -59,7 +65,7 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in
hash
=
ethutil
.
FromHex
(
recipient
)
hash
=
ethutil
.
FromHex
(
recipient
)
}
}
keyPair
,
err
:=
ethchain
.
NewKeyPairFromSec
([]
byte
(
key
))
keyPair
,
err
:=
ethchain
.
NewKeyPairFromSec
([]
byte
(
ethutil
.
FromHex
(
key
)
))
if
err
!=
nil
{
if
err
!=
nil
{
return
""
,
err
return
""
,
err
}
}
...
@@ -81,15 +87,12 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in
...
@@ -81,15 +87,12 @@ func (lib *PEthereum) createTx(key, recipient, valueStr, gasStr, gasPriceStr, in
tx
=
ethchain
.
NewContractCreationTx
(
value
,
gas
,
gasPrice
,
mainScript
,
initScript
)
tx
=
ethchain
.
NewContractCreationTx
(
value
,
gas
,
gasPrice
,
mainScript
,
initScript
)
}
else
{
}
else
{
/*
// Just in case it was submitted as a 0x prefixed string
lines := strings.Split(dataStr, "\n")
if
initStr
[
0
:
2
]
==
"0x"
{
var data []byte
initStr
=
initStr
[
2
:
len
(
initStr
)]
for _, line := range lines {
}
data = append(data, ethutil.BigToBytes(ethutil.Big(line), 256)...)
fmt
.
Println
(
"DATA:"
,
initStr
)
}
tx
=
ethchain
.
NewTransactionMessage
(
hash
,
value
,
gas
,
gasPrice
,
ethutil
.
FromHex
(
initStr
))
*/
tx
=
ethchain
.
NewTransactionMessage
(
hash
,
value
,
gas
,
gasPrice
,
[]
byte
(
initStr
))
}
}
acc
:=
lib
.
stateManager
.
GetAddrState
(
keyPair
.
Address
())
acc
:=
lib
.
stateManager
.
GetAddrState
(
keyPair
.
Address
())
...
...
utils/types.go
View file @
f1da6f05
...
@@ -34,9 +34,16 @@ func NewPTx(tx *ethchain.Transaction) *PTx {
...
@@ -34,9 +34,16 @@ func NewPTx(tx *ethchain.Transaction) *PTx {
}
}
type
PKey
struct
{
type
PKey
struct
{
Address
string
Address
string
PrivateKey
string
PublicKey
string
}
}
func
NewPKey
(
key
*
ethchain
.
KeyPair
)
*
PKey
{
return
&
PKey
{
ethutil
.
Hex
(
key
.
Address
()),
ethutil
.
Hex
(
key
.
PrivateKey
),
ethutil
.
Hex
(
key
.
PublicKey
)}
}
/*
type PKeyRing struct {
type PKeyRing struct {
Keys []interface{}
Keys []interface{}
}
}
...
@@ -44,6 +51,7 @@ type PKeyRing struct {
...
@@ -44,6 +51,7 @@ type PKeyRing struct {
func NewPKeyRing(keys []interface{}) *PKeyRing {
func NewPKeyRing(keys []interface{}) *PKeyRing {
return &PKeyRing{Keys: keys}
return &PKeyRing{Keys: keys}
}
}
*/
type
PStateObject
struct
{
type
PStateObject
struct
{
object
*
ethchain
.
StateObject
object
*
ethchain
.
StateObject
...
...
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