diff --git a/make_post_sell/lib/crypto_watcher.py b/make_post_sell/lib/crypto_watcher.py index d659617..1314e0f 100644 --- a/make_post_sell/lib/crypto_watcher.py +++ b/make_post_sell/lib/crypto_watcher.py @@ -1223,6 +1223,42 @@ def run_once(env, interval): or {} ) incoming = res.get("in", []) or [] + + # Fallback: If no transfers found for subaddress, check all account transfers + # This helps with mempool transactions that might not immediately show up + # in subaddress-filtered queries + if not incoming: + logger.debug(f"No transfers found for subaddress {crypto_payment.subaddress_index}, checking all account transfers") + try: + # Check all transfers for this account (including mempool) + all_transfers_result = client._call("get_transfers", { + "in": True, + "out": False, + "pending": True, + "failed": False, + "pool": True, # Include mempool transactions + "account_index": crypto_payment.account_index, + # Don't filter by subaddr_indices - get all transfers + }) + + all_incoming = all_transfers_result.get("in", []) if all_transfers_result else [] + # Also check pool (mempool) transactions + pool_incoming = all_transfers_result.get("pool", []) if all_transfers_result else [] + all_incoming.extend(pool_incoming) + + # Filter for our specific subaddress + for tx in all_incoming: + if (tx.get("subaddr_index", {}).get("minor") == crypto_payment.subaddress_index and + tx.get("subaddr_index", {}).get("major") == crypto_payment.account_index): + incoming.append(tx) + logger.debug(f"Found transfer for our subaddress in all-account query: {tx.get('txid', 'unknown')[:8]}...") + except Exception as e: + logger.warning(f"Failed to query all account transfers for mempool fallback: {e}") + + if incoming: + logger.debug(f"Found {len(incoming)} transfers for payment {crypto_payment.id}") + else: + logger.debug(f"No transfers found for payment {crypto_payment.id} (subaddress {crypto_payment.subaddress_index})") elif coin_type == "DOGE": # Dogecoin: Query received by address incoming = get_dogecoin_incoming_transfers(client, crypto_payment)