|
|
|
@ -5,10 +5,10 @@ import ( |
|
|
|
|
"fmt" |
|
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
|
"github.com/ethereum/go-ethereum/core" |
|
|
|
|
"github.com/ethereum/go-ethereum/core/types" |
|
|
|
|
"github.com/ethereum/go-ethereum/crypto" |
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
|
"github.com/ethereum/go-ethereum/p2p" |
|
|
|
|
"github.com/ethereum/go-ethereum/rlp" |
|
|
|
|
"github.com/ethereum/go-ethereum/state" |
|
|
|
@ -95,12 +95,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()), |
|
|
|
|
GasLimit: block.GasLimit().String(), Hash: toHex(block.Hash().Bytes()), |
|
|
|
|
Transactions: txlist, Uncles: ulist, |
|
|
|
|
Time: block.Time(), |
|
|
|
|
Coinbase: toHex(block.Coinbase()), |
|
|
|
|
PrevHash: toHex(block.ParentHash()), |
|
|
|
|
Bloom: toHex(block.Bloom()), |
|
|
|
|
Coinbase: toHex(block.Coinbase().Bytes()), |
|
|
|
|
PrevHash: toHex(block.ParentHash().Bytes()), |
|
|
|
|
Bloom: toHex(block.Bloom().Bytes()), |
|
|
|
|
Raw: block.String(), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -114,7 +114,7 @@ func (self *Block) ToString() string { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (self *Block) GetTransaction(hash string) *Transaction { |
|
|
|
|
tx := self.ref.Transaction(common.FromHex(hash)) |
|
|
|
|
tx := self.ref.Transaction(common.HexToHash(hash)) |
|
|
|
|
if tx == nil { |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
@ -139,8 +139,8 @@ type Transaction struct { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func NewTx(tx *types.Transaction) *Transaction { |
|
|
|
|
hash := toHex(tx.Hash()) |
|
|
|
|
receiver := toHex(tx.To()) |
|
|
|
|
hash := tx.Hash().Hex() |
|
|
|
|
receiver := tx.To().Hex() |
|
|
|
|
if len(receiver) == 0 { |
|
|
|
|
receiver = toHex(core.AddressFromMessage(tx)) |
|
|
|
|
} |
|
|
|
|