fix: don't delete transfer records on empty wallet-rpc response

If wallet-rpc returns an empty response (transient network issue,
daemon temporarily unavailable), seen_txids is empty and ALL stored
InvoiceTransfer records for that invoice are deleted. When wallet-rpc
recovers, transfers are re-created with new DB IDs.

This guard only prunes transfers when we actually got data back.
This commit is contained in:
jwinterm
2026-03-31 09:45:43 -04:00
parent a15569c535
commit 92a16b39ec
+7 -4
View File
@@ -271,10 +271,13 @@ def _sync_invoice_transfers(
stored.timestamp = transfer.timestamp
stored.address = transfer.address
changed = True
for stored in existing:
if stored.txid not in seen_txids:
db.delete(stored)
changed = True
# Only prune transfers if we actually got data back from wallet-rpc.
# An empty response (transient RPC glitch) should not wipe confirmed records.
if transfers:
for stored in existing:
if stored.txid not in seen_txids:
db.delete(stored)
changed = True
return changed