OSDN Git Service

fix: fix api port (#108)
[bytom/vapor.git] / wallet / utxo.go
index 20775fd..77c956c 100644 (file)
@@ -79,12 +79,17 @@ func (w *Wallet) detachUtxos(batch dbm.Batch, b *types.Block, txStatus *bc.Trans
        for txIndex := len(b.Transactions) - 1; txIndex >= 0; txIndex-- {
                tx := b.Transactions[txIndex]
                for j := range tx.Outputs {
-                       resOut, err := tx.IntraChainOutput(*tx.ResultIds[j])
-                       if err != nil {
+                       code := []byte{}
+                       switch resOut := tx.Entries[*tx.ResultIds[j]].(type) {
+                       case *bc.IntraChainOutput:
+                               code = resOut.ControlProgram.Code
+                       case *bc.VoteOutput:
+                               code = resOut.ControlProgram.Code
+                       default:
                                continue
                        }
 
-                       if segwit.IsP2WScript(resOut.ControlProgram.Code) {
+                       if segwit.IsP2WScript(code) {
                                batch.Delete(account.StandardUTXOKey(*tx.ResultIds[j]))
                        } else {
                                batch.Delete(account.ContractUTXOKey(*tx.ResultIds[j]))
@@ -256,7 +261,7 @@ func txOutToUtxos(tx *types.Tx, statusFail bool, vaildHeight uint64) []*account.
                        }
 
                default:
-                       log.WithFields(log.Fields{"module": logModule}).Error("txOutToUtxos fail on get bcOut")
+                       log.WithFields(log.Fields{"module": logModule}).Warn("txOutToUtxos fail on get bcOut")
                        continue
                }