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
e30c3233
Commit
e30c3233
authored
Mar 18, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Plain Diff
merge develop
parents
67c9d9c2
3ea99f98
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
106 additions
and
111 deletions
+106
-111
common.go
common/common.go
+9
-0
api.go
rpc/api.go
+13
-13
responses.go
rpc/responses.go
+31
-30
util.go
rpc/util.go
+4
-13
whisper.go
ui/qt/qwhisper/whisper.go
+2
-4
types.go
xeth/types.go
+30
-34
whisper.go
xeth/whisper.go
+4
-4
xeth.go
xeth/xeth.go
+13
-13
No files found.
common/common.go
View file @
e30c3233
...
@@ -65,6 +65,15 @@ func DefaultDataDir() string {
...
@@ -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
{
func
FromHex
(
s
string
)
[]
byte
{
if
len
(
s
)
>
1
{
if
len
(
s
)
>
1
{
if
s
[
0
:
2
]
==
"0x"
{
if
s
[
0
:
2
]
==
"0x"
{
...
...
rpc/api.go
View file @
e30c3233
...
@@ -251,7 +251,7 @@ func (p *EthereumApi) Transact(args *NewTxArgs, reply *interface{}) (err error)
...
@@ -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))
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 {
if len(result) > 0 {
*reply =
t
oHex(result)
*reply =
common.T
oHex(result)
}
}
} else if _, exists := p.register[args.From]; exists {
} else if _, exists := p.register[args.From]; exists {
p.register[ags.From] = append(p.register[args.From], args)
p.register[ags.From] = append(p.register[args.From], args)
...
@@ -291,7 +291,7 @@ func (p *EthereumApi) GetBalance(args *GetBalanceArgs, reply *interface{}) error
...
@@ -291,7 +291,7 @@ func (p *EthereumApi) GetBalance(args *GetBalanceArgs, reply *interface{}) error
return
err
return
err
}
}
state
:=
p
.
getStateWithNum
(
args
.
BlockNumber
)
.
SafeGet
(
args
.
Address
)
state
:=
p
.
getStateWithNum
(
args
.
BlockNumber
)
.
SafeGet
(
args
.
Address
)
*
reply
=
t
oHex
(
state
.
Balance
()
.
Bytes
())
*
reply
=
common
.
T
oHex
(
state
.
Balance
()
.
Bytes
())
return
nil
return
nil
}
}
...
@@ -389,7 +389,7 @@ func (p *EthereumApi) NewWhisperFilter(args *WhisperFilterArgs, reply *interface
...
@@ -389,7 +389,7 @@ func (p *EthereumApi) NewWhisperFilter(args *WhisperFilterArgs, reply *interface
}
}
id
=
p
.
xeth
()
.
Whisper
()
.
Watch
(
opts
)
id
=
p
.
xeth
()
.
Whisper
()
.
Watch
(
opts
)
p
.
messages
[
id
]
=
&
whisperFilter
{
timeout
:
time
.
Now
()}
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
return
nil
}
}
...
@@ -485,7 +485,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -485,7 +485,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
return
err
return
err
}
}
*
reply
=
t
oHex
(
crypto
.
Sha3
(
common
.
FromHex
(
args
.
Data
)))
*
reply
=
common
.
T
oHex
(
crypto
.
Sha3
(
common
.
FromHex
(
args
.
Data
)))
case
"web3_clientVersion"
:
case
"web3_clientVersion"
:
*
reply
=
p
.
xeth
()
.
Backend
()
.
Version
()
*
reply
=
p
.
xeth
()
.
Backend
()
.
Version
()
case
"net_version"
:
case
"net_version"
:
...
@@ -493,7 +493,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -493,7 +493,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
case
"net_listening"
:
case
"net_listening"
:
*
reply
=
p
.
xeth
()
.
IsListening
()
*
reply
=
p
.
xeth
()
.
IsListening
()
case
"net_peerCount"
:
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"
:
case
"eth_coinbase"
:
// TODO handling of empty coinbase due to lack of accounts
// TODO handling of empty coinbase due to lack of accounts
res
:=
p
.
xeth
()
.
Coinbase
()
res
:=
p
.
xeth
()
.
Coinbase
()
...
@@ -505,11 +505,11 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -505,11 +505,11 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
case
"eth_mining"
:
case
"eth_mining"
:
*
reply
=
p
.
xeth
()
.
IsMining
()
*
reply
=
p
.
xeth
()
.
IsMining
()
case
"eth_gasPrice"
:
case
"eth_gasPrice"
:
*
reply
=
t
oHex
(
defaultGasPrice
.
Bytes
())
*
reply
=
common
.
T
oHex
(
defaultGasPrice
.
Bytes
())
case
"eth_accounts"
:
case
"eth_accounts"
:
*
reply
=
p
.
xeth
()
.
Accounts
()
*
reply
=
p
.
xeth
()
.
Accounts
()
case
"eth_blockNumber"
:
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"
:
case
"eth_getBalance"
:
args
:=
new
(
GetBalanceArgs
)
args
:=
new
(
GetBalanceArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
@@ -544,7 +544,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -544,7 +544,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
*
reply
=
t
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
case
"eth_getBlockTransactionCountByNumber"
:
case
"eth_getBlockTransactionCountByNumber"
:
args
:=
new
(
GetBlockByNumberArgs
)
args
:=
new
(
GetBlockByNumberArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
@@ -555,7 +555,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -555,7 +555,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
*
reply
=
t
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
case
"eth_getUncleCountByBlockHash"
:
case
"eth_getUncleCountByBlockHash"
:
args
:=
new
(
GetBlockByHashArgs
)
args
:=
new
(
GetBlockByHashArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
@@ -566,7 +566,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -566,7 +566,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
*
reply
=
t
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
case
"eth_getUncleCountByBlockNumber"
:
case
"eth_getUncleCountByBlockNumber"
:
args
:=
new
(
GetBlockByNumberArgs
)
args
:=
new
(
GetBlockByNumberArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
@@ -577,7 +577,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -577,7 +577,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
*
reply
=
t
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
*
reply
=
common
.
T
oHex
(
big
.
NewInt
(
v
)
.
Bytes
())
case
"eth_getData"
,
"eth_getCode"
:
case
"eth_getData"
,
"eth_getCode"
:
args
:=
new
(
GetDataArgs
)
args
:=
new
(
GetDataArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
@@ -668,7 +668,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -668,7 +668,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
NewValidationError
(
"Index"
,
"does not exist"
)
return
NewValidationError
(
"Index"
,
"does not exist"
)
}
}
uncle
,
err
:=
p
.
GetBlockByHash
(
t
oHex
(
v
.
Uncles
[
args
.
Index
]),
false
)
uncle
,
err
:=
p
.
GetBlockByHash
(
common
.
T
oHex
(
v
.
Uncles
[
args
.
Index
]),
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -687,7 +687,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
...
@@ -687,7 +687,7 @@ func (p *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) error
return
NewValidationError
(
"Index"
,
"does not exist"
)
return
NewValidationError
(
"Index"
,
"does not exist"
)
}
}
uncle
,
err
:=
p
.
GetBlockByHash
(
t
oHex
(
v
.
Uncles
[
args
.
Index
]),
false
)
uncle
,
err
:=
p
.
GetBlockByHash
(
common
.
T
oHex
(
v
.
Uncles
[
args
.
Index
]),
false
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
rpc/responses.go
View file @
e30c3233
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
// "fmt"
// "fmt"
"math/big"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
)
)
...
@@ -56,23 +57,23 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
...
@@ -56,23 +57,23 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
}
}
// convert strict types to hexified strings
// 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
=
t
oHex
(
b
.
BlockHash
)
ext
.
BlockHash
=
common
.
T
oHex
(
b
.
BlockHash
)
ext
.
ParentHash
=
t
oHex
(
b
.
ParentHash
)
ext
.
ParentHash
=
common
.
T
oHex
(
b
.
ParentHash
)
ext
.
Nonce
=
t
oHex
(
b
.
Nonce
)
ext
.
Nonce
=
common
.
T
oHex
(
b
.
Nonce
)
ext
.
Sha3Uncles
=
t
oHex
(
b
.
Sha3Uncles
)
ext
.
Sha3Uncles
=
common
.
T
oHex
(
b
.
Sha3Uncles
)
ext
.
LogsBloom
=
t
oHex
(
b
.
LogsBloom
)
ext
.
LogsBloom
=
common
.
T
oHex
(
b
.
LogsBloom
)
ext
.
TransactionRoot
=
t
oHex
(
b
.
TransactionRoot
)
ext
.
TransactionRoot
=
common
.
T
oHex
(
b
.
TransactionRoot
)
ext
.
StateRoot
=
t
oHex
(
b
.
StateRoot
)
ext
.
StateRoot
=
common
.
T
oHex
(
b
.
StateRoot
)
ext
.
Miner
=
t
oHex
(
b
.
Miner
)
ext
.
Miner
=
common
.
T
oHex
(
b
.
Miner
)
ext
.
Difficulty
=
t
oHex
(
big
.
NewInt
(
b
.
Difficulty
)
.
Bytes
())
ext
.
Difficulty
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
Difficulty
)
.
Bytes
())
ext
.
TotalDifficulty
=
t
oHex
(
big
.
NewInt
(
b
.
TotalDifficulty
)
.
Bytes
())
ext
.
TotalDifficulty
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
TotalDifficulty
)
.
Bytes
())
ext
.
Size
=
t
oHex
(
big
.
NewInt
(
b
.
Size
)
.
Bytes
())
ext
.
Size
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
Size
)
.
Bytes
())
// ext.ExtraData =
t
oHex(b.ExtraData)
// ext.ExtraData =
common.T
oHex(b.ExtraData)
ext
.
GasLimit
=
t
oHex
(
big
.
NewInt
(
b
.
GasLimit
)
.
Bytes
())
ext
.
GasLimit
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
GasLimit
)
.
Bytes
())
// ext.MinGasPrice =
t
oHex(big.NewInt(b.MinGasPrice).Bytes())
// ext.MinGasPrice =
common.T
oHex(big.NewInt(b.MinGasPrice).Bytes())
ext
.
GasUsed
=
t
oHex
(
big
.
NewInt
(
b
.
GasUsed
)
.
Bytes
())
ext
.
GasUsed
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
GasUsed
)
.
Bytes
())
ext
.
UnixTimestamp
=
t
oHex
(
big
.
NewInt
(
b
.
UnixTimestamp
)
.
Bytes
())
ext
.
UnixTimestamp
=
common
.
T
oHex
(
big
.
NewInt
(
b
.
UnixTimestamp
)
.
Bytes
())
ext
.
Transactions
=
make
([]
interface
{},
len
(
b
.
Transactions
))
ext
.
Transactions
=
make
([]
interface
{},
len
(
b
.
Transactions
))
if
b
.
fullTx
{
if
b
.
fullTx
{
for
i
,
tx
:=
range
b
.
Transactions
{
for
i
,
tx
:=
range
b
.
Transactions
{
...
@@ -80,12 +81,12 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
...
@@ -80,12 +81,12 @@ func (b *BlockRes) MarshalJSON() ([]byte, error) {
}
}
}
else
{
}
else
{
for
i
,
tx
:=
range
b
.
Transactions
{
for
i
,
tx
:=
range
b
.
Transactions
{
ext
.
Transactions
[
i
]
=
t
oHex
(
tx
.
Hash
)
ext
.
Transactions
[
i
]
=
common
.
T
oHex
(
tx
.
Hash
)
}
}
}
}
ext
.
Uncles
=
make
([]
string
,
len
(
b
.
Uncles
))
ext
.
Uncles
=
make
([]
string
,
len
(
b
.
Uncles
))
for
i
,
v
:=
range
b
.
Uncles
{
for
i
,
v
:=
range
b
.
Uncles
{
ext
.
Uncles
[
i
]
=
t
oHex
(
v
)
ext
.
Uncles
[
i
]
=
common
.
T
oHex
(
v
)
}
}
return
json
.
Marshal
(
ext
)
return
json
.
Marshal
(
ext
)
...
@@ -160,17 +161,17 @@ func (t *TransactionRes) MarshalJSON() ([]byte, error) {
...
@@ -160,17 +161,17 @@ func (t *TransactionRes) MarshalJSON() ([]byte, error) {
Input
string
`json:"input"`
Input
string
`json:"input"`
}
}
ext
.
Hash
=
t
oHex
(
t
.
Hash
)
ext
.
Hash
=
common
.
T
oHex
(
t
.
Hash
)
ext
.
Nonce
=
t
oHex
(
big
.
NewInt
(
t
.
Nonce
)
.
Bytes
())
ext
.
Nonce
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
Nonce
)
.
Bytes
())
ext
.
BlockHash
=
t
oHex
(
t
.
BlockHash
)
ext
.
BlockHash
=
common
.
T
oHex
(
t
.
BlockHash
)
ext
.
BlockNumber
=
t
oHex
(
big
.
NewInt
(
t
.
BlockNumber
)
.
Bytes
())
ext
.
BlockNumber
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
BlockNumber
)
.
Bytes
())
ext
.
TxIndex
=
t
oHex
(
big
.
NewInt
(
t
.
TxIndex
)
.
Bytes
())
ext
.
TxIndex
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
TxIndex
)
.
Bytes
())
ext
.
From
=
t
oHex
(
t
.
From
)
ext
.
From
=
common
.
T
oHex
(
t
.
From
)
ext
.
To
=
t
oHex
(
t
.
To
)
ext
.
To
=
common
.
T
oHex
(
t
.
To
)
ext
.
Value
=
t
oHex
(
big
.
NewInt
(
t
.
Value
)
.
Bytes
())
ext
.
Value
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
Value
)
.
Bytes
())
ext
.
Gas
=
t
oHex
(
big
.
NewInt
(
t
.
Gas
)
.
Bytes
())
ext
.
Gas
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
Gas
)
.
Bytes
())
ext
.
GasPrice
=
t
oHex
(
big
.
NewInt
(
t
.
GasPrice
)
.
Bytes
())
ext
.
GasPrice
=
common
.
T
oHex
(
big
.
NewInt
(
t
.
GasPrice
)
.
Bytes
())
ext
.
Input
=
t
oHex
(
t
.
Input
)
ext
.
Input
=
common
.
T
oHex
(
t
.
Input
)
return
json
.
Marshal
(
ext
)
return
json
.
Marshal
(
ext
)
}
}
...
...
rpc/util.go
View file @
e30c3233
...
@@ -90,17 +90,8 @@ func UnmarshalRawMessages(b []byte, iface interface{}, number *int64) (err error
...
@@ -90,17 +90,8 @@ func UnmarshalRawMessages(b []byte, iface interface{}, number *int64) (err error
return
nil
return
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
{
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
{
type
RpcServer
interface
{
...
@@ -121,11 +112,11 @@ func toLogs(logs state.Logs) (ls []Log) {
...
@@ -121,11 +112,11 @@ func toLogs(logs state.Logs) (ls []Log) {
for
i
,
log
:=
range
logs
{
for
i
,
log
:=
range
logs
{
var
l
Log
var
l
Log
l
.
Topic
=
make
([]
string
,
len
(
log
.
Topics
()))
l
.
Topic
=
make
([]
string
,
len
(
log
.
Topics
()))
l
.
Address
=
t
oHex
(
log
.
Address
())
l
.
Address
=
common
.
T
oHex
(
log
.
Address
())
l
.
Data
=
t
oHex
(
log
.
Data
())
l
.
Data
=
common
.
T
oHex
(
log
.
Data
())
l
.
Number
=
log
.
Number
()
l
.
Number
=
log
.
Number
()
for
j
,
topic
:=
range
log
.
Topics
()
{
for
j
,
topic
:=
range
log
.
Topics
()
{
l
.
Topic
[
j
]
=
t
oHex
(
topic
)
l
.
Topic
[
j
]
=
common
.
T
oHex
(
topic
)
}
}
ls
[
i
]
=
l
ls
[
i
]
=
l
}
}
...
...
ui/qt/qwhisper/whisper.go
View file @
e30c3233
...
@@ -4,8 +4,8 @@ package qwhisper
...
@@ -4,8 +4,8 @@ package qwhisper
import
(
import
(
"time"
"time"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/whisper"
"github.com/ethereum/go-ethereum/whisper"
"github.com/obscuren/qml"
"github.com/obscuren/qml"
...
@@ -13,8 +13,6 @@ import (
...
@@ -13,8 +13,6 @@ import (
var
qlogger
=
logger
.
NewLogger
(
"QSHH"
)
var
qlogger
=
logger
.
NewLogger
(
"QSHH"
)
func
toHex
(
b
[]
byte
)
string
{
return
"0x"
+
common
.
Bytes2Hex
(
b
)
}
type
Whisper
struct
{
type
Whisper
struct
{
*
whisper
.
Whisper
*
whisper
.
Whisper
view
qml
.
Object
view
qml
.
Object
...
@@ -66,7 +64,7 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr
...
@@ -66,7 +64,7 @@ func (self *Whisper) Post(payload []string, to, from string, topics []string, pr
func
(
self
*
Whisper
)
NewIdentity
()
string
{
func
(
self
*
Whisper
)
NewIdentity
()
string
{
key
:=
self
.
Whisper
.
NewIdentity
()
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
{
func
(
self
*
Whisper
)
HasIdentity
(
key
string
)
bool
{
...
...
xeth/types.go
View file @
e30c3233
...
@@ -5,19 +5,15 @@ import (
...
@@ -5,19 +5,15 @@ import (
"fmt"
"fmt"
"strings"
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
)
)
func
toHex
(
b
[]
byte
)
string
{
return
"0x"
+
common
.
Bytes2Hex
(
b
)
}
type
Object
struct
{
type
Object
struct
{
*
state
.
StateObject
*
state
.
StateObject
}
}
...
@@ -49,7 +45,7 @@ func (self *Object) Storage() (storage map[string]string) {
...
@@ -49,7 +45,7 @@ func (self *Object) Storage() (storage map[string]string) {
for
it
.
Next
()
{
for
it
.
Next
()
{
var
data
[]
byte
var
data
[]
byte
rlp
.
Decode
(
bytes
.
NewReader
(
it
.
Value
),
&
data
)
rlp
.
Decode
(
bytes
.
NewReader
(
it
.
Value
),
&
data
)
storage
[
toHex
(
it
.
Key
)]
=
t
oHex
(
data
)
storage
[
common
.
ToHex
(
it
.
Key
)]
=
common
.
T
oHex
(
data
)
}
}
return
return
...
@@ -95,12 +91,12 @@ func NewBlock(block *types.Block) *Block {
...
@@ -95,12 +91,12 @@ func NewBlock(block *types.Block) *Block {
return
&
Block
{
return
&
Block
{
ref
:
block
,
Size
:
block
.
Size
()
.
String
(),
ref
:
block
,
Size
:
block
.
Size
()
.
String
(),
Number
:
int
(
block
.
NumberU64
()),
GasUsed
:
block
.
GasUsed
()
.
String
(),
Number
:
int
(
block
.
NumberU64
()),
GasUsed
:
block
.
GasUsed
()
.
String
(),
GasLimit
:
block
.
GasLimit
()
.
String
(),
Hash
:
t
oHex
(
block
.
Hash
()),
GasLimit
:
block
.
GasLimit
()
.
String
(),
Hash
:
common
.
T
oHex
(
block
.
Hash
()),
Transactions
:
txlist
,
Uncles
:
ulist
,
Transactions
:
txlist
,
Uncles
:
ulist
,
Time
:
block
.
Time
(),
Time
:
block
.
Time
(),
Coinbase
:
t
oHex
(
block
.
Coinbase
()),
Coinbase
:
common
.
T
oHex
(
block
.
Coinbase
()),
PrevHash
:
t
oHex
(
block
.
ParentHash
()),
PrevHash
:
common
.
T
oHex
(
block
.
ParentHash
()),
Bloom
:
t
oHex
(
block
.
Bloom
()),
Bloom
:
common
.
T
oHex
(
block
.
Bloom
()),
Raw
:
block
.
String
(),
Raw
:
block
.
String
(),
}
}
}
}
...
@@ -139,22 +135,22 @@ type Transaction struct {
...
@@ -139,22 +135,22 @@ type Transaction struct {
}
}
func
NewTx
(
tx
*
types
.
Transaction
)
*
Transaction
{
func
NewTx
(
tx
*
types
.
Transaction
)
*
Transaction
{
hash
:=
t
oHex
(
tx
.
Hash
())
hash
:=
common
.
T
oHex
(
tx
.
Hash
())
receiver
:=
t
oHex
(
tx
.
To
())
receiver
:=
common
.
T
oHex
(
tx
.
To
())
if
len
(
receiver
)
==
0
{
if
len
(
receiver
)
==
0
{
receiver
=
t
oHex
(
core
.
AddressFromMessage
(
tx
))
receiver
=
common
.
T
oHex
(
core
.
AddressFromMessage
(
tx
))
}
}
sender
:=
t
oHex
(
tx
.
From
())
sender
:=
common
.
T
oHex
(
tx
.
From
())
createsContract
:=
core
.
MessageCreatesContract
(
tx
)
createsContract
:=
core
.
MessageCreatesContract
(
tx
)
var
data
string
var
data
string
if
createsContract
{
if
createsContract
{
data
=
strings
.
Join
(
core
.
Disassemble
(
tx
.
Data
()),
"
\n
"
)
data
=
strings
.
Join
(
core
.
Disassemble
(
tx
.
Data
()),
"
\n
"
)
}
else
{
}
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
,
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
,
CreatesContract
:
createsContract
,
RawData
:
common
.
T
oHex
(
tx
.
Data
())}
}
}
func
(
self
*
Transaction
)
ToString
()
string
{
func
(
self
*
Transaction
)
ToString
()
string
{
...
@@ -168,7 +164,7 @@ type Key struct {
...
@@ -168,7 +164,7 @@ type Key struct {
}
}
func
NewKey
(
key
*
crypto
.
KeyPair
)
*
Key
{
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
{
type
PReceipt
struct
{
...
@@ -181,9 +177,9 @@ type PReceipt struct {
...
@@ -181,9 +177,9 @@ type PReceipt struct {
func
NewPReciept
(
contractCreation
bool
,
creationAddress
,
hash
,
address
[]
byte
)
*
PReceipt
{
func
NewPReciept
(
contractCreation
bool
,
creationAddress
,
hash
,
address
[]
byte
)
*
PReceipt
{
return
&
PReceipt
{
return
&
PReceipt
{
contractCreation
,
contractCreation
,
t
oHex
(
creationAddress
),
common
.
T
oHex
(
creationAddress
),
t
oHex
(
hash
),
common
.
T
oHex
(
hash
),
t
oHex
(
address
),
common
.
T
oHex
(
address
),
}
}
}
}
...
@@ -220,8 +216,8 @@ type Receipt struct {
...
@@ -220,8 +216,8 @@ type Receipt struct {
func
NewReciept
(
contractCreation
bool
,
creationAddress
,
hash
,
address
[]
byte
)
*
Receipt
{
func
NewReciept
(
contractCreation
bool
,
creationAddress
,
hash
,
address
[]
byte
)
*
Receipt
{
return
&
Receipt
{
return
&
Receipt
{
contractCreation
,
contractCreation
,
t
oHex
(
creationAddress
),
common
.
T
oHex
(
creationAddress
),
t
oHex
(
hash
),
common
.
T
oHex
(
hash
),
t
oHex
(
address
),
common
.
T
oHex
(
address
),
}
}
}
}
xeth/whisper.go
View file @
e30c3233
...
@@ -56,7 +56,7 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
...
@@ -56,7 +56,7 @@ func (self *Whisper) Post(payload string, to, from string, topics []string, prio
func
(
self
*
Whisper
)
NewIdentity
()
string
{
func
(
self
*
Whisper
)
NewIdentity
()
string
{
key
:=
self
.
Whisper
.
NewIdentity
()
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
{
func
(
self
*
Whisper
)
HasIdentity
(
key
string
)
bool
{
...
@@ -112,9 +112,9 @@ type WhisperMessage struct {
...
@@ -112,9 +112,9 @@ type WhisperMessage struct {
func
NewWhisperMessage
(
msg
*
whisper
.
Message
)
WhisperMessage
{
func
NewWhisperMessage
(
msg
*
whisper
.
Message
)
WhisperMessage
{
return
WhisperMessage
{
return
WhisperMessage
{
ref
:
msg
,
ref
:
msg
,
Payload
:
t
oHex
(
msg
.
Payload
),
Payload
:
common
.
T
oHex
(
msg
.
Payload
),
From
:
t
oHex
(
crypto
.
FromECDSAPub
(
msg
.
Recover
())),
From
:
common
.
T
oHex
(
crypto
.
FromECDSAPub
(
msg
.
Recover
())),
To
:
t
oHex
(
crypto
.
FromECDSAPub
(
msg
.
To
)),
To
:
common
.
T
oHex
(
crypto
.
FromECDSAPub
(
msg
.
To
)),
Sent
:
msg
.
Sent
,
Sent
:
msg
.
Sent
,
}
}
}
}
xeth/xeth.go
View file @
e30c3233
...
@@ -8,10 +8,10 @@ import (
...
@@ -8,10 +8,10 @@ import (
"math/big"
"math/big"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p"
...
@@ -170,7 +170,7 @@ func (self *XEth) Accounts() []string {
...
@@ -170,7 +170,7 @@ func (self *XEth) Accounts() []string {
accounts
,
_
:=
self
.
eth
.
AccountManager
()
.
Accounts
()
accounts
,
_
:=
self
.
eth
.
AccountManager
()
.
Accounts
()
accountAddresses
:=
make
([]
string
,
len
(
accounts
))
accountAddresses
:=
make
([]
string
,
len
(
accounts
))
for
i
,
ac
:=
range
accounts
{
for
i
,
ac
:=
range
accounts
{
accountAddresses
[
i
]
=
t
oHex
(
ac
.
Address
)
accountAddresses
[
i
]
=
common
.
T
oHex
(
ac
.
Address
)
}
}
return
accountAddresses
return
accountAddresses
}
}
...
@@ -201,7 +201,7 @@ func (self *XEth) IsListening() bool {
...
@@ -201,7 +201,7 @@ func (self *XEth) IsListening() bool {
func
(
self
*
XEth
)
Coinbase
()
string
{
func
(
self
*
XEth
)
Coinbase
()
string
{
cb
,
_
:=
self
.
eth
.
AccountManager
()
.
Coinbase
()
cb
,
_
:=
self
.
eth
.
AccountManager
()
.
Coinbase
()
return
t
oHex
(
cb
)
return
common
.
T
oHex
(
cb
)
}
}
func
(
self
*
XEth
)
NumberToHuman
(
balance
string
)
string
{
func
(
self
*
XEth
)
NumberToHuman
(
balance
string
)
string
{
...
@@ -213,7 +213,7 @@ 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
{
func
(
self
*
XEth
)
StorageAt
(
addr
,
storageAddr
string
)
string
{
storage
:=
self
.
State
()
.
SafeGet
(
addr
)
.
StorageString
(
storageAddr
)
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
{
func
(
self
*
XEth
)
BalanceAt
(
addr
string
)
string
{
...
@@ -225,7 +225,7 @@ func (self *XEth) TxCountAt(address string) int {
...
@@ -225,7 +225,7 @@ func (self *XEth) TxCountAt(address string) int {
}
}
func
(
self
*
XEth
)
CodeAt
(
address
string
)
string
{
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
{
func
(
self
*
XEth
)
IsContract
(
address
string
)
bool
{
...
@@ -238,7 +238,7 @@ func (self *XEth) SecretToAddress(key string) string {
...
@@ -238,7 +238,7 @@ func (self *XEth) SecretToAddress(key string) string {
return
""
return
""
}
}
return
t
oHex
(
pair
.
Address
())
return
common
.
T
oHex
(
pair
.
Address
())
}
}
type
KeyVal
struct
{
type
KeyVal
struct
{
...
@@ -251,7 +251,7 @@ func (self *XEth) EachStorage(addr string) string {
...
@@ -251,7 +251,7 @@ func (self *XEth) EachStorage(addr string) string {
object
:=
self
.
State
()
.
SafeGet
(
addr
)
object
:=
self
.
State
()
.
SafeGet
(
addr
)
it
:=
object
.
Trie
()
.
Iterator
()
it
:=
object
.
Trie
()
.
Iterator
()
for
it
.
Next
()
{
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
)
valuesJson
,
err
:=
json
.
Marshal
(
values
)
...
@@ -265,7 +265,7 @@ func (self *XEth) EachStorage(addr string) string {
...
@@ -265,7 +265,7 @@ func (self *XEth) EachStorage(addr string) string {
func
(
self
*
XEth
)
ToAscii
(
str
string
)
string
{
func
(
self
*
XEth
)
ToAscii
(
str
string
)
string
{
padded
:=
common
.
RightPadBytes
([]
byte
(
str
),
32
)
padded
:=
common
.
RightPadBytes
([]
byte
(
str
),
32
)
return
"0x"
+
t
oHex
(
padded
)
return
"0x"
+
common
.
T
oHex
(
padded
)
}
}
func
(
self
*
XEth
)
FromAscii
(
str
string
)
string
{
func
(
self
*
XEth
)
FromAscii
(
str
string
)
string
{
...
@@ -293,9 +293,9 @@ func (self *XEth) PushTx(encodedTx string) (string, error) {
...
@@ -293,9 +293,9 @@ func (self *XEth) PushTx(encodedTx string) (string, error) {
if
tx
.
To
()
==
nil
{
if
tx
.
To
()
==
nil
{
addr
:=
core
.
AddressFromMessage
(
tx
)
addr
:=
core
.
AddressFromMessage
(
tx
)
return
t
oHex
(
addr
),
nil
return
common
.
T
oHex
(
addr
),
nil
}
}
return
t
oHex
(
tx
.
Hash
()),
nil
return
common
.
T
oHex
(
tx
.
Hash
()),
nil
}
}
var
(
var
(
...
@@ -325,7 +325,7 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
...
@@ -325,7 +325,7 @@ func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr st
vmenv
:=
core
.
NewEnv
(
statedb
,
self
.
chainManager
,
msg
,
block
)
vmenv
:=
core
.
NewEnv
(
statedb
,
self
.
chainManager
,
msg
,
block
)
res
,
err
:=
vmenv
.
Call
(
msg
.
from
,
msg
.
to
,
msg
.
data
,
msg
.
gas
,
msg
.
gasPrice
,
msg
.
value
)
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
)
{
func
(
self
*
XEth
)
Transact
(
fromStr
,
toStr
,
valueStr
,
gasStr
,
gasPriceStr
,
codeStr
string
)
(
string
,
error
)
{
...
@@ -371,9 +371,9 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
...
@@ -371,9 +371,9 @@ func (self *XEth) Transact(fromStr, toStr, valueStr, gasStr, gasPriceStr, codeSt
}
}
if
types
.
IsContractAddr
(
to
)
{
if
types
.
IsContractAddr
(
to
)
{
return
t
oHex
(
core
.
AddressFromMessage
(
tx
)),
nil
return
common
.
T
oHex
(
core
.
AddressFromMessage
(
tx
)),
nil
}
}
return
t
oHex
(
tx
.
Hash
()),
nil
return
common
.
T
oHex
(
tx
.
Hash
()),
nil
}
}
func
(
self
*
XEth
)
sign
(
tx
*
types
.
Transaction
,
from
[]
byte
,
didUnlock
bool
)
error
{
func
(
self
*
XEth
)
sign
(
tx
*
types
.
Transaction
,
from
[]
byte
,
didUnlock
bool
)
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