Query editor
WITH RECURSIVE btc_addresses_txns (tx_id, wallet_address, individual_entity_id) AS (SELECTbi.tx_id, sanctioned_address.wallet_address, sanctioned_address.individual_entity_idFROM bitcoin.inputs biINNER JOIN dune.kkgddb.dataset_ofac_sanctioned_wallet_may_2025 sanctioned_addressON sanctioned_address.wallet_address = bi.address), btc_commonly_sent (address, individual_entity_id, tx_id, depth) AS (SELECTbi.address, txns.individual_entity_id, bi.tx_id, 0 AS depthFROM bitcoin.inputs biINNER JOIN btc_addresses_txns txnsON bi.tx_id = txns.tx_idAND bi.address <> txns.wallet_addressUNION ALLSELECTbi.address, bcs.individual_entity_id, bi.tx_id, bcs.depth + 1FROM bitcoin.inputs biINNER JOIN btc_commonly_sent bcsON bi.tx_id = bcs.tx_idAND bi.address <> bcs.addressWHERE bcs.depth < 10 -- max depth allowed)SELECTindividual_entity_id, COUNT(DISTINCT address), ANY_VALUE(address)FROM btc_commonly_sentGROUP BY 1