CW-328-Restore-wallet-from-QRCode-and-sweep-all-funds-in-a-new-wallet WIP

This commit is contained in:
Blazebrain 2023-05-17 12:00:20 +01:00
parent 34b63b4603
commit 8c609f09a1
4 changed files with 23 additions and 4 deletions

View file

@ -250,7 +250,7 @@ Future<bool> sweepFundsToNewWallet({
}) async {
final uri = Uri.http(node.uriRaw, '');
final path = '/json_rpc';
final rpcUri = Uri.https(uri.authority, path);
final rpcUri = node.isSSL ? Uri.https(uri.authority, path) : Uri.http(uri.authority, path);
final realm = 'monero-rpc';
final body = {
'method': 'sweep_all',

View file

@ -67,11 +67,13 @@ class RestoreOptionsPage extends BasePage {
}
if (!isNewInstall || isPinSet) {
try {
//! This gives us the restored wallet
final restoreWallet =
await WalletRestoreFromQRCode.scanQRCodeForRestoring(context);
final restoreFromQRViewModel = getIt.get<WalletRestorationFromQRVM>(param1: restoreWallet.type);
//! Next step will be to create a new wallet from this
final restoreFromQRViewModel =
getIt.get<WalletRestorationFromQRVM>(param1: restoreWallet.type);
await restoreFromQRViewModel.create(restoreWallet: restoreWallet);
if (restoreFromQRViewModel.state is FailureState) {
_onWalletCreateFailure(context,

View file

@ -83,6 +83,18 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
default:
throw Exception('Unexpected type: ${type.toString()}');
}
case WalletRestoreMode.txids:
switch (restoreWallet.type) {
case WalletType.monero:
return monero!
.createMoneroNewWalletCredentials(name: name, language: options as String);
case WalletType.bitcoin:
return bitcoin!.createBitcoinNewWalletCredentials(name: name);
case WalletType.litecoin:
return bitcoin!.createBitcoinNewWalletCredentials(name: name);
default:
throw Exception('Unexpected type: ${restoreWallet.type.toString()}');
}
default:
throw Exception('Unexpected type: ${type.toString()}');
}

View file

@ -65,11 +65,16 @@ abstract class WalletCreationVMBase with Store {
address: '',
showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven);
credentials.walletInfo = walletInfo;
//! Restored
final wallet = restoreWallet != null
? await processFromRestoredWallet(credentials, restoreWallet)
: await process(credentials);
walletInfo.address = wallet.walletAddresses.address;
await _walletInfoSource.add(walletInfo);
//---- Code to create new
//! Before we switch
_appStore.changeCurrentWallet(wallet);
_appStore.authenticationStore.allowed();
state = ExecutedSuccessfullyState();