commit
877d319ff3
1 changed files with 46 additions and 32 deletions
|
|
@ -622,24 +622,58 @@ module.exports = async (
|
||||||
await Storage.set('trustedPKs', [...(trustedKeys || []), publicKey])
|
await Storage.set('trustedPKs', [...(trustedKeys || []), publicKey])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send an event to update lightning's status
|
const { lightning } = LightningServices.services
|
||||||
mySocketsEvents.emit('updateLightning')
|
|
||||||
|
// Generate auth token and send it as a JSON response
|
||||||
|
const token = await auth.generateToken()
|
||||||
|
|
||||||
|
// wait for wallet to warm up
|
||||||
|
await Common.Utils.makePromise((res, rej) => {
|
||||||
|
let tries = 0
|
||||||
|
let intervalID = null
|
||||||
|
|
||||||
|
intervalID = setInterval(() => {
|
||||||
|
if (tries === 3) {
|
||||||
|
rej(new Error(`Wallet did not warm up in under 3 seconds.`))
|
||||||
|
|
||||||
|
clearInterval(intervalID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tries++
|
||||||
|
|
||||||
|
lightning.listInvoices({}, err => {
|
||||||
|
if (!err) {
|
||||||
|
clearInterval(intervalID)
|
||||||
|
res()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
|
||||||
//get the latest channel backups before subscribing
|
//get the latest channel backups before subscribing
|
||||||
const user = require('../services/gunDB/Mediator').getUser()
|
const user = require('../services/gunDB/Mediator').getUser()
|
||||||
const SEA = require('../services/gunDB/Mediator').mySEA
|
const SEA = require('../services/gunDB/Mediator').mySEA
|
||||||
const { lightning } = LightningServices.services
|
|
||||||
lightning.exportAllChannelBackups({}, (err, channelBackups) => {
|
await Common.Utils.makePromise((res, rej) => {
|
||||||
if (err) {
|
lightning.exportAllChannelBackups({}, (err, channelBackups) => {
|
||||||
return handleError(res, err)
|
if (err) {
|
||||||
}
|
return rej(new Error(err.details))
|
||||||
GunActions.saveChannelsBackup(
|
}
|
||||||
JSON.stringify(channelBackups),
|
|
||||||
user,
|
res(
|
||||||
SEA
|
GunActions.saveChannelsBackup(
|
||||||
)
|
JSON.stringify(channelBackups),
|
||||||
|
user,
|
||||||
|
SEA
|
||||||
|
)
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Send an event to update lightning's status
|
||||||
|
mySocketsEvents.emit('updateLightning')
|
||||||
|
|
||||||
//register to listen for channel backups
|
//register to listen for channel backups
|
||||||
const onNewChannelBackup = () => {
|
const onNewChannelBackup = () => {
|
||||||
logger.warn('Subscribing to channel backup ...')
|
logger.warn('Subscribing to channel backup ...')
|
||||||
|
|
@ -701,31 +735,11 @@ module.exports = async (
|
||||||
onNewChannelBackup()
|
onNewChannelBackup()
|
||||||
startTipStatusJob()
|
startTipStatusJob()
|
||||||
|
|
||||||
// Generate auth token and send it as a JSON response
|
|
||||||
const token = await auth.generateToken()
|
|
||||||
res.json({
|
res.json({
|
||||||
authorization: token,
|
authorization: token,
|
||||||
user: {
|
user: {
|
||||||
alias,
|
alias,
|
||||||
publicKey
|
publicKey
|
||||||
},
|
|
||||||
follows: await GunGetters.Follows.currentFollows(),
|
|
||||||
data: {
|
|
||||||
invoices: await Common.makePromise((res, rej) => {
|
|
||||||
lightning.listInvoices(
|
|
||||||
{
|
|
||||||
reversed: true,
|
|
||||||
num_max_invoices: 50
|
|
||||||
},
|
|
||||||
(err, lres) => {
|
|
||||||
if (err) {
|
|
||||||
rej(new Error(err.details))
|
|
||||||
} else {
|
|
||||||
res(lres)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue