Skip to content

Add get_cashtoken_addresses to NetworkAPI#161

Merged
merc1er merged 15 commits into
pybitcash:masterfrom
yashasvi-ranawat:feature/cashtoken-addresses
Apr 29, 2026
Merged

Add get_cashtoken_addresses to NetworkAPI#161
merc1er merged 15 commits into
pybitcash:masterfrom
yashasvi-ranawat:feature/cashtoken-addresses

Conversation

@yashasvi-ranawat

@yashasvi-ranawat yashasvi-ranawat commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Description

Adds NetworkAPI.get_cashtoken_addresses(category_id) to fetch all BCH addresses currently holding unspent outputs of a given cashtoken category. The query is implemented via ChaingraphAPI's GraphQL interface and returns a set[str] of unique addresses.

Changes

  • Add get_cashtoken_addresses abstract method to BaseAPI
  • Implement in ChaingraphAPI using a GraphQL query on the output table filtered by token_category
  • Add NotImplementedError stubs in FulcrumProtocolAPI and BitcoinDotComAPI; NetworkAPI skips these transparently
  • Add optional filters: nft_capability: Optional[NFTCapability], nft_commitment: Optional[bytes], has_token: bool — translated to additional Chaingraph GraphQL where conditions
  • Document the feature in docs/guide/cashtokens.rst with usage examples for each filter
  • Add note in docs/guide/network.rst under NetworkAPI
  • Update README to mention CashToken and address subscription support

yashasvi-ranawat and others added 5 commits March 20, 2026 08:17
Adds a new method to fetch all addresses currently holding unspent
outputs of a given cashtoken category. Implemented via ChaingraphAPI
GraphQL query on the output table filtered by token_category.
FulcrumProtocolAPI and BitcoinDotComAPI raise NotImplementedError,
which NetworkAPI skips transparently. Returns a set[str] since
address order is not meaningful.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sses

Allows callers to narrow results to addresses holding NFTs, a specific
NFT commitment, or fungible tokens of a given cashtoken category.
Filters are composable and translate to additional Chaingraph GraphQL
where conditions; nft_commitment is passed as a typed bytea variable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Allows filtering addresses by a specific NFT capability (none, mutable,
minting) rather than a plain boolean. The capability enum name is passed
as a typed enum_nonfungible_token_capability variable in the Chaingraph
GraphQL query.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yashasvi-ranawat yashasvi-ranawat changed the title Feature/cashtoken addresses Add get_cashtoken_addresses to NetworkAPI Mar 20, 2026
@yashasvi-ranawat
yashasvi-ranawat marked this pull request as ready for review March 20, 2026 18:58
yashasvi-ranawat and others added 3 commits March 20, 2026 21:03
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yashasvi-ranawat

Copy link
Copy Markdown
Contributor Author

@merc1er This PR is ready. I'd want to merge this first before #163

@merc1er merc1er left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks!

I tested with your example token category and was able to cross check with https://3xpl.com/bitcoin-cash/transaction/afe979e6b52e37d29f6c4d7edd922bddb91b5e4d55ebfa8cd59a0f90bc03b802 and https://tokenexplorer.cash/?tokenId=afe979e6b52e37d29f6c4d7edd922bddb91b5e4d55ebfa8cd59a0f90bc03b802.

I wonder what would happen with a token with a very large amount of holders, but I haven't tested this scenario.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new NetworkAPI.get_cashtoken_addresses(category_id, ...) API to retrieve the set of addresses currently holding unspent outputs for a given CashToken category, with optional Chaingraph-backed filters.

Changes:

  • Extends BaseAPI with get_cashtoken_addresses(...) and wires a NetworkAPI classmethod that falls back across configured endpoints.
  • Implements the query in ChaingraphAPI via GraphQL on output with optional nft_capability, nft_commitment, and has_token filters; adds stubs to other APIs.
  • Adds tests for Chaingraph behavior and updates docs/README to document the feature and usage.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
bitcash/network/services.py Adds NetworkAPI.get_cashtoken_addresses fallback method with filter passthrough.
bitcash/network/APIs/__init__.py Adds abstract BaseAPI.get_cashtoken_addresses definition.
bitcash/network/APIs/ChaingraphAPI.py Implements get_cashtoken_addresses using a Chaingraph GraphQL query and script→address decoding.
bitcash/network/APIs/FulcrumProtocolAPI.py Adds get_cashtoken_addresses stub raising NotImplementedError.
bitcash/network/APIs/BitcoinDotComAPI.py Adds get_cashtoken_addresses stub raising NotImplementedError.
tests/network/APIs/test_ChaingraphAPI.py Adds unit tests for the new Chaingraph API method and filter query construction.
tests/network/APIs/test_FulcrumProtolAPI.py Refactors test constants to reuse tests.samples values.
docs/guide/network.rst Notes NetworkAPI.get_cashtoken_addresses is Chaingraph-only.
docs/guide/cashtokens.rst Documents “CashToken holders” feature and filter usage examples.
README.md Mentions CashToken support and real-time subscriptions in feature list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bitcash/network/APIs/ChaingraphAPI.py Outdated
Comment thread bitcash/network/services.py
Comment thread bitcash/network/services.py
@merc1er

merc1er commented Apr 27, 2026

Copy link
Copy Markdown
Member

@yashasvi-ranawat see if it makes sense to implement any of the feedback above. Otherwise happy to merge as-is.

yashasvi-ranawat and others added 7 commits April 28, 2026 22:10
Address.from_script now accepts a Network enum parameter (defaults to
Network.main) so testnet/regtest addresses are encoded with the correct
prefix and checksum. NetworkAPI.get_cashtoken_addresses passes the
network through to the endpoint.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add network: Network param to BaseAPI.__init__ and all concrete endpoint
constructors. get_endpoints_for passes the correct Network enum at
construction time, so ChaingraphAPI can use self.network in
get_transaction and get_cashtoken_addresses without relying on kwargs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yashasvi-ranawat

Copy link
Copy Markdown
Contributor Author

Good comments. I fixed them. Merge when ready :)

@merc1er merc1er left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@merc1er
merc1er merged commit 7524cd6 into pybitcash:master Apr 29, 2026
yashasvi-ranawat added a commit to yashasvi-ranawat/bitcash that referenced this pull request Apr 29, 2026
Lists addresses holding tokens of a given category ID. Supports
--nft-capability, --nft-commitment (hex), --has-amount, and --network
filters. Now that get_cashtoken_addresses landed in master (PR pybitcash#161),
the command is fully wired up.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants