<p>The migration tool will go through all the keys in the legacy wallet and create descriptors for them. This requires considering everything that <code>IsMine</code> matches on. From the Bitcoin Core release notes:</p>
<blockquote>
<p>IsMine refers to the function used to determine whether a script belongs to the wallet. This is used to determine whether an output belongs to the wallet. IsMine in Legacy Wallets returns true if the wallet would be able to sign an input that spends an output with that script. Since keys can be involved in a variety of different scripts, this definition for IsMine can lead to many unexpected scripts being considered part of the wallet.</p>
</blockquote>
<p>For HD wallets, it is pretty simple to compute the xpriv for the HD seed using a single descriptor. For non-HD wallets but still only key things, it's a descriptor for each key. The set of scriptPubKeys is finite and O(n!) so it is doable.</p>
<p>For watch-only wallets and multisigs it gets more complicated. Also getting the Descriptor Wallet to treat as <code>IsMine</code> any future script that the Legacy Wallet would have treated as <code>IsMine</code> is probably impossible for all edge cases.</p>
<p>Thanks to Andrew Chow and Pieter Wuille for answering this question on IRC. Any errors are my own.</p>

CC BY-SA 4.0
2022-10-31T21:31:45.790Z
Does this migration tool exist yet?
Bitcoin Hodler
CC BY-SA 4.0
2020-10-24T15:10:34.340Z
2020-10-24T15:10:34.340Z
Michael Folkson
<p>In this Andrew Chow <a href="https://achow101.com/2020/10/0.21-wallets" rel="nofollow noreferrer">blog post</a> on what's coming to the Bitcoin Core wallet in 0.21 he states:</p>
<blockquote>
<p>It is, and will be, possible to take an existing Legacy Wallet, and make a Descriptor Wallet which exactly matches it. There will be tooling that allows users to do this. Even after the removal of Legacy Wallets and Berkeley DB, it will be possible to migrate Legacy Wallets to Descriptor Wallets through the use of a minimally dependent migration tool.</p>
</blockquote>
<p>How will this migration tool work? How can the <a href="https://bitcoin.stackexchange.com/questions/99540/what-are-output-descriptors">descriptor wallet</a> obtain the descriptor from the legacy wallet given that the legacy wallet doesn't know what a descriptor is?</p>

<wallet><bitcoin-core-development><output-script-descriptors>
How will the migration tool from a Bitcoin Core legacy wallet to a descriptor wallet work?
Michael Folkson
# How will the migration tool from a Bitcoin Core legacy wallet to a descriptor wallet work?

(Asked by: username_0 on 2020-10-24)

In this Andrew Chow [blog post](https://achow101.com/2020/10/0.21-wallets) on what's coming to the username_1 Core wallet in 0.21 he states:

> It is, and will be, possible to take an existing Legacy Wallet, and make a Descriptor Wallet which exactly matches it. There will be tooling that allows users to do this. Even after the removal of Legacy Wallets and Berkeley DB, it will be possible to migrate Legacy Wallets to Descriptor Wallets through the use of a minimally dependent migration tool.

How will this migration tool work? How can the [descriptor wallet](https://username_1.stackexchange.com/questions/99540/what-are-output-descriptors) obtain the descriptor from the legacy wallet given that the legacy wallet doesn't know what a descriptor is?

**Tags:** wallet, bitcoin-core-development, output-script-descriptors


---

## 1 answers

### Answer by username_0 on 2020-10-24. Score: 2 | Accepted answer

The migration tool will go through all the keys in the legacy wallet and create descriptors for them. This requires considering everything that `IsMine` matches on. From the username_1 Core release notes:

> IsMine refers to the function used to determine whether a script belongs to the wallet. This is used to determine whether an output belongs to the wallet. IsMine in Legacy Wallets returns true if the wallet would be able to sign an input that spends an output with that script. Since keys can be involved in a variety of different scripts, this definition for IsMine can lead to many unexpected scripts being considered part of the wallet.

For HD wallets, it is pretty simple to compute the xpriv for the HD seed using a single descriptor. For non-HD wallets but still only key things, it's a descriptor for each key. The set of scriptPubKeys is finite and O(n!) so it is doable.

For watch-only wallets and multisigs it gets more complicated. Also getting the Descriptor Wallet to treat as `IsMine` any future script that the Legacy Wallet would have treated as `IsMine` is probably impossible for all edge cases.

Thanks to Andrew Chow and Pieter Wuille for answering this question on IRC. Any errors are my own.

> **Comments:**
> **username_1**: Does this migration tool exist yet?  

---

