From 4029b512bb92f011296cdf86ddca03df6dfc9688 Mon Sep 17 00:00:00 2001 From: JoeGruff Date: Tue, 12 Mar 2024 14:58:21 +0900 Subject: [PATCH] decred: Add change wallet pass. --- cw_decred/lib/api/libdcrwallet.dart | 13 ++++++++++--- cw_decred/lib/wallet.dart | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cw_decred/lib/api/libdcrwallet.dart b/cw_decred/lib/api/libdcrwallet.dart index ad9d66122..e9b4c435a 100644 --- a/cw_decred/lib/api/libdcrwallet.dart +++ b/cw_decred/lib/api/libdcrwallet.dart @@ -96,9 +96,16 @@ void closeWallet(String walletName) { ); } -Future changeWalletPassword( - String walletName, String currentPassword, String newPassword) async { - // TODO. +String changeWalletPassword( + String walletName, String currentPassword, String newPassword) { + final cName = walletName.toCString(); + final cCurrentPass = currentPassword.toCString(); + final cNewPass = newPassword.toCString(); + final res = executePayloadFn( + fn: () => dcrwalletApi.changePassphrase(cName, cCurrentPass, cNewPass), + ptrsToFree: [cName, cCurrentPass, cNewPass], + ); + return res.payload; } String? walletSeed(String walletName, String walletPassword) { diff --git a/cw_decred/lib/wallet.dart b/cw_decred/lib/wallet.dart index d7e4b9f69..955bd05a4 100644 --- a/cw_decred/lib/wallet.dart +++ b/cw_decred/lib/wallet.dart @@ -418,8 +418,9 @@ abstract class DecredWalletBase extends WalletBase changePassword(String password) async { - await libdcrwallet.changeWalletPassword( - walletInfo.name, _password, password); + return () async { + libdcrwallet.changeWalletPassword(walletInfo.name, _password, password); + }(); } @override