Jack Mallers
8 years ago
30 changed files with 180 additions and 250 deletions
@ -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' |
|||
} |
|||
|
@ -1,3 +0,0 @@ |
|||
export default function(channels, pendingchannels) { |
|||
return Promise.all([channels, pendingchannels]) |
|||
} |
@ -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) |
|||
} |
|||
|
|||
return new Promise((resolve, reject) => |
|||
pushchannel(lnd, event, payload) |
|||
.then(data => resolve(data)) |
|||
.catch(error => reject(err)) |
|||
pushchannel(lnd, event, res) |
|||
.then(data => resolve(data)) |
|||
.catch(error => reject(error)) |
|||
) |
|||
} |
@ -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 |
|||
} |
Loading…
Reference in new issue