Fix spent computation on a multiple of 8 txout tx.

This commit is contained in:
Dale Rahn 2013-07-18 16:43:36 -04:00 committed by Dave Collins
parent bee05db603
commit 92651c6d13

View file

@ -678,8 +678,10 @@ func (db *SqliteDb) InsertBlock(block *btcutil.Block) (height int64, err error)
}
spentbuflen := (len(tx.TxOut) + 7) / 8
spentbuf := make([]byte, spentbuflen, spentbuflen)
for i := uint(len(tx.TxOut) % 8); i < 8; i++ {
spentbuf[spentbuflen-1] |= (byte(1) << i)
if len(tx.TxOut)%8 != 0 {
for i := uint(len(tx.TxOut) % 8); i < 8; i++ {
spentbuf[spentbuflen-1] |= (byte(1) << i)
}
}
err = db.insertTx(&txsha, newheight, txloc[txidx].TxStart, txloc[txidx].TxLen, spentbuf)