Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Plugging in additional wallets to the dApp #177

Open
2 of 4 tasks
liamzebedee opened this issue Feb 6, 2020 · 1 comment
Open
2 of 4 tasks

Plugging in additional wallets to the dApp #177

liamzebedee opened this issue Feb 6, 2020 · 1 comment

Comments

@liamzebedee
Copy link
Contributor

liamzebedee commented Feb 6, 2020

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
  • Web3.js has the concept of Web3 subproviders, which respond to ETH RPC calls (eth_sign).
    • Simple to integrate
    • Works with existing code (although we still have to move from Truffle-Web3 to Web3.js)
  • Ledger implements a web3-subprovider, which is a middleware over their own API.
  • Trezor has only unofficial implementations of a subprovider.
  • WalletLink
  • There's also a couple other libraries worth knowing about:
    • web3-react: integrates with Metamask, wallets, WalletConnect
Bitcoin
  • ledgerjs hw-app-btc
    • Official Ledger API
    • Supports P2SH transactions and signing arbitrary payloads (eg. segwit tx's).
    • Only the P2SH API shows transaction amounts I believe, which may be a threat to UX.
  • trezor connect
    • Official Trezor API
    • Supports non-SW and SW tx types, and signing arbitrary messages.

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.

  • Ledger
    • We can detect disconnect of the USB and Bluetooth transports using transport.on('disconnect')
    • Reauthentication: authenticating the device is not a separate call.
  • Trezor
    • We can detect connect/disconnect events from the Trezor (doc).
    • It's worth noting Trezor uses a separate iframe popup, which is a bit more fragile than just an API since the user can close it at will.
    • Reauthentication: device authentication is remembered by the iframe popup.
  • WalletConnect
    • WalletConnect uses a bridge server to relay events from the mobile wallet
    • We can connect/disconnect events using the WalletConnect object.
    • Reauthentication: we must redisplay the QR code for pairing every time.

Progress

@Shadowfiend
Copy link
Contributor

web3-react

Well I'm instantly down for that.

@liamzebedee liamzebedee mentioned this issue Feb 18, 2020
6 tasks
@mhluongo mhluongo changed the title Plugging in HW wallets to dApp Plugging in additional wallets to the dApp Aug 10, 2020
This was referenced Aug 10, 2020
@mhluongo mhluongo removed dev labels Aug 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants