From 34b37d95cdb249f7203d76633640862b009d6561 Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Fri, 19 Apr 2024 09:26:41 -0700 Subject: [PATCH] verify messages working for monero --- cw_monero/lib/api/wallet.dart | 2 +- cw_monero/macos/Classes/monero_api.cpp | 2 +- .../screens/dashboard/widgets/sign_form.dart | 21 +++++++------------ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/cw_monero/lib/api/wallet.dart b/cw_monero/lib/api/wallet.dart index 292dd6e3e..9fb1913aa 100644 --- a/cw_monero/lib/api/wallet.dart +++ b/cw_monero/lib/api/wallet.dart @@ -405,7 +405,7 @@ String signMessage(String message, {String address = ""}) { bool verifyMessage(String message, String address, String signature) { final messagePointer = message.toNativeUtf8(); final addressPointer = address.toNativeUtf8(); - final signaturePointer = address.toNativeUtf8(); + final signaturePointer = signature.toNativeUtf8(); final isVerified = verifyMessageNative(messagePointer, addressPointer, signaturePointer); calloc.free(messagePointer); diff --git a/cw_monero/macos/Classes/monero_api.cpp b/cw_monero/macos/Classes/monero_api.cpp index 74c82dcd0..83c5223c7 100644 --- a/cw_monero/macos/Classes/monero_api.cpp +++ b/cw_monero/macos/Classes/monero_api.cpp @@ -1029,7 +1029,7 @@ extern "C" bool verify_message(char *message, char *address, char *signature) { - return get_current_wallet()->verifySignedMessage(std::string(message), std::string(address), std::string(verifySignedMessage)); + return get_current_wallet()->verifySignedMessage(std::string(message), std::string(address), std::string(signature)); } #ifdef __cplusplus diff --git a/lib/src/screens/dashboard/widgets/sign_form.dart b/lib/src/screens/dashboard/widgets/sign_form.dart index 6a022305a..2bc161751 100644 --- a/lib/src/screens/dashboard/widgets/sign_form.dart +++ b/lib/src/screens/dashboard/widgets/sign_form.dart @@ -1,23 +1,10 @@ -import 'package:cake_wallet/core/wallet_name_validator.dart'; -import 'package:cake_wallet/entities/generate_name.dart'; -import 'package:cake_wallet/entities/seed_type.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/widgets/address_text_field.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; -import 'package:cake_wallet/src/widgets/blockchain_height_widget.dart'; -import 'package:cake_wallet/src/widgets/picker.dart'; -import 'package:cake_wallet/src/widgets/seed_language_picker.dart'; -import 'package:cake_wallet/src/widgets/seed_widget.dart'; -import 'package:cake_wallet/themes/extensions/address_theme.dart'; -import 'package:cake_wallet/themes/extensions/send_page_theme.dart'; import 'package:cake_wallet/utils/show_bar.dart'; -import 'package:cake_wallet/utils/show_pop_up.dart'; -import 'package:cake_wallet/view_model/seed_type_view_model.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:mobx/mobx.dart'; -import 'package:polyseed/polyseed.dart'; class SignForm extends StatefulWidget { SignForm({ @@ -75,7 +62,10 @@ class SignFormState extends State { const SizedBox(height: 20), AddressTextField( controller: addressController, - options: [AddressTextFieldOption.paste, AddressTextFieldOption.walletAddresses], + options: [ + AddressTextFieldOption.paste, + AddressTextFieldOption.walletAddresses + ], buttonColor: Theme.of(context).hintColor, onSelectedContact: (contact) { addressController.text = contact.address; @@ -89,6 +79,9 @@ class SignFormState extends State { GestureDetector( onTap: () async { final text = signatureController.text; + if (text.isEmpty) { + return; + } Clipboard.setData(ClipboardData(text: text)); showBar(context, S.of(context).transaction_details_copied(text)); },