We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
Is there a way to detect deposits realtime? Like subscribing pendingTransactions in Ethereum or executing walletnotify command in Bitcoin.
pendingTransactions
walletnotify
Thanks.
The text was updated successfully, but these errors were encountered:
import requests import time # Bytecoin daemon JSON-RPC URL RPC_URL = "http://127.0.0.1:8081/json_rpc" # Wallet address to monitor WALLET_ADDRESS = "your_wallet_address_here" # JSON-RPC headers headers = { "Content-Type": "application/json" } def get_last_block_height(): payload = { "jsonrpc": "2.0", "id": "1", "method": "getlastblockheader" } response = requests.post(RPC_URL, json=payload, headers=headers) if response.status_code == 200: return response.json()["result"]["block_header"]["height"] else: raise Exception("Failed to get last block height") def get_block(height): payload = { "jsonrpc": "2.0", "id": "1", "method": "f_block_json", "params": { "height": height } } response = requests.post(RPC_URL, json=payload, headers=headers) if response.status_code == 200: return response.json()["result"]["block"] else: raise Exception("Failed to get block") def check_transactions(block): for tx in block["transactions"]: for out in tx["outputs"]: if out["address"] == WALLET_ADDRESS: print(f"Deposit detected: {out['amount']} BCN in transaction {tx['hash']}") def monitor_deposits(): last_height = get_last_block_height() while True: current_height = get_last_block_height() if current_height > last_height: for height in range(last_height + 1, current_height + 1): block = get_block(height) check_transactions(block) last_height = current_height time.sleep(10) # Check every 10 seconds if __name__ == "__main__": monitor_deposits()
Sorry, something went wrong.
No branches or pull requests
Hello,
Is there a way to detect deposits realtime? Like subscribing
pendingTransactions
in Ethereum or executingwalletnotify
command in Bitcoin.Thanks.
The text was updated successfully, but these errors were encountered: