Sub topic 5
Grouping Addresses into Entities with Clustering Heuristics
Assume you understand blockchain transactions, wallet addresses, and the difference between UTXO and account models. Also assume basic Python skills. This chapter focuses on a practical problem: several addresses may belong to one person, company, exchange, or other entity.
An address is an identifier on a blockchain. An entity is the real-world owner or operator behind one or more addresses. The blockchain usually shows addresses, not verified identities. Clustering heuristics are rules that estimate which addresses are controlled by the same entity.
Why clustering is needed
A single user may have many addresses for privacy, organization, or wallet software requirements. An exchange may use thousands of deposit addresses plus separate hot and cold wallets. Counting each address separately can therefore make one entity appear to be many holders.
Clustering combines addresses into estimated ownership groups. Analysts can then calculate entity-level balances, flows, and concentration. The result is useful only when the assumptions behind the cluster are reasonable.
The common-input heuristic
The most familiar rule applies to UTXO blockchains such as Bitcoin. If a transaction spends outputs from several input addresses, one wallet may control all those inputs. The addresses are therefore placed in the same cluster.
For example, a transaction spending inputs from addresses A and B suggests that A and B share control. If another transaction later spends inputs from B and C, the cluster expands to A, B, and C.
def cluster_by_common_input(transactions):
"""Return a cluster representative for each input address."""
parent = {}
def find(address):
parent.setdefault(address, address)
while parent[address] != address:
parent[address] = parent[parent[address]]
address = parent[address]
return address
def union(first, second):
root_first = find(first)
root_second = find(second)
if root_first != root_second:
parent[root_second] = root_first
for inputs in transactions:
for address in inputs:
find(address)
for address in inputs[1:]:
union(inputs[0], address)
return {address: find(address) for address in parent}
transactions = [["A", "B"], ["B", "C"], ["D"]]
print(cluster_by_common_input(transactions))The code uses a union-find structure. Each address starts in its own group. union joins groups, and find retrieves a group's representative.
Other clues and their risks
Common-input ownership is not the only clue. Analysts may also compare:
- Repeated use of the same change-address pattern.
- Transactions that move funds between addresses soon after one another.
- Shared transaction timing, fees, or spending behavior.
- Known deposits and withdrawals connected to a labeled service.
- Wallet software patterns or address derivation paths.
These clues are probabilistic. They do not prove legal ownership.
| Heuristic | Useful signal | Main failure |
|---|---|---|
| Common inputs | Inputs likely share control | CoinJoin can deliberately combine unrelated users |
| Change patterns | Identifies likely wallet change | Wallet software can create unusual outputs |
| Repeated timing | Reveals operational coordination | Automated services create coincidental patterns |
| Known service links | Connects addresses to an entity | Labels can be outdated or wrong |
Account chains and false grouping
Account-based chains such as Ethereum do not normally list multiple input addresses in one transaction. The common-input rule therefore does not transfer directly. Analysts instead use known labels, contract relationships, funding paths, and repeated operational behavior.
A transfer between two addresses does not prove common ownership. It may represent a customer payment, a loan, a bridge operation, or a transfer between unrelated parties. Smart contracts also hold assets and can make one action appear as many transfers.
Validate before using a cluster
Compare heuristic clusters with independently labeled addresses. Exclude known exchange wallets, custodians, mixers, bridges, and smart contracts when measuring individual-holder concentration. Keep the original addresses and the cluster version so that you can reproduce or revise the analysis.
A strong workflow treats clustering as an evolving hypothesis. New transactions, corrected labels, and improved heuristics can split or merge groups. Any alert or concentration statistic should record the data snapshot and rules that produced it.
Exercise
A Bitcoin transaction spends inputs from X and Y. A later transaction spends inputs from Y and Z. What cluster does the common-input heuristic produce, and why might that result be wrong?
Show answer
It produces the cluster X, Y, and Z because the shared address Y links both transactions. The result may be wrong if either transaction uses a CoinJoin or another construction that combines inputs from unrelated owners.