}
//hand update the transaction output utxos
- validHeight := uint64(0)
- if txIndex == 0 {
- validHeight = b.Height + consensus.CoinbasePendingBlockNumber
- }
- outputUtxos := txOutToUtxos(tx, statusFail, validHeight, b.Height)
+ outputUtxos := txOutToUtxos(tx, statusFail, b.Height)
utxos := w.filterAccountUtxo(outputUtxos)
if err := batchSaveUtxos(utxos, batch); err != nil {
log.WithFields(log.Fields{"module": logModule, "err": err}).Error("attachUtxos fail on batchSaveUtxos")
return utxos
}
-func txOutToUtxos(tx *types.Tx, statusFail bool, vaildHeight, blockHeight uint64) []*account.UTXO {
+func txOutToUtxos(tx *types.Tx, statusFail bool, blockHeight uint64) []*account.UTXO {
+ validHeight := uint64(0)
+ if tx.Inputs[0].InputType() == types.CoinbaseInputType {
+ validHeight = blockHeight + consensus.CoinbasePendingBlockNumber
+ }
+
utxos := []*account.UTXO{}
for i, out := range tx.Outputs {
entryOutput, err := tx.Entry(*tx.ResultIds[i])
ControlProgram: out.ControlProgram(),
SourceID: *bcOut.Source.Ref,
SourcePos: bcOut.Source.Position,
- ValidHeight: vaildHeight,
+ ValidHeight: validHeight,
}
case *bc.VoteOutput:
}
voteValidHeight := blockHeight + consensus.VotePendingBlockNumber
- if vaildHeight < voteValidHeight {
- vaildHeight = voteValidHeight
+ if validHeight < voteValidHeight {
+ validHeight = voteValidHeight
}
utxo = &account.UTXO{
ControlProgram: out.ControlProgram(),
SourceID: *bcOut.Source.Ref,
SourcePos: bcOut.Source.Position,
- ValidHeight: vaildHeight,
+ ValidHeight: validHeight,
Vote: bcOut.Vote,
}