Browse Source

fix(lnd-ipc): fix create + pay invoice bug

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
fc0876b893
  1. 2
      app/lnd/methods/createinvoice.js
  2. 10
      app/lnd/methods/index.js
  3. 2
      app/lnd/methods/payinvoice.js

2
app/lnd/methods/createinvoice.js

@ -1,5 +1,5 @@
// LND Create an invoice
export function createInvoice(lnd, { memo, value }) {
export default function createInvoice(lnd, { memo, value }) {
return new Promise((resolve, reject) => {
lnd.addInvoice({ memo, value }, (err, data) => {
if (err) { reject(err) }

10
app/lnd/methods/index.js

@ -60,16 +60,16 @@ export default function(lnd, event, msg, data) {
case 'createInvoice':
// Invoice looks like { r_hash: Buffer, payment_request: '' }
// { memo, value } = data
createInvoice(lnd, data)
.then(invoice => event.sender.send('createdInvoice', Object.assign(invoice, { memo, value, r_hash: new Buffer(invoice.r_hash,'hex').toString('hex') })))
createinvoice(lnd, data)
.then(invoice => event.sender.send('createdInvoice', Object.assign(invoice, { memo: data.memo, value: data.value, r_hash: new Buffer(invoice.r_hash,'hex').toString('hex') })))
.catch(error => console.log('createInvoice error: ', error))
break
case 'sendPayment':
// Payment looks like { payment_preimage: Buffer, payment_route: Object }
// { paymentRequest } = data
sendPayment(lnd, data)
.then(payment => event.sender.send('paymentSuccessful'))
.catch(error => console.log('sendPayment error: ', error))
payinvoice(lnd, data)
.then(({ payment_route }) => event.sender.send('paymentSuccessful', Object.assign(data, { payment_route })))
.catch(error => console.log('payinvoice error: ', error))
break
case 'openChannel':
// Response is empty. Streaming updates on channel status and updates

2
app/lnd/methods/payinvoice.js

@ -1,5 +1,5 @@
// LND Pay an invoice
export function payinvoice(lnd, { paymentRequest }) {
export default function payinvoice(lnd, { paymentRequest }) {
return new Promise((resolve, reject) => {
lnd.sendPaymentSync({ payment_request: paymentRequest }, (err, data) => {
if (err) { reject(err) }

Loading…
Cancel
Save