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
f9a6038f
Commit
f9a6038f
authored
Mar 18, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
4d0ae8b0
baca0c22
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
92 additions
and
78 deletions
+92
-78
Dockerfile
Dockerfile
+3
-4
main.go
cmd/ethereum/main.go
+21
-0
common.go
common/common.go
+9
-0
api.go
rpc/api.go
+11
-11
responses.go
rpc/responses.go
+18
-18
util.go
rpc/util.go
+2
-11
whisper.go
ui/qt/qwhisper/whisper.go
+2
-4
types.go
xeth/types.go
+14
-18
whisper.go
xeth/whisper.go
+4
-4
xeth.go
xeth/xeth.go
+8
-8
No files found.
Dockerfile
View file @
f9a6038f
...
...
@@ -26,12 +26,11 @@ RUN tar -C /usr/local -xzf go*.tar.gz && go version
ADD
https://api.github.com/repos/ethereum/go-ethereum/git/refs/heads/develop file_does_not_exist
## Fetch and install go-ethereum
RUN
go get github.com/tools/godep
RUN
g
o get
-d
github.com/ethereum/go-ethereum/...
RUN
mkdir
-p
$GOPATH
/src/github.com/ethereum/
RUN
g
it clone https://github.com/ethereum/go-ethereum
$GOPATH
/src/github.com/ethereum/go-ethereum
WORKDIR
$GOPATH/src/github.com/ethereum/go-ethereum
RUN
git checkout develop
RUN
godep restore
RUN
go
install
-v
./cmd/ethereum
RUN
GOPATH
=
$GOPATH
:
$GOPATH
/src/github.com/ethereum/go-ethereum/Godeps/_workspace go
install
-v
./cmd/ethereum
## Run & expose JSON RPC
ENTRYPOINT
["ethereum", "-rpc=true", "-rpcport=8545"]
...
...
cmd/ethereum/main.go
View file @
f9a6038f
...
...
@@ -30,6 +30,7 @@ import (
"time"
"github.com/codegangsta/cli"
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
...
...
@@ -54,6 +55,17 @@ func init() {
app
.
HideVersion
=
true
// we have a command to print the version
app
.
Commands
=
[]
cli
.
Command
{
blocktestCmd
,
{
Action
:
makedag
,
Name
:
"makedag"
,
Usage
:
"generate ethash dag (for testing)"
,
Description
:
`
The makedag command generates an ethash DAG in /tmp/dag.
This command exists to support the system testing project.
Regular users do not need to execute it.
`
,
},
{
Action
:
version
,
Name
:
"version"
,
...
...
@@ -318,6 +330,15 @@ func dump(ctx *cli.Context) {
}
}
func
makedag
(
ctx
*
cli
.
Context
)
{
chain
,
_
,
_
:=
utils
.
GetChain
(
ctx
)
pow
:=
ethash
.
New
(
chain
)
fmt
.
Println
(
"making cache"
)
pow
.
UpdateCache
(
true
)
fmt
.
Println
(
"making DAG"
)
pow
.
UpdateDAG
()
}
func
version
(
c
*
cli
.
Context
)
{
fmt
.
Printf
(
`%v
Version: %v
...
...
common/common.go
View file @
f9a6038f
...
...
@@ -65,6 +65,15 @@ func DefaultDataDir() string {
}
}
func
ToHex
(
b
[]
byte
)
string
{
hex
:=
Bytes2Hex
(
b
)
// Prefer output of "0x0" instead of "0x"
if
len
(
hex
)
==
0
{
hex
=
"0"
}
return
"0x"
+
hex
}
func
FromHex
(
s
string
)
[]
byte
{
if
len
(
s
)
>
1
{
if
s
[
0
:
2
]
==
"0x"
{
...
...
rpc/api.go
View file @
f9a6038f
...
...
@@ -251,7 +251,7 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) (err error)
result, _ := account.Transact(common.FromHex(args.To), common.FromHex(args.Value), common.FromHex(args.Gas), common.FromHex(args.GasPrice), common.FromHex(args.Data))
if len(result) > 0 {
*reply =
t
oHex(result)
*reply =
common.T
oHex(result)
}
} else if _, exists := p.register[args.From]; exists {
p.register[ags.From] = append(p.register[args.From], args)
...
...
@@ -291,7 +291,7 @@ func (p *EthereumApi) GetBalance(args *GetBalanceArgs, reply *interface{}) error
return
err
}
state
:=
p
.
getStateWithNum
(
args
.
BlockNumber
)
.
SafeGet
(
args
.
Address
)
*
reply
=
t
oHex
(
state
.
Balance
()
.
Bytes
())
*
reply
=
common
.
T
oHex
(
state
.
Balance
()
.
Bytes
())
return
nil
}
...
...
@@ -389,7 +389,7 @@ func (p *EthereumApi) NewWhisperFilter(args *WhisperFilterArgs, reply *interface
}
id
=
p
.
xeth
()
.
Whisper
()
.
Watch
(
opts
)
p
.
messages
[
id
]
=
&
whisperFilter
{
timeout
:
time
.
Now
()}
*
reply
=
t
oHex
(
big
.
NewInt
(
int64
(
id
))
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
int64
(
id
))
.
Bytes
())
return
nil
}
...
...
@@ -485,7 +485,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
return
err
}
*
reply
=
t
oHex
(
crypto
.
Sha3
(
common
.
FromHex
(
args
.
Data
)))
*
reply
=
common
.
T
oHex
(
crypto
.
Sha3
(
common
.
FromHex
(
args
.
Data
)))
case
"web3_clientVersion"
:
*
reply
=
p
.
xeth
()
.
Backend
()
.
Version
()
case
"net_version"
:
...
...
@@ -493,7 +493,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
case
"net_listening"
:
*
reply
=
p
.
xeth
()
.
IsListening
()
case
"net_peerCount"
:
*
reply
=
t
oHex
(
big
.
NewInt
(
int64
(
p
.
xeth
()
.
PeerCount
()))
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
int64
(
p
.
xeth
()
.
PeerCount
()))
.
Bytes
())
case
"eth_coinbase"
:
// TODO handling of empty coinbase due to lack of accounts
res
:=
p
.
xeth
()
.
Coinbase
()
...
...
@@ -505,11 +505,11 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
case
"eth_mining"
:
*
reply
=
p
.
xeth
()
.
IsMining
()
case
"eth_gasPrice"
:
*
reply
=
t
oHex
(
defaultGasPrice
.
Bytes
())
*
reply
=
common
.
T
oHex
(
defaultGasPrice
.
Bytes
())
case
"eth_accounts"
:
*
reply
=
p
.
xeth
()
.
Accounts
()
case
"eth_blockNumber"
:
*
reply
=
t
oHex
(
p
.
xeth
()
.
Backend
()
.
ChainManager
()
.
CurrentBlock
()
.
Number
()
.
Bytes
())
*
reply
=
common
.
T
oHex
(
p
.
xeth
()
.
Backend
()
.
ChainManager
()
.
CurrentBlock
()
.
Number
()
.
Bytes
())
case
"eth_getBalance"
:
args
:=
new
(
GetBalanceArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
@@ -544,7 +544,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
!=
nil
{
return
err
}
*
reply
=
t
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
case
"eth_getBlockTransactionCountByNumber"
:
args
:=
new
(
GetBlockByNumberArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
@@ -555,7 +555,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
!=
nil
{
return
err
}
*
reply
=
t
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
case
"eth_getUncleCountByBlockHash"
:
args
:=
new
(
GetBlockByHashArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
@@ -566,7 +566,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
!=
nil
{
return
err
}
*
reply
=
t
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
case
"eth_getUncleCountByBlockNumber"
:
args
:=
new
(
GetBlockByNumberArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
@@ -577,7 +577,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
!=
nil
{
return
err
}
*
reply
=
t
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
case
"eth_getData"
,
"eth_getCode"
:
args
:=
new
(
GetDataArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
rpc/responses.go
View file @
f9a6038f
...
...
@@ -57,23 +57,23 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
}
// convert strict types to hexified strings
ext
.
BlockNumber
=
t
oHex
(
big
.
NewInt
(
b
.
BlockNumber
)
.
Bytes
())
ext
.
BlockNumber
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
BlockNumber
)
.
Bytes
())
ext
.
BlockHash
=
b
.
BlockHash
.
Hex
()
ext
.
ParentHash
=
b
.
ParentHash
.
Hex
()
ext
.
Nonce
=
t
oHex
(
b
.
Nonce
[
:
])
ext
.
Nonce
=
common
.
T
oHex
(
b
.
Nonce
[
:
])
ext
.
Sha3Uncles
=
b
.
Sha3Uncles
.
Hex
()
ext
.
LogsBloom
=
t
oHex
(
b
.
LogsBloom
[
:
])
ext
.
LogsBloom
=
common
.
T
oHex
(
b
.
LogsBloom
[
:
])
ext
.
TransactionRoot
=
b
.
TransactionRoot
.
Hex
()
ext
.
StateRoot
=
b
.
StateRoot
.
Hex
()
ext
.
Miner
=
b
.
Miner
.
Hex
()
ext
.
Difficulty
=
t
oHex
(
big
.
NewInt
(
b
.
Difficulty
)
.
Bytes
())
ext
.
TotalDifficulty
=
t
oHex
(
big
.
NewInt
(
b
.
TotalDifficulty
)
.
Bytes
())
ext
.
Size
=
t
oHex
(
big
.
NewInt
(
b
.
Size
)
.
Bytes
())
// ext.ExtraData =
t
oHex(b.ExtraData)
ext
.
GasLimit
=
t
oHex
(
big
.
NewInt
(
b
.
GasLimit
)
.
Bytes
())
// ext.MinGasPrice =
t
oHex(big.NewInt(b.MinGasPrice).Bytes())
ext
.
GasUsed
=
t
oHex
(
big
.
NewInt
(
b
.
GasUsed
)
.
Bytes
())
ext
.
UnixTimestamp
=
t
oHex
(
big
.
NewInt
(
b
.
UnixTimestamp
)
.
Bytes
())
ext
.
Difficulty
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
Difficulty
)
.
Bytes
())
ext
.
TotalDifficulty
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
TotalDifficulty
)
.
Bytes
())
ext
.
Size
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
Size
)
.
Bytes
())
// ext.ExtraData =
common.T
oHex(b.ExtraData)
ext
.
GasLimit
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
GasLimit
)
.
Bytes
())
// ext.MinGasPrice =
common.T
oHex(big.NewInt(b.MinGasPrice).Bytes())
ext
.
GasUsed
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
GasUsed
)
.
Bytes
())
ext
.
UnixTimestamp
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
UnixTimestamp
)
.
Bytes
())
ext
.
Transactions
=
make
([]
interface
{},
len
(
b
.
Transactions
))
if
b
.
fullTx
{
for
i
,
tx
:=
range
b
.
Transactions
{
...
...
@@ -162,20 +162,20 @@ func (t *TransactionRes) MarshalJSON() ([]byte, error) {
}
ext
.
Hash
=
t
.
Hash
.
Hex
()
ext
.
Nonce
=
t
oHex
(
big
.
NewInt
(
t
.
Nonce
)
.
Bytes
())
ext
.
Nonce
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
Nonce
)
.
Bytes
())
ext
.
BlockHash
=
t
.
BlockHash
.
Hex
()
ext
.
BlockNumber
=
t
oHex
(
big
.
NewInt
(
t
.
BlockNumber
)
.
Bytes
())
ext
.
TxIndex
=
t
oHex
(
big
.
NewInt
(
t
.
TxIndex
)
.
Bytes
())
ext
.
BlockNumber
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
BlockNumber
)
.
Bytes
())
ext
.
TxIndex
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
TxIndex
)
.
Bytes
())
ext
.
From
=
t
.
From
.
Hex
()
if
t
.
To
==
nil
{
ext
.
To
=
"0x00"
}
else
{
ext
.
To
=
t
.
To
.
Hex
()
}
ext
.
Value
=
t
oHex
(
big
.
NewInt
(
t
.
Value
)
.
Bytes
())
ext
.
Gas
=
t
oHex
(
big
.
NewInt
(
t
.
Gas
)
.
Bytes
())
ext
.
GasPrice
=
t
oHex
(
big
.
NewInt
(
t
.
GasPrice
)
.
Bytes
())
ext
.
Input
=
t
oHex
(
t
.
Input
)
ext
.
Value
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
Value
)
.
Bytes
())
ext
.
Gas
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
Gas
)
.
Bytes
())
ext
.
GasPrice
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
GasPrice
)
.
Bytes
())
ext
.
Input
=
common
.
T
oHex
(
t
.
Input
)
return
json
.
Marshal
(
ext
)
}
...
...
rpc/util.go
View file @
f9a6038f
...
...
@@ -124,17 +124,8 @@ func (self JsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error)
return
reqParsed
,
nil
}
func
toHex
(
b
[]
byte
)
string
{
hex
:=
common
.
Bytes2Hex
(
b
)
// Prefer output of "0x0" instead of "0x"
if
len
(
hex
)
==
0
{
hex
=
"0"
}
return
"0x"
+
hex
}
func
i2hex
(
n
int
)
string
{
return
t
oHex
(
big
.
NewInt
(
int64
(
n
))
.
Bytes
())
return
common
.
T
oHex
(
big
.
NewInt
(
int64
(
n
))
.
Bytes
())
}
type
RpcServer
interface
{
...
...
@@ -156,7 +147,7 @@ func toLogs(logs state.Logs) (ls []Log) {
var
l
Log
l
.
Topic
=
make
([]
string
,
len
(
log
.
Topics
()))
l
.
Address
=
log
.
Address
()
.
Hex
()
l
.
Data
=
t
oHex
(
log
.
Data
())
l
.
Data
=
common
.
T
oHex
(
log
.
Data
())
l
.
Number
=
log
.
Number
()
for
j
,
topic
:=
range
log
.
Topics
()
{
l
.
Topic
[
j
]
=
topic
.
Hex
()
...
...
ui/qt/qwhisper/whisper.go
View file @
f9a6038f
...
...
@@ -4,8 +4,8 @@ package qwhisper
import
(
"time"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/whisper"
"github.com/obscuren/qml"
...
...
@@ -13,8 +13,6 @@ import (
var
qlogger
=
logger
.
NewLogger
(
"QSHH"
)
func
toHex
(
b
[]
byte
)
string
{
return
"0x"
+
common
.
Bytes2Hex
(
b
)
}
type
Whisper
struct
{
*
whisper
.
Whisper
view
qml
.
Object
...
...
@@ -66,7 +64,7 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr
func
(
self
*
Whisper
)
NewIdentity
()
string
{
key
:=
self
.
Whisper
.
NewIdentity
()
return
t
oHex
(
crypto
.
FromECDSAPub
(
&
key
.
PublicKey
))
return
common
.
T
oHex
(
crypto
.
FromECDSAPub
(
&
key
.
PublicKey
))
}
func
(
self
*
Whisper
)
HasIdentity
(
key
string
)
bool
{
...
...
xeth/types.go
View file @
f9a6038f
...
...
@@ -14,10 +14,6 @@ import (
"github.com/ethereum/go-ethereum/state"
)
func
toHex
(
b
[]
byte
)
string
{
return
"0x"
+
common
.
Bytes2Hex
(
b
)
}
type
Object
struct
{
*
state
.
StateObject
}
...
...
@@ -49,7 +45,7 @@ func (self *Object) Storage() (storage map[string]string) {
for
it
.
Next
()
{
var
data
[]
byte
rlp
.
Decode
(
bytes
.
NewReader
(
it
.
Value
),
&
data
)
storage
[
toHex
(
it
.
Key
)]
=
t
oHex
(
data
)
storage
[
common
.
ToHex
(
it
.
Key
)]
=
common
.
T
oHex
(
data
)
}
return
...
...
@@ -95,12 +91,12 @@ func NewBlock(block *types.Block) *Block {
return
&
Block
{
ref
:
block
,
Size
:
block
.
Size
()
.
String
(),
Number
:
int
(
block
.
NumberU64
()),
GasUsed
:
block
.
GasUsed
()
.
String
(),
GasLimit
:
block
.
GasLimit
()
.
String
(),
Hash
:
toHex
(
block
.
Hash
()
.
Bytes
()
),
GasLimit
:
block
.
GasLimit
()
.
String
(),
Hash
:
block
.
Hash
()
.
Hex
(
),
Transactions
:
txlist
,
Uncles
:
ulist
,
Time
:
block
.
Time
(),
Coinbase
:
toHex
(
block
.
Coinbase
()
.
Bytes
()
),
PrevHash
:
toHex
(
block
.
ParentHash
()
.
Bytes
()
),
Bloom
:
t
oHex
(
block
.
Bloom
()
.
Bytes
()),
Coinbase
:
block
.
Coinbase
()
.
Hex
(
),
PrevHash
:
block
.
ParentHash
()
.
Hex
(
),
Bloom
:
common
.
T
oHex
(
block
.
Bloom
()
.
Bytes
()),
Raw
:
block
.
String
(),
}
}
...
...
@@ -151,10 +147,10 @@ func NewTx(tx *types.Transaction) *Transaction {
if
createsContract
{
data
=
strings
.
Join
(
core
.
Disassemble
(
tx
.
Data
()),
"
\n
"
)
}
else
{
data
=
t
oHex
(
tx
.
Data
())
data
=
common
.
T
oHex
(
tx
.
Data
())
}
return
&
Transaction
{
ref
:
tx
,
Hash
:
hash
,
Value
:
common
.
CurrencyToString
(
tx
.
Value
()),
Address
:
receiver
,
Contract
:
createsContract
,
Gas
:
tx
.
Gas
()
.
String
(),
GasPrice
:
tx
.
GasPrice
()
.
String
(),
Data
:
data
,
Sender
:
sender
.
Hex
(),
CreatesContract
:
createsContract
,
RawData
:
t
oHex
(
tx
.
Data
())}
return
&
Transaction
{
ref
:
tx
,
Hash
:
hash
,
Value
:
common
.
CurrencyToString
(
tx
.
Value
()),
Address
:
receiver
,
Contract
:
createsContract
,
Gas
:
tx
.
Gas
()
.
String
(),
GasPrice
:
tx
.
GasPrice
()
.
String
(),
Data
:
data
,
Sender
:
sender
.
Hex
(),
CreatesContract
:
createsContract
,
RawData
:
common
.
T
oHex
(
tx
.
Data
())}
}
func
(
self
*
Transaction
)
ToString
()
string
{
...
...
@@ -168,7 +164,7 @@ type Key struct {
}
func
NewKey
(
key
*
crypto
.
KeyPair
)
*
Key
{
return
&
Key
{
toHex
(
key
.
Address
()),
toHex
(
key
.
PrivateKey
),
t
oHex
(
key
.
PublicKey
)}
return
&
Key
{
common
.
ToHex
(
key
.
Address
()),
common
.
ToHex
(
key
.
PrivateKey
),
common
.
T
oHex
(
key
.
PublicKey
)}
}
type
PReceipt
struct
{
...
...
@@ -181,9 +177,9 @@ type PReceipt struct {
func
NewPReciept
(
contractCreation
bool
,
creationAddress
,
hash
,
address
[]
byte
)
*
PReceipt
{
return
&
PReceipt
{
contractCreation
,
t
oHex
(
creationAddress
),
t
oHex
(
hash
),
t
oHex
(
address
),
common
.
T
oHex
(
creationAddress
),
common
.
T
oHex
(
hash
),
common
.
T
oHex
(
address
),
}
}
...
...
@@ -220,8 +216,8 @@ type Receipt struct {
func
NewReciept
(
contractCreation
bool
,
creationAddress
,
hash
,
address
[]
byte
)
*
Receipt
{
return
&
Receipt
{
contractCreation
,
t
oHex
(
creationAddress
),
t
oHex
(
hash
),
t
oHex
(
address
),
common
.
T
oHex
(
creationAddress
),
common
.
T
oHex
(
hash
),
common
.
T
oHex
(
address
),
}
}
xeth/whisper.go
View file @
f9a6038f
...
...
@@ -56,7 +56,7 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
func
(
self
*
Whisper
)
NewIdentity
()
string
{
key
:=
self
.
Whisper
.
NewIdentity
()
return
t
oHex
(
crypto
.
FromECDSAPub
(
&
key
.
PublicKey
))
return
common
.
T
oHex
(
crypto
.
FromECDSAPub
(
&
key
.
PublicKey
))
}
func
(
self
*
Whisper
)
HasIdentity
(
key
string
)
bool
{
...
...
@@ -112,9 +112,9 @@ type WhisperMessage struct {
func
NewWhisperMessage
(
msg
*
whisper
.
Message
)
WhisperMessage
{
return
WhisperMessage
{
ref
:
msg
,
Payload
:
t
oHex
(
msg
.
Payload
),
From
:
t
oHex
(
crypto
.
FromECDSAPub
(
msg
.
Recover
())),
To
:
t
oHex
(
crypto
.
FromECDSAPub
(
msg
.
To
)),
Payload
:
common
.
T
oHex
(
msg
.
Payload
),
From
:
common
.
T
oHex
(
crypto
.
FromECDSAPub
(
msg
.
Recover
())),
To
:
common
.
T
oHex
(
crypto
.
FromECDSAPub
(
msg
.
To
)),
Sent
:
msg
.
Sent
,
}
}
xeth/xeth.go
View file @
f9a6038f
...
...
@@ -170,7 +170,7 @@ func (self *XEth) Accounts() []string {
accounts
,
_
:=
self
.
eth
.
AccountManager
()
.
Accounts
()
accountAddresses
:=
make
([]
string
,
len
(
accounts
))
for
i
,
ac
:=
range
accounts
{
accountAddresses
[
i
]
=
t
oHex
(
ac
.
Address
)
accountAddresses
[
i
]
=
common
.
T
oHex
(
ac
.
Address
)
}
return
accountAddresses
}
...
...
@@ -201,7 +201,7 @@ func (self *XEth) IsListening() bool {
func
(
self
*
XEth
)
Coinbase
()
string
{
cb
,
_
:=
self
.
eth
.
AccountManager
()
.
Coinbase
()
return
t
oHex
(
cb
)
return
common
.
T
oHex
(
cb
)
}
func
(
self
*
XEth
)
NumberToHuman
(
balance
string
)
string
{
...
...
@@ -213,7 +213,7 @@ func (self *XEth) NumberToHuman(balance string) string {
func
(
self
*
XEth
)
StorageAt
(
addr
,
storageAddr
string
)
string
{
storage
:=
self
.
State
()
.
SafeGet
(
addr
)
.
StorageString
(
storageAddr
)
return
t
oHex
(
storage
.
Bytes
())
return
common
.
T
oHex
(
storage
.
Bytes
())
}
func
(
self
*
XEth
)
BalanceAt
(
addr
string
)
string
{
...
...
@@ -225,7 +225,7 @@ func (self *XEth) TxCountAt(address string) int {
}
func
(
self
*
XEth
)
CodeAt
(
address
string
)
string
{
return
t
oHex
(
self
.
State
()
.
SafeGet
(
address
)
.
Code
())
return
common
.
T
oHex
(
self
.
State
()
.
SafeGet
(
address
)
.
Code
())
}
func
(
self
*
XEth
)
IsContract
(
address
string
)
bool
{
...
...
@@ -238,7 +238,7 @@ func (self *XEth) SecretToAddress(key string) string {
return
""
}
return
t
oHex
(
pair
.
Address
())
return
common
.
T
oHex
(
pair
.
Address
())
}
type
KeyVal
struct
{
...
...
@@ -251,7 +251,7 @@ func (self *XEth) EachStorage(addr string) string {
object
:=
self
.
State
()
.
SafeGet
(
addr
)
it
:=
object
.
Trie
()
.
Iterator
()
for
it
.
Next
()
{
values
=
append
(
values
,
KeyVal
{
toHex
(
it
.
Key
),
t
oHex
(
it
.
Value
)})
values
=
append
(
values
,
KeyVal
{
common
.
ToHex
(
it
.
Key
),
common
.
T
oHex
(
it
.
Value
)})
}
valuesJson
,
err
:=
json
.
Marshal
(
values
)
...
...
@@ -265,7 +265,7 @@ func (self *XEth) EachStorage(addr string) string {
func
(
self
*
XEth
)
ToAscii
(
str
string
)
string
{
padded
:=
common
.
RightPadBytes
([]
byte
(
str
),
32
)
return
"0x"
+
t
oHex
(
padded
)
return
"0x"
+
common
.
T
oHex
(
padded
)
}
func
(
self
*
XEth
)
FromAscii
(
str
string
)
string
{
...
...
@@ -325,7 +325,7 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
vmenv
:=
core
.
NewEnv
(
statedb
,
self
.
chainManager
,
msg
,
block
)
res
,
err
:=
vmenv
.
Call
(
msg
.
from
,
msg
.
to
,
msg
.
data
,
msg
.
gas
,
msg
.
gasPrice
,
msg
.
value
)
return
t
oHex
(
res
),
err
return
common
.
T
oHex
(
res
),
err
}
func
(
self
*
XEth
)
Transact
(
fromStr
,
toStr
,
valueStr
,
gasStr
,
gasPriceStr
,
codeStr
string
)
(
string
,
error
)
{
...
...
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