Browse Source

fix(lnd-ipc): fix linting errors

renovate/lint-staged-8.x
Jack Mallers 8 years ago
parent
commit
6c87563aa2
  1. 34
      app/api/index.js
  2. 7
      app/lnd/config/index.js
  3. 2
      app/lnd/index.js
  4. 9
      app/lnd/lib/lightning.js
  5. 3
      app/lnd/methods/allchannels.js
  6. 2
      app/lnd/methods/channelbalance.js
  7. 2
      app/lnd/methods/channels.js
  8. 4
      app/lnd/methods/createinvoice.js
  9. 156
      app/lnd/methods/index.js
  10. 8
      app/lnd/methods/invoice.js
  11. 4
      app/lnd/methods/invoices.js
  12. 23
      app/lnd/methods/openchannel.js
  13. 4
      app/lnd/methods/payinvoice.js
  14. 4
      app/lnd/methods/payments.js
  15. 2
      app/lnd/methods/peers.js
  16. 2
      app/lnd/methods/pendingchannels.js
  17. 2
      app/lnd/methods/walletbalance.js
  18. 6
      app/lnd/push/channel.js
  19. 15
      app/lnd/utils/index.js
  20. 54
      app/reducers/activity.js
  21. 7
      app/reducers/balance.js
  22. 12
      app/reducers/channels.js
  23. 4
      app/reducers/index.js
  24. 6
      app/reducers/invoice.js
  25. 34
      app/reducers/ipc.js
  26. 6
      app/reducers/payment.js
  27. 12
      app/reducers/peers.js
  28. 2
      app/reducers/ticker.js
  29. 3
      app/routes/app/components/App.js
  30. 1
      app/routes/wallet/components/components/Channels/components/ChannelForm/ChannelForm.js

34
app/api/index.js

@ -1,38 +1,6 @@
import axios from 'axios'
export function callApi(endpoint, method = 'get', data = null) {
const BASE_URL = 'http://localhost:3000/api/'
let payload
if (data) {
payload = {
headers: {
'Content-Type': 'application/json'
},
method,
data,
url: `${BASE_URL}${endpoint}`
}
} else {
payload = {
headers: {
'Content-Type': 'application/json'
},
method,
url: `${BASE_URL}${endpoint}`
}
}
return axios(payload)
.then(response => response.data)
.catch(error => error)
}
export function callApis(endpoints) {
return axios.all(endpoints.map(endpoint => callApi(endpoint)))
}
export function requestTicker() {
export default function requestTicker() {
const BASE_URL = 'https://api.coinmarketcap.com/v1/ticker/bitcoin/'
return axios({
method: 'get',

7
app/lnd/config/index.js

@ -1,4 +1,9 @@
// Cert will be located depending on your machine
// Mac OS X: /Users/user/Library/Application Support/Lnd/tls.cert
// Linux: ~/.lnd/tls.cert
// Windows: TODO find out where cert is located for windows machine
export default {
lightningRpc: `${__dirname}/rpc.proto`,
lightningHost: 'localhost:10009'
lightningHost: 'localhost:10009',
cert: '/Users/jmow/Library/Application Support/Lnd/tls.cert'
}

2
app/lnd/index.js

@ -4,4 +4,4 @@ import methods from './methods'
const lnd = lightning(config.lightningRpc, config.lightningHost)
export default (event, msg, data) => methods(lnd, event, msg, data)
export default (event, msg, data) => methods(lnd, event, msg, data)

9
app/lnd/lib/lightning.js

@ -1,13 +1,14 @@
import fs from 'fs'
import grpc from 'grpc'
import config from '../config'
module.exports = (path, host, cert) => {
process.env['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
module.exports = (path, host) => {
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA'
const rpc = grpc.load(path)
const lndCert = fs.readFileSync('/Users/jmow/Library/Application Support/Lnd/tls.cert')
const lndCert = fs.readFileSync(config.cert)
const credentials = grpc.credentials.createSsl(lndCert)
return new rpc.lnrpc.Lightning(host, credentials)
}
}

3
app/lnd/methods/allchannels.js

@ -1,3 +0,0 @@
export default function(channels, pendingchannels) {
return Promise.all([channels, pendingchannels])
}

2
app/lnd/methods/channelbalance.js

@ -7,4 +7,4 @@ export default function channelbalance(lnd) {
resolve(data)
})
})
}
}

2
app/lnd/methods/channels.js

@ -7,4 +7,4 @@ export default function channels(lnd) {
resolve(data)
})
})
}
}

4
app/lnd/methods/createinvoice.js

@ -3,8 +3,8 @@ export default function createInvoice(lnd, { memo, value }) {
return new Promise((resolve, reject) => {
lnd.addInvoice({ memo, value }, (err, data) => {
if (err) { reject(err) }
resolve(data)
})
})
}
}

156
app/lnd/methods/index.js

@ -1,4 +1,3 @@
import allchannels from './allchannels'
import channelbalance from './channelbalance'
import channels from './channels'
import connectpeer from './connectpeer'
@ -14,94 +13,101 @@ import peers from './peers'
import pendingchannels from './pendingchannels'
import walletbalance from './walletbalance'
export default function(lnd, event, msg, data) {
switch(msg) {
export default function (lnd, event, msg, data) {
switch (msg) {
case 'info':
info(lnd)
.then(info =>event.sender.send('receiveInfo', info))
.catch(error => console.log('info error: ', error))
break
case 'peers':
info(lnd)
.then(infoData => event.sender.send('receiveInfo', infoData))
.catch(error => console.log('info error: ', error))
break
case 'peers':
// Data looks like { peers: [] }
peers(lnd)
.then(peers => event.sender.send('receivePeers', peers))
.catch(error => console.log('peers error: ', error))
break
case 'channels':
// Data looks like [ { channels: [channel, channel, channel] }, { total_limbo_balance: 0, pending_open_channels: [], pending_closing_channels: [], pending_force_closing_channels: [] } ]
Promise.all([channels, pendingchannels].map(func => func(lnd)))
.then(data => event.sender.send('receiveChannels', { channels: data[0].channels, pendingChannels: data[1] }))
.catch(error => console.log('channels error: ', error))
break
case 'payments':
peers(lnd)
.then(peersData => event.sender.send('receivePeers', peersData))
.catch(error => console.log('peers error: ', error))
break
case 'channels':
// Data looks like
// [ { channels: [] }, { total_limbo_balance: 0, pending_open_channels: [], pending_closing_channels: [], pending_force_closing_channels: [] } ]
Promise.all([channels, pendingchannels].map(func => func(lnd)))
.then(channelsData =>
event.sender.send('receiveChannels', { channels: channelsData[0].channels, pendingChannels: channelsData[1] })
)
.catch(error => console.log('channels error: ', error))
break
case 'payments':
// Data looks like { payments: [] }
payments(lnd)
.then(payments => event.sender.send('receivePayments', payments))
.catch(error => console.log('payments error: ', error))
break
case 'invoices':
payments(lnd)
.then(paymentsData => event.sender.send('receivePayments', paymentsData))
.catch(error => console.log('payments error: ', error))
break
case 'invoices':
// Data looks like { invoices: [] }
invoices(lnd)
.then(invoices => event.sender.send('receiveInvoices', invoices))
.catch(error => console.log('invoices error: ', error))
break
case 'invoice':
invoices(lnd)
.then(invoicesData => event.sender.send('receiveInvoices', invoicesData))
.catch(error => console.log('invoices error: ', error))
break
case 'invoice':
// Data looks like { invoices: [] }
invoice(data.payreq)
.then(invoice => event.sender.send('receiveInvoice', invoice))
.catch(error => console.log('invoice error: ', error))
break
case 'balance':
invoice(data.payreq)
.then(invoiceData => event.sender.send('receiveInvoice', invoiceData))
.catch(error => console.log('invoice error: ', error))
break
case 'balance':
// Balance looks like [ { balance: '129477456' }, { balance: '243914' } ]
Promise.all([walletbalance, channelbalance].map(func => func(lnd)))
.then(balance => event.sender.send('receiveBalance', { walletBalance: balance[0].balance, channelBalance: balance[1].balance }))
.catch(error => console.log('balance error: ', error))
break
case 'createInvoice':
Promise.all([walletbalance, channelbalance].map(func => func(lnd)))
.then(balance => event.sender.send('receiveBalance', { walletBalance: balance[0].balance, channelBalance: balance[1].balance }))
.catch(error => console.log('balance error: ', error))
break
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: 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':
createinvoice(lnd, data)
.then(newinvoice =>
event.sender.send(
'createdInvoice',
Object.assign(newinvoice, { memo: data.memo, value: data.value, r_hash: new Buffer(newinvoice.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
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':
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
// { pubkey, localamt, pushamt } = data
openchannel(lnd, event, data)
.then(channel => {
console.log('CHANNEL: ', channel)
event.sender.send('channelSuccessful', { channel })
})
.catch(error => console.log('openChannel error: ', error))
break
case 'connectPeer':
openchannel(lnd, event, data)
.then((channel) => {
console.log('CHANNEL: ', channel)
event.sender.send('channelSuccessful', { channel })
})
.catch(error => console.log('openChannel error: ', error))
break
case 'connectPeer':
// Returns a peer_id. Pass the pubkey, host and peer_id so we can add a new peer to the list
// { pubkey, host } = data
connectpeer(lnd, data)
.then(({ peer_id }) => {
console.log('peer_id: ', peer_id)
event.sender.send('connectSuccess', { pub_key: data.pubkey, address: data.host, peer_id })
})
.catch(error => console.log('connectPeer error: ', error))
break
case 'disconnectPeer':
connectpeer(lnd, data)
.then(({ peer_id }) => {
console.log('peer_id: ', peer_id)
event.sender.send('connectSuccess', { pub_key: data.pubkey, address: data.host, peer_id })
})
.catch(error => console.log('connectPeer error: ', error))
break
case 'disconnectPeer':
// Empty response. Pass back pubkey on success to remove it from the peers list
// { pubkey } = data
disconnectpeer(lnd, data)
.then(() => {
console.log('pubkey: ', data.pubkey)
event.sender.send('disconnectSuccess', { pubkey: data.pubkey })
})
.catch(error => console.log('disconnectPeer error: ', error))
break
default:
return
disconnectpeer(lnd, data)
.then(() => {
console.log('pubkey: ', data.pubkey)
event.sender.send('disconnectSuccess', { pubkey: data.pubkey })
})
.catch(error => console.log('disconnectPeer error: ', error))
break
default:
}
}
}

8
app/lnd/methods/invoice.js

@ -3,6 +3,10 @@ import { decodeInvoice } from '../utils'
// LND Get Invoice
export default function invoice(payreq) {
return new Promise((resolve, reject) => {
resolve(decodeInvoice(payreq))
try {
resolve(decodeInvoice(payreq))
} catch (error) {
reject(error)
}
})
}
}

4
app/lnd/methods/invoices.js

@ -3,8 +3,8 @@ export default function invoices(lnd) {
return new Promise((resolve, reject) => {
lnd.listInvoices({}, (err, data) => {
if (err) { reject(err) }
resolve(data)
})
})
}
}

23
app/lnd/methods/openchannel.js

@ -1,18 +1,19 @@
import pushchannel from '../push/channel'
import bitcore from 'bitcore-lib'
import pushchannel from '../push/channel'
const BufferUtil = bitcore.util.buffer
export default function openchannel(lnd, event, data) {
const { pubkey, localamt, pushamt } = data
const payload = {
export default function openchannel(lnd, event, payload) {
const { pubkey, localamt, pushamt } = payload
const res = {
node_pubkey: BufferUtil.hexToBuffer(pubkey),
local_funding_amount: Number(localamt),
push_sat: Number(pushamt)
local_funding_amount: Number(localamt),
push_sat: Number(pushamt)
}
return new Promise((resolve, reject) =>
pushchannel(lnd, event, payload)
.then(data => resolve(data))
.catch(error => reject(err))
return new Promise((resolve, reject) =>
pushchannel(lnd, event, res)
.then(data => resolve(data))
.catch(error => reject(error))
)
}
}

4
app/lnd/methods/payinvoice.js

@ -3,8 +3,8 @@ export default function payinvoice(lnd, { paymentRequest }) {
return new Promise((resolve, reject) => {
lnd.sendPaymentSync({ payment_request: paymentRequest }, (err, data) => {
if (err) { reject(err) }
resolve(data)
})
})
}
}

4
app/lnd/methods/payments.js

@ -3,8 +3,8 @@ export default function payments(lnd) {
return new Promise((resolve, reject) => {
lnd.listPayments({}, (err, data) => {
if (err) { reject(err) }
resolve(data)
})
})
}
}

2
app/lnd/methods/peers.js

@ -7,4 +7,4 @@ export default function peers(lnd) {
resolve(data)
})
})
}
}

2
app/lnd/methods/pendingchannels.js

@ -7,4 +7,4 @@ export default function channels(lnd) {
resolve(data)
})
})
}
}

2
app/lnd/methods/walletbalance.js

@ -7,4 +7,4 @@ export default function walletbalance(lnd) {
resolve(data)
})
})
}
}

6
app/lnd/push/channel.js

@ -2,15 +2,15 @@ export default function pushchannel(lnd, event, payload) {
return new Promise((resolve, reject) => {
try {
const call = lnd.openChannel(payload)
call.on('data', data => event.sender.send('pushchannelupdated', { data }))
call.on('end', () => event.sender.send('pushchannelend'))
call.on('error', error => event.sender.send('pushchannelerror', { error }))
call.on('status', status => event.sender.send('pushchannelstatus', { status }))
resolve(null, payload)
} catch (error) {
reject(error, null)
}
})
}
}

15
app/lnd/utils/index.js

@ -3,8 +3,8 @@ import zbase32 from 'zbase32'
function convertBigEndianBufferToLong(longBuffer) {
let longValue = 0
const byteArray = Buffer.from(longBuffer).swap64()
for (let i = byteArray.length - 1; i >= 0; i--) {
for (let i = byteArray.length - 1; i >= 0; i -= 1) {
longValue = (longValue * 256) + byteArray[i]
}
@ -19,9 +19,6 @@ export function decodeInvoice(payreq) {
+ bufferHexRotated.substr(0, bufferHexRotated.length - 1)
const buffer = Buffer.from(bufferHex, 'hex')
const pubKeyBuffer = buffer.slice(0, 33)
const pubKeyHex = pubKeyBuffer.toString('hex')
const paymentHashBuffer = buffer.slice(33, 65)
const paymentHashHex = paymentHashBuffer.toString('hex')
@ -32,6 +29,10 @@ export function decodeInvoice(payreq) {
return {
payreq,
amount,
r_hash: paymentHashHex,
r_hash: paymentHashHex
}
}
}
export default {
decodeInvoice
}

54
app/reducers/activity.js

@ -1,54 +0,0 @@
import { callApis } from '../api'
// ------------------------------------
// Constants
// ------------------------------------
export const GET_ACTIVITY = 'GET_ACTIVITY'
export const RECEIVE_ACTIVITY = 'RECEIVE_ACTIVITY'
// ------------------------------------
// Actions
// ------------------------------------
export function getActivity() {
return {
type: GET_ACTIVITY
}
}
export function receiveActvity(data) {
return {
type: RECEIVE_ACTIVITY,
payments: data[0].data.payments.reverse(),
invoices: data[1].data.invoices.reverse()
}
}
export const fetchActivity = () => async (dispatch) => {
dispatch(getActivity())
const activity = await callApis(['payments', 'invoices'])
dispatch(receiveActvity(activity))
}
// ------------------------------------
// Action Handlers
// ------------------------------------
const ACTION_HANDLERS = {
[GET_ACTIVITY]: state => ({ ...state, activityLoading: true }),
[RECEIVE_ACTIVITY]: (state, { payments, invoices }) => (
{ ...state, activityLoading: false, payments, invoices }
)
}
// ------------------------------------
// Reducer
// ------------------------------------
const initialState = {
activityLoading: false,
payments: [],
invoices: []
}
export default function activityReducer(state = initialState, action) {
const handler = ACTION_HANDLERS[action.type]
return handler ? handler(state, action) : state
}

7
app/reducers/balance.js

@ -14,13 +14,16 @@ export function getBalance() {
}
}
// Send IPC event for balance
export const fetchBalance = () => async (dispatch) => {
dispatch(getBalance())
ipcRenderer.send('lnd', { msg: 'balance' })
}
// Receive IPC event for peers
export const receiveBalance = (event, { walletBalance, channelBalance }) => dispatch => dispatch({ type: RECEIVE_BALANCE, walletBalance, channelBalance })
// Receive IPC event for balance
export const receiveBalance = (event, { walletBalance, channelBalance }) => dispatch => (
dispatch({ type: RECEIVE_BALANCE, walletBalance, channelBalance })
)
// ------------------------------------
// Action Handlers

12
app/reducers/channels.js

@ -66,34 +66,34 @@ export const fetchChannels = () => async (dispatch) => {
export const receiveChannels = (event, { channels, pendingChannels }) => dispatch => dispatch({ type: RECEIVE_CHANNELS, channels, pendingChannels })
// Send IPC event for opening a channel
export const openChannel = ({ pubkey, localamt, pushamt }) => dispatch => {
export const openChannel = ({ pubkey, localamt, pushamt }) => (dispatch) => {
dispatch(openingChannel())
ipcRenderer.send('lnd', { msg: 'openChannel', data: { pubkey, localamt, pushamt } })
}
// TODO: Decide how to handle streamed updates for channels
// Receive IPC event for openChannel
export const channelSuccessful = (event, { channel }) => dispatch => {
export const channelSuccessful = () => (dispatch) => {
dispatch(fetchChannels())
}
// Receive IPC event for updated channel
export const pushchannelupdated = (event, data) => dispatch => {
export const pushchannelupdated = () => (dispatch) => {
dispatch(fetchChannels())
}
// Receive IPC event for channel end
export const pushchannelend = (event, data) => dispatch => {
export const pushchannelend = () => (dispatch) => {
dispatch(fetchChannels())
}
// Receive IPC event for channel error
export const pushchannelerror = (event, data) => dispatch => {
export const pushchannelerror = () => (dispatch) => {
dispatch(fetchChannels())
}
// Receive IPC event for channel status
export const pushchannelstatus = (event, data) => dispatch => {
export const pushchannelstatus = () => (dispatch) => {
dispatch(fetchChannels())
}

4
app/reducers/index.js

@ -9,7 +9,6 @@ import peers from './peers'
import channels from './channels'
import form from './form'
import invoice from './invoice'
import activity from './activity'
const rootReducer = combineReducers({
router,
@ -20,8 +19,7 @@ const rootReducer = combineReducers({
peers,
channels,
form,
invoice,
activity
invoice
})
export default rootReducer

6
app/reducers/invoice.js

@ -69,7 +69,7 @@ export function invoiceFailed() {
}
// Send IPC event for a specific invoice
export const fetchInvoice = payreq => dispatch => {
export const fetchInvoice = payreq => (dispatch) => {
dispatch(getInvoice())
ipcRenderer.send('lnd', { msg: 'invoice', data: { payreq } })
}
@ -78,7 +78,7 @@ export const fetchInvoice = payreq => dispatch => {
export const receiveFormInvoice = (event, formInvoice) => dispatch => dispatch({ type: RECEIVE_FORM_INVOICE, formInvoice })
// Send IPC event for invoices
export const fetchInvoices = () => dispatch => {
export const fetchInvoices = () => (dispatch) => {
dispatch(getInvoices())
ipcRenderer.send('lnd', { msg: 'invoices' })
}
@ -87,7 +87,7 @@ export const fetchInvoices = () => dispatch => {
export const receiveInvoices = (event, { invoices }) => dispatch => dispatch({ type: RECEIVE_INVOICES, invoices })
// Send IPC event for creating an invoice
export const createInvoice = (amount, memo, currency, rate) => dispatch => {
export const createInvoice = (amount, memo, currency, rate) => (dispatch) => {
const value = currency === 'btc' ? btc.btcToSatoshis(amount) : btc.btcToSatoshis(usd.usdToBtc(amount, rate))
dispatch(sendInvoice())
ipcRenderer.send('lnd', { msg: 'createInvoice', data: { value, memo } })

34
app/reducers/ipc.js

@ -15,22 +15,22 @@ import { receiveBalance } from './balance'
// Import all receiving IPC event handlers and pass them into createIpc
const ipc = createIpc({
'receiveInfo': receiveInfo,
'receivePeers': receivePeers,
'receiveChannels': receiveChannels,
'receivePayments': receivePayments,
'receiveInvoices': receiveInvoices,
'receiveInvoice': receiveFormInvoice,
'receiveBalance': receiveBalance,
'createdInvoice': createdInvoice,
'paymentSuccessful': paymentSuccessful,
'channelSuccessful': channelSuccessful,
'pushchannelupdated': pushchannelupdated,
'pushchannelend': pushchannelend,
'pushchannelerror': pushchannelerror,
'pushchannelstatus': pushchannelstatus,
'connectSuccess': connectSuccess,
'disconnectSuccess': disconnectSuccess
receiveInfo,
receivePeers,
receiveChannels,
receivePayments,
receiveInvoices,
receiveInvoice: receiveFormInvoice,
receiveBalance,
createdInvoice,
paymentSuccessful,
channelSuccessful,
pushchannelupdated,
pushchannelend,
pushchannelerror,
pushchannelstatus,
connectSuccess,
disconnectSuccess
})
export default ipc
export default ipc

6
app/reducers/payment.js

@ -1,6 +1,5 @@
import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import { callApi } from '../api'
// ------------------------------------
// Constants
@ -50,7 +49,7 @@ export function paymentFailed() {
}
// Send IPC event for payments
export const fetchPayments = () => dispatch => {
export const fetchPayments = () => (dispatch) => {
dispatch(getPayments())
ipcRenderer.send('lnd', { msg: 'payments' })
}
@ -58,12 +57,13 @@ export const fetchPayments = () => dispatch => {
// Receive IPC event for payments
export const receivePayments = (event, { payments }) => dispatch => dispatch({ type: RECEIVE_PAYMENTS, payments })
export const payInvoice = paymentRequest => dispatch => {
export const payInvoice = paymentRequest => (dispatch) => {
dispatch(sendPayment())
ipcRenderer.send('lnd', { msg: 'sendPayment', data: { paymentRequest } })
}
// Receive IPC event for successful payment
// TODO: Add payment to state, not a total re-fetch
export const paymentSuccessful = () => fetchPayments()

12
app/reducers/peers.js

@ -75,7 +75,7 @@ export const fetchPeers = () => async (dispatch) => {
export const receivePeers = (event, { peers }) => dispatch => dispatch({ type: RECEIVE_PEERS, peers })
// Send IPC event for connecting to a peer
export const connectRequest = ({ pubkey, host }) => dispatch => {
export const connectRequest = ({ pubkey, host }) => (dispatch) => {
dispatch(connectPeer())
ipcRenderer.send('lnd', { msg: 'connectPeer', data: { pubkey, host } })
}
@ -84,7 +84,7 @@ export const connectRequest = ({ pubkey, host }) => dispatch => {
export const connectSuccess = (event, peer) => dispatch => dispatch({ type: CONNECT_SUCCESS, peer })
// Send IPC send for disconnecting from a peer
export const disconnectRequest = ({ pubkey }) => dispatch => {
export const disconnectRequest = ({ pubkey }) => (dispatch) => {
dispatch(disconnectPeer())
ipcRenderer.send('lnd', { msg: 'disconnectPeer', data: { pubkey } })
}
@ -97,11 +97,15 @@ export const disconnectSuccess = (event, { pubkey }) => dispatch => dispatch({ t
// ------------------------------------
const ACTION_HANDLERS = {
[DISCONNECT_PEER]: state => ({ ...state, disconnecting: true }),
[DISCONNECT_SUCCESS]: (state, { pubkey }) => ({ ...state, disconnecting: false, peer: null, peers: state.peers.filter(peer => peer.pub_key !== pubkey) }),
[DISCONNECT_SUCCESS]: (state, { pubkey }) => (
{ ...state, disconnecting: false, peer: null, peers: state.peers.filter(peer => peer.pub_key !== pubkey) }
),
[DISCONNECT_FAILURE]: state => ({ ...state, disconnecting: false }),
[CONNECT_PEER]: state => ({ ...state, connecting: true }),
[CONNECT_SUCCESS]: (state, { peer }) => ({ ...state, connecting: false, peerForm: { pubkey: '', host: '', isOpen: false }, peers: [...state.peers, peer] }),
[CONNECT_SUCCESS]: (state, { peer }) => (
{ ...state, connecting: false, peerForm: { pubkey: '', host: '', isOpen: false }, peers: [...state.peers, peer] }
),
[CONNECT_FAILURE]: state => ({ ...state, connecting: false }),
[SET_PEER_FORM]: (state, { form }) => ({ ...state, peerForm: Object.assign({}, state.peerForm, form) }),

2
app/reducers/ticker.js

@ -1,4 +1,4 @@
import { requestTicker } from '../api'
import requestTicker from '../api'
// ------------------------------------
// Constants
// ------------------------------------

3
app/routes/app/components/App.js

@ -1,4 +1,3 @@
import { ipcRenderer } from 'electron'
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import Form from './components/Form'
@ -29,7 +28,6 @@ class App extends Component {
setForm,
createInvoice,
payInvoice,
fetchChannels,
fetchInvoice,
children
} = this.props
@ -83,7 +81,6 @@ App.propTypes = {
setForm: PropTypes.func.isRequired,
createInvoice: PropTypes.func.isRequired,
payInvoice: PropTypes.func.isRequired,
fetchChannels: PropTypes.func.isRequired,
fetchInvoice: PropTypes.func.isRequired,
children: PropTypes.object.isRequired
}

1
app/routes/wallet/components/components/Channels/components/ChannelForm/ChannelForm.js

@ -14,7 +14,6 @@ const ChannelForm = ({ form, setForm, ticker, peers, openChannel }) => {
openChannel({ pubkey: node_key, localamt, pushamt })
setForm({ isOpen: false })
}
const customStyles = {

Loading…
Cancel
Save