mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-13 06:14:45 +00:00
CW-328-Restore-wallet-from-QRCode-and-sweep-all-funds-in-a-new-wallet WIP
This commit is contained in:
parent
34b63b4603
commit
8c609f09a1
4 changed files with 23 additions and 4 deletions
|
@ -250,7 +250,7 @@ Future<bool> sweepFundsToNewWallet({
|
||||||
}) async {
|
}) async {
|
||||||
final uri = Uri.http(node.uriRaw, '');
|
final uri = Uri.http(node.uriRaw, '');
|
||||||
final path = '/json_rpc';
|
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 realm = 'monero-rpc';
|
||||||
final body = {
|
final body = {
|
||||||
'method': 'sweep_all',
|
'method': 'sweep_all',
|
||||||
|
|
|
@ -67,11 +67,13 @@ class RestoreOptionsPage extends BasePage {
|
||||||
}
|
}
|
||||||
if (!isNewInstall || isPinSet) {
|
if (!isNewInstall || isPinSet) {
|
||||||
try {
|
try {
|
||||||
|
//! This gives us the restored wallet
|
||||||
final restoreWallet =
|
final restoreWallet =
|
||||||
await WalletRestoreFromQRCode.scanQRCodeForRestoring(context);
|
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);
|
await restoreFromQRViewModel.create(restoreWallet: restoreWallet);
|
||||||
if (restoreFromQRViewModel.state is FailureState) {
|
if (restoreFromQRViewModel.state is FailureState) {
|
||||||
_onWalletCreateFailure(context,
|
_onWalletCreateFailure(context,
|
||||||
|
|
|
@ -83,6 +83,18 @@ abstract class WalletRestorationFromQRVMBase extends WalletCreationVM with Store
|
||||||
default:
|
default:
|
||||||
throw Exception('Unexpected type: ${type.toString()}');
|
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:
|
default:
|
||||||
throw Exception('Unexpected type: ${type.toString()}');
|
throw Exception('Unexpected type: ${type.toString()}');
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,11 +65,16 @@ abstract class WalletCreationVMBase with Store {
|
||||||
address: '',
|
address: '',
|
||||||
showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven);
|
showIntroCakePayCard: (!walletCreationService.typeExists(type)) && type != WalletType.haven);
|
||||||
credentials.walletInfo = walletInfo;
|
credentials.walletInfo = walletInfo;
|
||||||
|
|
||||||
|
//! Restored
|
||||||
final wallet = restoreWallet != null
|
final wallet = restoreWallet != null
|
||||||
? await processFromRestoredWallet(credentials, restoreWallet)
|
? await processFromRestoredWallet(credentials, restoreWallet)
|
||||||
: await process(credentials);
|
: await process(credentials);
|
||||||
walletInfo.address = wallet.walletAddresses.address;
|
walletInfo.address = wallet.walletAddresses.address;
|
||||||
await _walletInfoSource.add(walletInfo);
|
await _walletInfoSource.add(walletInfo);
|
||||||
|
//---- Code to create new
|
||||||
|
|
||||||
|
//! Before we switch
|
||||||
_appStore.changeCurrentWallet(wallet);
|
_appStore.changeCurrentWallet(wallet);
|
||||||
_appStore.authenticationStore.allowed();
|
_appStore.authenticationStore.allowed();
|
||||||
state = ExecutedSuccessfullyState();
|
state = ExecutedSuccessfullyState();
|
||||||
|
|
Loading…
Reference in a new issue