Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix holder value error #214

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions electrumx/server/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class FlushData:
# atomicals_adds is used to track atomicals locations and unspent utxos with the b'i' and b'a' indexes
# It uses a field 'deleted' to indicate whether to write the b'a' (active unspent utxo) or not - because it may have been spent before the cache flushed
# Maps location_id to atomical_ids and the value/deleted entry
atomicals_adds = attr.ib() # type: Dict[bytes, Dict[bytes, { value: bytes, deleted: bool }] ]
atomicals_adds = attr.ib() # type: ignore # type: Dict[bytes, Dict[bytes, { value: bytes, deleted: bool }] ]
# general_adds is a general purpose storage for key-value, used for the majority of atomicals data
general_adds = attr.ib() # type: List[Tuple[Sequence[bytes], Sequence[bytes]]]
# realm_adds map realm names to tx_num ints, which then map onto an atomical_id
Expand All @@ -111,7 +111,7 @@ class FlushData:
dmpay_adds = attr.ib() # type: Dict[bytes, Dict[int, bytes]]
# distmint_adds tracks the b'gi' which is the initial distributed mint location tracked to determine if any more mints are allowed
# It maps atomical_id (of the dft deploy token mint) to location_ids and then the details of the scripthash+sat_value of the mint
distmint_adds = attr.ib() # type: Dict[bytes, Dict[bytes, bytes]
distmint_adds = attr.ib() # type: Dict[bytes, Dict[bytes, bytes]]
# state_adds is for evt, mod state updates
# It maps atomical_id to the data of the state update
state_adds = attr.ib() # type: Dict[bytes, Dict[bytes, bytes]]
Expand Down Expand Up @@ -1492,15 +1492,13 @@ def query_holders():
atomical_output_script_key = b"po" + location
atomical_output_script_value = self.utxo_db.get(atomical_output_script_key)
location_script = atomical_output_script_value
(location_value,) = unpack_le_uint64(
atomical_active_location_value[HASHX_LEN + SCRIPTHASH_LEN : HASHX_LEN + SCRIPTHASH_LEN + 8]
)
atomical_value = self.get_uxto_atomicals_value(location, atomical_id)

script = location_script.hex()
if holder_dict.get(script, None):
holder_dict[script] += location_value
holder_dict[script] += atomical_value
else:
holder_dict[script] = location_value
holder_dict[script] = atomical_value

for script, holding in holder_dict.items():
holders.append(
Expand Down
Loading