Browse Source

hotfix(fetchBalance): fetch balance after payments/transactions are sent/received

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
bbb20214d1
  1. 2
      app/lnd/subscribe/index.js
  2. 5
      app/lnd/subscribe/transactions.js
  3. 4
      app/main.dev.js
  4. 4
      app/reducers/balance.js
  5. 4
      app/reducers/invoice.js
  6. 4
      app/reducers/payment.js
  7. 7
      app/reducers/transaction.js
  8. BIN
      resources/bin/darwin/lnd
  9. BIN
      resources/bin/linux/lnd
  10. BIN
      resources/bin/win32/lnd.exe

2
app/lnd/subscribe/index.js

@ -2,6 +2,8 @@ import subscribeToTransactions from './transactions'
import subscribeToInvoices from './invoices' import subscribeToInvoices from './invoices'
export default (mainWindow, lnd) => { export default (mainWindow, lnd) => {
console.log('mainWindow: ', mainWindow)
console.log('lnd: ', lnd)
subscribeToTransactions(mainWindow, lnd) subscribeToTransactions(mainWindow, lnd)
subscribeToInvoices(mainWindow, lnd) subscribeToInvoices(mainWindow, lnd)
} }

5
app/lnd/subscribe/transactions.js

@ -3,7 +3,10 @@
export default function subscribeToTransactions(mainWindow, lnd) { export default function subscribeToTransactions(mainWindow, lnd) {
const call = lnd.subscribeTransactions({}) const call = lnd.subscribeTransactions({})
call.on('data', transaction => mainWindow.send('newTransaction', { transaction })) call.on('data', transaction => {
console.log('TRANSACTION: ', transaction)
mainWindow.send('newTransaction', { transaction })
})
call.on('end', () => console.log('end')) call.on('end', () => console.log('end'))
call.on('error', error => console.log('error: ', error)) call.on('error', error => console.log('error: ', error))
call.on('status', status => console.log('status: ', status)) call.on('status', status => console.log('status: ', status))

4
app/main.dev.js

@ -117,7 +117,6 @@ app.on('ready', async () => {
// After the certs are generated, it's time to start LND // After the certs are generated, it's time to start LND
console.log('STARTING LND') console.log('STARTING LND')
const lndPath = path.join(__dirname, '..', 'resources', 'bin', plat, plat === 'win32' ? 'lnd.exe' : 'lnd') const lndPath = path.join(__dirname, '..', 'resources', 'bin', plat, plat === 'win32' ? 'lnd.exe' : 'lnd')
neutrino = spawn(lndPath, neutrino = spawn(lndPath,
[ [
'--bitcoin.active', '--bitcoin.active',
@ -126,7 +125,8 @@ app.on('ready', async () => {
'--neutrino.connect=faucet.lightning.community:18333', '--neutrino.connect=faucet.lightning.community:18333',
'--autopilot.active', '--autopilot.active',
'--debuglevel=debug', '--debuglevel=debug',
'--no-macaroons' '--no-macaroons',
'--noencryptwallet'
] ]
) )
.on('error', error => console.log(`lnd error: ${error}`)) .on('error', error => console.log(`lnd error: ${error}`))

4
app/reducers/balance.js

@ -21,9 +21,9 @@ export const fetchBalance = () => async (dispatch) => {
} }
// Receive IPC event for balance // Receive IPC event for balance
export const receiveBalance = (event, { walletBalance, channelBalance }) => dispatch => ( export const receiveBalance = (event, { walletBalance, channelBalance }) => dispatch => {
dispatch({ type: RECEIVE_BALANCE, walletBalance, channelBalance }) dispatch({ type: RECEIVE_BALANCE, walletBalance, channelBalance })
) }
// ------------------------------------ // ------------------------------------
// Action Handlers // Action Handlers

4
app/reducers/invoice.js

@ -1,6 +1,7 @@
import { createSelector } from 'reselect' import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import { fetchBalance } from './balance'
import { setFormType } from './form' import { setFormType } from './form'
import { setPayInvoice } from './payform' import { setPayInvoice } from './payform'
import { resetRequestForm } from './requestform' import { resetRequestForm } from './requestform'
@ -120,6 +121,9 @@ export const createdInvoice = (event, invoice) => (dispatch) => {
export const invoiceUpdate = (event, { invoice }) => (dispatch) => { export const invoiceUpdate = (event, { invoice }) => (dispatch) => {
dispatch({ type: UPDATE_INVOICE, invoice }) dispatch({ type: UPDATE_INVOICE, invoice })
// Fetch new balance
dispatch(fetchBalance())
// HTML 5 desktop notification for the invoice update // HTML 5 desktop notification for the invoice update
const notifTitle = 'You\'ve been Zapped' const notifTitle = 'You\'ve been Zapped'
const notifBody = 'Congrats, someone just paid an invoice of yours' const notifBody = 'Congrats, someone just paid an invoice of yours'

4
app/reducers/payment.js

@ -1,5 +1,6 @@
import { createSelector } from 'reselect' import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import { fetchBalance } from './balance'
import { setFormType } from './form' import { setFormType } from './form'
import { resetPayForm } from './payform' import { resetPayForm } from './payform'
import { showModal } from './modal' import { showModal } from './modal'
@ -81,6 +82,9 @@ export const paymentSuccessful = () => (dispatch) => {
// Reset the payment form // Reset the payment form
dispatch(resetPayForm()) dispatch(resetPayForm())
// Fetch new balance
dispatch(fetchBalance())
} }

7
app/reducers/transaction.js

@ -1,6 +1,7 @@
import { ipcRenderer } from 'electron' import { ipcRenderer } from 'electron'
import { showNotification } from '../notifications' import { showNotification } from '../notifications'
import { btc, usd } from '../utils' import { btc, usd } from '../utils'
import { fetchBalance } from './balance'
import { setFormType } from './form' import { setFormType } from './form'
import { resetPayForm } from './payform' import { resetPayForm } from './payform'
import { showModal } from './modal' import { showModal } from './modal'
@ -60,6 +61,8 @@ export const transactionSuccessful = (event, { amount, addr, txid }) => (dispatc
// TODO: Add successful on-chain payment to payments list once payments list supports on-chain and LN // TODO: Add successful on-chain payment to payments list once payments list supports on-chain and LN
// dispatch({ type: PAYMENT_SUCCESSFULL, payment: { amount, addr, txid, pending: true } }) // dispatch({ type: PAYMENT_SUCCESSFULL, payment: { amount, addr, txid, pending: true } })
dispatch({ type: TRANSACTION_SUCCESSFULL }) dispatch({ type: TRANSACTION_SUCCESSFULL })
// Fetch new balance
dispatch(fetchBalance())
// Reset the payment form // Reset the payment form
dispatch(resetPayForm()) dispatch(resetPayForm())
} }
@ -70,6 +73,10 @@ export const transactionError = () => (dispatch) => {
// Listener for when a new transaction is pushed from the subscriber // Listener for when a new transaction is pushed from the subscriber
export const newTransaction = (event, { transaction }) => (dispatch) => { export const newTransaction = (event, { transaction }) => (dispatch) => {
console.log('transaction: ', transaction)
// Fetch new balance
dispatch(fetchBalance())
dispatch({ type: ADD_TRANSACTION, transaction }) dispatch({ type: ADD_TRANSACTION, transaction })
// HTML 5 desktop notification for the new transaction // HTML 5 desktop notification for the new transaction

BIN
resources/bin/darwin/lnd

Binary file not shown.

BIN
resources/bin/linux/lnd

Binary file not shown.

BIN
resources/bin/win32/lnd.exe

Binary file not shown.
Loading…
Cancel
Save