<p>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:</p>
<p><code>cardano-address address inspect &lt;&lt;&lt; addr1...</code></p>
<p>This is a sample query to db-sync that lets you query all addresses for a given stake address.</p>
<p><code>SELECT * FROM utxo_view INNER JOIN stake_address ON stake_address.id = utxo_view.stake_address_id WHERE stake_address.view = 'stake1...';</code></p>
<p>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.</p>

CC BY-SA 4.0
2021-12-02T19:55:29.807Z
I did this query but my `stake_address` table is empty. Any idea why is this happening?
Daniel Cukier
CC BY-SA 4.0
2021-12-23T18:04:06.953Z
Probably your db-sync never completed syncing.
Samuel Leathers
CC BY-SA 4.0
2021-10-04T15:23:57.193Z
2021-10-04T15:23:57.193Z
Samuel Leathers
<p>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.</p>
<p>Cardano wallet will do the trick however.</p>

CC BY-SA 4.0
2021-12-02T23:40:10.087Z
How does Yoroi or Daedalus do calculate the wallet balance when the address is not staked?
Daniel Cukier
CC BY-SA 4.0
2021-12-31T17:31:05.347Z
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
Patrick Sturm
CC BY-SA 4.0
2021-09-25T19:59:18.980Z
2021-09-25T19:59:18.980Z
Patrick Sturm
<p>In the Daedalus wallet under &quot;Receive&quot; it says</p>
<blockquote>
<p>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.</p>
</blockquote>
<p>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 <code>cardano-cli</code> and <code>cardano-wallet</code>?</p>
<p>I already know, that I can read the balance of a single address with <code>cardano-cli query utxo --address</code>, but how can I discover the related addresses in the same wallet?</p>

CC BY-SA 4.0
2021-09-24T21:55:17.413Z
I have this exact question. Did you already solved it?
Luis Carlos
CC BY-SA 4.0
2021-09-25T01:29:46.570Z
no, but I believe it can be possible with the cardano-graphql api
njank
<wallet><cardano-cli><query>
Finding related addresses and total balance of wallet for any given address
# Finding related addresses and total balance of wallet for any given address

(Asked by: username_0 on 2021-09-15)

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?

**Tags:** wallet, cardano-cli, query
> **Comments:**
> **username_1**: I have this exact question. Did you already solved it?  
> **username_0**: no, but I believe it can be possible with the cardano-graphql api  

---

## 2 answers

### Answer by username_2 on 2021-10-04. Score: 9 | Accepted answer

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.

> **Comments:**
> **username_3**: I did this query but my `stake_address` table is empty. Any idea why is this happening?  
> **username_2**: Probably your db-sync never completed syncing.  

---

### Answer by username_4 on 2021-09-25. Score: 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.

> **Comments:**
> **username_3**: How does Yoroi or Daedalus do calculate the wallet balance when the address is not staked?  
> **username_4**: 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  

---

