mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-25 13:09:32 +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 {
|
||||
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',
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()}');
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue