PIP-41: Address Recovery
Recovering Address after Wallet Recovery
Authors | Pactus Development Team [info@pactus.org] |
---|---|
Discussion | View Discussion PIP-41 |
Category | Core |
Created | 2025-03-22 |
Table of Contents
Abstract #
This proposal enables automatic recovery of used addresses when restoring a wallet from a mnemonic phrase.
Motivation #
Problem #
Right now, when a wallet is recovered using a mnemonic phrase, it cannot restore all previously used or balance-holding addresses. Users must manually create addresses, which is not efficient. It can also cause problems, especially if there is a gap in address usage.
Solution #
This proposal suggests recovering addresses that have activity on the blockchain. An address is considered active if its public key is saved in the blockchain database. Otherwise, it is inactive or empty.
Specification #
When recovering a wallet from an external source (e.g., mnemonic phrase), the software should follow these steps:
- Create a temporary in-memory wallet for address recovery.
- Set
recovered_count = 1
. - Set
inactive_count = 1
. - Derive the first address.
- Loop:
- Check if the address’s public key is indexed in the blockchain.
- If not indexed (inactive):
- Increase
inactive_count
by 1. - If
inactive_count > 32
, break the loop. - Derive the next address.
- Increase
- If indexed (active):
- Add
inactive_count
torecovered_count
. - Reset
inactive_count = 1
. - Derive the next address.
- Add
After finding all recoverable addresses, the software should delete the temporary in-memory wallet, create a permanent wallet, and recover addresses based on the total number of recovered addresses.
Limitation #
Users can’t automatically recover a used address if it is separated by more than 32 inactive or empty addresses. In this case, the user needs to manually create addresses until they reach the desired one.
Backward Compatibility #
This change is backward-compatible.
Copyright
Copyright and related rights waived via CC0.