Skip to content

Commit

Permalink
Last updates pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
sr-gi committed Jun 15, 2018
1 parent 304b985 commit c5c7e28
Show file tree
Hide file tree
Showing 4 changed files with 31 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
2 changes: 2 additions & 0 deletions bitcoin_tools/analysis/status/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# STATUS

### THIS VERSION ONLY WORKS WITH BITCOIN CORE'S LEVELDB 0.14-, FOR 0.15+ REFER TO THE MASTER BRANCH.

**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)


Expand Down
21 changes: 21 additions & 0 deletions bitcoin_tools/analysis/status/data_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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

# Input file
Expand Down Expand Up @@ -34,6 +44,17 @@ def transaction_dump(fin_name, fout_name):


def utxo_dump(fin_name, fout_name, coin, count_p2sh=False, non_std_only=False, ordered_dict=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
15 changes: 5 additions & 10 deletions bitcoin_tools/analysis/status/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ def check_multisig_type(script):
"""

if len(OutputScript.deserialize(script).split()) > 2:
# TODO: should we be more restrictive?
m = OutputScript.deserialize(script).split()[0]
n = OutputScript.deserialize(script).split()[-2]
op_multisig = OutputScript.deserialize(script).split()[-1]
Expand Down Expand Up @@ -820,15 +819,13 @@ def get_est_input_size(out, height, p2pkh_pksize, p2sh_scriptsize, nonstd_script
return fixed_size + var_size


def get_utxo(tx_id, index, fin_name=CFG.chainstate_path):
def get_tx(tx_id, fin_name=CFG.chainstate_path):
"""
Gets a UTXO from the chainstate identified by a given transaction id and index.
If the requested UTXO does not exist, return None.
:param tx_id: Transaction ID that identifies the UTXO you are looking for.
:type tx_id: str
:param index: Index that identifies the specific output.
:type index: int
:param fin_name: Name of the LevelDB folder (chainstate by default)
:type fin_name: str
:return: A outpoint:coin pair representing the requested UTXO
Expand All @@ -849,16 +846,14 @@ def get_utxo(tx_id, index, fin_name=CFG.chainstate_path):
if o_key is not None:
o_key = hexlify(o_key)[2:]

coin = db.get(outpoint)
tx = db.get(outpoint)

if coin is not None and o_key is not None:
coin = deobfuscate_value(o_key, hexlify(coin))
if tx is not None and o_key is not None:
tx = deobfuscate_value(o_key, hexlify(tx))

db.close()

# ToDO: Add code to return a single output for 0.8 - 0.14

return coin
return tx


def deobfuscate_value(obfuscation_key, value):
Expand Down

0 comments on commit c5c7e28

Please sign in to comment.