mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
fixes
This commit is contained in:
parent
3fd8430e83
commit
c7dd20fa41
13 changed files with 187 additions and 244 deletions
|
@ -35,7 +35,6 @@ import 'package:cw_core/utils/file.dart';
|
|||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hex/hex.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:rxdart/subjects.dart';
|
||||
|
@ -623,16 +622,9 @@ abstract class ElectrumWalletBase
|
|||
final ins = <bitcoin_base.BtcTransaction>[];
|
||||
|
||||
for (final vin in original.inputs) {
|
||||
try {
|
||||
final id = HEX.encode(HEX.decode(vin.txId).reversed.toList());
|
||||
final txHex = await electrumClient.getTransactionHex(hash: id);
|
||||
final tx = bitcoin_base.BtcTransaction.fromRaw(txHex);
|
||||
ins.add(tx);
|
||||
} catch (_) {
|
||||
ins.add(bitcoin_base.BtcTransaction.fromRaw(
|
||||
await electrumClient.getTransactionHex(hash: vin.txId),
|
||||
));
|
||||
}
|
||||
final txHex = await electrumClient.getTransactionHex(hash: vin.txId);
|
||||
final tx = bitcoin_base.BtcTransaction.fromRaw(txHex);
|
||||
ins.add(tx);
|
||||
}
|
||||
|
||||
return ElectrumTransactionBundle(original,
|
||||
|
@ -913,4 +905,4 @@ BitcoinAddressType _getScriptType(BitcoinBaseAddress type) {
|
|||
} else {
|
||||
return SegwitAddresType.p2wpkh;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ import 'package:cake_wallet/core/yat_service.dart';
|
|||
import 'package:cake_wallet/entities/background_tasks.dart';
|
||||
import 'package:cake_wallet/entities/exchange_api_mode.dart';
|
||||
import 'package:cake_wallet/entities/parse_address_from_domain.dart';
|
||||
import 'package:cake_wallet/view_model/LightningSendViewModel.dart';
|
||||
import 'package:cake_wallet/view_model/lightning_send_view_model.dart';
|
||||
import 'package:cw_core/receive_page_option.dart';
|
||||
import 'package:cake_wallet/ethereum/ethereum.dart';
|
||||
import 'package:cake_wallet/lightning/lightning.dart';
|
||||
|
|
|
@ -29,18 +29,22 @@ Future<void> startFiatRateUpdate(
|
|||
|
||||
if (appStore.wallet!.type == WalletType.haven) {
|
||||
await updateHavenRate(fiatConversionStore);
|
||||
return;
|
||||
}
|
||||
|
||||
Iterable<CryptoCurrency>? currencies = [];
|
||||
switch (appStore.wallet!.type) {
|
||||
case WalletType.ethereum:
|
||||
currencies = ethereum!.getERC20Currencies(appStore.wallet!).where((element) => element.enabled);
|
||||
currencies =
|
||||
ethereum!.getERC20Currencies(appStore.wallet!).where((element) => element.enabled);
|
||||
break;
|
||||
case WalletType.polygon:
|
||||
currencies = polygon!.getERC20Currencies(appStore.wallet!).where((element) => element.enabled);
|
||||
currencies =
|
||||
polygon!.getERC20Currencies(appStore.wallet!).where((element) => element.enabled);
|
||||
break;
|
||||
case WalletType.solana:
|
||||
currencies = solana!.getSPLTokenCurrencies(appStore.wallet!).where((element) => element.enabled);
|
||||
currencies =
|
||||
solana!.getSPLTokenCurrencies(appStore.wallet!).where((element) => element.enabled);
|
||||
break;
|
||||
case WalletType.lightning:
|
||||
currencies = [CryptoCurrency.btc];
|
||||
|
|
|
@ -24,22 +24,17 @@ import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
|||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
|
||||
|
||||
void showInformation(
|
||||
ExchangeTradeViewModel exchangeTradeViewModel, BuildContext context) {
|
||||
void showInformation(ExchangeTradeViewModel exchangeTradeViewModel, BuildContext context) {
|
||||
final trade = exchangeTradeViewModel.trade;
|
||||
final walletName = exchangeTradeViewModel.wallet.name;
|
||||
|
||||
final information = exchangeTradeViewModel.isSendable
|
||||
? S.current.exchange_result_confirm(
|
||||
trade.amount, trade.from.toString(), walletName) +
|
||||
exchangeTradeViewModel.extraInfo
|
||||
: S.current.exchange_result_description(
|
||||
trade.amount, trade.from.toString()) +
|
||||
exchangeTradeViewModel.extraInfo;
|
||||
? S.current.exchange_result_confirm(trade.amount, trade.from.toString(), walletName) +
|
||||
exchangeTradeViewModel.extraInfo
|
||||
: S.current.exchange_result_description(trade.amount, trade.from.toString()) +
|
||||
exchangeTradeViewModel.extraInfo;
|
||||
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (_) => InformationPage(information: information));
|
||||
showPopUp<void>(context: context, builder: (_) => InformationPage(information: information));
|
||||
}
|
||||
|
||||
class ExchangeTradePage extends BasePage {
|
||||
|
@ -72,8 +67,7 @@ class ExchangeTradePage extends BasePage {
|
|||
}
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) =>
|
||||
ExchangeTradeForm(exchangeTradeViewModel);
|
||||
Widget body(BuildContext context) => ExchangeTradeForm(exchangeTradeViewModel);
|
||||
}
|
||||
|
||||
class ExchangeTradeForm extends StatefulWidget {
|
||||
|
@ -138,7 +132,9 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
|
||||
color: Theme.of(context)
|
||||
.extension<TransactionTradeTheme>()!
|
||||
.detailsTitlesColor),
|
||||
),
|
||||
if (trade.expiredAt != null)
|
||||
TimerWidget(trade.expiredAt!,
|
||||
|
@ -159,10 +155,13 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
width: 3,
|
||||
color: Theme.of(context).extension<ExchangePageTheme>()!.qrCodeColor
|
||||
)
|
||||
color: Theme.of(context)
|
||||
.extension<ExchangePageTheme>()!
|
||||
.qrCodeColor)),
|
||||
child: QrImage(
|
||||
data: trade.inputAddress ?? fetchingLabel,
|
||||
version: 14,
|
||||
),
|
||||
child: QrImage(data: trade.inputAddress ?? fetchingLabel),
|
||||
)))),
|
||||
Spacer(flex: 3)
|
||||
]),
|
||||
|
@ -192,10 +191,8 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
? Builder(
|
||||
builder: (context) => GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(text: value));
|
||||
showBar<void>(context,
|
||||
S.of(context).copied_to_clipboard);
|
||||
Clipboard.setData(ClipboardData(text: value));
|
||||
showBar<void>(context, S.of(context).copied_to_clipboard);
|
||||
},
|
||||
child: content,
|
||||
))
|
||||
|
@ -209,17 +206,14 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
bottomSectionPadding: EdgeInsets.fromLTRB(24, 0, 24, 24),
|
||||
bottomSection: Observer(builder: (_) {
|
||||
final trade = widget.exchangeTradeViewModel.trade;
|
||||
final sendingState =
|
||||
widget.exchangeTradeViewModel.sendViewModel.state;
|
||||
final sendingState = widget.exchangeTradeViewModel.sendViewModel.state;
|
||||
|
||||
return widget.exchangeTradeViewModel.isSendable &&
|
||||
!(sendingState is TransactionCommitted)
|
||||
? LoadingPrimaryButton(
|
||||
isDisabled: trade.inputAddress == null ||
|
||||
trade.inputAddress!.isEmpty,
|
||||
isDisabled: trade.inputAddress == null || trade.inputAddress!.isEmpty,
|
||||
isLoading: sendingState is IsExecutingState,
|
||||
onPressed: () =>
|
||||
widget.exchangeTradeViewModel.confirmSending(),
|
||||
onPressed: () => widget.exchangeTradeViewModel.confirmSending(),
|
||||
text: S.of(context).confirm,
|
||||
color: Theme.of(context).primaryColor,
|
||||
textColor: Colors.white)
|
||||
|
@ -257,26 +251,24 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
return ConfirmSendingAlert(
|
||||
alertTitle: S.of(popupContext).confirm_sending,
|
||||
amount: S.of(popupContext).send_amount,
|
||||
amountValue: widget.exchangeTradeViewModel.sendViewModel
|
||||
.pendingTransaction!.amountFormatted,
|
||||
amountValue: widget
|
||||
.exchangeTradeViewModel.sendViewModel.pendingTransaction!.amountFormatted,
|
||||
fee: S.of(popupContext).send_fee,
|
||||
feeValue: widget.exchangeTradeViewModel.sendViewModel
|
||||
.pendingTransaction!.feeFormatted,
|
||||
feeValue: widget
|
||||
.exchangeTradeViewModel.sendViewModel.pendingTransaction!.feeFormatted,
|
||||
rightButtonText: S.of(popupContext).send,
|
||||
leftButtonText: S.of(popupContext).cancel,
|
||||
actionRightButton: () async {
|
||||
Navigator.of(popupContext).pop();
|
||||
await widget.exchangeTradeViewModel.sendViewModel
|
||||
.commitTransaction();
|
||||
await widget.exchangeTradeViewModel.sendViewModel.commitTransaction();
|
||||
transactionStatePopup();
|
||||
},
|
||||
actionLeftButton: () => Navigator.of(popupContext).pop(),
|
||||
feeFiatAmount: widget.exchangeTradeViewModel
|
||||
.pendingTransactionFeeFiatAmountFormatted,
|
||||
fiatAmountValue: widget.exchangeTradeViewModel
|
||||
.pendingTransactionFiatAmountValueFormatted,
|
||||
outputs: widget.exchangeTradeViewModel.sendViewModel
|
||||
.outputs);
|
||||
feeFiatAmount:
|
||||
widget.exchangeTradeViewModel.pendingTransactionFeeFiatAmountFormatted,
|
||||
fiatAmountValue:
|
||||
widget.exchangeTradeViewModel.pendingTransactionFiatAmountValueFormatted,
|
||||
outputs: widget.exchangeTradeViewModel.sendViewModel.outputs);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -304,85 +296,26 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
void transactionStatePopup() {
|
||||
if (this.mounted) {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext popupContext) {
|
||||
return Observer(builder: (_) {
|
||||
final state = widget
|
||||
.exchangeTradeViewModel.sendViewModel.state;
|
||||
context: context,
|
||||
builder: (BuildContext popupContext) {
|
||||
return Observer(builder: (_) {
|
||||
final state = widget.exchangeTradeViewModel.sendViewModel.state;
|
||||
|
||||
if (state is TransactionCommitted) {
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Theme.of(popupContext).colorScheme.background,
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/images/birthday_cake.png'),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: 220, left: 24, right: 24),
|
||||
child: Text(
|
||||
S.of(popupContext).send_success(widget
|
||||
.exchangeTradeViewModel
|
||||
.wallet
|
||||
.currency
|
||||
.toString()),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(popupContext).extension<CakeTextTheme>()!.titleColor,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
if (state is TransactionCommitted) {
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Theme.of(popupContext).colorScheme.background,
|
||||
child: Center(
|
||||
child: Image.asset('assets/images/birthday_cake.png'),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 24,
|
||||
right: 24,
|
||||
bottom: 24,
|
||||
child: PrimaryButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
popupContext,
|
||||
Routes.dashboard,
|
||||
(route) => false,
|
||||
);
|
||||
RequestReviewHandler.requestReview();
|
||||
},
|
||||
text: S.of(popupContext).got_it,
|
||||
color: Theme.of(popupContext).primaryColor,
|
||||
textColor: Colors.white))
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Theme.of(popupContext).colorScheme.background,
|
||||
child: Center(
|
||||
child: Image.asset(
|
||||
'assets/images/birthday_cake.png'),
|
||||
),
|
||||
),
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(
|
||||
sigmaX: 3.0, sigmaY: 3.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(popupContext)
|
||||
.colorScheme
|
||||
.background
|
||||
.withOpacity(0.25)),
|
||||
child: Center(
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 220),
|
||||
padding: EdgeInsets.only(top: 220, left: 24, right: 24),
|
||||
child: Text(
|
||||
S.of(popupContext).send_sending,
|
||||
S.of(popupContext).send_success(
|
||||
widget.exchangeTradeViewModel.wallet.currency.toString()),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
|
@ -393,12 +326,60 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
|
|||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 24,
|
||||
right: 24,
|
||||
bottom: 24,
|
||||
child: PrimaryButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamedAndRemoveUntil(
|
||||
popupContext,
|
||||
Routes.dashboard,
|
||||
(route) => false,
|
||||
);
|
||||
RequestReviewHandler.requestReview();
|
||||
},
|
||||
text: S.of(popupContext).got_it,
|
||||
color: Theme.of(popupContext).primaryColor,
|
||||
textColor: Colors.white))
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
return Stack(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
color: Theme.of(popupContext).colorScheme.background,
|
||||
child: Center(
|
||||
child: Image.asset('assets/images/birthday_cake.png'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(popupContext).colorScheme.background.withOpacity(0.25)),
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 220),
|
||||
child: Text(
|
||||
S.of(popupContext).send_sending,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(popupContext).extension<CakeTextTheme>()!.titleColor,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:cake_wallet/lightning/lightning.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/lightning_input_form.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions_content_override.dart';
|
||||
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/exchange_page_theme.dart';
|
||||
|
@ -242,9 +243,10 @@ class LightningInvoicePage extends BasePage {
|
|||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithTwoActionsContentOverride(
|
||||
return AlertWithTwoActions(
|
||||
alertTitle: S.of(context).invoice_created,
|
||||
alertContent: Column(
|
||||
alertContent: '',
|
||||
contentWidget: Column(
|
||||
children: [
|
||||
Center(
|
||||
child: AspectRatio(
|
||||
|
|
|
@ -23,8 +23,7 @@ class QrImage extends StatelessWidget {
|
|||
return qr.QrImageView(
|
||||
data: data,
|
||||
errorCorrectionLevel: errorCorrectionLevel,
|
||||
// Previous value: 7 something happened after flutter upgrade monero wallets addresses are longer than ver. 7 ???
|
||||
version: 14,// previously 9, but btc lightning addresses are /really/ long
|
||||
version: 9,// Previous value: 7 something happened after flutter upgrade monero wallets addresses are longer than ver. 7 ???
|
||||
size: size,
|
||||
foregroundColor: foregroundColor,
|
||||
backgroundColor: backgroundColor,
|
||||
|
|
|
@ -11,7 +11,7 @@ import 'package:cake_wallet/themes/extensions/keyboard_theme.dart';
|
|||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cake_wallet/view_model/LightningSendViewModel.dart';
|
||||
import 'package:cake_wallet/view_model/lightning_send_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/lightning_view_model.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -250,24 +250,10 @@ class LightningSendConfirmPage extends BasePage {
|
|||
text: S.of(context).send,
|
||||
onPressed: () async {
|
||||
try {
|
||||
final sdk = await BreezSDK();
|
||||
late BZG.SendPaymentRequest req;
|
||||
|
||||
lightningSendViewModel.setLoading(true);
|
||||
|
||||
if (invoice.amountMsat == null) {
|
||||
req = BZG.SendPaymentRequest(
|
||||
bolt11: invoice.bolt11,
|
||||
amountMsat: int.parse(_amountController.text) * 1000,
|
||||
);
|
||||
} else {
|
||||
req = BZG.SendPaymentRequest(bolt11: invoice.bolt11);
|
||||
}
|
||||
|
||||
await sdk.sendPayment(req: req);
|
||||
|
||||
lightningSendViewModel.setLoading(false);
|
||||
|
||||
await lightningSendViewModel.send(
|
||||
invoice,
|
||||
int.parse(_amountController.text)
|
||||
);
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
|
@ -281,7 +267,6 @@ class LightningSendConfirmPage extends BasePage {
|
|||
});
|
||||
});
|
||||
} catch (e) {
|
||||
lightningSendViewModel.setLoading(false);
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
|
|
|
@ -11,8 +11,7 @@ import 'package:cake_wallet/themes/theme_base.dart';
|
|||
import 'package:cake_wallet/utils/payment_request.dart';
|
||||
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cake_wallet/view_model/LightningSendViewModel.dart';
|
||||
import 'package:cake_wallet/view_model/lightning_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/lightning_send_view_model.dart';
|
||||
import 'package:cake_wallet/view_model/send/output.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -35,7 +34,6 @@ class LightningSendPage extends BasePage {
|
|||
final AuthService authService;
|
||||
final LightningSendViewModel lightningSendViewModel;
|
||||
final GlobalKey<FormState> _formKey;
|
||||
final controller = PageController(initialPage: 0);
|
||||
|
||||
final bolt11Controller = TextEditingController();
|
||||
final bolt11FocusNode = FocusNode();
|
||||
|
@ -206,7 +204,7 @@ class LightningSendPage extends BasePage {
|
|||
|
||||
Future<void> send(BuildContext context) async {
|
||||
try {
|
||||
await processInput(context);
|
||||
await lightningSendViewModel.processInput(context, bolt11Controller.text);
|
||||
} catch (e) {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
|
@ -225,29 +223,6 @@ class LightningSendPage extends BasePage {
|
|||
return false;
|
||||
}
|
||||
|
||||
Future<void> processInput(BuildContext context) async {
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
final sdk = await BreezSDK();
|
||||
|
||||
late InputType inputType;
|
||||
|
||||
try {
|
||||
inputType = await sdk.parseInput(input: bolt11Controller.text);
|
||||
} catch (_) {
|
||||
throw Exception("Unknown input type");
|
||||
}
|
||||
|
||||
if (inputType is InputType_Bolt11) {
|
||||
final bolt11 = await sdk.parseInvoice(bolt11Controller.text);
|
||||
Navigator.of(context).pushNamed(Routes.lightningSendConfirm, arguments: bolt11);
|
||||
} else if (inputType is InputType_LnUrlPay) {
|
||||
throw Exception("Unsupported input type");
|
||||
} else {
|
||||
throw Exception("Unknown input type");
|
||||
}
|
||||
}
|
||||
|
||||
void _setEffects(BuildContext context) {
|
||||
if (_effectsInstalled) {
|
||||
return;
|
||||
|
|
|
@ -10,6 +10,7 @@ class AlertWithTwoActions extends BaseAlertDialog {
|
|||
required this.rightButtonText,
|
||||
required this.actionLeftButton,
|
||||
required this.actionRightButton,
|
||||
this.contentWidget,
|
||||
this.alertBarrierDismissible = true,
|
||||
this.isDividerExist = false,
|
||||
// this.leftActionColor,
|
||||
|
@ -20,6 +21,7 @@ class AlertWithTwoActions extends BaseAlertDialog {
|
|||
final String alertContent;
|
||||
final String leftButtonText;
|
||||
final String rightButtonText;
|
||||
final Widget? contentWidget;
|
||||
final VoidCallback actionLeftButton;
|
||||
final VoidCallback actionRightButton;
|
||||
final bool alertBarrierDismissible;
|
||||
|
@ -47,4 +49,9 @@ class AlertWithTwoActions extends BaseAlertDialog {
|
|||
// Color get rightButtonColor => rightActionColor;
|
||||
@override
|
||||
bool get isDividerExists => isDividerExist;
|
||||
|
||||
@override
|
||||
Widget content(BuildContext context) {
|
||||
return contentWidget ?? super.content(context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
import 'dart:ui';
|
||||
import 'package:cake_wallet/src/widgets/base_alert_dialog.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class AlertWithTwoActionsContentOverride extends BaseAlertDialog {
|
||||
AlertWithTwoActionsContentOverride({
|
||||
required this.alertTitle,
|
||||
required this.alertContent,
|
||||
required this.leftButtonText,
|
||||
required this.rightButtonText,
|
||||
required this.actionLeftButton,
|
||||
required this.actionRightButton,
|
||||
this.alertBarrierDismissible = true,
|
||||
this.isDividerExist = false,
|
||||
});
|
||||
|
||||
final String alertTitle;
|
||||
final Widget alertContent;
|
||||
final String leftButtonText;
|
||||
final String rightButtonText;
|
||||
final VoidCallback actionLeftButton;
|
||||
final VoidCallback actionRightButton;
|
||||
final bool alertBarrierDismissible;
|
||||
// final Color leftActionColor;
|
||||
// final Color rightActionColor;
|
||||
final bool isDividerExist;
|
||||
|
||||
@override
|
||||
String get titleText => alertTitle;
|
||||
@override
|
||||
String get leftActionButtonText => leftButtonText;
|
||||
@override
|
||||
String get rightActionButtonText => rightButtonText;
|
||||
@override
|
||||
VoidCallback get actionLeft => actionLeftButton;
|
||||
@override
|
||||
VoidCallback get actionRight => actionRightButton;
|
||||
@override
|
||||
bool get barrierDismissible => alertBarrierDismissible;
|
||||
|
||||
@override
|
||||
Widget content(BuildContext context) {
|
||||
return alertContent;
|
||||
}
|
||||
|
||||
@override
|
||||
bool get isDividerExists => isDividerExist;
|
||||
}
|
|
@ -74,6 +74,8 @@ class TransactionListItem extends ActionListItem with Keyable {
|
|||
price: price);
|
||||
break;
|
||||
case WalletType.bitcoin:
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
amount = calculateFiatAmountRaw(
|
||||
cryptoAmount: bitcoin!.formatterBitcoinAmountToDouble(amount: transaction.amount),
|
||||
price: price);
|
||||
|
@ -83,12 +85,6 @@ class TransactionListItem extends ActionListItem with Keyable {
|
|||
cryptoAmount: lightning!.formatterLightningAmountToDouble(amount: transaction.amount),
|
||||
price: price);
|
||||
break;
|
||||
case WalletType.litecoin:
|
||||
case WalletType.bitcoinCash:
|
||||
amount = calculateFiatAmountRaw(
|
||||
cryptoAmount: bitcoin!.formatterBitcoinAmountToDouble(amount: transaction.amount),
|
||||
price: price);
|
||||
break;
|
||||
case WalletType.haven:
|
||||
final asset = haven!.assetOfTransaction(transaction);
|
||||
final price = balanceViewModel.fiatConvertationStore.prices[asset];
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
import 'dart:async';
|
||||
import 'package:breez_sdk/breez_sdk.dart';
|
||||
import 'package:breez_sdk/bridge_generated.dart' as BZG;
|
||||
import 'package:breez_sdk/bridge_generated.dart';
|
||||
import 'package:cake_wallet/entities/calculate_fiat_amount_raw.dart';
|
||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
import 'package:cake_wallet/lightning/lightning.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'lightning_send_view_model.g.dart';
|
||||
|
@ -21,7 +26,7 @@ abstract class LightningSendViewModelBase with Store {
|
|||
|
||||
final SettingsStore settingsStore;
|
||||
final FiatConversionStore fiatConversionStore;
|
||||
|
||||
|
||||
@observable
|
||||
bool loading = false;
|
||||
|
||||
|
@ -40,4 +45,52 @@ abstract class LightningSendViewModelBase with Store {
|
|||
return amount;
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> send(BZG.LNInvoice invoice, int satAmount) async {
|
||||
try {
|
||||
setLoading(true);
|
||||
|
||||
final sdk = await BreezSDK();
|
||||
late BZG.SendPaymentRequest req;
|
||||
|
||||
if (invoice.amountMsat == null) {
|
||||
req = BZG.SendPaymentRequest(
|
||||
bolt11: invoice.bolt11,
|
||||
amountMsat: satAmount * 1000,
|
||||
);
|
||||
} else {
|
||||
req = BZG.SendPaymentRequest(bolt11: invoice.bolt11);
|
||||
}
|
||||
|
||||
await sdk.sendPayment(req: req);
|
||||
|
||||
setLoading(false);
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
Future<void> processInput(BuildContext context, String input) async {
|
||||
FocusScope.of(context).unfocus();
|
||||
|
||||
final sdk = await BreezSDK();
|
||||
|
||||
late InputType inputType;
|
||||
|
||||
try {
|
||||
inputType = await sdk.parseInput(input: input);
|
||||
} catch (_) {
|
||||
throw Exception("Unknown input type");
|
||||
}
|
||||
|
||||
if (inputType is InputType_Bolt11) {
|
||||
final bolt11 = await sdk.parseInvoice(input);
|
||||
Navigator.of(context).pushNamed(Routes.lightningSendConfirm, arguments: bolt11);
|
||||
} else if (inputType is InputType_LnUrlPay) {
|
||||
throw Exception("Unsupported input type");
|
||||
} else {
|
||||
throw Exception("Unknown input type");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/lightning/lightning.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
|
||||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
|
@ -63,8 +62,6 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
|||
return monero!.formatterMoneroAmountToString(amount: fullBalance);
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(wallet.type))
|
||||
return bitcoin!.formatterBitcoinAmountToString(amount: fullBalance);
|
||||
if (wallet.type == WalletType.lightning)
|
||||
return lightning!.formatterLightningAmountToString(amount: fullBalance);
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -72,7 +69,7 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
|||
if (wallet.type == WalletType.monero) {
|
||||
await monero!.updateUnspents(wallet);
|
||||
}
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash, WalletType.lightning]
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash]
|
||||
.contains(wallet.type)) {
|
||||
await bitcoin!.updateUnspents(wallet);
|
||||
}
|
||||
|
@ -82,7 +79,7 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
|||
|
||||
List<Unspent> _getUnspents() {
|
||||
if (wallet.type == WalletType.monero) return monero!.getUnspents(wallet);
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash, WalletType.lightning]
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash]
|
||||
.contains(wallet.type)) return bitcoin!.getUnspents(wallet);
|
||||
return List.empty();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue