OSDN Git Service

Fix wallet issue asset tx annotate problem (#199)
authoryahtoo <yahtoo.ma@gmail.com>
Thu, 14 Dec 2017 10:39:01 +0000 (18:39 +0800)
committerGuanghua Guo <1536310027@qq.com>
Thu, 14 Dec 2017 10:39:01 +0000 (18:39 +0800)
blockchain/wallet/annotated.go

index 445c377..4670fcd 100755 (executable)
@@ -1,7 +1,6 @@
 package wallet
 
 import (
-       "chain/protocol/vmutil"
        "encoding/json"
        "fmt"
 
@@ -16,6 +15,7 @@ import (
        "github.com/bytom/errors"
        "github.com/bytom/protocol/bc"
        "github.com/bytom/protocol/bc/legacy"
+       "github.com/bytom/protocol/vm/vmutil"
 )
 
 // annotateTxs adds asset data to transactions
@@ -57,11 +57,16 @@ func getAliasFromAssetID(assetID bc.AssetID, walletDB db.DB) (*asset.Asset, erro
 func annotateTxsAccount(txs []*query.AnnotatedTx, walletDB db.DB) {
        for i, tx := range txs {
                for j, input := range tx.Inputs {
+                       //issue asset tx input SpentOutputID is nil
+                       if input.SpentOutputID == nil {
+                               continue
+                       }
                        account, err := getAccountFromUTXO(*input.SpentOutputID, walletDB)
                        if account == nil || err != nil {
                                continue
                        }
                        txs[i].Inputs[j].AccountAlias = account.Alias
+                       txs[i].Inputs[j].AccountID = account.ID
                }
                for j, output := range tx.Outputs {
                        account, err := getAccountFromACP(output.ControlProgram, walletDB)
@@ -69,6 +74,7 @@ func annotateTxsAccount(txs []*query.AnnotatedTx, walletDB db.DB) {
                                continue
                        }
                        txs[i].Outputs[j].AccountAlias = account.Alias
+                       txs[i].Outputs[j].AccountID = account.ID
                }
        }
 }