You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

73 lines
1.3 KiB

const axios = require('axios');
// axios requires http
const lnapiUrl = process.env.MIDDLEWARE_API_URL || 'http://localhost';
const lnapiPort = process.env.MIDDLEWARE_API_PORT || 3005;
async function changePassword(currentPassword, newPassword, jwt) {
const headers = {
headers: {
Authorization: 'JWT ' + jwt,
}
};
const body = {
currentPassword,
newPassword,
};
return axios
.post(lnapiUrl + ':' + lnapiPort + '/v1/lnd/wallet/changePassword', body, headers);
}
async function initializeWallet(password, seed, jwt) {
const headers = {
headers: {
Authorization: 'JWT ' + jwt,
}
};
const body = {
password,
seed,
};
return axios
.post(lnapiUrl + ':' + lnapiPort + '/v1/lnd/wallet/init', body, headers);
}
async function unlockLnd(password, jwt) {
const headers = {
headers: {
Authorization: 'JWT ' + jwt,
}
};
const body = {
password,
};
return axios
.post(lnapiUrl + ':' + lnapiPort + '/v1/lnd/wallet/unlock', body, headers);
}
async function getBitcoindAddresses(jwt) {
const headers = {
headers: {
Authorization: 'JWT ' + jwt,
}
};
return axios
.get(lnapiUrl + ':' + lnapiPort + '/v1/bitcoind/info/addresses', headers);
}
module.exports = {
changePassword,
initializeWallet,
unlockLnd,
getBitcoindAddresses,
};