Return nil for certain fields on eth_getTransactionByHash when not part of a block
This commit is contained in:
		
							parent
							
								
									d381d9a74c
								
							
						
					
					
						commit
						a528bd04db
					
				
							
								
								
									
										10
									
								
								rpc/api.go
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								rpc/api.go
									
									
									
									
									
								
							| @ -1,6 +1,7 @@ | |||||||
| package rpc | package rpc | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"bytes" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"math/big" | 	"math/big" | ||||||
| 	// "sync"
 | 	// "sync"
 | ||||||
| @ -247,9 +248,12 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err | |||||||
| 		tx, bhash, bnum, txi := api.xeth().EthTransactionByHash(args.Hash) | 		tx, bhash, bnum, txi := api.xeth().EthTransactionByHash(args.Hash) | ||||||
| 		if tx != nil { | 		if tx != nil { | ||||||
| 			v := NewTransactionRes(tx) | 			v := NewTransactionRes(tx) | ||||||
| 			v.BlockHash = newHexData(bhash) | 			// if the blockhash is 0, assume this is a pending transaction
 | ||||||
| 			v.BlockNumber = newHexNum(bnum) | 			if bytes.Compare(bhash.Bytes(), []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) != 0 { | ||||||
| 			v.TxIndex = newHexNum(txi) | 				v.BlockHash = newHexData(bhash) | ||||||
|  | 				v.BlockNumber = newHexNum(bnum) | ||||||
|  | 				v.TxIndex = newHexNum(txi) | ||||||
|  | 			} | ||||||
| 			*reply = v | 			*reply = v | ||||||
| 		} | 		} | ||||||
| 	case "eth_getTransactionByBlockHashAndIndex": | 	case "eth_getTransactionByBlockHashAndIndex": | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user