Skip to content

Commit 23b8ae7

Browse files
committed
fix(open_crypto_pay): verify transaction amount matches quote
1 parent ed27bf7 commit 23b8ae7

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/pages/open_crypto_pay/open_crypto_pay_confirm_view.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ class _OpenCryptoPayConfirmViewState
168168
return null;
169169
}
170170

171+
bool _matchesQuotedAmount(Decimal amount) {
172+
final quotedAmount = Decimal.tryParse(widget.selectedAsset.amount);
173+
return quotedAmount != null && amount.compareTo(quotedAmount) == 0;
174+
}
175+
171176
Future<EthTokenWallet> _loadTokenWallet(EthContract contract) async {
172177
final wallet = ref.read(pWallets).getWallet(widget.walletId);
173178
if (wallet is! EthereumWallet) {
@@ -275,6 +280,10 @@ class _OpenCryptoPayConfirmViewState
275280
_warn("Could not parse payment amount");
276281
return;
277282
}
283+
if (!_matchesQuotedAmount(parsed.amount!)) {
284+
_warn("Payment amount does not match the quoted amount");
285+
return;
286+
}
278287
if (parsed.scheme != null &&
279288
parsed.scheme!.isNotEmpty &&
280289
parsed.scheme != widget.coin.uriScheme) {
@@ -354,6 +363,11 @@ class _OpenCryptoPayConfirmViewState
354363
}
355364

356365
final amount = evmUri.amount(fractionDigits: contract.decimals);
366+
if (!_matchesQuotedAmount(amount)) {
367+
_warn("Payment amount does not match the quoted amount");
368+
return;
369+
}
370+
357371
final autoFillData = SendViewAutoFillData(
358372
address: evmUri.recipientAddress!,
359373
contactLabel: recipient,

0 commit comments

Comments
 (0)