Skip to content

Commit

Permalink
Merge pull request #1134 from Foundation-Devices/invertedx/env-850-rb…
Browse files Browse the repository at this point in the history
…f-boosting-a-transaction-from-a-passport-account-does-not

fix missing confirmation screen in passport RBF
  • Loading branch information
icota committed May 21, 2024
2 parents ccd1ad4 + cc5bd1e commit 8e5a995
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
16 changes: 10 additions & 6 deletions lib/ui/home/cards/accounts/spend/rbf/rbf_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,18 @@ class _TxRBFButtonState extends ConsumerState<TxRBFButton> {
});
}
} catch (e) {
setState(() {
_isLoading = false;
});
if (mounted) {
setState(() {
_isLoading = false;
});
}
kPrint(e);
} finally {
setState(() {
_isLoading = false;
});
if (mounted) {
setState(() {
_isLoading = false;
});
}
}
}

Expand Down
38 changes: 35 additions & 3 deletions lib/ui/home/cards/accounts/spend/rbf/rbf_spend_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class _RBFSpendScreenState extends ConsumerState<RBFSpendScreen> {
bool _warningShown = false;
bool _inputsChanged = false;
RawTransaction? _rawTransaction;
Psbt? finalizedPsbt;

@override
void initState() {
Expand Down Expand Up @@ -179,8 +180,7 @@ class _RBFSpendScreenState extends ConsumerState<RBFSpendScreen> {
Opacity(
opacity: _rebuildingTx ? 0.3 : 1,
child: EnvoyButton(
label: S()
.replaceByFee_coindetails_overlay_modal_heading,
label: getButtonText(context),
state: ButtonState.defaultState,
onTap: !_rebuildingTx
? () => _boostTx(context)
Expand Down Expand Up @@ -566,14 +566,22 @@ class _RBFSpendScreenState extends ConsumerState<RBFSpendScreen> {
if (account.wallet.hot) {
broadcastTx(account, psbt, context);
} else {
if (finalizedPsbt != null) {
broadcastTx(account, psbt, context);
return;
}
await Navigator.of(context, rootNavigator: false).push(MaterialPageRoute(
builder: (context) => background(
child: PsbtCard(
psbt,
account,
onSignedPsbtScanned: (psbt) {
Navigator.pop(context);
broadcastTx(account, psbt, context);
if (mounted) {
setState(() {
finalizedPsbt = psbt;
});
}
},
),
context: context)));
Expand Down Expand Up @@ -967,9 +975,33 @@ class _RBFSpendScreenState extends ConsumerState<RBFSpendScreen> {
),
).show(context);
return;
} else {
if (context.mounted) {
EnvoyToast(
backgroundColor: EnvoyColors.danger,
replaceExisting: true,
duration: const Duration(seconds: 4),
message: "Error: Unable to construct transaction.",
// TODO: Figma
icon: const Icon(
Icons.info_outline,
color: EnvoyColors.solidWhite,
),
).show(context);
}
}
}
}
}
}

String getButtonText(BuildContext context) {
Account? account = ref.read(selectedAccountProvider);
if (account != null && !account.wallet.hot) {
if (finalizedPsbt == null) {
return S().coincontrol_txDetail_cta1_passport;
}
}
return S().replaceByFee_coindetails_overlay_modal_heading;
}
}

0 comments on commit 8e5a995

Please sign in to comment.