<p>Here is the solution I ended up using:</p>
<pre><code>// var invoice *lnrpc.Invoice

inva, err := zpay32.Decode(invoice.PaymentRequest, &amp;chaincfg.MainNetParams)
if err != nil {
    return err
}

fmt.Sprintf(&quot;%x&quot;, inva.Destination.SerializeCompressed())
</code></pre>
<p>Alternatively, I think you can replace the <code>fmt.Sprintf</code> with <code>hex.EncodeToString</code></p>
<pre><code>hex.EncodeToString(inva.Destination.SerializeCompressed())
</code></pre>

CC BY-SA 4.0
2022-06-21T09:13:14.080Z
2022-06-21T09:21:24.857Z
2022-06-21T09:21:24.857Z
Ole Henrik Skogstrøm
<p>I'm trying to get the payees public key (destination node) from the payment request. You can <a href="https://lightningdecoder.com/lnbc4300n1p320r89pp59wlvxy3dky9t69q5jx5yupe9mrsxt8yp5dgwe3dnqn9fnjmz0zfsdp8xgcryv3dxqmj6vfn2scnjw33x5argwfwxv6nwkscqzpgxqyz5vqrzjq0nfr7qlprzkl2rke380tj0gkunm66pv7dtqt0396jrq02qz2fs9xzeqeyqqyucqqqqqqqqqqqqzwrcq9gsp5hc5nutnjdvalz4x3a8972s3rj4smh5c9hq857w2ksx357x34xx2q9qyyssq49mawcvxvr0faestf7f5xy8rnfpn9ls3uwjlkpsudk8lh9w9d2p5nal7plje0dfq54ww66pr6hgwucakp78k3ntcmxtsm9frpewm4ycq7sltp5" rel="nofollow noreferrer">see an example here</a>.</p>
<p>In the source code for (<a href="https://lightningdecoder.com/" rel="nofollow noreferrer">https://lightningdecoder.com/</a>) it seems like they get it from a tag or tag 19 (?) but I can't find this information in the decoded payment requests i get from LND:</p>
<p><a href="https://github.com/andrerfneves/lightning-decoder/blob/0fd4bdcd9ec01e8bacd0a475543186ad2de3fe27/src/lib/bolt11.js#L386-L394" rel="nofollow noreferrer">https://github.com/andrerfneves/lightning-decoder/blob/0fd4bdcd9ec01e8bacd0a475543186ad2de3fe27/src/lib/bolt11.js#L386-L394</a></p>
<p><strong>Does any one know how to get this?</strong> Preferably using Go and the invoice returned by LND</p>
<p><a href="https://i.sstatic.net/48RPK.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/48RPK.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-06-13T20:32:56.033Z
It's not quoite a duplicate question but I think the answer you seek for was given in the past to a similar question: https://bitcoin.stackexchange.com/a/96205
Rene Pickhardt
CC BY-SA 4.0
2022-06-15T08:34:43.880Z
Thank you Rene, I think I can solve my question based on the answer you posted above. I’ll update this post once I have an example of the solution for future reference here.
Ole Henrik Skogstrøm
<lightning-network><lightning-network-daemon><invoices>
How can i get the payee public key from the payment request
Ole Henrik Skogstrøm
# How can i get the payee public key from the payment request

(Asked by: username_0 on 2022-06-13)

I'm trying to get the payees public key (destination node) from the payment request. You can [see an example here](https://lightningdecoder.com/lnbc4300n1p320r89pp59wlvxy3dky9t69q5jx5yupe9mrsxt8yp5dgwe3dnqn9fnjmz0zfsdp8xgcryv3dxqmj6vfn2scnjw33x5argwfwxv6nwkscqzpgxqyz5vqrzjq0nfr7qlprzkl2rke380tj0gkunm66pv7dtqt0396jrq02qz2fs9xzeqeyqqyucqqqqqqqqqqqqzwrcq9gsp5hc5nutnjdvalz4x3a8972s3rj4smh5c9hq857w2ksx357x34xx2q9qyyssq49mawcvxvr0faestf7f5xy8rnfpn9ls3uwjlkpsudk8lh9w9d2p5nal7plje0dfq54ww66pr6hgwucakp78k3ntcmxtsm9frpewm4ycq7sltp5).

In the source code for (<https://lightningdecoder.com/>) it seems like they get it from a tag or tag 19 (?) but I can't find this information in the decoded payment requests i get from LND:

<https://github.com/andrerfneves/lightning-decoder/blob/0fd4bdcd9ec01e8bacd0a475543186ad2de3fe27/src/lib/bolt11.js#L386-L394>

**Does any one know how to get this?** Preferably using Go and the invoice returned by LND

[![enter image description here](https://i.sstatic.net/48RPK.png)](https://i.sstatic.net/48RPK.png)

**Tags:** lightning-network, lightning-network-daemon, invoices

> **Comments:**
> **username_1**: It's not quoite a duplicate question but I think the answer you seek for was given in the past to a similar question: https://bitcoin.stackexchange.com/a/96205  
> **username_0**: Thank you username_1, I think I can solve my question based on the answer you posted above. I’ll update this post once I have an example of the solution for future reference here.  

---

## 1 answers

### Answer by username_0 on 2022-06-21. Score: 1 | Accepted answer

Here is the solution I ended up using:

```
// var invoice *lnrpc.Invoice

inva, err := zpay32.Decode(invoice.PaymentRequest, &chaincfg.MainNetParams)
if err != nil {
    return err
}

fmt.Sprintf("%x", inva.Destination.SerializeCompressed())

```

Alternatively, I think you can replace the `fmt.Sprintf` with `hex.EncodeToString`

```
hex.EncodeToString(inva.Destination.SerializeCompressed())

```


---

