listaddresses()
It will spit out a list of all your receiving and change addresses visible on the addresses tab, so you can copy the whole list at once. You'll still need to manually remove the " and , symbols before attempting to import them, though.
Would it make sense to use
listunspent[1] afterwards? This would allow the OP to get the current balance of each address, albeit it wouldn't provide him with a total sum. Is there any command that OP could use in CLI to sum each value from the provided addresses and spit the result at the end? JQ[1] seems very promising to do this kind of filtering but I'm not sure what the command line could be:
Use JSON for Simple Calculation by Value
Usage Example: Automatically calculate the value of the UTXOs used in a transaction.You can now go one step further, and request the .amount (or any other JSON key-value) from the UTXOs you're retrieving.
This example repeats the usage the $usedtxid and $usedvout arrays that were set as follows:
$ usedtxid=($(bitcoin-cli decoderawtransaction $rawtxhex | jq -r '.vin | .[] | .txid'))
$ usedvout=($(bitcoin-cli decoderawtransaction $rawtxhex | jq -r '.vin | .[] | .vout'))
The same for script can be used to step through those arrays, but with an added pipe in the JQ that outputs the amount value for each of the UTXOs selected.
$ for ((i=0; i<${#usedtxid
- }; i++)); do txid=${usedtxid}; vout=${usedvout}; bitcoin-cli listunspent | jq -r '.[] | select (.txid | contains("'${txid}'")) | select(.vout | contains('$vout')) | .amount'; done;
0.9
0.4
At this point, you can also sum up the .amounts with an awk script, to really see how much money is in the UTXOs that the transaction is spending:
$ for ((i=0; i<${#usedtxid
- }; i++)); do txid=${usedtxid}; vout=${usedvout}; bitcoin-cli listunspent | jq -r '.[] | select (.txid | contains("'${txid}'")) | select(.vout | contains('$vout')) | .amount'; done | awk '{s+=$1} END {print s}'
1.3
Whew!
OP: In order to achieve a better degree of privacy, I would recommend you to run your own node and then you could retrieve this information without relying on any external entity by using Bitcoin Core CLI.
[1]
https://thunderbiscuit.github.io/Learning-Bitcoin-from-the-Command-Line/04_2__Interlude_Using_JQ.html