<p>You will have to generate all the addresses corresponding to the public or private key you want to check, and then look for them all in the UTXO set. For example you might want to look for P2PK, P2PKH, P2WPKH, 1-of-1 multisig address with just that public key, etc. There is no "one search fits all"</p>

CC BY-SA 3.0
2018-04-08T06:46:30.480Z
Should other multisig apart from 1-of-1 included, such as 1-of-2, 2-of-3.
LF-DevJourney
CC BY-SA 3.0
2018-04-08T07:12:18.563Z
@KrisRoofe there are technically a near infinite possible amount of them, no point checking addresses unless you think someone might have sent something to them
meshcollider
CC BY-SA 3.0
2018-04-08T06:32:43.993Z
2018-04-08T06:32:43.993Z
meshcollider
<p>next to the answer from MeshCollider, I would like to outline a bit more, what can/cannot be done...</p>

<blockquote>
  <ol>
  <li>How can I get the whole balance of the privatekey or publickey?</li>
  </ol>
</blockquote>

<p>a priv/pubkey pair can generate several addresses. A privkey is the most standard used for P2PKH addresses (beginning with "1" on bitcoin network). They can be derived from a compressed or an uncompressed pubkey. A good <a href="http://gobittest.appspot.com/Address" rel="nofollow noreferrer">playground is here</a>. Then you can create P2SH addresses, of all kind with this key. They would start with a "3". And yes, multisig addresses would just be one of the possibilities. There are many combinations possible (1-of-1, 1-of-2, 1-of-3, 2-of-3, 2-of-4 ...), each resulting in a different "type 3" address. So if you have created the addresses within bitcoin client, you can use the command "getbalance". This command is linked to accounts, and once the addresses are grouped in accounts, one can display total balance in wallet or particular accounts. Addresses used in accounts can be seen with "getaddressesbyaccount", and then the addresses can be evaluated with "listunspent", gripping for the address you need. There is also the command to see the total amount received per address (getreceivedbyaddress).</p>

<p>In summary: you may want to create some coding logic to use the API calls. The API calls list is available in the source code, or in <a href="https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list" rel="nofollow noreferrer">the wiki</a>. </p>

<blockquote>
  <ol start="2">
  <li>How can list all the address from one privatekey or publickey?</li>
  </ol>
</blockquote>

<p>as MeshCollider explained, this needs some manual setup, nothing in bitcoin client that fits the request.</p>

<blockquote>
  <ol start="3">
  <li>What's more how to process multisig address which generated from not
  the same privatekey of publickey?</li>
  </ol>
</blockquote>

<p>When you created the multisig address with bitcoin core client ("addmultisigaddress"), then the client should display the values on this address. When the multisig was created "outsides" of the client, it will not display values for the account, even if you add the address as a "watch only" address (setaccount is now deprecated, and impogrtaddress is obviously the way to go). Anyhow I couldn't make my wallet see a balance on these imported addresses (though I am on regtest, and used txindex=1 in bitcoin.conf). 
Even more, if the address is "only" known, and hasn't been used on the blockchain, then the P2SH multisig addresses are covered behind a hash, which is a one-way function. So you never know the details of keys or logic used inside...   </p>

CC BY-SA 3.0
2018-04-08T15:09:06.353Z
2018-04-08T15:09:06.353Z
pebwindkraft
<p>As there are some bitcoin address types of one privatekey or publickey. I can get the balance of one address, but how can I get the whole balance of the privatekey or publickey. How can list all the address from one privatekey or publickey. What's more how to process multisig address which generated from not the same privatekey of publickey.</p>

CC BY-SA 3.0
2018-04-08T05:14:34.570Z
do you want to know how to do this for bitcoins with the bitcoin client, or any other wallet, or are you looking for a program (in which language) to extract this data for you? A general guideline is here: https://bitcoin.stackexchange.com/questions/10090/how-to-get-an-addresss-balance-with-the-bitcoin-client
pebwindkraft
CC BY-SA 3.0
2018-04-08T05:23:31.673Z
@pebwindkraft In my question I said, I know how to get the balance of one address. Here I want to get the whole balance from the addresses generated from one public key or privatekey.
LF-DevJourney
CC BY-SA 3.0
2018-04-08T05:25:56.897Z
@pebwindkraft any language is ok. I just want to know the idea to make it.
LF-DevJourney
<address><private-key><public-key><balance>
how to get the whole balance of a privatekey or publickey BTC
LF-DevJourney
# how to get the whole balance of a privatekey or publickey BTC

(Asked by: username_0 on 2018-04-08)

As there are some bitcoin address types of one privatekey or publickey. I can get the balance of one address, but how can I get the whole balance of the privatekey or publickey. How can list all the address from one privatekey or publickey. What's more how to process multisig address which generated from not the same privatekey of publickey.

**Tags:** address, private-key, public-key, balance

> **Comments:**
> **username_1**: do you want to know how to do this for bitcoins with the bitcoin client, or any other wallet, or are you looking for a program (in which language) to extract this data for you? A general guideline is here: https://bitcoin.stackexchange.com/questions/10090/how-to-get-an-addresss-balance-with-the-bitcoin-client  
> **username_0**: @username_1 In my question I said, I know how to get the balance of one address. Here I want to get the whole balance from the addresses generated from one public key or privatekey.  
> **username_0**: @username_1 any language is ok. I just want to know the idea to make it.  

---

## 2 answers

### Answer by username_2 on 2018-04-08. Score: 1 | Accepted answer

You will have to generate all the addresses corresponding to the public or private key you want to check, and then look for them all in the UTXO set. For example you might want to look for P2PK, P2PKH, P2WPKH, 1-of-1 multisig address with just that public key, etc. There is no "one search fits all"

> **Comments:**
> **username_0**: Should other multisig apart from 1-of-1 included, such as 1-of-2, 2-of-3.  
> **username_2**: @KrisRoofe there are technically a near infinite possible amount of them, no point checking addresses unless you think someone might have sent something to them  

---

### Answer by username_1 on 2018-04-08. Score: 2

next to the answer from MeshCollider, I would like to outline a bit more, what can/cannot be done...

> 1. How can I get the whole balance of the privatekey or publickey?

a priv/pubkey pair can generate several addresses. A privkey is the most standard used for P2PKH addresses (beginning with "1" on bitcoin network). They can be derived from a compressed or an uncompressed pubkey. A good [playground is here](http://gobittest.appspot.com/Address). Then you can create P2SH addresses, of all kind with this key. They would start with a "3". And yes, multisig addresses would just be one of the possibilities. There are many combinations possible (1-of-1, 1-of-2, 1-of-3, 2-of-3, 2-of-4 ...), each resulting in a different "type 3" address. So if you have created the addresses within bitcoin client, you can use the command "getbalance". This command is linked to accounts, and once the addresses are grouped in accounts, one can display total balance in wallet or particular accounts. Addresses used in accounts can be seen with "getaddressesbyaccount", and then the addresses can be evaluated with "listunspent", gripping for the address you need. There is also the command to see the total amount received per address (getreceivedbyaddress).

In summary: you may want to create some coding logic to use the API calls. The API calls list is available in the source code, or in [the wiki](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list).

> 2. How can list all the address from one privatekey or publickey?

as MeshCollider explained, this needs some manual setup, nothing in bitcoin client that fits the request.

> 3. What's more how to process multisig address which generated from not
>    the same privatekey of publickey?

When you created the multisig address with bitcoin core client ("addmultisigaddress"), then the client should display the values on this address. When the multisig was created "outsides" of the client, it will not display values for the account, even if you add the address as a "watch only" address (setaccount is now deprecated, and impogrtaddress is obviously the way to go). Anyhow I couldn't make my wallet see a balance on these imported addresses (though I am on regtest, and used txindex=1 in bitcoin.conf).
Even more, if the address is "only" known, and hasn't been used on the blockchain, then the P2SH multisig addresses are covered behind a hash, which is a one-way function. So you never know the details of keys or logic used inside...


---

