Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 2bfb5e8

Browse files
authored
Merge pull request #2 from lightninglabs/update-rpc
Update RPC
2 parents a6fc5b6 + ba295e6 commit 2bfb5e8

File tree

8 files changed

+150
-41
lines changed

8 files changed

+150
-41
lines changed

.eslintrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
module.exports = { extends: '@case/eslint-config' }
1+
module.exports = {
2+
extends: '@case/eslint-config',
3+
rules: {
4+
'import/imports-first': 0,
5+
}
6+
}

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ npm run setup
2626

2727
If the window doesn't load after running `npm start`: try clicking on dev tools window and hitting `cmd-r` to refresh the window.
2828

29+
### Building
30+
31+
To build binaries for OSX:
32+
```
33+
cd $GOPATH/src/github.com/lightningnetwork/lnd
34+
git pull
35+
glide install
36+
go install . ./cmd/...
37+
```
38+
39+
To build binaries for Windows:
40+
```
41+
cd $GOPATH/src/github.com/lightningnetwork/lnd
42+
git pull
43+
glide install
44+
GOOS=windows GOARCH=amd64 go build -v
45+
```
46+
2947
### Packaging
3048
To package the app for all platforms run `npm run package-all-electron`. Make sure you have xquartz `brew cask install xquartz` wine installed `brew install wine`. If you run into `ENFILE: file table overflow` as an error put `ulimit -n 2560` in your bash profile.
3149

packages/lightning-core/accounts/ChannelListItem.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ const { Menu, MenuItem } = remote
1515
export const ChannelListItem = ({ id, capacity, localBalance, remoteBalance,
1616
active, status, hover, channelPoint, onShowPopup, onClosePopup, onCloseChannel,
1717
onSuccess, onFetchChannels }) => {
18+
const pending = status === 'pending-open'
19+
|| status === 'pending-closing'
20+
|| status === 'pending-force-closing'
21+
1822
const styles = reactCSS({
1923
'default': {
2024
channel: {
@@ -86,9 +90,9 @@ export const ChannelListItem = ({ id, capacity, localBalance, remoteBalance,
8690
background: 'light-gray',
8791
},
8892
},
89-
}, { hover, pending: status === 'pending' || status === 'closing' })
93+
}, { hover, pending })
9094

91-
const PROMPT = 'CHANNEL_LIST/PROMPT'
95+
const PROMPT = `CHANNEL_LIST/PROMPT-${ channelPoint }`
9296

9397
// eslint-disable-next-line
9498
const close = ({ channelPoint, force }) => {
@@ -112,13 +116,19 @@ export const ChannelListItem = ({ id, capacity, localBalance, remoteBalance,
112116
const handleCancel = () => onClosePopup(PROMPT)
113117

114118
const width = `${ (localBalance / capacity) * 100 }%`
119+
const title = {
120+
'open': `CID: ${ id }`,
121+
'pending-open': 'OPENING',
122+
'pending-closing': 'CLOSING',
123+
'pending-force-closing': 'CLOSING',
124+
}[status]
115125

116126
return (
117127
<div style={ styles.channel } onContextMenu={ handleMenu }>
118128
<div style={ styles.split }>
119129
<div style={ styles.id }>
120-
{ status === 'pending' ? 'PENDING' : `CID:${ id }` }
121-
{ status !== 'pending' && status !== 'closing' && (
130+
{ title }
131+
{ !pending && (
122132
<div style={ styles.closeLabel } onClick={ showPopupOrClose }>
123133
<Icon small name="close" />
124134
</div>

packages/lightning-core/accounts/Wallet.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,15 @@ export const Wallet = ({ pubkey, balances }) => {
7070
label: 'In Channels',
7171
amount: balances.channel,
7272
},
73-
// {
74-
// label: 'Frozen',
75-
// amount: '2,510',
76-
// },
7773
]
7874

75+
if (balances.limbo) {
76+
breakdown.push({
77+
label: 'In Limbo',
78+
amount: balances.limbo,
79+
})
80+
}
81+
7982
return (
8083
<div style={ styles.bg }>
8184
<div style={ styles.title }>Your Wallet</div>

packages/lightning-core/accounts/reducer.js

Lines changed: 65 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const initialState = {
2626
channel: 0,
2727
},
2828
channels: [],
29+
pendingChannels: [],
2930
loadingChannels: false,
3031
}
3132

@@ -42,10 +43,19 @@ export default (state = initialState, action) => {
4243
case SET_BALANCES:
4344
return { ...state, balances: { ...state.balances, ...action.balances } }
4445
case PENDING_CHANNELS:
46+
return {
47+
...state,
48+
pendingChannels: action.pendingChannels,
49+
balances: {
50+
...state.balances,
51+
limbo: action.limboBalance,
52+
},
53+
loadingChannels: false,
54+
}
4555
case FETCH_CHANNELS:
4656
return {
4757
...state,
48-
channels: _.uniqBy([...action.channels, ...state.channels], 'channelPoint'),
58+
channels: action.channels,
4959
loadingChannels: false,
5060
}
5161
case START_CLOSING_CHANNEL:
@@ -114,17 +124,56 @@ export const actions = {
114124
[GRPC]: {
115125
method: 'pendingChannels',
116126
types: [null, PENDING_CHANNELS, FETCH_CHANNELS_FAILURE],
117-
schema: data => ({
118-
channels: _.map(data.pending_channels, channel => ({
119-
remotePubkey: channel.identity_key,
120-
id: 'PENDING',
121-
capacity: channel.capacity,
122-
localBalance: channel.local_balance,
123-
remoteBalance: channel.remote_balance,
124-
channelPoint: channel.channel_point,
125-
status: channel.status,
126-
})),
127-
}),
127+
schema: (data) => {
128+
const decorateChannels = (channels, transform) =>
129+
_.map(channels, channel => ({
130+
remotePubkey: channel.remote_node_pub,
131+
capacity: channel.capacity,
132+
localBalance: channel.local_balance,
133+
remoteBalance: channel.remote_balance,
134+
channelPoint: channel.channel_point,
135+
...transform(channel),
136+
}))
137+
138+
return {
139+
pendingChannels: [
140+
...decorateChannels(data.pending_open_channels, () => ({ status: 'pending-open' })),
141+
...decorateChannels(data.pending_closing_channels, () => ({ status: 'pending-closing' })),
142+
...decorateChannels(data.pending_force_closing_channels, () => ({ status: 'pending-force-closing' })),
143+
// {
144+
// remotePubkey: '1asd78964b54ad8f8og7a59sfg6s4d7f6g4a538dfs97gsd',
145+
// id: '1925401284578204',
146+
// capacity: '40000',
147+
// localBalance: '4000',
148+
// remoteBalance: '36000',
149+
// channelPoint: '1',
150+
// status: 'open',
151+
// }, {
152+
// remotePubkey: 'asd0fg864a8df79g876adf98g69sd86f7g46s8d68f57gi6',
153+
// capacity: '4000',
154+
// localBalance: '2000',
155+
// remoteBalance: '2000',
156+
// channelPoint: '2',
157+
// status: 'pending-open',
158+
// }, {
159+
// remotePubkey: 'vafgg3zf789s78df97a0s9f867g3s6df5fdgsghafd9hg876ad',
160+
// capacity: '100000',
161+
// localBalance: '90000',
162+
// remoteBalance: '10000',
163+
// channelPoint: '3',
164+
// status: 'pending-closing',
165+
// }, {
166+
// remotePubkey: 'xzcb8976d4bv645z657v6ba6pfdb9s8d7gb537sf6g43b42s3',
167+
// capacity: '4400',
168+
// localBalance: '1900',
169+
// remoteBalance: '2500',
170+
// channelPoint: '4',
171+
// status: 'pending-force-closing',
172+
// },
173+
],
174+
limboBalance: parseInt(data.total_limbo_balance, 0),
175+
}
176+
},
128177
},
129178
}),
130179
listChannels: () => ({
@@ -246,6 +295,9 @@ export const selectors = {
246295
getAccountPubkey: state => state.pubkey,
247296
getCurrency: state => state.currency,
248297
getAccountBalances: state => state.balances,
249-
getChannels: state => state.channels || [],
298+
getChannels: (state) => {
299+
const channels = [...state.channels, ...state.pendingChannels]
300+
return channels.length ? channels : []
301+
},
250302
getChannelsLoading: state => state.loadingChannels,
251303
}

packages/lightning-core/common/Streams.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class Streams extends React.Component {
1111
componentWillReceiveProps(nextProps) {
1212
if (this.props.serverRunning === false && nextProps.serverRunning === true) {
1313
this.props.onFetchAccount()
14+
this.props.onFetchChannels()
1415

1516
this.interval = setInterval(() => {
1617
// POLL

packages/lightning-desktop/main.development.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ const runProcesses = (processes, logs) => {
6060

6161
const logBuffer = []
6262
const logs = observe(logBuffer)
63-
const network = isDev ? '--simnet' : '--testnet'
6463
const miningaddr = isDev ? '--miningaddr=4NyWssGkW6Nbwj3nXrJU54U2ijHgWaKZ1N19w' : ''
6564

6665
const processes = [
6766
{
6867
name: 'lnd',
6968
args: [
70-
'--btcdhost=127.0.0.1',
71-
'--rpcuser=kek',
72-
'--rpcpass=kek',
73-
network,
69+
'--bitcoin.active',
70+
'--bitcoin.rpchost=localhost',
71+
'--bitcoin.rpcuser=kek',
72+
'--bitcoin.rpcpass=kek',
73+
isDev ? '--bitcoin.simnet' : '--bitcoin.testnet',
7474
'--debuglevel=debug',
7575
'--debughtlc',
7676
],
@@ -79,7 +79,7 @@ const processes = [
7979
args: [
8080
'--rpcuser=kek',
8181
'--rpcpass=kek',
82-
network,
82+
isDev ? '--simnet' : '--testnet',
8383
miningaddr,
8484
'--txindex',
8585
],
@@ -129,7 +129,7 @@ const createWindow = () => {
129129

130130
setInterval(() => {
131131
try {
132-
mainWindow.webContents.send('logs', logQueue)
132+
logQueue.length && mainWindow.webContents.send('logs', logQueue)
133133
logQueue = []
134134
} catch (err) {
135135
console.log('WARNING: App Was Closed While Writing Logs')

packages/lightning-desktop/rpc.proto

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ message GetInfoResponse {
312312

313313
bool synced_to_chain = 9 [ json_name = "synced_to_chain" ];
314314
bool testnet = 10 [ json_name = "testnet" ];
315+
316+
repeated string chains = 11[ json_name = "chains" ] ;
315317
}
316318

317319
message ConfirmationUpdate {
@@ -367,29 +369,47 @@ message OpenStatusUpdate {
367369
}
368370
}
369371

370-
enum ChannelStatus {
371-
ALL = 0;
372-
OPENING = 1;
373-
CLOSING = 2;
374-
}
375-
message PendingChannelRequest {
376-
ChannelStatus status = 1;
377-
}
372+
message PendingChannelRequest {}
378373
message PendingChannelResponse {
379374
message PendingChannel {
380-
string identity_key = 1 [ json_name = "identity_key" ];
375+
string remote_node_pub = 1 [ json_name = "remote_node_pub" ];
381376
string channel_point = 2 [ json_name = "channel_point" ];
382377

383378
int64 capacity = 3 [ json_name = "capacity" ];
379+
384380
int64 local_balance = 4 [ json_name = "local_balance" ];
385381
int64 remote_balance = 5 [ json_name = "remote_balance" ];
382+
}
383+
384+
message PendingOpenChannel {
385+
PendingChannel channel = 1 [ json_name = "channel" ];
386+
387+
uint32 confirmation_height = 2 [ json_name = "confirmation_height" ];
388+
uint32 blocks_till_open = 3 [ json_name = "blocks_till_open" ];
389+
}
390+
391+
message ClosedChannel {
392+
PendingChannel channel = 1;
393+
394+
string closing_txid = 2 [ json_name = "closing_txid" ];
395+
}
396+
397+
message ForceClosedChannel {
398+
PendingChannel channel = 1 [ json_name = "channel" ];
399+
400+
// TODO(roasbeef): HTLC's as well?
386401

387-
string closing_txid = 6 [ json_name = "closing_txid" ];
402+
string closing_txid = 2 [ json_name = "closing_txid" ];
388403

389-
ChannelStatus status = 7 [ json_name = "status" ];
404+
int64 limbo_balance = 3 [ json_name = "limbo_balance" ];
405+
uint32 maturity_height = 4 [ json_name = "maturity_height" ];
406+
uint32 blocks_til_maturity = 5 [ json_name = "blocks_til_maturity" ];
390407
}
391408

392-
repeated PendingChannel pending_channels = 1 [ json_name = "pending_channels" ];
409+
int64 total_limbo_balance = 1 [ json_name = "total_limbo_balance" ];
410+
repeated PendingOpenChannel pending_open_channels = 2 [ json_name = "pending_open_channels" ];
411+
repeated ClosedChannel pending_closing_channels = 3 [ json_name = "pending_closing_channels" ];
412+
repeated ForceClosedChannel pending_force_closing_channels = 4 [ json_name = "pending_force_closing_channels" ];
393413
}
394414

395415
message WalletBalanceRequest {

0 commit comments

Comments
 (0)