Query editor
-- Bitcoin Quantum Risk Tracker — per-address unspent state (materialized weekly)-- 21Shares Research---- One row per address of a hash or Taproot type that still holds >=1 unspent output.-- Snapshot: everything confirmed before 00:00 UTC on the run date (block_date < CURRENT_DATE),-- so every chart on the dashboard reconciles to the same instant.---- Method: unspent = received - spent, per address. Every input spends an output of the-- same address with the same value, so netting equals the unspent-UTXO sum without the-- costly outpoint anti-join. Counts net the same way (outputs - inputs).---- Columns-- unspent_sats balance in satoshis-- unspent_utxos number of unspent outputs (incl. zero-value)-- unspent_utxos_ge_001 unspent outputs worth >= 0.001 BTC (migration calculator)-- first_signed_at first spend from the address (key revealed); NULL = never spent-- last_signed_at most recent spend (dormancy)WITH flows AS (SELECTaddress,type,CAST(ROUND(value * 1e8) AS bigint) AS sats_in,CAST(0 AS bigint) AS sats_out,1 AS n_in,0 AS n_out,IF(value >= 0.001, 1, 0) AS n_in_ge,0 AS n_out_ge,IF(false, block_time) AS sign_timeFROM bitcoin.outputsWHERE block_date < CURRENT_DATEAND type IN ('pubkeyhash','witness_v0_keyhash','scripthash','witness_v0_scripthash','witness_v1_taproot')AND address IS NOT NULL AND address <> ''UNION ALLSELECTaddress,type,CAST(0 AS bigint),CAST(ROUND(value * 1e8) AS bigint),0,1,0,IF(value >= 0.001, 1, 0),block_timeFROM bitcoin.inputsWHERE block_date < CURRENT_DATEAND type IN ('pubkeyhash','witness_v0_keyhash','scripthash','witness_v0_scripthash','witness_v1_taproot')AND address IS NOT NULL AND address <> '')SELECTaddress,MAX(type) AS type,SUM(sats_in) - SUM(sats_out) AS unspent_sats,SUM(n_in) - SUM(n_out) AS unspent_utxos,SUM(n_in_ge) - SUM(n_out_ge) AS unspent_utxos_ge_001,MIN(sign_time) AS first_signed_at,MAX(sign_time) AS last_signed_atFROM flows