@@ -534,8 +534,8 @@ func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Add
534534 return b , state .Error ()
535535}
536536
537- // GetTransactionProof returns the Trie proof of the given transaction.
538- func (s * PublicBlockChainAPI ) GetTransactionProof (ctx context.Context , hash common.Hash ) (map [string ]interface {}, error ) {
537+ // GetTransactionAndReceiptProof returns the Trie transaction and receipt proof of the given transaction hash .
538+ func (s * PublicBlockChainAPI ) GetTransactionAndReceiptProof (ctx context.Context , hash common.Hash ) (map [string ]interface {}, error ) {
539539 tx , blockHash , _ , index := core .GetTransaction (s .b .ChainDb (), hash )
540540 if tx == nil {
541541 return nil , nil
@@ -544,51 +544,35 @@ func (s *PublicBlockChainAPI) GetTransactionProof(ctx context.Context, hash comm
544544 if err != nil {
545545 return nil , err
546546 }
547- tr := deriveTrie (block .Transactions ())
547+ tx_tr := deriveTrie (block .Transactions ())
548548
549- var proof proofPairList
550549 keybuf := new (bytes.Buffer )
551550 rlp .Encode (keybuf , uint (index ))
552- if err := tr .Prove (keybuf .Bytes (), 0 , & proof ); err != nil {
551+ var tx_proof proofPairList
552+ if err := tx_tr .Prove (keybuf .Bytes (), 0 , & tx_proof ); err != nil {
553553 return nil , err
554554 }
555- fields := map [string ]interface {}{
556- "blockHash" : blockHash ,
557- "txRoot" : tr .Hash (),
558- "key" : hexutil .Encode (keybuf .Bytes ()),
559- "proofKeys" : proof .keys ,
560- "proofValues" : proof .values ,
561- }
562- return fields , nil
563- }
564-
565- // GetReceiptProof returns the Trie proof of the receipt for a given transaction.
566- func (s * PublicBlockChainAPI ) GetReceiptProof (ctx context.Context , hash common.Hash ) (map [string ]interface {}, error ) {
567- tx , blockHash , _ , index := core .GetTransaction (s .b .ChainDb (), hash )
568- if tx == nil {
569- return nil , nil
570- }
571555 receipts , err := s .b .GetReceipts (ctx , blockHash )
572556 if err != nil {
573557 return nil , err
574558 }
575559 if len (receipts ) <= int (index ) {
576560 return nil , nil
577561 }
578- tr := deriveTrie (receipts )
579-
580- var proof proofPairList
581- keybuf := new (bytes.Buffer )
582- rlp .Encode (keybuf , uint (index ))
583- if err := tr .Prove (keybuf .Bytes (), 0 , & proof ); err != nil {
562+ receipt_tr := deriveTrie (receipts )
563+ var receipt_proof proofPairList
564+ if err := receipt_tr .Prove (keybuf .Bytes (), 0 , & receipt_proof ); err != nil {
584565 return nil , err
585566 }
586567 fields := map [string ]interface {}{
587- "blockHash" : blockHash ,
588- "receiptRoot" : tr .Hash (),
589- "key" : hexutil .Encode (keybuf .Bytes ()),
590- "proofKeys" : proof .keys ,
591- "proofValues" : proof .values ,
568+ "blockHash" : blockHash ,
569+ "txRoot" : tx_tr .Hash (),
570+ "receiptRoot" : receipt_tr .Hash (),
571+ "key" : hexutil .Encode (keybuf .Bytes ()),
572+ "txProofKeys" : tx_proof .keys ,
573+ "txProofValues" : tx_proof .values ,
574+ "receiptProofKeys" : receipt_proof .keys ,
575+ "receiptProofValues" : receipt_proof .values ,
592576 }
593577 return fields , nil
594578}
0 commit comments