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.

  • 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: bitcoin.stackexchange.com/questions/10090/… – pebwindkraft Apr 8 at 5:14
  • @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. – Kris Roofe Apr 8 at 5:23
  • @pebwindkraft any language is ok. I just want to know the idea to make it. – Kris Roofe Apr 8 at 5:25
up vote 1 down vote accepted

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"

  • Should other multisig apart from 1-of-1 included, such as 1-of-2, 2-of-3. – Kris Roofe Apr 8 at 6:46
  • 1
    @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 Apr 8 at 7:12

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. 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.

  1. 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.

  1. 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...

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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