diff --git a/.eslintrc b/.eslintrc
index c67c328e..096e0b74 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -11,7 +11,7 @@
},
"rules": {
"comma-dangle": ["error", "never"],
- "semi": 0,
+ "semi": ["error", "never"],
"indent": 2,
"jsx-quotes": ["error", "prefer-single"],
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
diff --git a/app/components/ChannelForm/StepOne.js b/app/components/ChannelForm/StepOne.js
index 0a92df0e..b7aac4e1 100644
--- a/app/components/ChannelForm/StepOne.js
+++ b/app/components/ChannelForm/StepOne.js
@@ -5,7 +5,7 @@ import styles from './StepOne.scss'
class StepOne extends Component {
constructor(props) {
- super(props);
+ super(props)
this.state = {
peers: props.peers,
searchQuery: ''
diff --git a/app/components/LndSyncing/LndSyncing.js b/app/components/LndSyncing/LndSyncing.js
index 176a9c27..09d35047 100644
--- a/app/components/LndSyncing/LndSyncing.js
+++ b/app/components/LndSyncing/LndSyncing.js
@@ -4,7 +4,7 @@ import styles from './LndSyncing.scss'
class LndSyncing extends Component {
constructor(props) {
- super(props);
+ super(props)
this.state = {
facts: [
{
diff --git a/app/containers/Root.js b/app/containers/Root.js
index e54a8840..da0e6794 100644
--- a/app/containers/Root.js
+++ b/app/containers/Root.js
@@ -3,9 +3,10 @@ import React from 'react'
import { Provider, connect } from 'react-redux'
import { ConnectedRouter } from 'react-router-redux'
import PropTypes from 'prop-types'
-import { fetchBlockHeight, lndSelectors } from 'reducers/lnd'
-import LoadingBolt from 'components/LoadingBolt'
-import LndSyncing from 'components/LndSyncing'
+
+import LoadingBolt from '../components/LoadingBolt'
+import LndSyncing from '../components/LndSyncing'
+import { fetchBlockHeight, lndSelectors } from '../reducers/lnd'
import Routes from '../routes'
const mapDispatchToProps = {
@@ -18,11 +19,6 @@ const mapStateToProps = state => ({
syncPercentage: lndSelectors.syncPercentage(state)
})
-type RootType = {
- store: {},
- history: {}
-};
-
const Root = ({
store,
history,
@@ -40,7 +36,7 @@ const Root = ({
/>
)
}
-
+
// Don't launch the app without gRPC connection
if (!lnd.grpcStarted) { return }
diff --git a/app/index.js b/app/index.js
index f7d279f0..c260f491 100644
--- a/app/index.js
+++ b/app/index.js
@@ -1,27 +1,27 @@
-import React from 'react';
-import { render } from 'react-dom';
-import { AppContainer } from 'react-hot-loader';
-import Root from './containers/Root';
-import { configureStore, history } from './store/configureStore';
-import './app.global.scss';
+import React from 'react'
+import { render } from 'react-dom'
+import { AppContainer } from 'react-hot-loader'
+import Root from './containers/Root'
+import { configureStore, history } from './store/configureStore'
+import './app.global.scss'
-const store = configureStore();
+const store = configureStore()
render(
,
document.getElementById('root')
-);
+)
if (module.hot) {
module.hot.accept('./containers/Root', () => {
- const NextRoot = require('./containers/Root'); // eslint-disable-line global-require
+ const NextRoot = require('./containers/Root') // eslint-disable-line global-require
render(
,
document.getElementById('root')
- );
- });
+ )
+ })
}
diff --git a/app/lnd/config/index.js b/app/lnd/config/index.js
index fb37f404..c0366490 100644
--- a/app/lnd/config/index.js
+++ b/app/lnd/config/index.js
@@ -8,7 +8,7 @@ import { join } from 'path'
let loc
switch (platform()) {
case 'darwin':
- loc = 'Library/Application\ Support/Lnd/tls.cert'
+ loc = 'Library/Application Support/Lnd/tls.cert'
break
case 'linux':
loc = '.lnd/tls.cert'
diff --git a/app/lnd/lib/lightning.js b/app/lnd/lib/lightning.js
index a289e39d..f01c0ed1 100644
--- a/app/lnd/lib/lightning.js
+++ b/app/lnd/lib/lightning.js
@@ -6,7 +6,7 @@ import config from '../config'
module.exports = (rpcpath, host) => {
const lndCert = fs.readFileSync(config.cert)
const credentials = grpc.credentials.createSsl(lndCert)
-
+
const rpc = grpc.load(path.join(__dirname, 'rpc.proto'))
return new rpc.lnrpc.Lightning(host, credentials)
diff --git a/app/lnd/utils/index.js b/app/lnd/utils/index.js
new file mode 100644
index 00000000..6fa3f7c6
--- /dev/null
+++ b/app/lnd/utils/index.js
@@ -0,0 +1,42 @@
+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 -= 1) {
+ longValue = (longValue * 256) + byteArray[i]
+ }
+
+ return longValue
+}
+
+export function decodeInvoice(payreq) {
+ const payreqBase32 = zbase32.decode(payreq)
+
+ const bufferHexRotated = Buffer.from(payreqBase32).toString('hex')
+ const bufferHex = bufferHexRotated.substr(bufferHexRotated.length - 1, bufferHexRotated.length)
+ + bufferHexRotated.substr(0, bufferHexRotated.length - 1)
+ const buffer = Buffer.from(bufferHex, 'hex')
+
+ const pubkeyBuffer = buffer.slice(0, 33)
+ const pubkey = pubkeyBuffer.toString('hex')
+
+ const paymentHashBuffer = buffer.slice(33, 65)
+ const paymentHashHex = paymentHashBuffer.toString('hex')
+
+ const valueBuffer = buffer.slice(65, 73)
+
+ const amount = convertBigEndianBufferToLong(valueBuffer)
+
+ return {
+ payreq,
+ pubkey,
+ amount,
+ r_hash: paymentHashHex
+ }
+}
+
+export default {
+ decodeInvoice
+}
diff --git a/app/reducers/address.js b/app/reducers/address.js
index 7ecb63f5..fb676836 100644
--- a/app/reducers/address.js
+++ b/app/reducers/address.js
@@ -5,7 +5,7 @@ import { ipcRenderer } from 'electron'
export const GET_ADDRESS = 'GET_ADDRESS'
export const RECEIVE_ADDRESS = 'RECEIVE_ADDRESS'
-// LND expects types to be sent as int, so this object will allow mapping from string to int
+// LND expects types to be sent as int, so this object will allow mapping from string to int
const addressTypes = {
p2wkh: 0,
np2wkh: 1,
diff --git a/app/reducers/channels.js b/app/reducers/channels.js
index 0a919805..a8457bf2 100644
--- a/app/reducers/channels.js
+++ b/app/reducers/channels.js
@@ -200,13 +200,13 @@ export const channelGraphData = (event, data) => (dispatch, getState) => {
dispatch(fetchDescribeNetwork())
// loop through the channel updates
- for (let i = 0; i < channel_updates.length; i++) {
+ for (let i = 0; i < channel_updates.length; i += 1) {
const channel_update = channel_updates[i]
const { advertising_node, connecting_node } = channel_update
// if our node is involved in this update we wanna show a notification
if (info.data.identity_pubkey === advertising_node || info.data.identity_pubkey === connecting_node) {
- // this channel has to do with the user, lets fetch a new channel list for them
+ // this channel has to do with the user, lets fetch a new channel list for them
// TODO: full fetch is probably not necessary
dispatch(fetchChannels())
diff --git a/app/reducers/lnd.js b/app/reducers/lnd.js
index 997fec38..eaa19de3 100644
--- a/app/reducers/lnd.js
+++ b/app/reducers/lnd.js
@@ -59,7 +59,7 @@ export const lndStdout = (event, line) => (dispatch) => {
trimmed = line.slice(line.indexOf('Catching up block hashes to height') + 'Catching up block hashes to height'.length).trim()
height = trimmed.match(/[-]{0,1}[\d.]*[\d]+/g)[0]
}
-
+
dispatch({ type: RECEIVE_LINE, lndBlockHeight: height })
}
@@ -95,7 +95,7 @@ const ACTION_HANDLERS = {
[GET_BLOCK_HEIGHT]: state => ({ ...state, fetchingBlockHeight: true }),
[RECEIVE_BLOCK_HEIGHT]: (state, { blockHeight }) => ({ ...state, blockHeight, fetchingBlockHeight: false }),
-
+
[GRPC_DISCONNECTED]: state => ({ ...state, grpcStarted: false }),
[GRPC_CONNECTED]: state => ({ ...state, grpcStarted: true })
}
diff --git a/app/reducers/network.js b/app/reducers/network.js
index 28dfedaf..0fc82592 100644
--- a/app/reducers/network.js
+++ b/app/reducers/network.js
@@ -111,9 +111,9 @@ const ACTION_HANDLERS = {
),
[SET_CURRENT_CHANNEL]: (state, { selectedChannel }) => ({ ...state, selectedChannel }),
-
+
[SET_CURRENT_TAB]: (state, { currentTab }) => ({ ...state, currentTab }),
-
+
[SET_CURRENT_PEER]: (state, { currentPeer }) => ({ ...state, currentPeer }),
[UPDATE_PAY_REQ]: (state, { pay_req }) => ({ ...state, pay_req })
@@ -149,7 +149,7 @@ const initialState = {
currentRoute: {}
},
selectedChannel: {},
-
+
currentTab: 1,
currentPeer: {},
diff --git a/app/reducers/peers.js b/app/reducers/peers.js
index 78084db4..7d88b705 100644
--- a/app/reducers/peers.js
+++ b/app/reducers/peers.js
@@ -124,7 +124,7 @@ const ACTION_HANDLERS = {
[GET_PEERS]: state => ({ ...state, peersLoading: true }),
[RECEIVE_PEERS]: (state, { peers }) => ({ ...state, peersLoading: false, peers }),
-
+
[UPDATE_SEARCH_QUERY]: (state, { searchQuery }) => ({ ...state, searchQuery })
}
diff --git a/app/routes/channels/components/Channels.js b/app/routes/channels/components/Channels.js
index 4c68986d..8a086aac 100644
--- a/app/routes/channels/components/Channels.js
+++ b/app/routes/channels/components/Channels.js
@@ -22,7 +22,7 @@ class Channels extends Component {
componentWillMount() {
const { fetchChannels, fetchPeers } = this.props
-
+
fetchChannels()
fetchPeers()
}
@@ -64,7 +64,7 @@ class Channels extends Component {
fetchChannels()
// wait for the svg to appear as child
- const svgTimeout = setTimeout(() => {
+ const svgTimeout = setTimeout(() => {
if (icon[0].tagName === 'svg') {
// spin icon for 1 sec
icon[0].style.animation = 'spin 1000ms linear 1'
@@ -73,7 +73,7 @@ class Channels extends Component {
}, 1)
// clear animation after the second so we can reuse it
- const refreshTimeout = setTimeout(() => {
+ const refreshTimeout = setTimeout(() => {
icon[0].style.animation = ''
this.setState({ refreshing: false })
clearTimeout(refreshTimeout)
@@ -96,7 +96,7 @@ class Channels extends Component {
-
+