stacks.js icon indicating copy to clipboard operation
stacks.js copied to clipboard

Allow wallets to specify the derivation path for stx private key

Open friedger opened this issue 3 years ago • 4 comments

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

friedger avatar Feb 22 '22 11:02 friedger

Should this issue also revert the previous changes that change the derivation based on the name's lookup?

kyranjamie avatar Feb 22 '22 12:02 kyranjamie

@kyranjamie We can keep them to make it possible for other wallets to choose their own derivation path

friedger avatar Feb 22 '22 12:02 friedger

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?

kyranjamie avatar Feb 22 '22 12:02 kyranjamie

Yes, restoreWalletAccounts would only use stxPrivateKey for account derivation.

As restoreWalletAccounts is very specific, an extra paramater does not make sense.

friedger avatar Feb 22 '22 13:02 friedger