leather-io / extension

Leather browser extension
https://leather.io
MIT License
293 stars 140 forks source link

STX Address Derivation Should Match BTC Wallets #2402

Closed owenstrevor closed 1 month ago

owenstrevor commented 2 years ago

Currently, every STX address can derive a BTC address.

The problem is, the BTC address we derive does not use the same algorithm as BTC wallets. While every BTC wallet may use a different derivation algo, we should be able to match them based on what people use.

Essentially, current Bitcoiners can't get the same BTC address with the same seed phrase on their Hiro/Xverse wallet.

Every Bitcoiner's BTC address should be able to be used as a STX address, without even having Hiro wallet

e.g. I could use the BTC wallet of Pomp, Nic Carter, etc and send them dope NFTs that they can use later with the same seed phrase and Hiro. Easy onboarding!

markmhendrickson commented 2 years ago

I certainly agree with this principle, and we expect to build Bitcoin support into Hiro Wallet in a way that ensures that the user can take their seed phrase / Secret Key to other (Bitcoin) wallets and see their addresses seamlessly.

Though since we haven't built this support yet, "the BTC address we derive does not use the same algorithm as BTC wallets" is not an outstanding problem with the Hiro Wallet per se? Is that perhaps unique to Xverse?

aulneau commented 2 years ago

Though since we haven't built this support yet, "the BTC address we derive does not use the same algorithm as BTC wallets" is not an outstanding problem with the Hiro Wallet per se? Is that perhaps unique to Xverse?

Both Hiro wallets and Xverse use the same derivation path to generate Stacks addresses, they conform to the BIP44 derivation paths standard:

`m / purpose' / coin_type' / account' / change / address_index

This is the stacks derivation path:

`m/44'/5757'/0'/0

Here is a list of all coin types: https://github.com/satoshilabs/slips/blob/master/slip-0044.md

To support standard bitcoin addresses, we could implement it so all stacks wallets can derive the 5757 stacks coin type, but also the 0 bitcoin coin type. For each coin type, you're able to represent both bitcoin and stacks addresses, so if we switched over to using the standard bitcoin derivation path, folks could easily do actions with any bitcoin wallet and see their associated stacks activity, too.

yknl commented 2 years ago

Essentially, current Bitcoiners can't get the same BTC address with the same seed phrase on their Hiro/Xverse wallet.

The BTC address in Xverse is a P2SH-P2WPKH segwit address using the standard m/49’/0’/0’/0/0 path. Meaning you can get the same BTC address using the same key in other BTC wallets as long as you choose P2SH segwit.

And we are looking into allowing users to send/receive NFTs using that Bitcoin address, as Bitcoin NFTs should be.

owenstrevor commented 2 years ago

Essentially, current Bitcoiners can't get the same BTC address with the same seed phrase on their Hiro/Xverse wallet.

The BTC address in Xverse is a P2SH-P2WPKH segwit address using the standard m/49’/0’/0’/0/0 path. Meaning you can get the same BTC address using the same key in other BTC wallets as long as you choose P2SH segwit.

And we are looking into allowing users to send/receive NFTs using that Bitcoin address, as Bitcoin NFTs should be.

  1. How do we implement it on Gamma so that I can send an NFT to someone's BTC address or send BTC to someone's STX address?

  2. Or I could send an NFT to Bitcoiner address without them having Xverse yet and then they just sign up for Xverse?

owenstrevor commented 2 years ago

I certainly agree with this principle, and we expect to build Bitcoin support into Hiro Wallet in a way that ensures that the user can take their seed phrase / Secret Key to other (Bitcoin) wallets and see their addresses seamlessly.

Though since we haven't built this support yet, "the BTC address we derive does not use the same algorithm as BTC wallets" is not an outstanding problem with the Hiro Wallet per se? Is that perhaps unique to Xverse?

should we move this issue over to Stacks.js then?

ceramicwhite commented 2 years ago
  1. Gamma has already implemented the translation. You can type in the BTC address and the site will do the C32 translation(Stacks) but the displayed address at signing shown will be the C32 translation

You can do the conversion yourself easily from the CLI with: stx convert_address I sent Adam Back a boombox awhile ago

  1. No they couldn't just sign up to Xverse and access these assets. Problem is that neither the Hiro wallets or Xverse allow derivation paths outside of the SLIP-44 standard. In Xverse case, it doesn't allow deriving more addresses beyond the 0 address_index

Hiro wallet you can easily modify and build the wallet without the 5757 coin_type, but defeats the point. You also need to rely on the "Bitcoiner" supplying the address is aware of the derivation path to the address they gave you.

A powerful feature here for both wallets the ability to import an xPub/zPub and scan for assets.

The Hiro Wallet should also have a toggle setting to switch between /5757'/ & /0'/ coin_type

yknl commented 2 years ago

In Xverse case, it doesn't allow deriving more addresses beyond the 0 address_index

That is not true anymore. You can generate BTC/STX addresses in Xverse beyond the first index.

A powerful feature here for both wallets the ability to import an xPub/zPub and scan for assets.

I feel like 90% of the people using NFTs will have no idea what an xPub/zPub is.

Wallets using different derivation paths is for sure an issue. I don't think there's an easy solution here. But perhaps a web-based NFT viewer that takes BTC addresses would be sufficient to trigger the aha moment. And then if they want to access the asset they can install Xverse wallet.

larrysalibra commented 2 years ago

This is an interesting idea. I like how it makes Stacks more interoperable with bitcoin from a UX perspective.

Just wanted raise a few points for consideration:

friedger commented 2 years ago

This should be an issue on the SIP repo!