<p>You cannot generate public key from a bitcoin address. From bitcoin address, all you can get is the hash160. Following <a href="https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses" rel="nofollow noreferrer">reference</a>, this can be done through base58 decoding, going from Step 9 -> Step 8. So you get same output as from Step 4 along with checksum at the end.</p>

<p>Basically you have two alternatives:</p>

<ul>
<li>If you have the private key, generate the public key and use <code>importpubkey</code></li>
<li>Use <code>importaddress</code></li>
</ul>

CC BY-SA 3.0
2017-11-21T07:01:28.463Z
2017-11-21T07:01:28.463Z
dark knight
<p>You might want to use the <code>importaddress</code> RPC method (I'm not even aware of an <code>importpubkey</code> method).  The <code>importaddress</code> method accepts the base58 address string you have.  I recently asked a slightly-related question and ended up answering it myself here: <a href="https://bitcoin.stackexchange.com/questions/62939/how-to-make-importmulti-function-like-importaddress-for-watch-only-addresses-pla/62987#62987">How to make ImportMulti function like ImportAddress for watch-only addresses placed into Accounts?</a></p>

CC BY-SA 3.0
2017-11-21T02:25:22.890Z
When I do that, I get the error "couldn't connect to server".
Harry Pillsbury
CC BY-SA 3.0
2017-11-21T09:44:35.323Z
Then you have a bigger problem!
Pieter Wuille
CC BY-SA 3.0
2017-11-20T22:31:29.267Z
2017-11-20T22:31:29.267Z
dimsumcode
<p>If I want to watch a public address, I need the hex string for that address, because the <code>importpubkey</code> command only takes a hex input. How can I convert a  base 58 address to a hex string using the bitcoin core?</p>

CC BY-SA 3.0
2017-11-20T21:50:52.743Z
Possible duplicate of [How can I convert a SHA256 hash into a Bitcoin base58 private key?](https://bitcoin.stackexchange.com/questions/8247/how-can-i-convert-a-sha256-hash-into-a-bitcoin-base58-private-key)
Hannah Vernon
CC BY-SA 3.0
2017-11-20T21:51:24.490Z
I realize the above link does the conversion the other way; however it should help you get started.
Hannah Vernon
CC BY-SA 3.0
2017-11-20T21:56:32.217Z
@MaxVernon Uh, what??? This has nothing to do with private keys. Also, the conversion you cited is going the wrong way. That does not get me started. I want to know how to convert a base 58 pub key to a hex pub key USING THE CORE CLIENT.
Harry Pillsbury
<bitcoin-core><bitcoin-cli>
Get hex string for a public address
Harry Pillsbury
# Get hex string for a public address

(Asked by: username_0 on 2017-11-20)

If I want to watch a public address, I need the hex string for that address, because the `importpubkey` command only takes a hex input. How can I convert a base 58 address to a hex string using the bitcoin core?

**Tags:** bitcoin-core, bitcoin-cli

> **Comments:**
> **username_1**: Possible duplicate of [How can I convert a SHA256 hash into a Bitcoin base58 private key?](https://bitcoin.stackexchange.com/questions/8247/how-can-i-convert-a-sha256-hash-into-a-bitcoin-base58-private-key)  
> **username_1**: I realize the above link does the conversion the other way; however it should help you get started.  
> **username_0**: @MaxVernon Uh, what??? This has nothing to do with private keys. Also, the conversion you cited is going the wrong way. That does not get me started. I want to know how to convert a base 58 pub key to a hex pub key USING THE CORE CLIENT.  

---

## 2 answers

### Answer by username_2 on 2017-11-21. Score: 4

You cannot generate public key from a bitcoin address. From bitcoin address, all you can get is the hash160. Following [reference](https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses), this can be done through base58 decoding, going from Step 9 -> Step 8. So you get same output as from Step 4 along with checksum at the end.

Basically you have two alternatives:

* If you have the private key, generate the public key and use `importpubkey`
* Use `importaddress`


---

### Answer by username_3 on 2017-11-20. Score: 2

You might want to use the `importaddress` RPC method (I'm not even aware of an `importpubkey` method). The `importaddress` method accepts the base58 address string you have. I recently asked a slightly-related question and ended up answering it myself here: [How to make ImportMulti function like ImportAddress for watch-only addresses placed into Accounts?](https://bitcoin.stackexchange.com/questions/62939/how-to-make-importmulti-function-like-importaddress-for-watch-only-addresses-pla/62987#62987)

> **Comments:**
> **username_0**: When I do that, I get the error "couldn't connect to server".  
> **username_4**: Then you have a bigger problem!  

---

