SatoshiPortal / bullbitcoin-mobile

The Bull Bitcoin Mobile Wallet and Exchange App
MIT License
62 stars 24 forks source link

Wallet selection logic for SEND BITCOIN #247

Open BullishNode opened 6 months ago

BullishNode commented 6 months ago

FOR SEND BITCOIN

Destination is Bitcoin address

  1. Check if Secure Bitcoin Wallet has enough balance
  2. Check if another Bitcoin wallet has enough balance
  3. If more than one secondary Bitcoin wallet has enough balance, choose whichever has the highest balance
  4. Check if a fiat account has enough balance (Buy Bitcoin Order)
  5. If more than one fiat account has enough balance, choose whichever is preferred currency
  6. Check if Instant Payments Wallet has enough balance (L-BTC -> BTC swap)
  7. If nothing has enough balance, return error message

Destination is Lightning

  1. Check if Instant Payment Wallet has enough balance
  2. Check if a fiat account has enough balance (Buy Bitcoin Order)
  3. If more than one fiat account has enough balance, choose whichever is preferred currency
  4. Check if Secure Bitcoin Wallet has enough balance (BTC -> LN swap)
  5. Check if another Bitcoin wallet has enough balance
  6. If more than one secondary Bitcoin wallet has enough balance, choose whichever has the highest balance
  7. If nothing has enough balance, return error message

Destination is Liquid

  1. Check if Instant Payment Wallet has enough balance
  2. Check if a fiat account has enough balance (Buy Bitcoin Order)
  3. If more than one fiat account has enough balance, choose whichever is preferred currency
  4. Check if Secure Bitcoin Wallet has enough balance (BTC -> L-BTC swap)
  5. Check if another Bitcoin wallet has enough balance
  6. If more than one secondary Bitcoin wallet has enough balance, choose whichever has the highest balance
  7. If nothing has enough balance, return error message

Destination is either Bitcoin or Lightning

  1. Check if BIP21 contains a Bolt 11
  2. If contains a Bolt 11 invoice, check if Instant Payment Wallet has enough balance
  3. If Instant Payment Wallet does not have enough balance
  4. Check if a fiat account has enough balance
  5. If fiat account has enough balance, use the fiat account for a Lightning transaction
  6. If no fiat account has enough balance, check if Secure Bitcoin Wallet has enough balance
  7. Check if another Bitcoin wallet has enough balance
  8. If no Bitcoin wallet has enough balance, return error message
i5hi commented 1 month ago

Test case:

Both Instant and Secure have similar balance.

Paste an onchain Bitcoin bip21 with an amount higher than what is available in both wallets.

Result:

Instant Wallet is selected and we show, not enough balance. If the amount is updated to a smaller amount within balance, send is still disabled.

Expected:

Secure wallet should be selected and if the amount is changed to something less, Send button should be enabled