diff --git a/backend/script/bitcoin_rpc.py b/backend/script/bitcoin_rpc.py index b35d345..7a0b328 100644 --- a/backend/script/bitcoin_rpc.py +++ b/backend/script/bitcoin_rpc.py @@ -5,7 +5,6 @@ Connection settings are read from config.ini in the same directory. import json import subprocess -import time import os import configparser @@ -42,10 +41,6 @@ def _build_base_args(section): _cfg = _load_config() _BASE_ARGS = _build_base_args(_cfg) -# Keep these for any scripts that might reference them directly -CLI = _cfg.get("cli", "bitcoin-cli") -SIGNET_ARGS = _BASE_ARGS - def cli(*args, wallet=None): """Call bitcoin-cli [network] [wallet] and return parsed JSON or string.""" cmd = list(_BASE_ARGS) @@ -73,23 +68,6 @@ def mine_blocks(n=1): return int(cli("getblockcount")) -def fund_wallet(wallet_name, amount=1.0, from_wallet="miner"): - """Send `amount` BTC from `from_wallet` to a new address in `wallet_name`.""" - addr = cli("getnewaddress", "", "bech32", wallet=wallet_name) - txid = cli("sendtoaddress", addr, f"{amount:.8f}", wallet=from_wallet) - return txid, addr - - -def wait_for_mempool_empty(timeout=60): - """Wait until mempool is empty (all txs mined).""" - for _ in range(timeout * 2): - info = cli("getmempoolinfo") - if info["size"] == 0: - return True - time.sleep(0.5) - return False - - def get_tx(txid): """Get decoded transaction.""" return cli("getrawtransaction", txid, "true") @@ -128,11 +106,6 @@ def finalize_psbt(psbt): return cli("finalizepsbt", psbt) -def decode_psbt(psbt): - """Decode a PSBT.""" - return cli("decodepsbt", psbt) - - def create_raw_tx(inputs, outputs): """Create a raw transaction.""" return cli("createrawtransaction", json.dumps(inputs), json.dumps(outputs)) @@ -143,11 +116,6 @@ def sign_raw_tx(wallet_name, hex_tx): return cli("signrawtransactionwithwallet", hex_tx, wallet=wallet_name) -def decode_raw_tx(hex_tx): - """Decode a raw transaction.""" - return cli("decoderawtransaction", hex_tx) - - def get_block_count(): """Get current block height.""" return int(cli("getblockcount")) @@ -163,15 +131,3 @@ def send_to_address(wallet_name, address, amount): return cli("sendtoaddress", address, f"{amount:.8f}", wallet=wallet_name) -if __name__ == "__main__": - print("Testing RPC connection...") - info = cli("getblockchaininfo") - print(f" Chain: {info['chain']}") - print(f" Blocks: {info['blocks']}") - - for w in ["miner", "alice", "bob", "carol", "exchange", "risky"]: - try: - bal = get_balance(w) - print(f" {w}: {bal} BTC") - except Exception as e: - print(f" {w}: ERROR - {e}") diff --git a/backend/script/detect.py b/backend/script/detect.py index dd8ca96..6f60007 100644 --- a/backend/script/detect.py +++ b/backend/script/detect.py @@ -20,11 +20,8 @@ Usage: import sys import os import json -import time -import hashlib import argparse from collections import defaultdict -from math import log2 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from bitcoin_rpc import cli, get_tx