Skip to content

Commit

Permalink
Last comments pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
sr-gi committed Jun 15, 2018
1 parent f3fa36a commit 1863f22
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ from bitcoin_tools.analysis.status.utils import parse_ldb

# Set the version of the Bitcoin Core you are using (which defines the chainstate format)
# and the IO files.
version = 0.15

f_utxos = "decoded_utxos.txt"
f_parsed_utxos = "parsed_utxos.txt"

# Parse all the data in the chainstate.
parse_ldb(f_utxos, version=version)
parse_ldb(f_utxos)
# Parses transactions and utxos from the dumped data.
utxo_dump(f_utxos, f_parsed_utxos, version=version)
utxo_dump(f_utxos, f_parsed_utxos)

# Data is stored in f_utxos and f_parsed_utxos files respectively
```
Expand Down
6 changes: 4 additions & 2 deletions bitcoin_tools/analysis/status/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
**STATUS** (**ST**atistical **A**nalysis **T**ool for **U**txo **S**et) is an open source tool that provides an easy way to access, decode and analyze data from the Bitcoin's `utxo set`. The accompanying working paper further explains its design, application, and presents results of a recently performed analysis: [https://eprint.iacr.org/2017/1095.pdf](https://eprint.iacr.org/2017/1095.pdf)


STATUS is coded in Python 2 and works for both the existing versions of Bitcoin Core's `utxo set`, that is, the first defined format (versions 0.8 - 0.14) and the recently defined one (version 0.15).
STATUS is coded in Python 2 and works for both the existing versions of Bitcoin Core's `utxo set`, that is, the first defined format (versions 0.8 - 0.14) and the recently defined one (version 0.15).

STATUS reads from a LevelDB folder (usually located under `.bitcoin/chainstate`) and parses all the `utxo` entries into a `json` file. From the parsed file, STATUS allows you to perform two type of analysis, a `utxo` based one, and a `transaction` based one, by decoding all the parsed information from the chainstate.
STATUS works, from now on, with 0.15 format. For 0.8-0.14 version refer to `ldb_0.14` branch.

STATUS reads from a LevelDB folder (usually located under `.bitcoin/chainstate`) and parses all the `utxo` entries into a `json` file. From the parsed file, STATUS allows you to perform two type of analysis, a `utxo` based one, and a `transaction` based one, by decoding all the parsed information from the chainstate.

## UTXO based analysis

Expand Down
38 changes: 30 additions & 8 deletions bitcoin_tools/analysis/status/data_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@


def transaction_dump(fin_name, fout_name):
"""
Reads from a parsed utxo file and dumps additional metadata related to transactions.
:param fin_name: Name of the parsed utxo file.
:type fin_name: str
:param fout_name: Name of the file where the final data will be stored.
:type fout_name: str
:return: None
:rtype: None
"""
# Transaction dump

# Set the input and output files
Expand Down Expand Up @@ -44,7 +54,19 @@ def transaction_dump(fin_name, fout_name):
fout.close()


def utxo_dump(fin_name, fout_name, coin, count_p2sh=False, non_std_only=False, ordered_dict=False):
def utxo_dump(fin_name, fout_name, coin, count_p2sh=False, non_std_only=False):
"""
Reads from a parsed utxo file and dumps additional metadata related to utxos.
:param fin_name: Name of the parsed utxo file.
:type fin_name: str
:param fout_name: Name of the file where the final data will be stored.
:type fout_name: str
:param coin: Currency that will be analysed
:return: None
:rtype: None
"""

# UTXO dump

# Input file
Expand Down Expand Up @@ -108,14 +130,14 @@ def utxo_dump(fin_name, fout_name, coin, count_p2sh=False, non_std_only=False, o
"index": utxo['index'],
"register_len": utxo['len']}

# Additional data used to explain dust figures (describes the size taken into account by each metric
# when computing dust/unprofitability). It is not used in most of the cases, and generates overhead
# in both size and time of execution, so ity is not added by default. Uncomment if necessary.
# Additional data used to explain dust figures (describes the size taken into account by each metric
# when computing dust/unprofitability). It is not used in most of the cases, and generates overhead
# in both size and time of execution, so ity is not added by default. Uncomment if necessary.

# result["dust_size"] = out_size + in_size
# result["min_size"] = min_size
# result["est_size"] = get_est_input_size(out, utxo["height"], p2pkh_pksize, p2sh_scriptsize,
# nonstd_scriptsize, p2wsh_scriptsize)}
# result["dust_size"] = out_size + in_size
# result["min_size"] = min_size
# result["est_size"] = get_est_input_size(out, utxo["height"], p2pkh_pksize, p2sh_scriptsize,
# nonstd_scriptsize, p2wsh_scriptsize)}

# Updates the dictionary with the remaining data from out, and stores it in disk.
result.update(out)
Expand Down

0 comments on commit 1863f22

Please sign in to comment.