Merge pull request #281 from Bucko13/import-key-passphrase
pass passphrase for key import
This commit is contained in:
commit
bdeb72a035
4
bin/cli
4
bin/cli
@ -429,12 +429,12 @@ CLI.prototype.backup = async function backup() {
|
|||||||
CLI.prototype.importKey = async function importKey() {
|
CLI.prototype.importKey = async function importKey() {
|
||||||
const key = this.config.str(0);
|
const key = this.config.str(0);
|
||||||
const account = this.config.str('account');
|
const account = this.config.str('account');
|
||||||
|
const passphrase = this.config.str('passphrase');
|
||||||
if (!key)
|
if (!key)
|
||||||
throw new Error('No key for import.');
|
throw new Error('No key for import.');
|
||||||
|
|
||||||
if (util.isBase58(key)) {
|
if (util.isBase58(key)) {
|
||||||
await this.wallet.importPrivate(account, key);
|
await this.wallet.importPrivate(account, key, passphrase);
|
||||||
this.log('Imported private key.');
|
this.log('Imported private key.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -785,8 +785,8 @@ HTTPClient.prototype.removeSharedKey = function removeSharedKey(id, account, key
|
|||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HTTPClient.prototype.importPrivate = function importPrivate(id, account, key) {
|
HTTPClient.prototype.importPrivate = function importPrivate(id, account, key, passphrase) {
|
||||||
const body = { account: account, privateKey: key };
|
const body = { account: account, privateKey: key, passphrase: passphrase };
|
||||||
return this._post(`/wallet/${id}/import`, body);
|
return this._post(`/wallet/${id}/import`, body);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -360,8 +360,8 @@ HTTPWallet.prototype.retoken = async function retoken(passphrase) {
|
|||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HTTPWallet.prototype.importPrivate = function importPrivate(account, key) {
|
HTTPWallet.prototype.importPrivate = function importPrivate(account, key, passphrase='') {
|
||||||
return this.client.importPrivate(this.id, account, key);
|
return this.client.importPrivate(this.id, account, key, passphrase);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -337,6 +337,7 @@ HTTPServer.prototype.initRouter = function initRouter() {
|
|||||||
this.post('/:id/import', async (req, res) => {
|
this.post('/:id/import', async (req, res) => {
|
||||||
const valid = req.valid();
|
const valid = req.valid();
|
||||||
const acct = valid.str('account');
|
const acct = valid.str('account');
|
||||||
|
const passphrase = valid.str('passphrase');
|
||||||
const pub = valid.buf('publicKey');
|
const pub = valid.buf('publicKey');
|
||||||
const priv = valid.str('privateKey');
|
const priv = valid.str('privateKey');
|
||||||
const b58 = valid.str('address');
|
const b58 = valid.str('address');
|
||||||
@ -350,7 +351,7 @@ HTTPServer.prototype.initRouter = function initRouter() {
|
|||||||
|
|
||||||
if (priv) {
|
if (priv) {
|
||||||
const key = KeyRing.fromSecret(priv, this.network);
|
const key = KeyRing.fromSecret(priv, this.network);
|
||||||
await req.wallet.importKey(acct, key);
|
await req.wallet.importKey(acct, key, passphrase);
|
||||||
res.send(200, { success: true });
|
res.send(200, { success: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user