|
@ -1,4 +1,5 @@ |
|
|
import { createSelector } from 'reselect' |
|
|
import { createSelector } from 'reselect' |
|
|
|
|
|
import { ipcRenderer } from 'electron' |
|
|
import { callApi } from '../api' |
|
|
import { callApi } from '../api' |
|
|
import { btc, usd } from '../utils' |
|
|
import { btc, usd } from '../utils' |
|
|
// ------------------------------------
|
|
|
// ------------------------------------
|
|
@ -63,13 +64,6 @@ export function getInvoices() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export function receiveInvoices(data) { |
|
|
|
|
|
return { |
|
|
|
|
|
type: RECEIVE_INVOICES, |
|
|
|
|
|
invoices: data.invoices.reverse() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function sendInvoice() { |
|
|
export function sendInvoice() { |
|
|
return { |
|
|
return { |
|
|
type: SEND_INVOICE |
|
|
type: SEND_INVOICE |
|
@ -101,18 +95,15 @@ export const fetchInvoice = payreq => async (dispatch) => { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Send IPC event for invoices
|
|
|
export const fetchInvoices = () => async (dispatch) => { |
|
|
export const fetchInvoices = () => async (dispatch) => { |
|
|
dispatch(getInvoice()) |
|
|
dispatch(getInvoices()) |
|
|
const invoices = await callApi('invoices') |
|
|
ipcRenderer.send('lnd', { msg: 'invoices' }) |
|
|
if (invoices) { |
|
|
|
|
|
dispatch(receiveInvoices(invoices.data)) |
|
|
|
|
|
} else { |
|
|
|
|
|
dispatch(invoiceFailed()) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return invoices |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Receive IPC event for invoices
|
|
|
|
|
|
export const receiveInvoices = (event, { invoices }) => dispatch => dispatch({ type: RECEIVE_INVOICES, invoices }) |
|
|
|
|
|
|
|
|
export const createInvoice = (amount, memo, currency, rate) => async (dispatch) => { |
|
|
export const createInvoice = (amount, memo, currency, rate) => async (dispatch) => { |
|
|
const value = currency === 'btc' ? btc.btcToSatoshis(amount) : btc.btcToSatoshis(usd.usdToBtc(amount, rate)) |
|
|
const value = currency === 'btc' ? btc.btcToSatoshis(amount) : btc.btcToSatoshis(usd.usdToBtc(amount, rate)) |
|
|
|
|
|
|
|
|