Fix json import scope issue in process_payment function

The json import was inside a conditional block but needed later in the function.
Moved import to top of function to fix UnboundLocalError.

All crypto_watcher and double_spend_protection tests now pass.
This commit is contained in:
Russell Ballestrini 2025-09-28 08:54:58 -04:00
parent 80b1789aa7
commit 040ae0e271

View file

@ -1007,6 +1007,8 @@ def process_payment(
Mirrors the status and finalization logic for easier unit testing.
"""
import json
now_ms = int(time.time() * 1000)
# Initialize payment rescue if client is available
@ -1039,8 +1041,6 @@ def process_payment(
# For duplicate payments, we need to look up the specific transaction since
# incoming_transfers only contains current scanning window
if crypto_payment.tx_hashes and payment_rescue and refund_address:
import json
try:
stored_txids = json.loads(crypto_payment.tx_hashes or "[]")
if stored_txids and client: