Emurgo / yoroi-frontend

Yoroi Wallet - Cardano ADA Wallet - Your gateway to the financial world (extension frontend)
https://yoroi-wallet.com/
MIT License
337 stars 102 forks source link

Add "reorganization transactions" to Yoroi (UI) #64

Closed SebastienGllmt closed 5 years ago

SebastienGllmt commented 6 years ago

Concept Sometimes users make transactions to themselves. It's inappropriate to label this as outgoing or incoming so we need a new category. I suggest reorganization to match the terminology used in the Cardano Wallet Spec.

Motivation for such transactions 1) Sometimes a wallet has a large UTXO that they would want to split into many small UTXO. Doing such makes your payment-to-change ration closer to 1.0 which helps improve privacy on transactions. 1) Sometimes a wallet has a lot of dust they would like to group together 1) Once we have smart contracts in the SL layer, some utxo may be associated with special meaning. You would need to reorganize your UTXO to give special meaning to a UTXO of the right amount. 1) Using a chimeric ledge means you would have to do transactions with yourself to convert between transaction-based and utxo-based models.

This will require a UI change (new icon, new way to display the fees, etc)

The current UI for this is at best misleading and depending on your definition also a bug.

vsubhuman commented 5 years ago

The bug is much more serious than just the UI labelling, unfortunately:

  1. In the case of a reorg tx - its value is calculated all wrong, just because code checks that there are our inputs, but does not check if there are our outputs too, and therefore transaction shows something like -100 even of we got -99 back to the same wallet.
  2. In the same case also wallet does not recognise ALL the outputs to the same wallet (my guess would be because it is hardcoded logic that there's expected to be only one [change] output to the same wallet, and so code stops after first found output like that). It means that if we have transaction from our address A to our addresses B and C - funds on either B or C might get locked out of wallet until next restoration, just because code does not checks if it's ours or not.

We gotta do something similar to how it's solved in our mobile apps with:

  1. Distinct tx types: https://github.com/Emurgo/yoroi-mobile/blob/a3d72218b1e63f6362152aae2f03c8763c168795/src/types/HistoryTransaction.js#L4-L9
  2. Distinct logic on value calculation: https://github.com/Emurgo/yoroi-mobile/blob/a3d72218b1e63f6362152aae2f03c8763c168795/src/crypto/transactionUtils.js#L73-L103