diff --git a/make_post_sell/lib/crypto_watcher.py b/make_post_sell/lib/crypto_watcher.py index ca8528e..42473dd 100644 --- a/make_post_sell/lib/crypto_watcher.py +++ b/make_post_sell/lib/crypto_watcher.py @@ -1610,6 +1610,25 @@ def process_payment( f"Failed to send sales email for payment {crypto_payment.id}: {e}" ) + # Auto-sweep confirmed payments that haven't been swept yet + if ( + client + and crypto_payment.status == CryptoPayment.STATUS_CONFIRMED + and crypto_payment.shop_sweep_to_address + and not crypto_payment.is_swept + ): + logger.info(f"Payment {crypto_payment.id} confirmed - attempting sweep") + try: + sweep_success = auto_sweep_payment( + client, crypto_payment, env_request.dbsession + ) + if sweep_success and crypto_payment.is_swept: + logger.info(f"Payment {crypto_payment.id} swept successfully") + except Exception as e: + logger.error( + f"Auto-sweep failed for confirmed payment {crypto_payment.id}: {e}" + ) + env_request.dbsession.add(crypto_payment) return