Expand description
§Recovery Pallet
Pallet Recovery allows you to have friends or family recover access to your account if you lose your seed phrase or private key.
§Terminology
lost: An account that has lost access to its private key and needs to be recovered.friend: A befriended account that can approve a recovery process.initiator: An account that initiated a recovery attempt.recovered: An account that has been successfully recovered.inheritor: An account that is inheriting access to a lost account after recovery.attempt: An attempt to recover a lost account by an initiator.priority: The priority of a friend group in inheritance conflicts. SeeInheritancePriority.deposit: An amount of currency that needs to be held for allocating on-chain storage.friends_needed: The number of friends that need to approve an attempt.inheritance delay: How long an attempt will be delayed before it can succeed.provided block: The blocks that are provided by theT::BlockNumberProvider.
§Scenario: Recovering a lost account
Story of how the user Alice loses access and is recovered by her friends.
- Alice uses the recovery pallet to configure one or more friends groups:
- Alice picks a suitable
inheritoraccount that will inherit the access to her account for each friend group. This could be a multisig. - Alice configures all groups via
set_friend_groups.
- Alice loses access to her account and becomes a
lostaccount. - Any member (aka
initiator) of Alice’s friend groups become aware of the situation and starts a recoveryattemptviainitiate_attempt. - The friend group self-organizes and one-by-one approve the ongoing attempt via
approve_attempt. - Exactly
friends_neededfriends approve the attempt (further approvals will fail since they are useless). - Any account finishes the attempt via
finish_attemptafter at least inheritance delay blocks since the initiation have passed. - Alice’s account is now officially
recoveredand accessible by theinheritoraccount. - The
inheritormay callcontrol_inherited_accountat any point to transfer Alice’s funds to her new account.
§Scenario: Multiple friend groups try to recover an account
Alice may have configured multiple friend groups that all try to recover her account at the same time. This can lead to a conflict of which friend group should eventually inherit the access.
- Alice configures groups Family (delay 10d, priority 0) and Friends (delay 20d, priority 1). Since numerical lower values denote higher priority, Family therefore has higher priority than Friends.
- Day 0: Alice loses access to her account.
- Day 6: Friends initiate a recovery attempt for Alice.
- Day 15: Family finally understands Polkadot and initiates an attempt as well.
- Day 25: Family inherits access to Alice account.
- Day 26: Friends group gets nothing since they have lower priority than Family.
In the case above you see how the Friends group is now unable to recover Alice account since the Family group already did it and has higher priority. Now, imagine the case that the Friends group would have started on day 4 and would have already recovered the account on day 24. Two days later, the Family group can take access back and will replace the inheritor account with their own. The Friends group had access for two days since they were faster. If Alice account has most balance locked in 28 day staking this would not make a big difference, since only the free balance would be immediately transferable.
After a recovery attempt was completed, lower-priority friend groups cannot open a new attempt to recover the account.
§Data Structures
The pallet has three storage items, see the in-code docs FriendGroups, Attempt and
Inheritor. Storage items may contain deposit “tickets” or similar noise and should therefore
not be read directly but only through the API.
§API
Reading data can be done through the view functions:
provided_block_number: The block number that will be used to measure time.friend_groups: The friend groups of an account that can initiate recovery attempts.attempts: Ongoing recovery attempts for a lost account.inheritor: The account that inherited full access to the lost account.inheritance: All the recovered accounts that an account inherited access to.
Re-exports§
pub use weights::WeightInfo;pub use pallet::*;
Modules§
- migrations
- Multi-block migrations for the recovery pallet.
- pallet
- The
palletmodule in each FRAME pallet hosts the most important items needed to construct this pallet. - types
- Generic types that can be moved to frame-support once stable.
- weights
- Autogenerated weights for
pallet_recovery
Structs§
- Attempt
- An attempt to recover an account.
- Friend
Group - Group of friends that can initiate a recovery attempt for a specific lost account.
Constants§
- MAX_
GROUPS_ PER_ ACCOUNT - Maximum number of friend groups that an account can have.
Type Aliases§
- Account
IdLookup Of - Approval
Bitfield - Approval bitfield for a specific number of friends.
- Approval
Bitfield Of - Bitfield to track approval per friend in a friend group.
- Attempt
Of - Attempt to recover an account.
- Attempt
Ticket Of - Ticket for an attempt to recover an account.
- Balance
Of - Credit
Of - Friend
Group Index - Index of a friend group of a lost account.
- Friend
Group Of - A
FriendGroupfor a specificConfig. - Friend
Groups Of - Collection of friend groups of a lost account.
- Friends
Of - Friends of a friend group.
- HashOf
- Inheritance
Priority - Priority of a friend group in account inheritance conflicts.
- Inheritor
Ticket Of - Ticket for the inheritor of an account.
- Provided
Block Number Of - The block number type that will be used to measure time.
- Security
Deposit Of - Amount of a security deposit - as opposed to a storage deposit.