Browse Source

fix(addInvoice): decode payreq and send all invoice data back after newly created invoice

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
225adf6a97
  1. 14
      app/lnd/methods/index.js

14
app/lnd/methods/index.js

@ -126,15 +126,25 @@ export default function (lnd, event, msg, data) {
invoicesController invoicesController
.addInvoice(lnd, data) .addInvoice(lnd, data)
.then(newinvoice => .then(newinvoice =>
invoicesController
.getInvoice(lnd, { pay_req: newinvoice.payment_request })
.then(decodedInvoice => {
event.sender.send( event.sender.send(
'createdInvoice', 'createdInvoice',
Object.assign(newinvoice, { Object.assign(decodedInvoice, {
memo: data.memo, memo: data.memo,
value: data.value, value: data.value,
r_hash: Buffer.from(newinvoice.r_hash, 'hex').toString('hex'), r_hash: Buffer.from(newinvoice.r_hash, 'hex').toString('hex'),
payment_request: newinvoice.payment_request,
creation_date: Date.now() / 1000 creation_date: Date.now() / 1000
}) })
)) )
})
.catch(error => {
console.log('decodedInvoice error: ', error)
event.sender.send('invoiceFailed', { error: error.toString() })
})
)
.catch((error) => { .catch((error) => {
console.log('addInvoice error: ', error) console.log('addInvoice error: ', error)
event.sender.send('invoiceFailed', { error: error.toString() }) event.sender.send('invoiceFailed', { error: error.toString() })

Loading…
Cancel
Save