Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes for getTransaction API #2205

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/types/transaction_marshalling.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ func (t *Transaction) MarshalJSON() ([]byte, error) {
// These are set for all tx types.
enc.Hash = t.Hash()
enc.Type = hexutil.Uint64(t.Type())

var to *common.MixedcaseAddress
if t.To() != nil {
to = t.To().MixedcaseAddressPtr()
}
// Other fields are set conditionally depending on tx type.
switch tx := t.inner.(type) {
case *QuaiTx:
Expand All @@ -91,7 +94,7 @@ func (t *Transaction) MarshalJSON() ([]byte, error) {
enc.GasPrice = (*hexutil.Big)(tx.GasPrice)
enc.Value = (*hexutil.Big)(tx.Value)
enc.Data = (*hexutil.Bytes)(&tx.Data)
enc.To = t.To().MixedcaseAddressPtr()
enc.To = to
enc.V = (*hexutil.Big)(tx.V)
enc.R = (*hexutil.Big)(tx.R)
enc.S = (*hexutil.Big)(tx.S)
Expand Down
8 changes: 6 additions & 2 deletions internal/quaiapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ type RPCTransaction struct {
GasPrice *hexutil.Big `json:"gasPrice,omitempty"`
Hash common.Hash `json:"hash,omitempty"`
Input hexutil.Bytes `json:"input,omitempty"`
Nonce hexutil.Uint64 `json:"nonce,omitempty"`
Nonce hexutil.Uint64 `json:"nonce"`
To *common.MixedcaseAddress `json:"to,omitempty"`
TransactionIndex *hexutil.Uint64 `json:"transactionIndex"`
Value *hexutil.Big `json:"value,omitempty"`
Expand Down Expand Up @@ -1054,14 +1054,18 @@ func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber
// because the return value of ChainId is zero for those transactions.
signer := types.LatestSignerForChainID(tx.ChainId(), nodeLocation)
from, _ := types.Sender(signer, tx)
var to *common.MixedcaseAddress
if tx.To() != nil {
to = tx.To().MixedcaseAddressPtr()
}
result = &RPCTransaction{
Type: hexutil.Uint64(tx.Type()),
From: from.MixedcaseAddressPtr(),
Gas: hexutil.Uint64(tx.Gas()),
Hash: tx.Hash(),
Input: hexutil.Bytes(tx.Data()),
Nonce: hexutil.Uint64(tx.Nonce()),
To: tx.To().MixedcaseAddressPtr(),
To: to,
Value: (*hexutil.Big)(tx.Value()),
ChainID: (*hexutil.Big)(tx.ChainId()),
GasPrice: (*hexutil.Big)(tx.GasPrice()),
Expand Down
Loading