<p>You cannot go from just the address to the wallet's public key. There is a hash step involved which is irreversible.</p>
<p>In the code example you're linking, this is not an issue, as it is code that is executed by the wallet <em>creating</em> the receive address. Obviously, they actually have the public key.</p>

CC BY-SA 4.0
2023-07-31T14:05:27.280Z
Can you explain me given the context how do I get the PSBT ?
Abhishek
CC BY-SA 4.0
2023-07-31T14:07:27.280Z
You don't "get" the PSBT; you, as the spending wallet, which has all the information, creates it.
Pieter Wuille
CC BY-SA 4.0
2023-07-31T13:50:54.877Z
2023-07-31T13:50:54.877Z
Pieter Wuille
<p>I have recently started dev on Bitcoin and have a doubt regarding the following code. I have a dApp that prompts users to connect their BTC Wallet and in return, I get their address(testnet).</p>
<p>I want to understand this piece of code from this link
<a href="https://docs.xverse.app/sats-connect/creating-psbts" rel="nofollow noreferrer">https://docs.xverse.app/sats-connect/creating-psbts</a></p>
<p>How do we get this <strong>02818b7ff740a40f311d002123087053d5d9e0e1546674aedb10e15a5b57fd3985</strong></p>
<p>Given that we can only receive the address of the user which is in this format</p>
<p><strong>tb1q32vcpx59fucfc0jmd3hd3uqvpdwuq85j024qfl</strong></p>
<p>on the successful connection of the BTC wallet</p>
<p>Is there any way to convert the normal address to the long form of the address mentioned above?</p>
<pre><code>const publicKey = hex.encode(&quot;02818b7ff740a40f311d002123087053d5d9e0e1546674aedb10e15a5b57fd3985&quot;)
const p2wpkh = btc.p2wpkh(publicKey, bitcoinTestnet);
const p2sh = btc.p2sh(p2wpkh, bitcoinTestnet);
</code></pre>

<segregated-witness><address-generation>
What do the following lines of code do in the context of sending Bitcoin?
Abhishek
# What do the following lines of code do in the context of sending Bitcoin?

(Asked by: username_0 on 2023-07-31)

I have recently started dev on Bitcoin and have a doubt regarding the following code. I have a dApp that prompts users to connect their BTC Wallet and in return, I get their address(testnet).
I want to understand this piece of code from this link
https://docs.xverse.app/sats-connect/creating-psbts
How do we get this 02818b7ff740a40f311d002123087053d5d9e0e1546674aedb10e15a5b57fd3985
Given that we can only receive the address of the user which is in this format
tb1q32vcpx59fucfc0jmd3hd3uqvpdwuq85j024qfl
on the successful connection of the BTC wallet
Is there any way to convert the normal address to the long form of the address mentioned above?
const publicKey = hex.encode("02818b7ff740a40f311d002123087053d5d9e0e1546674aedb10e15a5b57fd3985")
const p2wpkh = btc.p2wpkh(publicKey, bitcoinTestnet);
const p2sh = btc.p2sh(p2wpkh, bitcoinTestnet);

**Tags:** segregated-witness, address-generation


---

## 1 answers

### Answer by username_1 on 2023-07-31. Score: 3 | Accepted answer

You cannot go from just the address to the wallet's public key. There is a hash step involved which is irreversible.

In the code example you're linking, this is not an issue, as it is code that is executed by the wallet *creating* the receive address. Obviously, they actually have the public key.

> **Comments:**
> **username_0**: Can you explain me given the context how do I get the PSBT ?  
> **username_1**: You don't "get" the PSBT; you, as the spending wallet, which has all the information, creates it.  

---

