<blockquote>
<p>I created a new address p2wpkh from public key</p>
</blockquote>
<blockquote>
<p>public key of existing address,</p>
</blockquote>
<p>If you use the same public key as your starting point, you'll just generate the same address.</p>
<p>To create new addresses you need to first derive a new public key using the Hierarchical Deterministic (HD) process described by BIP-32.</p>
<p><sub>(This answer is Community Wiki since it is just a summary of comments with the aim of removing this question from the list of unanswered questions)</sub></p>

CC BY-SA 4.0
2022-11-10T18:15:45.437Z
2022-11-10T18:15:45.437Z
RedGrittyBrick
<p>this is certainly my lack of understanding, but it challenge what i know about blockchain.</p>
<p>I created a new address p2wpkh from public key with bech32 (testnet)  on ‎2022-11-10
: tb1q9ctu2t7zqvlevcamga9dfdhvlpeh93qdz6aawk
Made one transaction on 2022-11-10 10:29</p>
<p>pseudo code</p>
<pre><code>b_pubkey = bytes.fromhex(pubkey)
h160 = hash_160(b_pubkey)
segwit_hrp = 'tb'
encoding = Encoding.BECH32 
address = bech32_encode(encoding, segwit_hrp, [0] + convertbits(h160, 8, 5))
</code></pre>
<p>But in mempool it shows it has 3 transactions, goes back to ‎2022-11-07 15:10
<a href="https://mempool.space/testnet/address/tb1q9ctu2t7zqvlevcamga9dfdhvlpeh93qdz6aawk" rel="nofollow noreferrer">https://mempool.space/testnet/address/tb1q9ctu2t7zqvlevcamga9dfdhvlpeh93qdz6aawk</a></p>
<p>aren't addresses supposed to be unique and collision resistant  ?</p>

CC BY-SA 4.0
2022-11-10T15:43:31.033Z
How did you generate this address?
Pieter Wuille
CC BY-SA 4.0
2022-11-10T15:44:29.157Z
i added pseudo code to post
Kimboo Rasta
CC BY-SA 4.0
2022-11-10T15:50:20.047Z
Ok where did you get the pubkey?
Pieter Wuille
CC BY-SA 4.0
2022-11-10T15:56:30.107Z
public key of existing address, if that old address is linked to these transactions, why the NEW address is showing in output of confirmed block ?
Kimboo Rasta
CC BY-SA 4.0
2022-11-10T15:59:38.850Z
If you want a new address, you need a new key... Addresses just encode the hash of a key or a script. If you use the same key, you'll get the same address.
Pieter Wuille
CC BY-SA 4.0
2022-11-10T16:03:58.857Z
you mean new public key?, but what to do if you only have Master Public Key OR a pubkey of old address?
Kimboo Rasta
CC BY-SA 4.0
2022-11-10T16:06:35.367Z
If you have a master public key you can derive a new public key from it, and use *those* in the address. That's what master keys are for: generating multiple address keys for payments specifically so that they aren't all the same. If you have a public of an old address: don't, generate a new one.
Pieter Wuille
<bitcoin-core><p2wpkh>
Generated new p2wpkh address from pubkey of existing address - but found it has old transactions!
Kimboo Rasta
# Generated new p2wpkh address from pubkey of existing address - but found it has old transactions!

(Asked by: username_0 on 2022-11-10)

this is certainly my lack of understanding, but it challenge what i know about blockchain.

I created a new address p2wpkh from public key with bech32 (testnet) on ‎2022-11-10
: tb1q9ctu2t7zqvlevcamga9dfdhvlpeh93qdz6aawk
Made one transaction on 2022-11-10 10:29

pseudo code

```
b_pubkey = bytes.fromhex(pubkey)
h160 = hash_160(b_pubkey)
segwit_hrp = 'tb'
encoding = Encoding.BECH32 
address = bech32_encode(encoding, segwit_hrp, [0] + convertbits(h160, 8, 5))

```

But in mempool it shows it has 3 transactions, goes back to ‎2022-11-07 15:10
<https://mempool.space/testnet/address/tb1q9ctu2t7zqvlevcamga9dfdhvlpeh93qdz6aawk>

aren't addresses supposed to be unique and collision resistant ?

**Tags:** bitcoin-core, p2wpkh

> **Comments:**
> **username_1**: How did you generate this address?  
> **username_0**: i added pseudo code to post  
> **username_1**: Ok where did you get the pubkey?  
> **username_0**: public key of existing address, if that old address is linked to these transactions, why the NEW address is showing in output of confirmed block ?  
> **username_1**: If you want a new address, you need a new key... Addresses just encode the hash of a key or a script. If you use the same key, you'll get the same address.  
> **username_0**: you mean new public key?, but what to do if you only have Master Public Key OR a pubkey of old address?  
> **username_1**: If you have a master public key you can derive a new public key from it, and use *those* in the address. That's what master keys are for: generating multiple address keys for payments specifically so that they aren't all the same. If you have a public of an old address: don't, generate a new one.  

---

## 1 answers

### Answer by username_2 on 2022-11-10. Score: 2 | Accepted answer

> I created a new address p2wpkh from public key

> public key of existing address,

If you use the same public key as your starting point, you'll just generate the same address.

To create new addresses you need to first derive a new public key using the Hierarchical Deterministic (HD) process described by BIP-32.

(This answer is Community Wiki since it is just a summary of comments with the aim of removing this question from the list of unanswered questions)


---

