SatoshiPortal / bullbitcoin-mobile

The Bull Bitcoin Mobile Wallet and Exchange App
MIT License
54 stars 18 forks source link

[Recieve] Network Selection, Address Generation & Swap Warnings #245

Closed i5hi closed 2 months ago

i5hi commented 2 months ago

Receive requires review and some refactoring as some terminology used is confusing:

enum ReceiveWalletType { secure, lightning }

This naming is a bit confusing.

This makes me think which wallet is being recieved into. Although I think it means which address format we want to display.

We should instead use something like: RecieveAddressFormat which could be { bitcoin, liquid, lightning }

  String getQRStr() {
    if (walletType == ReceiveWalletType.lightning) {
      if (swapBloc.state.swapTx == null) return '';
      return swapBloc.state.swapTx!.invoice;
    }

    if (savedInvoiceAmount > 0 || savedDescription.isNotEmpty) {
      final btcAmt = (savedInvoiceAmount / 100000000).toStringAsFixed(8);

      var invoice = 'bitcoin:' + defaultAddress!.address + '?amount=' + btcAmt;
      if (savedDescription.isNotEmpty) invoice = invoice + '&label=' + savedDescription;

      return invoice;
    }

    return defaultAddress?.address ?? '';
  }

We need to also add a case for liquid where the address used is address.confidential; we are currently using standard addresses.

We should in general review this modules bloc and state and improve the naming conventions so its a bit more clear.

i5hi commented 2 months ago

Address generation logic seems to be buggy.

Everytime receive is clicked, generateNewAddress is run only when the liquid wallet is selected.

Get New Address button is not working.

The entire address generation logic needs a review.

i5hi commented 2 months ago

Network Selection Logic:

We have 3 potential networks that we can receive payments from:

We have 2 potential base wallet types that a payment can be received to:

User can toggle between the 3 potential networks and we must automatically chose the best wallet: A. Bitcoin -> Secure (Standard Bitcoin chain tx) B. Liquid -> Instant (Standard Liquid chain tx) C. Lightning -> Instant (Cheap Swap tx)

Users can override the default choices, but we must issue warnings accordingly.

D. Bitcoin -> Instant (Expensive swap tx) E. Liquid -> Secure (Expensive swap tx) F. Lightning -> Secure (Expensive swap tx)

User cannot swap into Imported, Hardware or Watch-only wallets. Only Secure/Instant.

i5hi commented 2 months ago

Currently we dont allow LBTC-BTC Swaps, so if the user choses this option, for now we just show a warning:

LBTC-BTC swaps are not supported yet

i5hi commented 2 months ago

First warning screen we can work on would be:

First create the swap. Then calculate what % of the transaction will be spent as fees.

Before displaying the Lightning Invoice, issue the following warning if the amount is less than 0.01 BTC

1  Small UTXO swap warning (LN -_ BTC)

If the fee is over 3% of the transaction amount, issue the high fee warning as well.

2  Small UTXO swap + high fee warning (LN -_ BTC)

Note that high fee warning can also happen if amount is over 0.01 BTC, in which case we dont show the small utxo warning, only the high fee warning.

i5hi commented 2 months ago

The button in both cases should say Continue not Confirm Send

i5hi commented 2 months ago

In summary:

A. Completed B. Completed - Pending issue related to address generation C. Pending (LBTC-LN swap) - Issue #246 D. Pending (LBTC-BTC swap) - show currently not supported E. Pending (LBTC-BTC swap) - show currently not supported F. Completed (BTC-LN swap) - show warnings above

i5hi commented 2 months ago

User can toggle between the 3 potential networks and we must automatically chose the best wallet: A. Bitcoin -> Secure (Standard Bitcoin chain tx) B. Liquid -> Instant (Standard Liquid chain tx) C. Lightning -> Instant (Cheap Swap tx)

Users can override the default choices, but we must issue warnings accordingly.

D. Bitcoin -> Instant (Expensive swap tx) E. Liquid -> Secure (Expensive swap tx) F. Lightning -> Secure (Expensive swap tx)

i5hi commented 2 months ago

https://github.com/SatoshiPortal/bullbitcoin-mobile/issues/248