OSDN Git Service

show all the tx in wallet (#1710)
authorPaladz <yzhu101@uottawa.ca>
Thu, 18 Apr 2019 07:37:02 +0000 (15:37 +0800)
committerGitHub <noreply@github.com>
Thu, 18 Apr 2019 07:37:02 +0000 (15:37 +0800)
wallet/indexer.go

index 0951a45..7bc68d2 100644 (file)
@@ -11,7 +11,6 @@ import (
        "github.com/bytom/account"
        "github.com/bytom/asset"
        "github.com/bytom/blockchain/query"
-       "github.com/bytom/crypto/sha3pool"
        dbm "github.com/bytom/database/leveldb"
        chainjson "github.com/bytom/encoding/json"
        "github.com/bytom/errors"
@@ -155,29 +154,12 @@ func (w *Wallet) indexTransactions(batch dbm.Batch, b *types.Block, txStatus *bc
 func (w *Wallet) filterAccountTxs(b *types.Block, txStatus *bc.TransactionStatus) []*query.AnnotatedTx {
        annotatedTxs := make([]*query.AnnotatedTx, 0, len(b.Transactions))
 
-transactionLoop:
        for pos, tx := range b.Transactions {
-               statusFail, _ := txStatus.GetStatus(pos)
-               for _, v := range tx.Outputs {
-                       var hash [32]byte
-                       sha3pool.Sum256(hash[:], v.ControlProgram)
-
-                       if bytes := w.DB.Get(account.ContractKey(hash)); bytes != nil {
-                               annotatedTxs = append(annotatedTxs, w.buildAnnotatedTransaction(tx, b, statusFail, pos))
-                               continue transactionLoop
-                       }
-               }
-
-               for _, v := range tx.Inputs {
-                       outid, err := v.SpentOutputID()
-                       if err != nil {
-                               continue
-                       }
-                       if bytes := w.DB.Get(account.StandardUTXOKey(outid)); bytes != nil {
-                               annotatedTxs = append(annotatedTxs, w.buildAnnotatedTransaction(tx, b, statusFail, pos))
-                               continue transactionLoop
-                       }
+               if pos == 0 {
+                       continue
                }
+               statusFail, _ := txStatus.GetStatus(pos)
+               annotatedTxs = append(annotatedTxs, w.buildAnnotatedTransaction(tx, b, statusFail, pos))
        }
 
        return annotatedTxs