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.
61 lines
1.2 KiB
61 lines
1.2 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 getBitcoindAddresses(jwt) {
|
|
|
|
const headers = {
|
|
headers: {
|
|
Authorization: 'JWT ' + jwt,
|
|
}
|
|
};
|
|
|
|
return axios
|
|
.get(lnapiUrl + ':' + lnapiPort + '/v1/bitcoind/info/addresses', headers);
|
|
}
|
|
|
|
async function getStatus() {
|
|
return axios.get(lnapiUrl + ':' + lnapiPort + '/v1/lnd/info/status');
|
|
}
|
|
|
|
module.exports = {
|
|
changePassword,
|
|
initializeWallet,
|
|
getBitcoindAddresses,
|
|
getStatus,
|
|
};
|
|
|