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
35add89c
Commit
35add89c
authored
Jul 06, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1397 from tgerring/rpcreceipt
getTransactionReceipt RPC support
parents
46e7c851
6c7f5e3d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
1 deletion
+60
-1
eth.go
rpc/api/eth.go
+26
-0
parsing.go
rpc/api/parsing.go
+33
-0
utils.go
rpc/api/utils.go
+1
-0
xeth.go
xeth/xeth.go
+0
-1
No files found.
rpc/api/eth.go
View file @
35add89c
...
...
@@ -77,6 +77,7 @@ var (
"eth_submitWork"
:
(
*
ethApi
)
.
SubmitWork
,
"eth_resend"
:
(
*
ethApi
)
.
Resend
,
"eth_pendingTransactions"
:
(
*
ethApi
)
.
PendingTransactions
,
"eth_getTransactionReceipt"
:
(
*
ethApi
)
.
GetTransactionReceipt
,
}
)
...
...
@@ -596,3 +597,28 @@ func (self *ethApi) PendingTransactions(req *shared.Request) (interface{}, error
return
ltxs
,
nil
}
func
(
self
*
ethApi
)
GetTransactionReceipt
(
req
*
shared
.
Request
)
(
interface
{},
error
)
{
args
:=
new
(
HashArgs
)
if
err
:=
self
.
codec
.
Decode
(
req
.
Params
,
&
args
);
err
!=
nil
{
return
nil
,
shared
.
NewDecodeParamError
(
err
.
Error
())
}
txhash
:=
common
.
BytesToHash
(
common
.
FromHex
(
args
.
Hash
))
tx
,
bhash
,
bnum
,
txi
:=
self
.
xeth
.
EthTransactionByHash
(
args
.
Hash
)
rec
:=
self
.
xeth
.
GetTxReceipt
(
txhash
)
// We could have an error of "not found". Should disambiguate
// if err != nil {
// return err, nil
// }
if
rec
!=
nil
&&
tx
!=
nil
{
v
:=
NewReceiptRes
(
rec
)
v
.
BlockHash
=
newHexData
(
bhash
)
v
.
BlockNumber
=
newHexNum
(
bnum
)
v
.
GasUsed
=
newHexNum
(
tx
.
Gas
()
.
Bytes
())
v
.
TransactionIndex
=
newHexNum
(
txi
)
return
v
,
nil
}
return
nil
,
nil
}
rpc/api/parsing.go
View file @
35add89c
package
api
import
(
"bytes"
"encoding/binary"
"encoding/hex"
"encoding/json"
...
...
@@ -402,6 +403,38 @@ func NewUncleRes(h *types.Header) *UncleRes {
// WorkProved string `json:"workProved"`
// }
type
ReceiptRes
struct
{
TransactionHash
*
hexdata
`json:transactionHash`
TransactionIndex
*
hexnum
`json:transactionIndex`
BlockNumber
*
hexnum
`json:blockNumber`
BlockHash
*
hexdata
`json:blockHash`
CumulativeGasUsed
*
hexnum
`json:cumulativeGasUsed`
GasUsed
*
hexnum
`json:gasUsed`
ContractAddress
*
hexdata
`json:contractAddress`
Logs
*
[]
interface
{}
`json:logs`
}
func
NewReceiptRes
(
rec
*
types
.
Receipt
)
*
ReceiptRes
{
if
rec
==
nil
{
return
nil
}
var
v
=
new
(
ReceiptRes
)
v
.
TransactionHash
=
newHexData
(
rec
.
TxHash
)
// v.TransactionIndex = newHexNum(input)
// v.BlockNumber = newHexNum(input)
// v.BlockHash = newHexData(input)
v
.
CumulativeGasUsed
=
newHexNum
(
rec
.
CumulativeGasUsed
)
// v.GasUsed = newHexNum(input)
// If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation
if
bytes
.
Compare
(
rec
.
ContractAddress
.
Bytes
(),
bytes
.
Repeat
([]
byte
{
0
},
20
))
!=
0
{
v
.
ContractAddress
=
newHexData
(
rec
.
ContractAddress
)
}
// v.Logs = rec.Logs()
return
v
}
func
numString
(
raw
interface
{})
(
*
big
.
Int
,
error
)
{
var
number
*
big
.
Int
// Parse as integer
...
...
rpc/api/utils.go
View file @
35add89c
...
...
@@ -86,6 +86,7 @@ var (
"submitWork"
,
"pendingTransactions"
,
"resend"
,
"getTransactionReceipt"
,
},
"miner"
:
[]
string
{
"hashrate"
,
...
...
xeth/xeth.go
View file @
35add89c
...
...
@@ -969,7 +969,6 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS
if
contractCreation
{
addr
:=
crypto
.
CreateAddress
(
from
,
nonce
)
glog
.
V
(
logger
.
Info
)
.
Infof
(
"Tx(%x) created: %x
\n
"
,
tx
.
Hash
(),
addr
)
return
addr
.
Hex
(),
nil
}
else
{
glog
.
V
(
logger
.
Info
)
.
Infof
(
"Tx(%x) to: %x
\n
"
,
tx
.
Hash
(),
tx
.
To
())
}
...
...
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