|
|
@ -23,6 +23,7 @@ type RPCTransaction struct { |
|
|
|
BlockHash common.Hash `json:"blockHash"` |
|
|
|
BlockHash common.Hash `json:"blockHash"` |
|
|
|
BlockNumber *hexutil.Big `json:"blockNumber"` |
|
|
|
BlockNumber *hexutil.Big `json:"blockNumber"` |
|
|
|
From string `json:"from"` |
|
|
|
From string `json:"from"` |
|
|
|
|
|
|
|
Timestamp hexutil.Uint64 `json:"timestamp"` |
|
|
|
Gas hexutil.Uint64 `json:"gas"` |
|
|
|
Gas hexutil.Uint64 `json:"gas"` |
|
|
|
GasPrice *hexutil.Big `json:"gasPrice"` |
|
|
|
GasPrice *hexutil.Big `json:"gasPrice"` |
|
|
|
Hash common.Hash `json:"hash"` |
|
|
|
Hash common.Hash `json:"hash"` |
|
|
@ -43,6 +44,7 @@ type RPCStakingTransaction struct { |
|
|
|
BlockHash common.Hash `json:"blockHash"` |
|
|
|
BlockHash common.Hash `json:"blockHash"` |
|
|
|
BlockNumber *hexutil.Big `json:"blockNumber"` |
|
|
|
BlockNumber *hexutil.Big `json:"blockNumber"` |
|
|
|
From string `json:"from"` |
|
|
|
From string `json:"from"` |
|
|
|
|
|
|
|
Timestamp hexutil.Uint64 `json:"timestamp"` |
|
|
|
Gas hexutil.Uint64 `json:"gas"` |
|
|
|
Gas hexutil.Uint64 `json:"gas"` |
|
|
|
GasPrice *hexutil.Big `json:"gasPrice"` |
|
|
|
GasPrice *hexutil.Big `json:"gasPrice"` |
|
|
|
Hash common.Hash `json:"hash"` |
|
|
|
Hash common.Hash `json:"hash"` |
|
|
@ -192,7 +194,7 @@ func newRPCValidator(validator *types2.Validator) *RPCValidator { |
|
|
|
|
|
|
|
|
|
|
|
// newRPCTransaction returns a transaction that will serialize to the RPC
|
|
|
|
// newRPCTransaction returns a transaction that will serialize to the RPC
|
|
|
|
// representation, with the given location metadata set (if available).
|
|
|
|
// representation, with the given location metadata set (if available).
|
|
|
|
func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCTransaction { |
|
|
|
func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, timestamp uint64, index uint64) *RPCTransaction { |
|
|
|
var signer types.Signer = types.FrontierSigner{} |
|
|
|
var signer types.Signer = types.FrontierSigner{} |
|
|
|
if tx.Protected() { |
|
|
|
if tx.Protected() { |
|
|
|
signer = types.NewEIP155Signer(tx.ChainID()) |
|
|
|
signer = types.NewEIP155Signer(tx.ChainID()) |
|
|
@ -208,6 +210,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber |
|
|
|
Value: (*hexutil.Big)(tx.Value()), |
|
|
|
Value: (*hexutil.Big)(tx.Value()), |
|
|
|
ShardID: tx.ShardID(), |
|
|
|
ShardID: tx.ShardID(), |
|
|
|
ToShardID: tx.ToShardID(), |
|
|
|
ToShardID: tx.ToShardID(), |
|
|
|
|
|
|
|
Timestamp: hexutil.Uint64(timestamp), |
|
|
|
V: (*hexutil.Big)(v), |
|
|
|
V: (*hexutil.Big)(v), |
|
|
|
R: (*hexutil.Big)(r), |
|
|
|
R: (*hexutil.Big)(r), |
|
|
|
S: (*hexutil.Big)(s), |
|
|
|
S: (*hexutil.Big)(s), |
|
|
@ -239,7 +242,7 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber |
|
|
|
|
|
|
|
|
|
|
|
// newRPCStakingTransaction returns a transaction that will serialize to the RPC
|
|
|
|
// newRPCStakingTransaction returns a transaction that will serialize to the RPC
|
|
|
|
// representation, with the given location metadata set (if available).
|
|
|
|
// representation, with the given location metadata set (if available).
|
|
|
|
func newRPCStakingTransaction(tx *types2.StakingTransaction, blockHash common.Hash, blockNumber uint64, index uint64) *RPCStakingTransaction { |
|
|
|
func newRPCStakingTransaction(tx *types2.StakingTransaction, blockHash common.Hash, blockNumber uint64, timestamp uint64, index uint64) *RPCStakingTransaction { |
|
|
|
from, _ := tx.SenderAddress() |
|
|
|
from, _ := tx.SenderAddress() |
|
|
|
v, r, s := tx.RawSignatureValues() |
|
|
|
v, r, s := tx.RawSignatureValues() |
|
|
|
|
|
|
|
|
|
|
@ -302,15 +305,16 @@ func newRPCStakingTransaction(tx *types2.StakingTransaction, blockHash common.Ha |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
result := &RPCStakingTransaction{ |
|
|
|
result := &RPCStakingTransaction{ |
|
|
|
Gas: hexutil.Uint64(tx.Gas()), |
|
|
|
Gas: hexutil.Uint64(tx.Gas()), |
|
|
|
GasPrice: (*hexutil.Big)(tx.Price()), |
|
|
|
GasPrice: (*hexutil.Big)(tx.Price()), |
|
|
|
Hash: tx.Hash(), |
|
|
|
Hash: tx.Hash(), |
|
|
|
Nonce: hexutil.Uint64(tx.Nonce()), |
|
|
|
Nonce: hexutil.Uint64(tx.Nonce()), |
|
|
|
V: (*hexutil.Big)(v), |
|
|
|
Timestamp: hexutil.Uint64(timestamp), |
|
|
|
R: (*hexutil.Big)(r), |
|
|
|
V: (*hexutil.Big)(v), |
|
|
|
S: (*hexutil.Big)(s), |
|
|
|
R: (*hexutil.Big)(r), |
|
|
|
Type: stakingTxType, |
|
|
|
S: (*hexutil.Big)(s), |
|
|
|
Msg: fields, |
|
|
|
Type: stakingTxType, |
|
|
|
|
|
|
|
Msg: fields, |
|
|
|
} |
|
|
|
} |
|
|
|
if blockHash != (common.Hash{}) { |
|
|
|
if blockHash != (common.Hash{}) { |
|
|
|
result.BlockHash = blockHash |
|
|
|
result.BlockHash = blockHash |
|
|
@ -329,7 +333,7 @@ func newRPCStakingTransaction(tx *types2.StakingTransaction, blockHash common.Ha |
|
|
|
|
|
|
|
|
|
|
|
// newRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation
|
|
|
|
// newRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation
|
|
|
|
func newRPCPendingTransaction(tx *types.Transaction) *RPCTransaction { |
|
|
|
func newRPCPendingTransaction(tx *types.Transaction) *RPCTransaction { |
|
|
|
return newRPCTransaction(tx, common.Hash{}, 0, 0) |
|
|
|
return newRPCTransaction(tx, common.Hash{}, 0, 0, 0) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RPCBlock represents a block that will serialize to the RPC representation of a block
|
|
|
|
// RPCBlock represents a block that will serialize to the RPC representation of a block
|
|
|
@ -448,7 +452,7 @@ func newRPCTransactionFromBlockIndex(b *types.Block, index uint64) *RPCTransacti |
|
|
|
if index >= uint64(len(txs)) { |
|
|
|
if index >= uint64(len(txs)) { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), index) |
|
|
|
return newRPCTransaction(txs[index], b.Hash(), b.NumberU64(), b.Time().Uint64(), index) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// newRPCStakingTransactionFromBlockHash returns a transaction that will serialize to the RPC representation.
|
|
|
|
// newRPCStakingTransactionFromBlockHash returns a transaction that will serialize to the RPC representation.
|
|
|
@ -467,7 +471,7 @@ func newRPCStakingTransactionFromBlockIndex(b *types.Block, index uint64) *RPCSt |
|
|
|
if index >= uint64(len(txs)) { |
|
|
|
if index >= uint64(len(txs)) { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
return newRPCStakingTransaction(txs[index], b.Hash(), b.NumberU64(), index) |
|
|
|
return newRPCStakingTransaction(txs[index], b.Hash(), b.NumberU64(), b.Time().Uint64(), index) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// CallArgs represents the arguments for a call.
|
|
|
|
// CallArgs represents the arguments for a call.
|
|
|
|