Browse Source

feat(invoice): add priv routing hints for light clients

renovate/lint-staged-8.x
Jack Mallers 6 years ago
parent
commit
545285f0c3
  1. 4
      app/lib/lnd/methods/invoicesController.js
  2. 14
      app/reducers/invoice.js
  3. 7
      test/unit/reducers/__snapshots__/activity.spec.js.snap

4
app/lib/lnd/methods/invoicesController.js

@ -7,9 +7,9 @@ import pushinvoices from '../push/subscribeinvoice'
* @param value [description]
* @return [description]
*/
export function addInvoice(lnd, { memo, value }) {
export function addInvoice(lnd, { memo, value, private: privateInvoice }) {
return new Promise((resolve, reject) => {
lnd.addInvoice({ memo, value }, (err, data) => {
lnd.addInvoice({ memo, value, private: privateInvoice }, (err, data) => {
if (err) {
return reject(err)
}

14
app/reducers/invoice.js

@ -1,6 +1,7 @@
import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import { push } from 'react-router-redux'
import Store from 'electron-store'
import { showNotification } from 'lib/utils/notifications'
import { btc } from 'lib/utils'
@ -118,7 +119,18 @@ export const createInvoice = (amount, memo, currency) => dispatch => {
const value = btc.convert(currency, 'sats', amount)
dispatch(sendInvoice())
ipcRenderer.send('lnd', { msg: 'createInvoice', data: { value, memo } })
// Grab the activeConnection type from our local store. If the active connection type is local (light clients using
// neutrino) we will have to flag private as true when creating this invoice. All light cliets open private channels
// (both manual and autopilot ones). In order for these clients to receive money through these channels the invoices
// need to come with routing hints for private channels
const store = new Store({ name: 'settings' })
const { type } = store.get('activeConnection', {})
ipcRenderer.send('lnd', {
msg: 'createInvoice',
data: { value, memo, private: type === 'local' }
})
}
// Receive IPC event for newly created invoice

7
test/unit/reducers/__snapshots__/activity.spec.js.snap

@ -29,6 +29,7 @@ Object {
},
"searchActive": false,
"searchText": "",
"showExpiredRequests": false,
}
`;
@ -63,6 +64,7 @@ Object {
},
"searchActive": false,
"searchText": "",
"showExpiredRequests": false,
}
`;
@ -98,6 +100,7 @@ Object {
},
"searchActive": false,
"searchText": "",
"showExpiredRequests": false,
}
`;
@ -132,6 +135,7 @@ Object {
},
"searchActive": false,
"searchText": "",
"showExpiredRequests": false,
}
`;
@ -167,6 +171,7 @@ Object {
},
"searchActive": false,
"searchText": "",
"showExpiredRequests": false,
}
`;
@ -202,6 +207,7 @@ Object {
},
"searchActive": undefined,
"searchText": "",
"showExpiredRequests": false,
}
`;
@ -237,5 +243,6 @@ Object {
},
"searchActive": false,
"searchText": undefined,
"showExpiredRequests": false,
}
`;

Loading…
Cancel
Save