Skip to content

Commit ee58a64

Browse files
authored
Merge pull request #108 from jamaljsr/update-lnd-loop
Update internal LND and loopd versions
2 parents 9d5c264 + 87499a6 commit ee58a64

File tree

8 files changed

+2043
-1434
lines changed

8 files changed

+2043
-1434
lines changed

app/src/__tests__/store/buildSwapStore.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { waitFor } from '@testing-library/react';
55
import Big from 'big.js';
66
import { BalanceMode } from 'util/constants';
77
import { injectIntoGrpcUnary } from 'util/tests';
8-
import { lndChannel, loopTerms } from 'util/tests/sampleData';
8+
import { lndChannel, loopInTerms } from 'util/tests/sampleData';
99
import { BuildSwapStore, createStore, Store } from 'store';
1010
import { Channel } from 'store/models';
1111
import { SWAP_ABORT_DELAY } from 'store/stores/buildSwapStore';
@@ -105,15 +105,15 @@ describe('BuildSwapStore', () => {
105105
});
106106

107107
it('should ensure amount is greater than the min terms', async () => {
108-
store.setAmount(Big(loopTerms.minSwapAmount - 100));
108+
store.setAmount(Big(loopInTerms.minSwapAmount - 100));
109109
await store.getTerms();
110-
expect(+store.amountForSelected).toBe(loopTerms.minSwapAmount);
110+
expect(+store.amountForSelected).toBe(loopInTerms.minSwapAmount);
111111
});
112112

113113
it('should ensure amount is less than the max terms', async () => {
114-
store.setAmount(Big(loopTerms.maxSwapAmount + 100));
114+
store.setAmount(Big(loopInTerms.maxSwapAmount + 100));
115115
await store.getTerms();
116-
expect(+store.amountForSelected).toBe(loopTerms.maxSwapAmount);
116+
expect(+store.amountForSelected).toBe(loopInTerms.maxSwapAmount);
117117
});
118118

119119
it('should select all channels with the same peer for loop in', () => {
@@ -135,7 +135,7 @@ describe('BuildSwapStore', () => {
135135
await store.getQuote();
136136
expect(+store.quote.swapFee).toEqual(83);
137137
expect(+store.quote.minerFee).toEqual(7387);
138-
expect(+store.quote.prepayAmount).toEqual(1337);
138+
expect(+store.quote.prepayAmount).toEqual(0);
139139
});
140140

141141
it('should fetch a loop out quote', async () => {

app/src/api/loop.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LoopApi extends BaseApi<LoopEvents> {
3333
/**
3434
* call the Loop `GetLoopInTerms` RPC and return the response
3535
*/
36-
async getLoopInTerms(): Promise<LOOP.TermsResponse.AsObject> {
36+
async getLoopInTerms(): Promise<LOOP.InTermsResponse.AsObject> {
3737
const req = new LOOP.TermsRequest();
3838
const res = await this._grpc.request(SwapClient.GetLoopInTerms, req, this._meta);
3939
return res.toObject();
@@ -42,7 +42,7 @@ class LoopApi extends BaseApi<LoopEvents> {
4242
/**
4343
* call the Loop `LoopOutTerms` RPC and return the response
4444
*/
45-
async getLoopOutTerms(): Promise<LOOP.TermsResponse.AsObject> {
45+
async getLoopOutTerms(): Promise<LOOP.OutTermsResponse.AsObject> {
4646
const req = new LOOP.TermsRequest();
4747
const res = await this._grpc.request(SwapClient.LoopOutTerms, req, this._meta);
4848
return res.toObject();
@@ -51,7 +51,7 @@ class LoopApi extends BaseApi<LoopEvents> {
5151
/**
5252
* call the Loop `GetLoopInQuote` RPC and return the response
5353
*/
54-
async getLoopInQuote(amount: Big): Promise<LOOP.QuoteResponse.AsObject> {
54+
async getLoopInQuote(amount: Big): Promise<LOOP.InQuoteResponse.AsObject> {
5555
const req = new LOOP.QuoteRequest();
5656
req.setAmt(+amount);
5757
const res = await this._grpc.request(SwapClient.GetLoopInQuote, req, this._meta);
@@ -61,7 +61,7 @@ class LoopApi extends BaseApi<LoopEvents> {
6161
/**
6262
* call the Loop `LoopOutQuote` RPC and return the response
6363
*/
64-
async getLoopOutQuote(amount: Big): Promise<LOOP.QuoteResponse.AsObject> {
64+
async getLoopOutQuote(amount: Big): Promise<LOOP.OutQuoteResponse.AsObject> {
6565
const req = new LOOP.QuoteRequest();
6666
req.setAmt(+amount);
6767
const res = await this._grpc.request(SwapClient.LoopOutQuote, req, this._meta);

app/src/store/stores/buildSwapStore.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,25 @@ class BuildSwapStore {
383383
this._store.log.info(`fetching ${direction} quote for ${amount} sats`);
384384

385385
try {
386-
const quote =
387-
direction === SwapDirection.IN
388-
? await this._store.api.loop.getLoopInQuote(amount)
389-
: await this._store.api.loop.getLoopOutQuote(amount);
386+
let quote: Quote;
387+
if (direction === SwapDirection.IN) {
388+
const inQuote = await this._store.api.loop.getLoopInQuote(amount);
389+
quote = {
390+
swapFee: Big(inQuote.swapFeeSat),
391+
minerFee: Big(inQuote.htlcPublishFeeSat),
392+
prepayAmount: Big(0),
393+
};
394+
} else {
395+
const outQuote = await this._store.api.loop.getLoopOutQuote(amount);
396+
quote = {
397+
swapFee: Big(outQuote.swapFeeSat),
398+
minerFee: Big(outQuote.htlcSweepFeeSat),
399+
prepayAmount: Big(outQuote.prepayAmtSat),
400+
};
401+
}
390402

391403
runInAction('getQuoteContinuation', () => {
392-
this.quote = {
393-
swapFee: Big(quote.swapFee),
394-
minerFee: Big(quote.minerFee),
395-
prepayAmount: Big(quote.prepayAmt),
396-
};
404+
this.quote = quote;
397405
this._store.log.info('updated buildSwapStore.quote', toJS(this.quote));
398406
});
399407
} catch (error) {

app/src/util/tests/sampleData.ts

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import * as LOOP from 'types/generated/loop_pb';
66
//
77

88
export const lndGetInfo: LND.GetInfoResponse.AsObject = {
9-
version: '0.10.0-beta commit=v0.10.0-beta',
9+
version: '0.11.0-beta commit=lightning-terminal-v0.1.0-alpha',
10+
commitHash: '9d5c264e7f0fd6751aeb41da497923512ac8fbea',
1011
identityPubkey: '038b3fc29cfc195c9b190d86ad2d40ce7550a5c6f13941f53c7d7ac5b25c912a6c',
1112
alias: 'alice',
1213
color: '#cccccc',
@@ -105,9 +106,12 @@ export const lndChannel: LND.Channel.AsObject = {
105106
localChanReserveSat: 150000,
106107
remoteChanReserveSat: 150000,
107108
staticRemoteKey: true,
109+
commitmentType: LND.CommitmentType.STATIC_REMOTE_KEY,
108110
lifetime: 21802,
109111
uptime: 21802,
110112
closeAddress: '',
113+
pushAmountSat: 5000000,
114+
thawHeight: 0,
111115
};
112116

113117
export const lndListChannelsMany: LND.ListChannelsResponse.AsObject = {
@@ -149,6 +153,9 @@ export const lndChannelEvent: Required<LND.ChannelEventUpdate.AsObject> = {
149153
remotePubkey: '030e98fdacf2464bdfb027b866a018d6cdc5108514208988873abea7eff59afd91',
150154
settledBalance: 12990950,
151155
timeLockedBalance: 0,
156+
openInitiator: 1,
157+
closeInitiator: 1,
158+
resolutionsList: [],
152159
},
153160
activeChannel: {
154161
fundingTxidBytes: txIdBytes,
@@ -160,6 +167,10 @@ export const lndChannelEvent: Required<LND.ChannelEventUpdate.AsObject> = {
160167
fundingTxidStr: '',
161168
outputIndex: outIndex,
162169
},
170+
pendingOpenChannel: {
171+
txid: '1f765f45f2a6d33837a203e3fc911915c891e9b86f9c9d91a1931b92efdedf5b',
172+
outputIndex: 0,
173+
},
163174
};
164175

165176
export const lndTransaction: LND.Transaction.AsObject = {
@@ -176,6 +187,7 @@ export const lndTransaction: LND.Transaction.AsObject = {
176187
timeStamp: 1591226124,
177188
totalFees: 0,
178189
txHash: '1f765f45f2a6d33837a203e3fc911915c891e9b86f9c9d91a1931b92efdedf5b',
190+
label: '',
179191
};
180192

181193
export const lndGetChanInfo: Required<LND.ChannelEdge.AsObject> = {
@@ -216,6 +228,7 @@ export const loopListSwaps: LOOP.ListSwapsResponse.AsObject = {
216228
idBytes: '9OsRg4PCsJ2MconOIcJZAM+0VF1GxH7SOjGtKqV86DU=',
217229
type: (i % 3) as LOOP.SwapStatus.AsObject['type'],
218230
state: i % 2 ? LOOP.SwapState.SUCCESS : LOOP.SwapState.FAILED,
231+
failureReason: (i % 2 === 0 ? 0 : i % 7) as LOOP.SwapStatus.AsObject['failureReason'],
219232
initiationTime: 1586390353623905000 + i * 100000000000000,
220233
lastUpdateTime: 1586398369729857000 + i * 200000000000000,
221234
htlcAddress: 'bcrt1qzu4077erkr78k52yuf2rwkk6ayr6m3wtazdfz2qqmd7taa5vvy9s5d75gd',
@@ -224,28 +237,43 @@ export const loopListSwaps: LOOP.ListSwapsResponse.AsObject = {
224237
costServer: 66,
225238
costOnchain: 6812,
226239
costOffchain: 2,
240+
label: `Sample Swap #${i + 1}`,
227241
})),
228242
};
229243

230-
export const loopTerms: LOOP.TermsResponse.AsObject = {
244+
export const loopOutTerms: LOOP.OutTermsResponse.AsObject = {
245+
minSwapAmount: 250000,
246+
maxSwapAmount: 1000000,
247+
minCltvDelta: 20,
248+
maxCltvDelta: 60,
249+
};
250+
251+
export const loopInTerms: LOOP.InTermsResponse.AsObject = {
231252
minSwapAmount: 250000,
232253
maxSwapAmount: 1000000,
233254
};
234255

235-
export const loopQuote: LOOP.QuoteResponse.AsObject = {
256+
export const loopOutQuote: LOOP.OutQuoteResponse.AsObject = {
236257
cltvDelta: 50,
237-
minerFee: 7387,
238-
prepayAmt: 1337,
239-
swapFee: 83,
258+
htlcSweepFeeSat: 7387,
259+
prepayAmtSat: 1337,
260+
swapFeeSat: 83,
240261
swapPaymentDest: 'Au1a9/hEsbxHUOwFC1QwxZq6EnnKYtpAdc74OZK8/syU',
241262
};
242263

264+
export const loopInQuote: LOOP.InQuoteResponse.AsObject = {
265+
cltvDelta: 50,
266+
htlcPublishFeeSat: 7387,
267+
swapFeeSat: 83,
268+
};
269+
243270
export const loopSwapResponse: LOOP.SwapResponse.AsObject = {
244271
htlcAddress: 'bcrt1qkjct8aqxfwyla50mfxdnzlmuphg3zwuz2zmuy99c9sw67xj7tn2sfkflhw',
245272
htlcAddressNp2wsh: '',
246273
htlcAddressP2wsh: 'bcrt1qkjct8aqxfwyla50mfxdnzlmuphg3zwuz2zmuy99c9sw67xj7tn2sfkflhw',
247274
id: '18e17a2f44efc7f344ef6330281765e569315f93d3eaf9b0f959b404836e3480',
248275
idBytes: 'GOF6L0Tvx/NE72MwKBdl5WkxX5PT6vmw+Vm0BINuNIA=',
276+
serverMessage: 'Loop, there it is!',
249277
};
250278

251279
// collection of sample API responses
@@ -257,10 +285,10 @@ export const sampleApiResponses: Record<string, any> = {
257285
'lnrpc.Lightning.WalletBalance': lndWalletBalance,
258286
'lnrpc.Lightning.ListChannels': lndListChannels,
259287
'looprpc.SwapClient.ListSwaps': loopListSwaps,
260-
'looprpc.SwapClient.LoopOutTerms': loopTerms,
261-
'looprpc.SwapClient.GetLoopInTerms': loopTerms,
262-
'looprpc.SwapClient.LoopOutQuote': loopQuote,
263-
'looprpc.SwapClient.GetLoopInQuote': loopQuote,
288+
'looprpc.SwapClient.LoopOutTerms': loopOutTerms,
289+
'looprpc.SwapClient.GetLoopInTerms': loopInTerms,
290+
'looprpc.SwapClient.LoopOutQuote': loopOutQuote,
291+
'looprpc.SwapClient.GetLoopInQuote': loopInQuote,
264292
'looprpc.SwapClient.LoopIn': loopSwapResponse,
265293
'looprpc.SwapClient.LoopOut': loopSwapResponse,
266294
};

go.mod

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,25 @@ module github.com/lightninglabs/lightning-terminal
33
require (
44
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
55
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
6-
github.com/gorilla/websocket v1.4.2 // indirect
76
github.com/grpc-ecosystem/grpc-gateway v1.14.3
87
github.com/improbable-eng/grpc-web v0.12.0
98
github.com/jessevdk/go-flags v1.4.0
10-
github.com/lightninglabs/faraday v0.2.0-alpha.0.20200708222452-2fe6222047a4
11-
github.com/lightninglabs/lndclient v1.0.1-0.20200708220508-33580b267beb
12-
github.com/lightninglabs/loop v0.6.5-beta
13-
github.com/lightningnetwork/lnd v0.10.3-beta
9+
github.com/lightninglabs/faraday v0.2.0-alpha.0.20200811090810-93547d433a66
10+
github.com/lightninglabs/lndclient v1.0.1-0.20200629081038-bb0726595df9
11+
github.com/lightninglabs/loop v0.8.0-beta
12+
github.com/lightningnetwork/lnd v0.11.0-beta
1413
github.com/lightningnetwork/lnd/cert v1.0.2
1514
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
1615
github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76
1716
github.com/prometheus/client_golang v1.5.1 // indirect
1817
github.com/rakyll/statik v0.1.7
1918
github.com/rs/cors v1.7.0 // indirect
20-
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
19+
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
2120
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
2221
golang.org/x/sys v0.0.0-20200406155108-e3b113bbe6a4 // indirect
2322
google.golang.org/grpc v1.28.0
2423
gopkg.in/macaroon-bakery.v2 v2.1.0
2524
gopkg.in/macaroon.v2 v2.1.0
2625
)
2726

28-
// Manually solve the conflict between loop's lndclient version of lnd and what
29-
// we explicitly need for the unified binary to work.
30-
replace (
31-
github.com/lightninglabs/lndclient => github.com/lightninglabs/lndclient v1.0.1-0.20200708223031-76709c25d859
32-
github.com/lightninglabs/loop => github.com/lightninglabs/loop v0.6.5-beta
33-
github.com/lightningnetwork/lnd => github.com/lightningnetwork/lnd v0.10.3-beta
34-
)
35-
3627
go 1.13

0 commit comments

Comments
 (0)