OSDN Git Service

rename (#465)
[bytom/vapor.git] / database / wallet_store.go
index 85eb2e1..d0bfa5a 100644 (file)
@@ -5,16 +5,17 @@ import (
        "encoding/hex"
        "encoding/json"
        "fmt"
+       "strings"
 
        log "github.com/sirupsen/logrus"
 
-       acc "github.com/vapor/account"
-       "github.com/vapor/asset"
-       "github.com/vapor/blockchain/query"
-       dbm "github.com/vapor/database/leveldb"
-       "github.com/vapor/errors"
-       "github.com/vapor/protocol/bc"
-       "github.com/vapor/wallet"
+       acc "github.com/bytom/vapor/account"
+       "github.com/bytom/vapor/asset"
+       "github.com/bytom/vapor/blockchain/query"
+       dbm "github.com/bytom/vapor/database/leveldb"
+       "github.com/bytom/vapor/errors"
+       "github.com/bytom/vapor/protocol/bc"
+       "github.com/bytom/vapor/wallet"
 )
 
 const (
@@ -190,7 +191,7 @@ func (store *WalletStore) DeleteWalletTransactions() {
        }
 }
 
-// DeleteWalletUTXOs delete all txs in wallet
+// DeleteWalletUTXOs delete all utxos in wallet
 func (store *WalletStore) DeleteWalletUTXOs() {
        batch := store.db.NewBatch()
        if store.batch != nil {
@@ -227,7 +228,7 @@ func (store *WalletStore) GetAsset(assetID *bc.AssetID) (*asset.Asset, error) {
                return nil, err
        }
 
-       alias := assetID.String()
+       alias := strings.ToUpper(assetID.String())
        externalAsset := &asset.Asset{
                AssetID:           *assetID,
                Alias:             &alias,
@@ -246,7 +247,7 @@ func (store *WalletStore) GetGlobalTransactionIndex(txID string) []byte {
 func (store *WalletStore) GetStandardUTXO(outid bc.Hash) (*acc.UTXO, error) {
        rawUTXO := store.db.Get(StandardUTXOKey(outid))
        if rawUTXO == nil {
-               return nil, fmt.Errorf("failed get standard UTXO, outputID: %s ", outid.String())
+               return nil, wallet.ErrGetStandardUTXO
        }
 
        UTXO := new(acc.UTXO)
@@ -342,6 +343,7 @@ func (store *WalletStore) ListAccountUTXOs(id string, isSmartContract bool) ([]*
 
                confirmedUTXOs = append(confirmedUTXOs, utxo)
        }
+
        return confirmedUTXOs, nil
 }
 
@@ -376,8 +378,10 @@ func (store *WalletStore) ListTransactions(accountID string, StartTxID string, c
                        return nil, err
                }
 
-               annotatedTxs = append(annotatedTxs, annotatedTx)
-               txNum--
+               if accountID == "" || wallet.FindTransactionsByAccount(annotatedTx, accountID) {
+                       annotatedTxs = append([]*query.AnnotatedTx{annotatedTx}, annotatedTxs...)
+                       txNum--
+               }
        }
 
        return annotatedTxs, nil