Skip to content

Commit

Permalink
fix ingest error on zcash shielded address
Browse files Browse the repository at this point in the history
  • Loading branch information
soad003 committed Oct 6, 2023
1 parent bc28558 commit fecf4fb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [23.09/1.8.1] 2023-10-06
### fixed
- handle zcash shielded inputs in import

## [23.09/1.8.0] 2023-10-02
### Added
- added flag forward-fill-rates to allow transform even if no current rates are available (last rate avail is used)
Expand Down
4 changes: 3 additions & 1 deletion scripts/dev-ingest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ RB=${5:-15}

echo "Import on ${NW} till ${EB} with delta updater version ${UV}"

if [ ${NW}=eth ]
if [ "${NW}" = "eth" ]
then
echo "account model ingest"
graphsense-cli -v ingest from-node -e dev -c ${NW} --end-block ${EB} --batch-size ${RB} --create-schema && \
graphsense-cli -v exchange-rates coindesk ingest -e dev -c ${NW} --abort-on-gaps && \
graphsense-cli -v exchange-rates coinmarketcap ingest -e dev -c ${NW} --abort-on-gaps && \
graphsense-cli -v delta-update update -e dev -c ${NW} --end-block ${EB} --write-batch-size ${WB} --updater-version ${UV} --create-schema --pedantic --forward-fill-rates
else
echo "utxo model ingest"
graphsense-cli -v ingest from-node -e dev -c ${NW} --end-block ${EB} --batch-size ${RB} --create-schema --mode='utxo_with_tx_graph' && \
graphsense-cli -v exchange-rates coindesk ingest -e dev -c ${NW} --abort-on-gaps && \
graphsense-cli -v exchange-rates coinmarketcap ingest -e dev -c ${NW} --abort-on-gaps && \
Expand Down
33 changes: 18 additions & 15 deletions src/graphsenselib/ingest/utxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ def prepare_blocks_inplace(blocks: Iterable, block_bucket_size: int) -> None:
"p2wshv0": 9,
"witness_unknown": 10,
"witness_v1_taproot": 11,
"shielded": 12,
}


Expand All @@ -362,7 +363,7 @@ def addresstype_to_int(addr_type: str) -> int:


def address_as_string(x):
if x["type"] in ["null", "nulldata", "nonstandard", "witness_unknown"]:
if x["type"] in ["null", "nulldata", "nonstandard", "witness_unknown", "shielded"]:
return None
return x["addresses"]

Expand Down Expand Up @@ -585,20 +586,22 @@ def get_tx_refs(spending_tx_hash: str, raw_inputs: Iterable, tx_hash_prefix_len:
spending_input_index = inp["index"]
spent_tx_hash = hex_to_bytearray(inp["spent_transaction_hash"])
spent_output_index = inp["spent_output_index"]
tx_refs.append(
{
"spending_tx_hash": spending_tx_hash,
"spending_input_index": spending_input_index,
"spent_tx_hash": spent_tx_hash,
"spent_output_index": spent_output_index,
"spending_tx_prefix": strip_0x(bytes_to_hex(spending_tx_hash))[
:tx_hash_prefix_len
],
"spent_tx_prefix": strip_0x(bytes_to_hex(spent_tx_hash))[
:tx_hash_prefix_len
],
}
)
if spending_tx_hash is not None and spent_tx_hash is not None:
# in zcash refs can be None in case of shielded txs.
tx_refs.append(
{
"spending_tx_hash": spending_tx_hash,
"spending_input_index": spending_input_index,
"spent_tx_hash": spent_tx_hash,
"spent_output_index": spent_output_index,
"spending_tx_prefix": strip_0x(bytes_to_hex(spending_tx_hash))[
:tx_hash_prefix_len
],
"spent_tx_prefix": strip_0x(bytes_to_hex(spent_tx_hash))[
:tx_hash_prefix_len
],
}
)

return tx_refs

Expand Down

0 comments on commit fecf4fb

Please sign in to comment.