2

I'm interested in knowing if there is an rpc method to determine whether or not an address was generated, and thus is owned by, a loaded Bitcoin Core wallet.

I have a few addresses that I generated a month or so ago using getnewaddress. These have been stored in a relatively secure encrypted location. In my paranoia, I am reluctant to now use the addresses to receive funds in the wallet, since as far as I know there is no benefit in doing so (besides increasing the gap between used addresses - but I am in no way approaching any gap limit, so this is irrelevant) over simply generating a new address which I can be sure is indeed owned by the loaded wallet. That said, I am curious to know if this is possible (since it may in some cases be useful, if sufficiently trustworthy - which if it were an rpc method for a trusted Bitcoin Corre instance, I'd assume to be the case) and after searching bitcoin.org RPC docs and on here, I have not been able to find an answer to this yet.

Note - I am aware of the validateaddress rpc, but as far as I understand, this only validates whether or not a Bitcoin address is valid, not whether it is associated with the loaded (or any particular) wallet.

2 Answers 2

3

You want the getaddressinfo wallet RPC. It will tell you whether an address is considers "yours", along with various other information like whether you have the keys, whether it's a payment address or change, what its label is, and how it was derived.

1
  • 1
    Thanks, exactly what I was looking for. To any onlookers, the relevant part of the json response to getaddressinfo is 'ismine'
    – qmux
    Commented Dec 15, 2020 at 23:35
1

I have written a program where you can search for any address on Bitcoin Core whether the address is yours or not. Actually it'll give you all the addresses in every block if you want. Here is my github link:

https://github.com/ORP967/Bitcoin_Core_RPC_par_address

Let me know what you guys think and any improvements you can come up with.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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