Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display account in app nav whenever signing via API #4859

Closed
314159265359879 opened this issue Jan 25, 2024 · 21 comments · Fixed by #5631
Closed

Display account in app nav whenever signing via API #4859

314159265359879 opened this issue Jan 25, 2024 · 21 comments · Fixed by #5631
Assignees
Labels
area:api area:bitcoin enhancement enhancement-p1 Critical functionality needed by many users, with no clear alternatives

Comments

@314159265359879
Copy link
Contributor

314159265359879 commented Jan 25, 2024

Some more testing revealed that this https://github.com/leather-wallet/extension/issues/4599 has different has a different result on Stacks compared to Bitcoin.

Reproduction steps on Bitcoin dapps

  1. Sign in to gamma.io on account 1
  2. Then on the leather extension switch to account 2
  3. Try to buy an ordinal or create an inscription
  4. See the screen pop up with Account 2 top left (expected is account 1).

A user reported that using unisat they signed transactions with another account than expected. I think it is caused by this. When you mint an inscription the transaction is signed with the active account on the wallet rather than the account signed in with on the dapp:

image

Trying the same thing buying an ordinal with unisat (signed in with account 1 and account 2 active will throw an error):
image

Trying the same thing on Magic Eden and Gamma resulted in no transmission of the transaction.
I tested minting a text inscription on Magic Eden after clicking confirm, the confirm screen closes but nothing is transmitted.
image

On Gamma I tested buying a print and the result was similar as on Magic Eden, clicking confirm closes the confirm screen but no transaction is transmitted.
image

Possible solutions: (a) better error handling, (b) the ME and gamma can show similar errors (c) (perhaps suggest them to make sure the active account on the extension is the same), (d) and allow trying again (not possible on ME without a refresh). (f) It would be great if the wallet could detect users who are trying to send with a different wallet and then allow an easy way for the user to switch.

@markmhendrickson markmhendrickson added bug Functionality broken bug-p2 Critical functionality broken for few users, with no clear workarounds and removed area:accounts labels Jan 25, 2024
@markmhendrickson markmhendrickson added this to the Fix urgent bugs milestone Jan 25, 2024
@edgarkhanzadian edgarkhanzadian self-assigned this Feb 1, 2024
@edgarkhanzadian
Copy link
Contributor

Gamma.io doesn't seem to require a specific account index on sign in:

testgamma.mov

cc @314159265359879

@314159265359879
Copy link
Contributor Author

with bitcoin it will sign in with the account that is active in the extension when you click connect. Then a user can switch in the extension and be surprised the transactions are being signed by a different address then expected. @edgarkhanzadian

Related stuff also due to reaching API limits
image

The same name can be displayed with different account numbers.

The active account (what ever is shown in the extension modal) is displayed in the top of the popup to sign. But what should be shown is the account the dapp is connected with. And that should be the only account that can be signed with (as is the case with Stacks network).

@markmhendrickson
Copy link
Collaborator

@314159265359879 does this fix require an API implementation change on the app side, or is it wallet side purely?

@markmhendrickson
Copy link
Collaborator

Ping @314159265359879

@314159265359879
Copy link
Contributor Author

@markmhendrickson This is partially wallet side, when it comes to the visual issue #4859 (comment) possibly fixed with #4923

However I believe that bitcoin issue (title) requires API implementation changes to prevent. It could be covered by the modern wallet API SIP if this is scoped in stacksgov/sips#166 (comment)

@pete-watters
Copy link
Contributor

@314159265359879 is this still causing a problem or has it been fixed by #4923 ?

@314159265359879
Copy link
Contributor Author

314159265359879 commented Jul 1, 2024

@pete-watters After a recent redesign you can nolonger see the account number/name on the approve transaction screen. So you can only know if you're signing with the right account after confirming.

The transaction is not signed. When I am signed in on Gamma with Account 1, and have Account 2 active in the extension. This is not fixed. The result is just different now.

(current) Reproduction steps
0. Switch extension to account 1

  1. Sign in to gamma.io (you will sign in with the active account = account 1)

  2. Then on the leather extension switch to account 2

  3. Try to buy an ordinal or create an inscription: for example one of these https://gamma.io/prints/c5528f39379cbaa6380a38c129c2788d4ca97259f15ddf27e6b0bc3a4568a569i0?tab=presale

  4. See this popup (without an account number or name)
    image

  5. Click confirm and see
    image

I propose the following solutions:
0. short-term fix, let the user sign with the signed in account rather than the active account?

  1. Warn users when they're not signed in on the right account, this likely requires additional API's: Missing listener: onAccountChanged #4891, Whenever there is a difference between the active account (on Leather extension) compared to what they are signed in with on the dapp, warn the user and ask for their intent (did they mean to sign with account 1 or account 2, then let them switch to it).

  2. Let users choose an account when they connect to a bitcoin dapp (as we have with Stacks connections): Add option to switch accounts on requestAddresses screen #4182

  3. Show the account name/number + addresses and balances on every screen especially on the approval screen because then users can identify if they're on the account intended. @mica000 @fabric-8

@markmhendrickson
Copy link
Collaborator

markmhendrickson commented Jul 1, 2024

Show the account name/number + addresses and balances on every screen especially on the approval screen because then users can identify if they're on the account intended.

Let's implement this suggestion as a quick fix of sorts, reverting to the app nav's display of the account used for signing?

@markmhendrickson
Copy link
Collaborator

  1. short-term fix, let the user sign with the signed in account rather than the active account?

As far as this solution, we already provide it. However, the app needs to indicate the "signed in account" while triggering API calls for signing transactions, and it seems Gamma isn't doing this. So we'd need them to upgrade their implementation to use that parameter?

@markmhendrickson markmhendrickson changed the title Bitcoin transactions sometimes signed by different account then expected or poor error handling Display account in app nav whenever signing via API Jul 1, 2024
@markmhendrickson markmhendrickson added enhancement-p1 Critical functionality needed by many users, with no clear alternatives enhancement area:api and removed bug Functionality broken bug-p2 Critical functionality broken for few users, with no clear workarounds labels Jul 1, 2024
@pete-watters pete-watters self-assigned this Jul 3, 2024
@pete-watters
Copy link
Contributor

I linked this bug as it relates to the same thing.

I will make a change so that instead of showing the logo on these screens we show the users account

@314159265359879
Copy link
Contributor Author

I noticed the same issue on Luminex.io when signing a runes transfer transaction. Connected with account 1 on the dapp. Switched extension to account 2. And the transaction gets rejected on device. After switching back to account 1 I was able to sign the transfer transaction normally.

@314159265359879
Copy link
Contributor Author

  1. short-term fix, let the user sign with the signed in account rather than the active account?

As far as this solution, we already provide it. However, the app needs to indicate the "signed in account" while triggering API calls for signing transactions, and it seems Gamma isn't doing this. So we'd need them to upgrade their implementation to use that parameter?

@markmhendrickson want to add a link to docs where devs can read more about how to resolve this issue?

@markmhendrickson
Copy link
Collaborator

See https://leather.gitbook.io/developers/methods/getaddresses#accounts

@pete-watters
Copy link
Contributor

I've made a small change here so that instead of showing the logo on the sign PSBT screen we show the users account and allow them to change the account.

We are still just showing the logo on the initial message signing screen:
Screenshot 2024-07-10 at 06 22 44

Do I need to update that also? When implementing the global header, it was unclear how some headers should display so I may have made more mistakes. I believe it a good idea to audit these when working on approval UX

@markmhendrickson
Copy link
Collaborator

Do I need to update that also?

Yep! Let's update there, too 🙏 The general idea is that we should show the account in the top nav wherever the user is signing something (transaction or message).

@markmhendrickson
Copy link
Collaborator

@fabric-8 @mica000 could one of you review the previous comment that @pete-watters links here (#4371 (comment)) in case there requires any further design input on how the header details work?

@pete-watters
Copy link
Contributor

pete-watters commented Jul 10, 2024

@fabric-8 @mica000 could one of you review the previous comment that @pete-watters links here (#4371 (comment)) in case there requires any further design input on how the header details work?

Thanks @markmhendrickson . That comment is a bit outdated now so I will gather some info on the current state of things so we can review it. I've updated my PR so that it handles the first signing step also. I have started looking into moving the Test App into CodeSandbox so I think that could help here. Then we will be able to test things more easily.

My code works by configuring the Header to show items based on the RouteUrl.

Before we were showing account info only on:

  • RouteUrls.TransactionRequest: /transaction
  • RouteUrls.ProfileUpdateRequest: /update-profile
  • RouteUrls.RpcSendTransfer: /send-transfer

I have updated it to also include:

  • RouteUrls.RpcSignPsbt: /sign-psbt(That's the APPROVE TRANSACTION popup first reported here)
  • RouteUrls.RpcSignBip322Message: /sign-bip322-message (That's the SIGN MESSAGE popup I later mentioned)

There are other places I'm not sure if we need to show it, for example on the summary / choose fee pages:

  • RouteUrls.RpcSignPsbtSummary: /sign-psbt/summary
  • RouteUrls.RpcSendTransferChooseFee: /send-transfer/choose-fee
  • RouteUrls.RpcSendTransferConfirmation: /send-transfer/confirmation
  • RouteUrls.RpcStacksSignature: /sign-stacks-message
  • RouteUrls.SignatureRequest: /signature
  • RouteUrls.RpcSendTransferSummary: /send-transfer/summary

@markmhendrickson
Copy link
Collaborator

markmhendrickson commented Jul 10, 2024

There are other places I'm not sure if we need to show it, for example on the summary / choose fee pages:

Based on the route names, these six routes appear to pertain to screens during transaction or message-signing flows. So yes, let's show the account in the nav there, too.

The one exception may be the choose-fee route, since perhaps the nav should just say "Edit fee" or similar with back option.

@markmhendrickson
Copy link
Collaborator

These may be a good opportunity to ensure all of these relevant routes / views are included in our views database. If you could include a screenshot of each per entry, that'd help evaluate them.

@pete-watters
Copy link
Contributor

These may be a good opportunity to ensure all of these relevant routes / views are included in our views database. If you could include a screenshot of each per entry, that'd help evaluate them.

Yes I think that's a good idea. I'll work on gathering that info and documenting it as I go. We have about 16 popup routes so it seems like we want to show that account info more often than not. I'll do an audit and take notes and we can decide on it.

@pete-watters
Copy link
Contributor

@markmhendrickson - FYI I merged my code that updates the header for sign-psbt and sign-bip322-message.

I will audit the others but I opened a separate task for that here https://github.com/leather-io/issues/issues/157 .

That way we can get this more urgent improvement out first and fix the others once I have documented and tested them all

kyranjamie pushed a commit that referenced this issue Jul 15, 2024
## [6.43.0](v6.42.2...v6.43.0) (2024-07-15)

### Features

* add Leather to WBIP004 array, closes [#5615](#5615) ([e38f6ab](e38f6ab))
* mock mainnet btc blockstream requests ([16d751c](16d751c))

### Bug Fixes

* choose account prevent bug, closes [#5509](#5509) ([89500a8](89500a8))
* collectible hover, closes [#4971](#4971) ([7728eeb](7728eeb))
* confine clickable area of account switcher to account name and chevron, closes [#5621](#5621) ([472c7e4](472c7e4))
* dust change amounts, closes [#4979](#4979) ([8b40ea7](8b40ea7))
* increase zIndex of tooltip to prevent it being obscured, closes [#5622](#5622) ([a1f86bb](a1f86bb))
* show account name in signPsbt and signBip322 header, ref [#4657](#4657) [#4859](#4859) ([71f2565](71f2565))

### Internal

* add new analytics events ([3f9548e](3f9548e))
* post-release merge back ([c1bbf89](c1bbf89))
* reenable swaps, closes leather-io/issues[#98](#98) ([5faba22](5faba22))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:api area:bitcoin enhancement enhancement-p1 Critical functionality needed by many users, with no clear alternatives
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants