Currently I can get a list of all keys listkeys, or generate a new address getnewaddress. However, I cannot list all generated but unused addresses.
Add a RPC method listunusedaddress that lists all addresses which have been generated and labeled, but which do not yet have coins on them.
That's already possible because the keys' details contains the key state.
curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 0)'
curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 0 and .internal == true)'
curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 0 and .internal == false and .label != "")'
curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 2)'
curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 2)'
You can play with this and other values to get exactly what you want. But again, remember rpc is not for humans, a program can request the list of keys and filter to get what it needs, we don't need to filter the information for them because there could be hundreds of thousands methods. We give them the sugar, the eggs, the butter and the chocolate and they can cook the cookies that they like more.
Fantastic, of course!!
Thanks @lontivero, I added your calls to the documentation!
Most helpful comment
That's already possible because the keys' details contains the key state.
All unused keys
All unused keys for change
Unused keys generated by the user
All already used keys
All unused locked keys (reserved for coinjoins)
You can play with this and other values to get exactly what you want. But again, remember rpc is not for humans, a program can request the list of keys and filter to get what it needs, we don't need to filter the information for them because there could be hundreds of thousands methods. We give them the sugar, the eggs, the butter and the chocolate and they can cook the cookies that they like more.