mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-09 08:04:45 +00:00
LocalCache must hold a single Note per event id/address and must never remove a Note from the cache map while another Note still strongly references it — a dangling reference both leaks the shell and lets a relay echo mint a second Note with the same id. Note.onchainZaps (NIP-BC) and Note.nutzaps (NIP-61) were added after the removal/migration routines were written and were never wired into them, so a pruned zap-source Note leaked through its target's maps: - removeNote() only detached reply/boost/reaction/zap/zapPayment/report/ label, leaving the target's onchainZaps/nutzaps entry dangling when the source note was pruned. Now also calls removeNutzap + a new source-keyed removeOnchainZap (unconditional cache removal, distinct from the verdict-respecting removeOnchainZapForSource). - removeAllChildNotes() cleared onchainZaps but never returned the source notes for removal from the cache map (asymmetric with nutzaps), so they lingered orphaned. Now included. - moveAllReferencesTo() dropped labels, zapPayments, and onchainZaps when a replaceable's old version was superseded — silent data loss plus orphaned onchain sources. Now migrated and cleared like the rest. Adds NotePruningReferenceTest covering all three paths. https://claude.ai/code/session_01RqJPYzmjb1pR3NBeH2yY3s