Walletwasabi: [RPC] add listunusedaddress method

Created on 22 Jan 2020  路  2Comments  路  Source: zkSNACKs/WalletWasabi

Problem

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.

Solution

Add a RPC method listunusedaddress that lists all addresses which have been generated and labeled, but which do not yet have coins on them.

featurenhancement

Most helpful comment

That's already possible because the keys' details contains the key state.

All unused keys

curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 0)'

All unused keys for change

curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 0 and .internal == true)'

Unused keys generated by the user

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 != "")'

All already used keys

curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 2)'

All unused locked keys (reserved for coinjoins)

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.

All 2 comments

That's already possible because the keys' details contains the key state.

All unused keys

curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 0)'

All unused keys for change

curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 0 and .internal == true)'

Unused keys generated by the user

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 != "")'

All already used keys

curl --data-binary '{"jsonrpc":"2.0","id":"1","method":"listkeys"}' http://127.0.0.1:37128/ | jq '.result[] | select(.keyState == 2)'

All unused locked keys (reserved for coinjoins)

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yahiheb picture yahiheb  路  3Comments

gabridome picture gabridome  路  3Comments

yahiheb picture yahiheb  路  3Comments

MaxHillebrand picture MaxHillebrand  路  3Comments

MaxHillebrand picture MaxHillebrand  路  3Comments