diff --git a/stores/chain_test.go b/stores/chain_test.go
index e0bcc8480..615e27098 100644
--- a/stores/chain_test.go
+++ b/stores/chain_test.go
@@ -9,6 +9,7 @@ import (
 
 	"go.sia.tech/core/types"
 	"go.sia.tech/coreutils/chain"
+	"go.sia.tech/coreutils/wallet"
 	"go.sia.tech/renterd/api"
 	"go.sia.tech/renterd/stores/sql"
 )
@@ -208,4 +209,49 @@ func TestProcessChainUpdate(t *testing.T) {
 	if err := ss.ProcessChainUpdate(context.Background(), func(tx sql.ChainUpdateTx) error { return nil }); err != nil {
 		panic("oh no")
 	}
+
+	if err := ss.ProcessChainUpdate(context.Background(), func(tx sql.ChainUpdateTx) error {
+		index3 := types.ChainIndex{Height: 3}
+		index4 := types.ChainIndex{Height: 4}
+		created := []types.SiacoinElement{
+			{
+				StateElement:   types.StateElement{},
+				SiacoinOutput:  types.SiacoinOutput{},
+				MaturityHeight: 100,
+			},
+		}
+		events := []wallet.Event{
+			{
+				Type: wallet.EventTypeV2Transaction,
+				Data: wallet.EventV2Transaction{},
+			},
+		}
+
+		// create some elements
+		err := tx.WalletApplyIndex(index3, created, nil, events, time.Now())
+		if err != nil {
+			return err
+		}
+
+		// spend them
+		err = tx.WalletApplyIndex(index4, nil, created, events, time.Now())
+		if err != nil {
+			return err
+		}
+
+		// revert the spend
+		err = tx.WalletRevertIndex(index4, nil, created, time.Now())
+		if err != nil {
+			return err
+		}
+
+		// revert the creation
+		err = tx.WalletRevertIndex(index3, nil, created, time.Now())
+		if err != nil {
+			return err
+		}
+		return nil
+	}); err != nil {
+		t.Fatal("unexpected error", err)
+	}
 }
diff --git a/stores/sql/sqlite/chain.go b/stores/sql/sqlite/chain.go
index 5ec690994..74a35d7b8 100644
--- a/stores/sql/sqlite/chain.go
+++ b/stores/sql/sqlite/chain.go
@@ -155,7 +155,7 @@ func (c chainUpdateTx) WalletRevertIndex(index types.ChainIndex, removed, unspen
 			c.l.Debugw(fmt.Sprintf("recreate unspent output %v", e.ID), "height", index.Height, "block_id", index.ID)
 			if _, err := insertOutputStmt.Exec(c.ctx,
 				time.Now().UTC(),
-				e.ID,
+				ssql.Hash256(e.ID),
 				e.StateElement.LeafIndex,
 				ssql.MerkleProof{Hashes: e.StateElement.MerkleProof},
 				ssql.Currency(e.SiacoinOutput.Value),