mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-09 12:29:31 +00:00
updates & verification for electrum currencies
This commit is contained in:
parent
82dc036a18
commit
ff0bdf8c7f
5 changed files with 35 additions and 2 deletions
|
@ -1229,6 +1229,15 @@ abstract class ElectrumWalletBase
|
|||
return base64Encode(HD.signMessage(message));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> verifyMessage(String message, String signature, {String? address = null}) async {
|
||||
final index = address != null
|
||||
? walletAddresses.allAddresses.firstWhere((element) => element.address == address).index
|
||||
: null;
|
||||
final HD = index == null ? hd : hd.derive(index);
|
||||
return HD.verify(message: message, signature: base64Decode(signature));
|
||||
}
|
||||
|
||||
static BasedUtxoNetwork _getNetwork(bitcoin.NetworkType networkType, CryptoCurrency? currency) {
|
||||
if (networkType == bitcoin.bitcoin && currency == CryptoCurrency.bch) {
|
||||
return BitcoinCashNetwork.mainnet;
|
||||
|
|
|
@ -175,4 +175,15 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
|||
final HD = index == null ? hd : hd.derive(index);
|
||||
return base64Encode(HD.signMessage(message));
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> verifyMessage(String message, String signature, {String? address = null}) async {
|
||||
final index = address != null
|
||||
? walletAddresses.allAddresses
|
||||
.firstWhere((element) => element.address == AddressUtils.toLegacyAddress(address))
|
||||
.index
|
||||
: null;
|
||||
final HD = index == null ? hd : hd.derive(index);
|
||||
return HD.verify(message: message, signature: base64Decode(signature));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,6 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
|
|||
|
||||
int calculateEstimatedFee(TransactionPriority priority, int? amount);
|
||||
|
||||
|
||||
// void fetchTransactionsAsync(
|
||||
// void Function(TransactionType transaction) onTransactionLoaded,
|
||||
// {void Function() onFinished});
|
||||
|
@ -88,7 +87,11 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
|
|||
|
||||
Future<void> renameWalletFiles(String newWalletName);
|
||||
|
||||
Future<String> signMessage(String message, {String? address = null}) => throw UnimplementedError();
|
||||
Future<String> signMessage(String message, {String? address = null}) =>
|
||||
throw UnimplementedError();
|
||||
|
||||
Future<bool> verifyMessage(String message, String signature, {String? address = null}) =>
|
||||
throw UnimplementedError();
|
||||
|
||||
bool? isTestnet;
|
||||
}
|
||||
|
|
|
@ -119,6 +119,11 @@ class EthereumWallet extends EVMChainWallet {
|
|||
return EthereumTransactionHistory(walletInfo: walletInfo, password: password);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> signMessage(String message, {String? address}) async {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
static Future<EthereumWallet> open(
|
||||
{required String name, required String password, required WalletInfo walletInfo}) async {
|
||||
final path = await pathForWallet(name: name, type: walletInfo.type);
|
||||
|
|
|
@ -527,5 +527,10 @@ abstract class SolanaWalletBase
|
|||
return signSolanaMessage(message);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> verifyMessage(String message, String signature, {String? address}) async {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
SolanaClient? get solanaClient => _client.getSolanaClient;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue