mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-31 06:55:59 +00:00
decred: Add new addr and addrs.
This commit is contained in:
parent
5ff6ff110a
commit
5d19f4f601
2 changed files with 31 additions and 4 deletions
|
@ -239,3 +239,28 @@ String signMessage(Map<String, String> args) {
|
|||
);
|
||||
return res.payload;
|
||||
}
|
||||
|
||||
String? newExternalAddress(String walletName) {
|
||||
final cName = walletName.toCString();
|
||||
final res = executePayloadFn(
|
||||
fn: () => dcrwalletApi.newExternalAddress(cName),
|
||||
ptrsToFree: [cName],
|
||||
skipErrorCheck: true, // errCode is checked below, before checking err
|
||||
);
|
||||
if (res.errCode == ErrCodeNotSynced) {
|
||||
// Wallet is not synced. We do not want to give out a used address so give
|
||||
// nothing.
|
||||
return null;
|
||||
}
|
||||
checkErr(res.err);
|
||||
return res.payload;
|
||||
}
|
||||
|
||||
String addresses(String walletName) {
|
||||
final cName = walletName.toCString();
|
||||
final res = executePayloadFn(
|
||||
fn: () => dcrwalletApi.addresses(cName),
|
||||
ptrsToFree: [cName],
|
||||
);
|
||||
return res.payload;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:cw_core/wallet_addresses.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_decred/api/libdcrwallet.dart' as libdcrwallet;
|
||||
|
@ -11,13 +13,13 @@ class DecredWalletAddresses extends WalletAddresses {
|
|||
}
|
||||
|
||||
String generateNewAddress() {
|
||||
// TODO: generate new external address with libdcrwallet.
|
||||
return "DsT4qJPPaYEuQRimfgvSKxKH3paysn1x3Nt";
|
||||
return libdcrwallet.newExternalAddress(walletInfo.name) ?? '';
|
||||
}
|
||||
|
||||
List<String> addresses() {
|
||||
final currentAddress = libdcrwallet.currentReceiveAddress(walletInfo.name);
|
||||
return currentAddress == null ? [] : [currentAddress];
|
||||
final res = libdcrwallet.addresses(walletInfo.name);
|
||||
final addrs = (json.decode(res) as List<dynamic>).cast<String>();
|
||||
return addrs;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in a new issue