11

In the Daedalus wallet under "Receive" it says

Please note that all of your receiving addresses include your stake key. When you share a receiving address, the recipient can search the blockchain using your stake key to locate all addresses associated with your wallet, and also discover your wallet balance and transaction history.

Does that mean I can query for any address the stake key and therefore all the child addresses with their total balance? If yes, how can I achieve this using the cardano-cli and cardano-wallet?

I already know, that I can read the balance of a single address with cardano-cli query utxo --address, but how can I discover the related addresses in the same wallet?

2
  • I have this exact question. Did you already solved it? Sep 24, 2021 at 21:55
  • no, but I believe it can be possible with the cardano-graphql api
    – njank
    Sep 25, 2021 at 1:29

2 Answers 2

9

You need db-sync to analyze wallets that you don't have the account public key for. Given an address from a wallet, you can run cardano-address inspect to identify the stake address:

cardano-address address inspect <<< addr1...

This is a sample query to db-sync that lets you query all addresses for a given stake address.

SELECT * FROM utxo_view INNER JOIN stake_address ON stake_address.id = utxo_view.stake_address_id WHERE stake_address.view = 'stake1...';

One caveat is anyone can send funds to a payment address not associated with your wallet that's associated with your stake key. This means there could be some addresses you query that the user doesn't have control, so you cannot assume the user with the wallet with that stake key can access all the addresses provided.

2
  • I did this query but my stake_address table is empty. Any idea why is this happening? Dec 2, 2021 at 19:55
  • Probably your db-sync never completed syncing. Dec 23, 2021 at 18:04
0

Some addresses may not belong to a stake pool so no. Any address which is staked can be verified though. Although the cli does not provide a method to do this, you'll need db sync or related tool, specifically one which runs the chainSync mini protocol which is not in the cli.

Cardano wallet will do the trick however.

2
  • How does Yoroi or Daedalus do calculate the wallet balance when the address is not staked? Dec 2, 2021 at 23:40
  • They have 'chain-sync', a smaller subset specifically for your wallet. When you create a new address via standard operation, the wallet already has the info about it locally. DB-sync is for global data and is structured differently, in a much sparser manner. There are 41 tables in total, each having fragments of the overall data. Sure, there is likely some form of link, but you would need to do that man power alone Dec 31, 2021 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.