Add get_cashtoken_addresses to NetworkAPI#161
Conversation
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>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
BaseAPIwithget_cashtoken_addresses(...)and wires aNetworkAPIclassmethod that falls back across configured endpoints. - Implements the query in
ChaingraphAPIvia GraphQL onoutputwith optionalnft_capability,nft_commitment, andhas_tokenfilters; 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.
|
@yashasvi-ranawat see if it makes sense to implement any of the feedback above. Otherwise happy to merge as-is. |
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>
|
Good comments. I fixed them. Merge when ready :) |
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>
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 aset[str]of unique addresses.Changes
get_cashtoken_addressesabstract method toBaseAPIChaingraphAPIusing a GraphQL query on theoutputtable filtered bytoken_categoryNotImplementedErrorstubs inFulcrumProtocolAPIandBitcoinDotComAPI;NetworkAPIskips these transparentlynft_capability: Optional[NFTCapability],nft_commitment: Optional[bytes],has_token: bool— translated to additional Chaingraph GraphQL where conditionsdocs/guide/cashtokens.rstwith usage examples for each filterdocs/guide/network.rstunder NetworkAPI