mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-31 06:55:59 +00:00
decred: Sign message.
This commit is contained in:
parent
ccc3db5007
commit
5ff6ff110a
2 changed files with 36 additions and 2 deletions
|
@ -216,3 +216,26 @@ String rescanFromHeight(String walletName, String height) {
|
|||
);
|
||||
return res.payload;
|
||||
}
|
||||
|
||||
Future<String> signMessageAsync(
|
||||
String name, String message, String address, String walletPass) {
|
||||
final args = <String, String>{
|
||||
"walletname": name,
|
||||
"message": message,
|
||||
"address": address,
|
||||
"walletpass": walletPass,
|
||||
};
|
||||
return compute(signMessage, args);
|
||||
}
|
||||
|
||||
String signMessage(Map<String, String> args) {
|
||||
final cName = args["walletname"]!.toCString();
|
||||
final cMessage = args["message"]!.toCString();
|
||||
final cAddress = args["address"]!.toCString();
|
||||
final cPass = args["walletpass"]!.toCString();
|
||||
final res = executePayloadFn(
|
||||
fn: () => dcrwalletApi.signMessage(cName, cMessage, cAddress, cPass),
|
||||
ptrsToFree: [cName, cMessage, cAddress, cPass],
|
||||
);
|
||||
return res.payload;
|
||||
}
|
||||
|
|
|
@ -450,8 +450,19 @@ abstract class DecredWalletBase extends WalletBase<DecredBalance,
|
|||
}
|
||||
|
||||
@override
|
||||
String signMessage(String message, {String? address = null}) {
|
||||
return ""; // TODO
|
||||
Future<String> signMessage(String message, {String? address = null}) {
|
||||
if (watchingOnly) {
|
||||
throw "a watching only wallet cannot sign";
|
||||
}
|
||||
var addr = address;
|
||||
if (addr == null) {
|
||||
addr = libdcrwallet.currentReceiveAddress(walletInfo.name);
|
||||
}
|
||||
if (addr == null) {
|
||||
throw "unable to get an address from unsynced wallet";
|
||||
}
|
||||
return libdcrwallet.signMessageAsync(
|
||||
walletInfo.name, message, addr!, _password);
|
||||
}
|
||||
|
||||
List<Unspent> unspents() {
|
||||
|
|
Loading…
Reference in a new issue