@@ -597,7 +597,7 @@ func (s *PublicBlockChainAPI) rpcOutputBlock(b *types.Block, inclTx bool, fullTx
597597 "gasUsed" : rpc .NewHexNumber (head .GasUsed ),
598598 "timestamp" : rpc .NewHexNumber (head .Time ),
599599 "transactionsRoot" : head .TxHash ,
600- "receiptsRoot" : head .ReceiptHash ,
600+ "receiptsRoot" : head .ReceiptHash ,
601601 }
602602
603603 if inclTx {
@@ -699,6 +699,16 @@ func newRPCTransactionFromBlockIndex(b *types.Block, txIndex int) (*RPCTransacti
699699 return nil , nil
700700}
701701
702+ // newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index.
703+ func newRPCRawTransactionFromBlockIndex (b * types.Block , txIndex int ) (rpc.HexBytes , error ) {
704+ if txIndex >= 0 && txIndex < len (b .Transactions ()) {
705+ tx := b .Transactions ()[txIndex ]
706+ return rlp .EncodeToBytes (tx )
707+ }
708+
709+ return nil , nil
710+ }
711+
702712// newRPCTransaction returns a transaction that will serialize to the RPC representation.
703713func newRPCTransaction (b * types.Block , txHash common.Hash ) (* RPCTransaction , error ) {
704714 for idx , tx := range b .Transactions () {
@@ -770,6 +780,22 @@ func (s *PublicTransactionPoolAPI) GetTransactionByBlockHashAndIndex(ctx context
770780 return nil , nil
771781}
772782
783+ // GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index.
784+ func (s * PublicTransactionPoolAPI ) GetRawTransactionByBlockNumberAndIndex (ctx context.Context , blockNr rpc.BlockNumber , index rpc.HexNumber ) (rpc.HexBytes , error ) {
785+ if block , _ := s .b .BlockByNumber (ctx , blockNr ); block != nil {
786+ return newRPCRawTransactionFromBlockIndex (block , index .Int ())
787+ }
788+ return nil , nil
789+ }
790+
791+ // GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index.
792+ func (s * PublicTransactionPoolAPI ) GetRawTransactionByBlockHashAndIndex (ctx context.Context , blockHash common.Hash , index rpc.HexNumber ) (rpc.HexBytes , error ) {
793+ if block , _ := s .b .GetBlock (ctx , blockHash ); block != nil {
794+ return newRPCRawTransactionFromBlockIndex (block , index .Int ())
795+ }
796+ return nil , nil
797+ }
798+
773799// GetTransactionCount returns the number of transactions the given address has sent for the given block number
774800func (s * PublicTransactionPoolAPI ) GetTransactionCount (ctx context.Context , address common.Address , blockNr rpc.BlockNumber ) (* rpc.HexNumber , error ) {
775801 state , _ , err := s .b .StateAndHeaderByNumber (blockNr )
@@ -835,6 +861,21 @@ func (s *PublicTransactionPoolAPI) GetTransactionByHash(ctx context.Context, txH
835861 return nil , nil
836862}
837863
864+ // GetRawTransactionByHash returns the bytes of the transaction for the given hash.
865+ func (s * PublicTransactionPoolAPI ) GetRawTransactionByHash (ctx context.Context , txHash common.Hash ) (rpc.HexBytes , error ) {
866+ var tx * types.Transaction
867+ var err error
868+
869+ if tx , _ , err = getTransaction (s .b .ChainDb (), s .b , txHash ); err != nil {
870+ glog .V (logger .Debug ).Infof ("%v\n " , err )
871+ return nil , nil
872+ } else if tx == nil {
873+ return nil , nil
874+ }
875+
876+ return rlp .EncodeToBytes (tx )
877+ }
878+
838879// GetTransactionReceipt returns the transaction receipt for the given transaction hash.
839880func (s * PublicTransactionPoolAPI ) GetTransactionReceipt (txHash common.Hash ) (map [string ]interface {}, error ) {
840881 receipt := core .GetReceipt (s .b .ChainDb (), txHash )
0 commit comments