From 80dfa8c461b950da6c6c2410dbf92edb642dc552 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Mon, 28 May 2018 18:33:15 +0200 Subject: [PATCH] fix(passwords): convert password to Buffer The wallet password is defined as `bytes` in the rpc.proto spec and we are passing it as a string, resulting in an incorrect password being set on a new wallet and an inability to unlock an existing wallet. Convert the wallet password to a Buffer before passing to `initWallet` and `unlockWallet`, which is the default data type used to represent bytes in the node grpc client. This is sures that the password is passed correctly to lnd. Fix #400 --- app/lnd/methods/walletController.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/lnd/methods/walletController.js b/app/lnd/methods/walletController.js index cfc4a4dd..8bee1dd9 100644 --- a/app/lnd/methods/walletController.js +++ b/app/lnd/methods/walletController.js @@ -112,7 +112,7 @@ export function genSeed(walletUnlocker) { */ export function unlockWallet(walletUnlocker, { wallet_password }) { return new Promise((resolve, reject) => { - walletUnlocker.unlockWallet({ wallet_password }, (err, data) => { + walletUnlocker.unlockWallet({ wallet_password: Buffer.from(wallet_password) }, (err, data) => { if (err) { reject(err) } resolve(data) @@ -128,7 +128,7 @@ export function unlockWallet(walletUnlocker, { wallet_password }) { export function initWallet(walletUnlocker, { wallet_password, cipher_seed_mnemonic, aezeed_passphrase }) { return new Promise((resolve, reject) => { walletUnlocker.initWallet({ - wallet_password, + wallet_password: Buffer.from(wallet_password), cipher_seed_mnemonic, aezeed_passphrase: Buffer.from(aezeed_passphrase, 'hex'), recovery_window: 250