Apply a Kaspa virtual selected-chain change to a payment index

A virtual chain update can remove an old selected-chain block while adding new ones. Payment state must track which accepting block supplied each transaction.

Journal acceptance by block

Starting from stored block C, request the virtual chain difference with accepted transaction IDs enabled. In one database transaction, reverse the acceptance records attributable to removed blocks and apply the groups supplied for the added side. Keep block-to-transaction links so an acceptance can be reversed without rescanning every deposit.

cursor C → removed [C] → added [D, E]
accepted transaction groups → index by accepting block

Commit the cursor with payments

Advance to E only after the payment changes have committed. If the same transaction appears again under another accepting block, update its provenance and preserve one economic credit. A transaction appearing in a DAG block's body is insufficient evidence of virtual-chain acceptance.

Sources