Browse Source

SubscribeInvoice implemented

renovate/lint-staged-8.x
João Almeida 8 years ago
parent
commit
0dc7a36880
  1. 17
      app/lnd/methods/invoicesController.js
  2. 16
      app/lnd/push/subscribeinvoice.js

17
app/lnd/methods/invoicesController.js

@ -66,4 +66,19 @@ export function lookupInvoice(lnd, { rhash }) {
})
})
}
//TODO - SubscribeInvoice
/**
* [subscribeInvoices description]
* @param {[type]} lnd [description]
* @param {[type]} event [description]
* @return {[type]} [description]
*/
export function subscribeInvoices(lnd, event) {
return new Promise((resolve, reject) => {
pushinvoices(lnd, event)
.then(data => resolve(data))
.catch(error => reject(error))
})
}

16
app/lnd/push/subscribeinvoice.js

@ -0,0 +1,16 @@
export default function pushinvoices(lnd, event) {
return new Promise((resolve, reject) => {
try {
const call = lnd.subscribeInvoices({})
call.on('data', data => event.sender.send('pushinvoicesupdated', { data }))
call.on('end', () => event.sender.send('pushinvoicesend'))
call.on('error', error => event.sender.send('pushinvoiceserror', { error }))
call.on('status', status => event.sender.send('pushinvoicesstatus', { status }))
resolve(null)
} catch (error) {
reject(error, null)
}
})
}
Loading…
Cancel
Save