keep-network / tbtc-dapp

Deposit BTC and redeem TBTC
http://dapp.test.tbtc.network/
MIT License
33 stars 31 forks source link

Plugging in additional wallets to the dApp #177

Open liamzebedee opened 4 years ago

liamzebedee commented 4 years ago

Hardware wallets: Ledger, Trezor

Mobile wallets: WalletConnect

Are there common APIs? Do they line up with Metamask's, or will we need some custom wrappers?

Overview

Ledger and Trezor both use BIP32 Hierarchical Wallet Paths for BTC and ETH wallets. That means we do the enumerating of the BTC/ETH addresses for user selection. After that, we're only concerned with signing transactions. For Ethereum, that generally means we can use Web3.js, and insert a middleware called a Web3 subprovider that only answers to calls for signing transactions. For Bitcoin, we will need to ask for transactions to be signed, and there is a question of whether we can afford some UX advantages due to the need for P2SWKH tx's over normal ones.

Aside: Metamask. Last time I used Metamask with my Ledger, the experience was poor. Multiple repeating dialogs, general slowness. Nearly all DApps (Maker, Uniswap, etc) integrate "natively" with the hardware wallet API's, rather than letting Metamask handle it.

Ethereum
Bitcoin

What do their failure scenarios look like? (e.g., if the device gets unplugged/plugged back in)

We can generally detect failures using events of connect/disconnect for each wallet.

Progress

Shadowfiend commented 4 years ago

web3-react

Well I'm instantly down for that.