mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
* add wallet create, restore and server integration * update transaction fee calculation * Updated tool/configure.dart * Add dogecoin support to app_config * minor fix [skip ci] * Update model_generator.sh * remove cw_bitcoin import from lib/ directory * update bitcoin base * update default node * add passphrase an QR restore option * add Dogecoin support for message signing * add Dogecoin support across wallet features * fix edit subaddress Updated the isElectrum getter to include WalletType.dogecoin, ensuring Dogecoin wallets are correctly identified as Electrum-compatible. * Update configure.dart * fix: address label not saved * remove unused derivationPath Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * address review comments * fix generateInitialAddresses type * enable auto switching for Dogecoin nodes --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
57 lines
1.5 KiB
Dart
57 lines
1.5 KiB
Dart
import 'package:cake_wallet/core/execution_state.dart';
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
import 'package:cw_core/wallet_base.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
part 'sign_view_model.g.dart';
|
|
|
|
class SignViewModel = SignViewModelBase with _$SignViewModel;
|
|
|
|
abstract class SignViewModelBase with Store {
|
|
SignViewModelBase(this.wallet) : state = InitialExecutionState();
|
|
|
|
final WalletBase wallet;
|
|
|
|
@observable
|
|
ExecutionState state;
|
|
|
|
@observable
|
|
bool isSigning = true;
|
|
|
|
bool get signIncludesAddress => [
|
|
WalletType.monero,
|
|
WalletType.bitcoin,
|
|
WalletType.bitcoinCash,
|
|
WalletType.litecoin,
|
|
WalletType.dogecoin,
|
|
WalletType.haven,
|
|
].contains(wallet.type);
|
|
|
|
@action
|
|
Future<void> sign(String message, {String? address}) async {
|
|
state = IsExecutingState();
|
|
try {
|
|
final signature = await wallet.signMessage(message, address: address);
|
|
state = ExecutedSuccessfullyState(payload: signature);
|
|
} catch (e) {
|
|
state = FailureState(e.toString());
|
|
}
|
|
}
|
|
|
|
@action
|
|
Future<void> verify(String message, String signature, {String? address}) async {
|
|
state = IsExecutingState();
|
|
try {
|
|
final sig = await wallet.verifyMessage(message, signature, address: address);
|
|
if (sig) {
|
|
state = ExecutedSuccessfullyState();
|
|
} else {
|
|
state = FailureState(S.current.signature_invalid_error);
|
|
}
|
|
} catch (e) {
|
|
state = FailureState(e.toString());
|
|
}
|
|
}
|
|
}
|