stacks.js
stacks.js copied to clipboard
Allow wallets to specify the derivation path for stx private key
Is your feature request related to a problem? Please describe. Currently, wallet accounts are restored such that the stxPrivateKey is either the wallet private key or the data private key depending on whether the user owns a BNS username on one of the corresponding addresses.
However, wallets might want to only support one derivation path.
Describe the solution you'd like
The function restoreWalletAccounts should take an extra parameter with the derivation type for the stx private key. If Unknown derivation type is provided, this the function tries to restore the accounts as now, If a different derivation type is provided, the accounts only look at the provided derivation path.
Describe alternatives you've considered This looks like the change with the least impact.
Additional context Main discussion happened in https://github.com/hirosystems/stacks-wallet-web/pull/2089
@kyranjamie
Should this issue also revert the previous changes that change the derivation based on the name's lookup?
@kyranjamie We can keep them to make it possible for other wallets to choose their own derivation path
We can keep them to make it possible for other wallets to choose their own derivation path
but specifically the logic which automatically determines the derivation path, by the username, won't be needed, right? This'll be changing this to only accept derivation path as an input?
Yes, restoreWalletAccounts would only use stxPrivateKey for account derivation.
As restoreWalletAccounts is very specific, an extra paramater does not make sense.