diff --git a/blockchain/chainio.go b/blockchain/chainio.go index b34492de..dccedad2 100644 --- a/blockchain/chainio.go +++ b/blockchain/chainio.go @@ -298,7 +298,7 @@ func decodeSpentTxOut(serialized []byte, stxo *spentTxOut, txVersion int32) (int // it. This should never happen unless there is database // corruption or this function is being called without the // proper state. - if txVersion == 0 { + if txVersion == -1 { return offset, AssertError("decodeSpentTxOut called " + "without a containing tx version when the " + "serialized stxo that does not encode the " + @@ -382,7 +382,7 @@ func deserializeSpendJournalEntry(serialized []byte, txns []*wire.MsgTx, view *U // to detect this case and pull the tx version from the // entry that contains the version information as just // described. - var txVersion int32 + txVersion := int32(-1) originHash := &txIn.PreviousOutPoint.Hash entry := view.LookupEntry(originHash) if entry != nil { diff --git a/blockchain/chainio_test.go b/blockchain/chainio_test.go index 7020923d..a3fcb5af 100644 --- a/blockchain/chainio_test.go +++ b/blockchain/chainio_test.go @@ -194,8 +194,9 @@ func TestStxoDecodeErrors(t *testing.T) { bytesRead: 2, }, { - name: "no serialized tx version and passed 0", + name: "no serialized tx version and passed -1", stxo: spentTxOut{}, + txVersion: -1, serialized: hexToBytes("003205"), errType: AssertError(""), bytesRead: 1,