<p>A <code>wallet.dat</code> file will contain many, many bitcoin keypairs/addresses. So there is no reason to delete an older address, and in fact this is probably a bad idea. If you or anyone else ever mistakenly sends bitcoins to that address, it will be impossible to recover them once you've deleted those keys.</p>

<p>If you do not have the private key for an address, you will not be able to spend any bitcoin stored at it. That said, you can still import the address as a <em><a href="https://bitcoin.stackexchange.com/questions/84306/watch-only-wallets/84307#84307">'watch-only'</a></em> address, meaning your wallet will keep track of the address' balance, but not be able to spend the coins (because you don't have the private key). </p>

<p>You can use the following commands:</p>

<p><code>bitcoin-cli importaddress</code> for a bitcoin address</p>

<p><code>bitcoin-cli importpubkey</code> for a bitcoin public key</p>

<p>Note that in order for your wallet to learn about transactions sent to the imported address/pubkey in the past, your wallet will need to rescan the blockchain (<code>rescan=true</code> by default when calling <code>importaddress</code> or <code>importpubkey</code>). If you happen to know which blocks the relevant transactions were included in, you can set <code>rescan=false</code> and then run <code>rescanblockchain ("start_height") ("stop_height")</code> and it will complete the rescan <strong>much</strong> faster.</p>

<p>And if you do have the private key, you can import it using:</p>

<p><code>bitcoin-cli importprivkey</code></p>

CC BY-SA 4.0
2024-02-05T15:16:23.847Z
Readers should also read https://bitcoincore.org/en/doc/26.0.0/rpc/wallet/importaddress/ and note the comment about **descriptor wallets** and the older type of wallet known as legacy wallets.
RedGrittyBrick
CC BY-SA 4.0
2019-05-07T06:07:04.820Z
2019-05-07T10:20:37.260Z
2019-05-07T10:20:37.260Z
chytrik
<p>I have a <strong>wallet.dat</strong> with Bitcoin Address: <code>15iRTcgqBk1QNtr2gKkq2dUsm5nN25dSeN</code></p>

<p>I want to delete this Bitcoin Address: <code>15iRTcgqBk1QNtr2gKkq2dUsm5nN25dSeN</code> and add another Bitcoin Address</p>

<p>How can I add another Bitcoin Address to this <strong>wallet.dat</strong> if I know its public key, but I don’t know the private key of this Bitcoin Address?</p>

<bitcoin-core><address><public-key><wallet.dat>
How can I import an address or public key into my wallet.dat file?
Rozwrcd
# How can I import an address or public key into my wallet.dat file?

(Asked by: username_0 on 2019-05-07)

I have a **wallet.dat** with Bitcoin Address: `15iRTcgqBk1QNtr2gKkq2dUsm5nN25dSeN`

I want to delete this Bitcoin Address: `15iRTcgqBk1QNtr2gKkq2dUsm5nN25dSeN` and add another Bitcoin Address

How can I add another Bitcoin Address to this **wallet.dat** if I know its public key, but I don’t know the private key of this Bitcoin Address?

**Tags:** bitcoin-core, address, public-key, wallet.dat


---

## 1 answers

### Answer by username_1 on 2019-05-07. Score: 3

A `wallet.dat` file will contain many, many bitcoin keypairs/addresses. So there is no reason to delete an older address, and in fact this is probably a bad idea. If you or anyone else ever mistakenly sends bitcoins to that address, it will be impossible to recover them once you've deleted those keys.

If you do not have the private key for an address, you will not be able to spend any bitcoin stored at it. That said, you can still import the address as a *['watch-only'](https://bitcoin.stackexchange.com/questions/84306/watch-only-wallets/84307#84307)* address, meaning your wallet will keep track of the address' balance, but not be able to spend the coins (because you don't have the private key).

You can use the following commands:

`bitcoin-cli importaddress` for a bitcoin address

`bitcoin-cli importpubkey` for a bitcoin public key

Note that in order for your wallet to learn about transactions sent to the imported address/pubkey in the past, your wallet will need to rescan the blockchain (`rescan=true` by default when calling `importaddress` or `importpubkey`). If you happen to know which blocks the relevant transactions were included in, you can set `rescan=false` and then run `rescanblockchain ("start_height") ("stop_height")` and it will complete the rescan **much** faster.

And if you do have the private key, you can import it using:

`bitcoin-cli importprivkey`

> **Comments:**
> **username_2**: Readers should also read https://bitcoincore.org/en/doc/26.0.0/rpc/wallet/importaddress/ and note the comment about **descriptor wallets** and the older type of wallet known as legacy wallets.  

---

