bws control on import
This commit is contained in:
parent
e304c49381
commit
a594880515
2 changed files with 35 additions and 35 deletions
|
|
@ -49,13 +49,11 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
}
|
}
|
||||||
|
|
||||||
self.loading = true;
|
self.loading = true;
|
||||||
|
opts.compressed = null;
|
||||||
|
opts.password = null;
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
profileService.importWallet(str2, {
|
profileService.importWallet(str2, opts, function(err, walletId) {
|
||||||
compressed: null,
|
|
||||||
password: null,
|
|
||||||
bwsurl: $scope.bwsurl
|
|
||||||
}, function(err, walletId) {
|
|
||||||
self.loading = false;
|
self.loading = false;
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = err;
|
self.error = err;
|
||||||
|
|
@ -69,11 +67,11 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
var _importExtendedPrivateKey = function(xPrivKey) {
|
var _importExtendedPrivateKey = function(xPrivKey, opts) {
|
||||||
self.loading = true;
|
self.loading = true;
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
profileService.importExtendedPrivateKey(xPrivKey, function(err, walletId) {
|
profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, walletId) {
|
||||||
self.loading = false;
|
self.loading = false;
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = err;
|
self.error = err;
|
||||||
|
|
@ -114,7 +112,9 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
// If we use onloadend, we need to check the readyState.
|
// If we use onloadend, we need to check the readyState.
|
||||||
reader.onloadend = function(evt) {
|
reader.onloadend = function(evt) {
|
||||||
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
|
if (evt.target.readyState == FileReader.DONE) { // DONE == 2
|
||||||
_importBlob(evt.target.result);
|
var opts = {};
|
||||||
|
opts.bwsurl = $scope.bwsurl;
|
||||||
|
_importBlob(evt.target.result, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -145,7 +145,9 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
if (backupFile) {
|
if (backupFile) {
|
||||||
reader.readAsBinaryString(backupFile);
|
reader.readAsBinaryString(backupFile);
|
||||||
} else {
|
} else {
|
||||||
_importBlob(backupText);
|
var opts = {};
|
||||||
|
opts.bwsurl = $scope.bwsurl;
|
||||||
|
_importBlob(backupText, opts);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -160,6 +162,8 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts = {};
|
var opts = {};
|
||||||
|
if ($scope.bwsurl)
|
||||||
|
opts.bwsurl = $scope.bwsurl;
|
||||||
|
|
||||||
var passphrase = form.passphrase.$modelValue;
|
var passphrase = form.passphrase.$modelValue;
|
||||||
var words = form.words.$modelValue;
|
var words = form.words.$modelValue;
|
||||||
|
|
@ -168,7 +172,7 @@ angular.module('copayApp.controllers').controller('importController',
|
||||||
if (!words) {
|
if (!words) {
|
||||||
this.error = gettext('Please enter the seed words');
|
this.error = gettext('Please enter the seed words');
|
||||||
} else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) {
|
} else if (words.indexOf('xprv') == 0 || words.indexOf('tprv') == 0) {
|
||||||
return _importExtendedPrivateKey(words)
|
return _importExtendedPrivateKey(words, opts);
|
||||||
} else {
|
} else {
|
||||||
var wordList = words.split(/[\u3000\s]+/);
|
var wordList = words.split(/[\u3000\s]+/);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -265,10 +265,7 @@ angular.module('copayApp.services')
|
||||||
root.setWalletClients();
|
root.setWalletClients();
|
||||||
|
|
||||||
root.setAndStoreFocus(walletId, function() {
|
root.setAndStoreFocus(walletId, function() {
|
||||||
storageService.storeProfile(root.profile, function(err) {
|
storageService.storeProfile(root.profile, cb);
|
||||||
if (err) return cb(err);
|
|
||||||
return cb(null);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -298,11 +295,7 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
walletClient.joinWallet(opts.secret, opts.myName || 'me', {}, function(err) {
|
walletClient.joinWallet(opts.secret, opts.myName || 'me', {}, function(err) {
|
||||||
if (err) return bwsError.cb(err, gettext('Could not join wallet'), cb);
|
if (err) return bwsError.cb(err, gettext('Could not join wallet'), cb);
|
||||||
|
root.storeData(walletClient, opts.bwsurl, cb);
|
||||||
root.storeData(walletClient, opts.bwsurl, function(err) {
|
|
||||||
if (err) return cb(err);
|
|
||||||
return cb(null);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -334,7 +327,7 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root._addWalletClient = function(walletClient, cb) {
|
root._addWalletClient = function(walletClient, opts, cb) {
|
||||||
var walletId = walletClient.credentials.walletId;
|
var walletId = walletClient.credentials.walletId;
|
||||||
|
|
||||||
// check if exist
|
// check if exist
|
||||||
|
|
@ -344,16 +337,7 @@ angular.module('copayApp.services')
|
||||||
if (w) {
|
if (w) {
|
||||||
return cb(gettext('Wallet already in Copay' + ": ") + w.walletName);
|
return cb(gettext('Wallet already in Copay' + ": ") + w.walletName);
|
||||||
}
|
}
|
||||||
|
root.storeData(walletClient, opts.bwsurl, cb);
|
||||||
root.profile.credentials.push(JSON.parse(walletClient.export()));
|
|
||||||
root.setWalletClients();
|
|
||||||
|
|
||||||
root.setAndStoreFocus(walletId, function() {
|
|
||||||
storageService.storeProfile(root.profile, function(err) {
|
|
||||||
return cb(null, walletId);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
root.importWallet = function(str, opts, cb) {
|
root.importWallet = function(str, opts, cb) {
|
||||||
|
|
@ -371,10 +355,13 @@ angular.module('copayApp.services')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return cb(gettext('Could not import. Check input file and password'));
|
return cb(gettext('Could not import. Check input file and password'));
|
||||||
}
|
}
|
||||||
root._addWalletClient(walletClient, cb);
|
root._addWalletClient(walletClient, opts, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.importExtendedPrivateKey = function(xPrivKey, cb) {
|
root.importExtendedPrivateKey = function(xPrivKey, opts, cb) {
|
||||||
|
if (opts.bwsurl)
|
||||||
|
bwcService.setBaseUrl(opts.bwsurl);
|
||||||
|
|
||||||
var walletClient = bwcService.getClient();
|
var walletClient = bwcService.getClient();
|
||||||
$log.debug('Importing Wallet xPrivKey');
|
$log.debug('Importing Wallet xPrivKey');
|
||||||
|
|
||||||
|
|
@ -382,7 +369,7 @@ angular.module('copayApp.services')
|
||||||
if (err)
|
if (err)
|
||||||
return bwsError.cb(err, gettext('Could not import'), cb);
|
return bwsError.cb(err, gettext('Could not import'), cb);
|
||||||
|
|
||||||
root._addWalletClient(walletClient, cb);
|
root._addWalletClient(walletClient, opts, cb);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -394,6 +381,9 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.importMnemonic = function(words, opts, cb) {
|
root.importMnemonic = function(words, opts, cb) {
|
||||||
|
if (opts.bwsurl)
|
||||||
|
bwcService.setBaseUrl(opts.bwsurl);
|
||||||
|
|
||||||
var walletClient = bwcService.getClient();
|
var walletClient = bwcService.getClient();
|
||||||
|
|
||||||
$log.debug('Importing Wallet Mnemonic');
|
$log.debug('Importing Wallet Mnemonic');
|
||||||
|
|
@ -406,11 +396,14 @@ angular.module('copayApp.services')
|
||||||
if (err)
|
if (err)
|
||||||
return bwsError.cb(err, gettext('Could not import'), cb);
|
return bwsError.cb(err, gettext('Could not import'), cb);
|
||||||
|
|
||||||
root._addWalletClient(walletClient, cb);
|
root._addWalletClient(walletClient, opts, cb);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.importExtendedPublicKey = function(opts, cb) {
|
root.importExtendedPublicKey = function(opts, cb) {
|
||||||
|
if (opts.bwsurl)
|
||||||
|
bwcService.setBaseUrl(opts.bwsurl);
|
||||||
|
|
||||||
var walletClient = bwcService.getClient();
|
var walletClient = bwcService.getClient();
|
||||||
$log.debug('Importing Wallet XPubKey');
|
$log.debug('Importing Wallet XPubKey');
|
||||||
|
|
||||||
|
|
@ -424,7 +417,7 @@ angular.module('copayApp.services')
|
||||||
return bwsError.cb(err, gettext('Could not import'), cb);
|
return bwsError.cb(err, gettext('Could not import'), cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
root._addWalletClient(walletClient, cb);
|
root._addWalletClient(walletClient, opts, cb);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -444,6 +437,9 @@ angular.module('copayApp.services')
|
||||||
};
|
};
|
||||||
|
|
||||||
root.importLegacyWallet = function(username, password, blob, cb) {
|
root.importLegacyWallet = function(username, password, blob, cb) {
|
||||||
|
if (opts.bwsurl)
|
||||||
|
bwcService.setBaseUrl(opts.bwsurl);
|
||||||
|
|
||||||
var walletClient = bwcService.getClient();
|
var walletClient = bwcService.getClient();
|
||||||
|
|
||||||
walletClient.createWalletFromOldCopay(username, password, blob, function(err, existed) {
|
walletClient.createWalletFromOldCopay(username, password, blob, function(err, existed) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue