# Data processing findings — Bitcoin complex-network study Status: dataset acquired, extraction code ported and applied end-to-end to real chain data. Date: 2026-10-02 ## 1. The paper's dataset (downloaded, verified) Source: `https://dynamics.cs.washington.edu/nobackup/bitcoin/bitcoin.tar.gz` - 678,858,686 bytes; last modified 2018-01-19; sha256 `3dfda89e481ec26051a9cca819698486ae5e38236dbe7f3d21da00491eabf499` - Landing page `https://dynamics.cs.washington.edu/data.html` is now an archival, unmaintained UW collection. Contents: **GraphLab SFrame** (`bitcoin.vertices.sframe/`, `bitcoin.links.sframe/`) plus CSV exports: - `bitcoin.vertices.csv` — `vid, first_transaction_date` — **6,336,769 users** - `bitcoin.links.csv` — `dst_id, src_id, count, maxdate, mindate` — **16,057,711 directed user pairs**, `sum(count)` = **28,143,065 transactions**, 5,397,167 sources / 6,229,737 destinations, 2009-01-11 → **2013-04-10**, **zero self-loops** (src == dst count = 0) Critical: this is an **already-clustered, pair-aggregated** graph. It is NOT an input to the extraction code, and the per-transaction edge list behind the paper's Table 1 is not in it. The published graph also has self-loops removed, which matters (see §4). ## 2. Extraction code (ported) Original: `github.com/ivanbrugere/Bitcoin-Transaction-Network-Extraction` (branch `master`), Python 2 (`bsddb`, `print` statements, `has_key`), written 2012-2013, reads a raw text dump produced by Harrigan's `bitcointools` fork (`dbdump.py --all-transactions`). Faithful Python 3 port in `code/btc_py3/` (algorithm unchanged; only `bsddb` → in-memory `HashDB` shim, print syntax, list semantics): `process_bitcoin_network.py`, `write_network_dictionaries.py`, `fix_missing_public_keys.py`, `write_user_public_keys.py`, `write_user_edges.py`, `hashdb.py` Input format: ``` in out ``` Outputs: `transactionkey_list.txt`, `pubkey_list.txt`, `userkey_list.txt`, `user_edge_inputs.txt`, `user_edge_input_public_keys.txt`, and the main file `user_edges.txt` = `[tx_id, user_from, user_to, date, value_btc]`. Validated with a synthetic input exercising every path (coinbase → self-loop, change-address self-loop, multi-input cluster merge, `(None)` bucket). Result matched predictions exactly. ## 3. Bridge from the AWS Open Data parquet `scripts/download_parquet_days.py` → `scripts/gen_transactions_txt.py` (public bucket `s3://aws-public-blockchain/v1.0/btc/`, HTTP, no credentials). Two format traps found by inspection — both silent, neither self-announcing: 1. **Timestamp must be a single whitespace-free token of ≥19 chars.** The parser slices fixed character positions 0:4,5:7,8:10,11:13,14:16,17:19, so an ISO `T` separator works and a space silently drops `HH:MM:SS` (and does NOT error). 2. **Coinbase txs must emit only their `out` lines** (the original dump tagged their referent `coinbase` and the parser skips those). That is the mechanism by which coinbase rewards become self-loop edges downstream. ### Node identity in early data (the big one) The ETL leaves `address` NULL for pay-to-pubkey scripts — i.e. essentially all early mining rewards. In the 2010 window measured: **29.15% of outputs and 24.65% of inputs had no address**. Bucketing them as `(None)` would collapse a quarter of early nodes into one pseudo-hub and destroy the graph. Recovery: - Outputs: the pubkey is inline in `script_hex` — `41|21 ac` (134 / 70 hex chars, note 65-byte *uncompressed* pubkeys, not 64). → 29.15% → **0.001%** unresolved. - Inputs: the ETL stores **only the signature** in a P2PK spend's `script_hex` (no pubkey, no address). Recovered by back-joining to the consumed output on `(spent_transaction_hash, spent_output_index)`. → 24.65% → **0.000%** unresolved. ### Schema drift across partitions — CORRECTED, it is NOT data loss The AWS `transactions` table shows three variants, interleaved day by day: - **255 days: no `inputs` column at all** - **18 days: `inputs` present but `outputs` has no `address`** - 450 days: complete Earlier I recorded that "those 255 days cannot yield edges or clustering". **That was wrong.** Two exhaustive tests over all 723 local 2009-2010 partitions show the drift is *empty-column omission by the ETL writer*, i.e. information-preserving: **Test A — `inputs` column present <=> the day has at least one non-coinbase transaction** ``` inputs absent & 0 non-coinbase txs : 255 days inputs present & >=1 non-coinbase : 468 days ``` Zero exceptions. And because coinbase transactions carry no inputs *by construction* (they are NULL even in complete partitions), a day with no non-coinbase transaction loses nothing: - 2009 degraded days: 20,628 txs, **20,628 coinbase, 0 non-coinbase** - 2010 degraded days: 1,893 txs, **1,893 coinbase, 0 non-coinbase** - non-coinbase transactions lost across 2009-2010: **0 of 117,604 (0.00%)** **Test C — `outputs.address` absent <=> every output on that day is P2PK** ``` 273/273 no-address days have 100% type='pubkey' outputs 0 days with any non-P2PK output lack the field ``` Control: on complete days P2PK outputs still carry `address = NULL`, but the column exists because at least one output is `pubkeyhash`. So the writer drops a column only when it is entirely empty for that partition. **Consequences** - No repair from Blockchair/BigQuery is needed; the plan to reconstruct 255 days is cancelled. - All 723 days of 2009-2010 are usable. 2009 is 358/358 usable: 243 of its days are coinbase-only (mining rewards), whose edges come from the output side, which every variant has. - The only lost capability on those days is input-side verification of spends — and the spend count there is zero. - `read_parquet(union_by_name=true)` is still required to read the corpus (different struct types across files), and DuckDB 1.5.6 hits an internal error on `UNNEST` + aggregate over a union of differing struct types — scan partitions per-file when that bites. ## 4. Result of applying the extraction to real data Window 2010-01-21 → 2010-12-31 (345 complete-schema days), 3.0 s runtime: | quantity | value | |---|---| | transactions in window (parquet) | 182,229 | | transactions recovered by extraction | 182,227 (99.999%) | | coinbase transactions | 64,857 | | addresses/pubkeys indexed | 145,606 | | **users (clusters)** | **98,063** | | **edges (`user_edges.txt`)** | **230,603** | | **self-loops** | **104,231 = 45.2%** | | largest user cluster | 928 pubkeys | | max user degree | 11,042 | Consistency check: 528.2 tx/day in the window vs blockchain.com's 2010 daily mean of 508/day. **Reconciliation flag:** the extraction emits 45.2% self-loops, while the published `links.csv` has zero. The published graph was therefore filtered or built by a different aggregation, and the paper's node/link counts do not reproduce from the tarball alone (1P: tarball gives 111,017 pairs vs the paper's 302,116 links; 2P: 11,147,849 pairs vs 11,432,100). Reproducing the paper requires running this pipeline, not using the tarball. ## 6. Network size: my numbers vs the paper ### What the paper states - Methods: "more than 25 million links (transactions) and more than 5 million nodes (users)", data 01 Jan 2009 → 08 Jan 2013. - Table 2: **1P (2009-2010): 193,012 nodes, 302,116 links**, avg degree 1.565, clustering 0.116. **2P (2011-2012): 4,689,069 nodes, 11,432,100 links**, avg degree 2.438, clustering 0.24. ### Measured values | quantity | paper | published tarball | raw chain (my measurement) | |---|---|---|---| | total transactions | ">25 M" | 28,143,065 | 2009-2010 only: 218,014 | | total users | ">5 M" | 6,336,769 vertices | — | | 1P nodes | 193,012 | 110,057 (−43%) | 176,343 distinct output addresses (−9%) | | 1P links | 302,116 | 111,017 pairs (−63%) | 266,467 outputs = one edge each (−12%) | | 2P nodes | 4,689,069 | 4,601,334 first-seen 2011-12 (−1.9%) | not downloaded | | 2P links | 11,432,100 | 11,148,049 pairs (−2.5%) | not downloaded | | 1P+2P nodes | 4,882,081 | 4,711,391 (−3.5%) | — | My own extraction run (2010-01-21 → 2010-12-31, 345 days) produced **98,063 users / 230,603 edges from 182,227 transactions**, against a raw-chain count of 182,229 transactions and 230,603 outputs in the same window — i.e. the port reproduces the chain exactly under its own definition (one edge per output, users = multi-input clusters, self-loops included). ### Where the two agree, and where they do not - **Agrees:** total scale (28.1M vs ">25M" transactions; 6.34M vs ">5M" users), the 2P period (−2%), and the 1P+2P node total (−3.5%). - **Disagrees:** the 1P split. The paper's 1P is 75% larger in nodes and 172% larger in links than the dataset it cites. ### Mechanism (measured, not guessed) The published tarball **excludes coinbase transactions and all self-loops**: - `links.csv` has exactly 0 self-loops (src == dst). - 2009 on chain: 32,709 transactions, of which **32,490 are coinbase** → only 219 non-coinbase. The tarball lists **218 transactions** for 2009. That is a direct proof of the filter. - 1P coinbase transactions are 100,410 of 218,014 = 46%. Coinbase outputs are the mining-reward self-loops that the extraction code *does* emit (verified in the unit test and in my run). So the paper's 1P figures are consistent with **address-level counting that includes mining activity** (176k addresses / 266k outputs, within 9-12%), while the published graph is **user-clustered, coinbase-free, self-loop-free, pair-aggregated** (110k / 111k). The residual ~12% on 1P links is not explained by this alone and remains open. ### Consequence for the study The tarball cannot be used as a drop-in baseline: it under-covers the first period by ~40% of chain transactions (130,739 vs 218,014) once coinbase is removed, and it silently drops 45% of edges as self-loops in the window I measured. Any comparison against the paper must state the inclusion policy for (a) coinbase, (b) self-loops, (c) edge aggregation (per-output vs per-pair), and (d) node entity level (address vs user) — all four change the numbers by 2-3x. ## 8. Which files can build temporal networks (verified) A temporal network needs edge endpoints + a per-event time. Only some of what we hold qualifies. ### Tier 1 - true link streams (per-event timestamps) **`runs/2010_window/user_edges.txt`** - the extraction output, the direct analogue of the paper's Table 1. Rows are `[tx_id, user_from, user_to, date, value_btc]`. - 230,603 edges, 98,063 users, 14-digit second-resolution timestamps, 20100121000527 -> 20101231235450, 345 days, **64,806 distinct timestamps**, 115-11,783 edges/day (100x swing). - Includes the 45.2% self-loops; policy must be declared. **`data/parquet/`** - address-level raw material, edge = (input address -> output address) with `block_timestamp`, `block_number`, `index` (position in block), `value`. - Local: 2009-01-03 -> 2010-12-31, 723 days, but 255 days have no `inputs` column, so no in-edges for those days. 64,857 blocks / 64,806 distinct second-timestamps in the clean window; `index` reaches 849, so intra-block order is recoverable via `(block_number, index)`. - Whole history 2009 -> 2026 is available from the same bucket (2.19 TB) with the same schema. ### Tier 2 - interval/aggregated temporal only (NOT link streams) **`data/bitcoin/bitcoin.links.csv`** - `dst_id, src_id, count, maxdate, mindate`. 16,057,711 pairs spanning 1,294 distinct mindate days (2009-01-11 -> 2013-04-10). Each row carries only the FIRST and LAST date plus a count, so the `count` individual interactions cannot be placed in time. Supports: edge-interval/active-period analysis, coarse first-seen timelines. Does NOT support: inter-event times, burstiness, snapshot sequences with correct edge sets, and critically **not the paper's own attachment analysis** - testing degree/wealth/fitness preferential attachment requires, for each new node, the degree of its target *at that instant*, which the aggregation has destroyed. **`data/bitcoin/bitcoin.vertices.csv`** - `vid, first_transaction_date`: node birth times for 6,336,769 users (2009-01-03 -> 2013-04-10). Node-appearance process only, no edges. ### Tier 3 - external temporal covariates (not networks) Daily/weekly series (tx/day, price) for activity-vs-price correlations; daily counts already pulled for 2009-2026. ### Temporal caveats - The honest causal granularity is the **block**, not the second: block timestamps are miner-set (bounded only by median-time-past), and within a block ordering is the miner's, recoverable via `index`. Sub-second/burst analysis below block level is not defensible. - Self-loops (45.2%) and coinbase edges are structural artifacts; decide before building. - For 2011+ windows, only the parquet path scales; the tarball stops at 2013-04-10. ## 10. Full paper-window run (in progress) Downloaded the paper's exact window: **1,462 partitions, 15.06 GB, 0 unreadable** (2009-01-03 -> 2013-01-08). Schema scan over the new period: ``` inputs=True addr=True : 1189 days inputs=False addr=False : 255 days (all in 2009-2010) inputs=True addr=False : 18 days (all in 2009-2010) per year: 2009 243/358 without inputs, 2010 12/365, 2011 0/365, 2012 0/366, 2013 0/8 ETL write batches: 2026-02-06 (1222 partitions), 2026-02-07 (240) ``` So 2011+ is completely clean, and every degraded day is a 2009-2010 coinbase-only day (consistent with the empty-column-omission mechanism in §3). Generation to the extraction's input format: 7.9 GB text, 2 min 54 s, peak RSS 25 GB. ### Engineering lesson: never ORDER BY inside the COPY The first two attempts died at the same place. The generator's `ORDER BY f1, sortkey` forced DuckDB to globally sort ~45M rows: with a 40 GB limit the process was killed externally (no Python traceback); with a 16 GB limit DuckDB raised a clean `OutOfMemoryException` at 14.9 GiB. Dropping the ORDER BY removes the sort entirely — the extraction code sorts rows itself in `fix_missing_public_keys` (by 1,2,0) and `write_user_edges` (by 1,0,2), so the sort was pure waste. Generation then streams. Debugging note: Python's stdout is block-buffered when redirected, so a log that appears to stop early may just be unflushed — re-run with `PYTHONUNBUFFERED=1` to see the real point of death. ### Extraction status and the 4 GB worker cap Generation to the extraction's input format: 7.9 GB text, 2 min 54 s, peak RSS 25 GB (22,030,699 `in` + 25,356,719 `out` = 47,387,418 rows). The extraction needs ~6 GB in the dictionary stage and ~13 GB during its first internal sort (measured: 155 bytes/row for the `array('L')` rows, +120 bytes/row for sort keys). **The agent runtime caps background jobs at 4 GB**, so every normal attempt died there: ``` the agent worker scope: memory.max = 4294967296 (4 GB) memory.peak = 4294967296, memory.events max = 67057 ``` `_DEFAULT_WORKER_MEMORY_MAX_BYTES = 1 GB`, `_WORKER_MEMORY_MAX_CAP_BYTES = 4 GB` in `tools/process_registry.py`; every background spawn gets `--property MemoryMax=`. Foreground calls run in the gateway cgroup (`memory.max = max`) but are capped at 600 s and the tool refuses `setsid`/`nohup` in foreground commands, so heavyweight jobs must go through Docker (own cgroup, unaffected by the scope cap). Diagnostic traps hit along the way: `ps` field 10 is CPU time, not wall clock; Python block-buffers stdout when redirected, so a log that "stops early" may just be unflushed (use `PYTHONUNBUFFERED=1`); and the OOM kill leaves no Python traceback — only `journalctl --user` shows `A process of this unit has been killed by the OOM killer`. Transport hazard (cost one complete 30-minute run): do NOT stream the output tar on the container's stdout. Stray `echo` lines land in the archive, the host tar aborts with `This does not look like a tar archive`, the pipe breaks, and `--rm` then deletes the results. Correct pattern, in `scripts/run_full_window_docker.sh`: the container writes `out.tar` into the bind mount, the host extracts it as the normal user (rootless docker has a userns offset, so a container cannot create user-owned files directly). Single run required: the union-find clustering must see the whole period, or a user active across years would get inconsistent cluster ids (so per-year chunking is not an option). Generation is skipped if the input exists, so the runner is resumable. ## 11. RESULTS: full paper-window extraction (complete) Ran in Docker on the paper's exact window (2009-01-03 -> 2013-01-08), **10 minutes wall clock** (10:01:41 -> 10:12:10), versus the 4 GB-capped attempts that died every time. ### Global output (`runs/full_window/out/`, 2.6 GB) | quantity | value | |---|---| | edges (`user_edges.txt`) | **25,356,719** | | transactions | **10,886,588** | | distinct users | **4,910,855** | | self-loops | **5,878,290 (23.18%)** | | date span | 20090103181505 -> 20130108235206 | | pubkeys indexed | 8,906,547 | | clusters | 4,910,855 (4,400,093 singletons = 89.6%) | **Independent validation:** the distinct-transaction count (10,886,588) matches blockchain.com's independent daily series for 2011-2012 (10.4M) to within 5%, and the edge count equals exactly the generator's `out` line count (25,356,719). The port reproduces the chain. ### Period split vs the paper's Table 2 | period | my nodes | my edges | my self-loops | my avg deg | paper nodes | paper links | paper avg deg | |---|---|---|---|---|---|---|---| | 1P 2009-2010 | 71,113 | 266,467 | 52.7% | 3.747 | 193,012 | 302,116 | 1.565 | | 2P 2011-2012 | 4,803,046 | 25,090,252 | 22.9% | 5.224 | 4,689,069 | 11,432,100 | 2.438 | Reading: - **2P nodes match**: 4,803,046 vs 4,689,069 = **+2.4%**. - **Global scale matches**: 25.36M edges vs ">25M links"; 4.91M users vs ">5M users" (their window runs 3 months further, to 2013-04-10, which explains the shortfall). - **1P links are close-ish**: 266,467 vs 302,116 = **-12%**. - **The paper's two periods use inconsistent link definitions.** Their 2P links (11,432,100) match the *aggregated distinct-pair* count (tarball: 11,148,049, -2.5%), not the per-output edge count (mine: 25,090,252, 2.2x). Their 1P links (302,116) instead match the per-output/address-level count (mine: 266,467, -12%), not the aggregated pairs (tarball: 111,017, -63%). So "links" cannot mean the same thing in both columns, and the paper's 1P figures cannot be reproduced from its own published dataset. - **1P nodes off by -63%** under the user-clustered definition, but my earlier address-level measurement (176,343 distinct output addresses) sits within 9% of their 193,012 - further evidence that their 1P table reflects address-level counting that includes mining activity. ### Structural findings worth carrying into the study - **Self-loop share collapses over time**: 52.7% in 1P -> 22.9% in 2P (coinbase/change self-loops dominate the early network and become a minority as real transfers grow). 97.8% of self-loops are change/other, only ~2.2% carry a ~50 BTC coinbase-like amount. - **Mega-clusters exist and are large**: largest user cluster = **261,808 pubkeys (2.94% of all addresses)**, then 127,073 / 99,645 / 78,895 / 40,969. The 2010-only window's largest was 928 pubkeys, so the multi-input heuristic collapses massively in the 2011-2013 exchange era (batching/consolidation, plus CoinJoin false merges). **Any degree-distribution or preferential-attachment result after ~2011 is dominated by this cluster-structure artifact** - it must be measured and either bounded or handled explicitly. - 89.6% of users are singletons, so the mean cluster size is 1.81 but the tail is extreme. ## 12. Next steps (not yet done) 1. ~~Repair the 255 no-input days + 273 no-address days~~ **CANCELLED — not data loss** (see §3): both variants are empty-column omission and cost zero edges. The 2009-2010 window is fully usable as-is. Next actual step: run the extraction over 2009-01-03 → 2013-01-08 (the paper's window, now downloaded) and compare with the tarball at pair level. 2. Decide the self-loop and change-address policy explicitly (45% of edges at user level). 3. Modern extension (2013 → 2026) once the pipeline is validated on the paper's window.