PIP-41: Address Recovery
Recovering Addresses 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 automatically restore all previously used or balance-holding addresses. Users must manually create addresses, which is not efficient. This 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 it is indexed in the blockchain database; otherwise, it is considered inactive or empty. Account activity can be determined using the GetAccount API.
Specification #
When recovering a wallet from an external source (e.g., mnemonic phrase), the software should follow these steps:
- Set
recovered_count = 1
. - Set
inactive_count = 0
. - Derive the first address.
- Loop:
- Check if the address’s public key is indexed in the blockchain.
- If indexed (active):
- Add
inactive_count
torecovered_count
. - Reset
inactive_count = 1
.
- Add
- If not indexed (inactive):
- Increase
inactive_count
by 1. - If
inactive_count > 8
, break the loop.
- Increase
- Derive the next address.
After finding all recoverable addresses, the software should recover all addresses up to the total number of recovered addresses.
Limitation #
Users cannot automatically recover a used address if it is separated by more than 8 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.
Reference #
BIP-44: Multi-Account Hierarchy for Deterministic Wallets - Account Discovery
Copyright
Copyright and related rights waived via CC0.