mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-24 11:36:21 +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));
|
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) {
|
static BasedUtxoNetwork _getNetwork(bitcoin.NetworkType networkType, CryptoCurrency? currency) {
|
||||||
if (networkType == bitcoin.bitcoin && currency == CryptoCurrency.bch) {
|
if (networkType == bitcoin.bitcoin && currency == CryptoCurrency.bch) {
|
||||||
return BitcoinCashNetwork.mainnet;
|
return BitcoinCashNetwork.mainnet;
|
||||||
|
|
|
@ -175,4 +175,15 @@ abstract class BitcoinCashWalletBase extends ElectrumWallet with Store {
|
||||||
final HD = index == null ? hd : hd.derive(index);
|
final HD = index == null ? hd : hd.derive(index);
|
||||||
return base64Encode(HD.signMessage(message));
|
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);
|
int calculateEstimatedFee(TransactionPriority priority, int? amount);
|
||||||
|
|
||||||
|
|
||||||
// void fetchTransactionsAsync(
|
// void fetchTransactionsAsync(
|
||||||
// void Function(TransactionType transaction) onTransactionLoaded,
|
// void Function(TransactionType transaction) onTransactionLoaded,
|
||||||
// {void Function() onFinished});
|
// {void Function() onFinished});
|
||||||
|
@ -88,7 +87,11 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
|
||||||
|
|
||||||
Future<void> renameWalletFiles(String newWalletName);
|
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;
|
bool? isTestnet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,11 @@ class EthereumWallet extends EVMChainWallet {
|
||||||
return EthereumTransactionHistory(walletInfo: walletInfo, password: password);
|
return EthereumTransactionHistory(walletInfo: walletInfo, password: password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> signMessage(String message, {String? address}) async {
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
static Future<EthereumWallet> open(
|
static Future<EthereumWallet> open(
|
||||||
{required String name, required String password, required WalletInfo walletInfo}) async {
|
{required String name, required String password, required WalletInfo walletInfo}) async {
|
||||||
final path = await pathForWallet(name: name, type: walletInfo.type);
|
final path = await pathForWallet(name: name, type: walletInfo.type);
|
||||||
|
|
|
@ -527,5 +527,10 @@ abstract class SolanaWalletBase
|
||||||
return signSolanaMessage(message);
|
return signSolanaMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<String> verifyMessage(String message, String signature, {String? address}) async {
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
SolanaClient? get solanaClient => _client.getSolanaClient;
|
SolanaClient? get solanaClient => _client.getSolanaClient;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue