Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Update lnd to 0.12 #3707

Merged
merged 7 commits into from
Jan 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"config": {
"lnd-binary": {
"binaryVersion": "0.11.1-beta-4-gb305c99fb",
"binaryVersion": "0.12.0-beta-2-g2dd779205",
"binarySite": "https://github.com/LN-Zap/lnd/releases/download"
}
},
Expand Down Expand Up @@ -321,6 +321,7 @@
},
"dependencies": {
"@hot-loader/react-dom": "16.13.0",
"@ln-zap/bolt11": "1.2.8-beta.3",
"@rebass/forms": "4.0.6",
"@styled-system/theme-get": "5.1.2",
"axios": "0.19.2",
Expand Down Expand Up @@ -351,7 +352,7 @@
"is-electron-renderer": "2.0.1",
"jstimezonedetect": "1.0.7",
"keytar": "5.6.0",
"lnd-grpc": "0.4.6",
"lnd-grpc": "0.4.8",
"lndconnect": "0.2.10",
"lodash": "4.17.20",
"new-github-issue-url": "0.2.1",
Expand Down
19 changes: 16 additions & 3 deletions renderer/reducers/payment/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import pick from 'lodash/pick'
import defaults from 'lodash/defaults'
import omitBy from 'lodash/omitBy'
import isNil from 'lodash/isNil'
import cloneDeep from 'lodash/cloneDeep'
import createReducer from '@zap/utils/createReducer'
import { isPubkey } from '@zap/utils/crypto'
import { isPubkey, getTag } from '@zap/utils/crypto'
import delay from '@zap/utils/delay'
import genId from '@zap/utils/genId'
import { mainLog } from '@zap/utils/log'
Expand Down Expand Up @@ -316,13 +317,25 @@ export const payInvoice = ({
if (route && route.isExact) {
let result = {}
try {
const routeToUse = { ...route }
const routeToUse = cloneDeep(route)
delete routeToUse.isExact
delete routeToUse.paymentHash
result = await grpc.services.Router.sendToRoute({

// Add payment secret into the route.
const paymentAddress = getTag(payReq, 'payment_secret')
if (paymentAddress) {
routeToUse.hops[routeToUse.hops.length - 1].tlvPayload = true
routeToUse.hops[routeToUse.hops.length - 1].mppRecord = {
paymentAddr: Buffer.from(paymentAddress, 'hex'),
totalAmtMsat: routeToUse.totalAmtMsat - routeToUse.totalFeesMsat,
}
}

result = await grpc.services.Router.sendToRouteV2({
paymentHash: route.paymentHash ? Buffer.from(route.paymentHash, 'hex') : null,
route: routeToUse,
})

if (result.failure) {
throw new Error(result.failure.code)
}
Expand Down
3 changes: 3 additions & 0 deletions renderer/reducers/payment/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ export const prepareBolt11Probe = (payReq, feeLimit) => {
// Extract route hints from the invoice.
const routingInfo = getTag(invoice, 'routing_info') || []
const paymentHash = getTag(invoice, 'payment_hash')
const paymentAddress = getTag(invoice, 'payment_secret')

const hopHints = routingInfo.map(hint => ({
nodeId: hint.pubkey,
chanId: chanNumber({ id: hint.short_channel_id }).number,
Expand All @@ -191,6 +193,7 @@ export const prepareBolt11Probe = (payReq, feeLimit) => {
finalCltvDelta: getTag(invoice, 'min_final_cltv_expiry') || DEFAULT_CLTV_DELTA,
routeHints: [{ hopHints }],
paymentHash: generateProbeHash(paymentHash),
paymentAddr: paymentAddress && Buffer.from(paymentAddress, 'hex'),
}
}

Expand Down
7 changes: 5 additions & 2 deletions services/neutrino/neutrino.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,12 @@ class Neutrino extends EventEmitter {
const { chain, network, whitelistPeers, neutrinoNodes } = this.lndConfig
const nodes = neutrinoNodes || config.lnd.neutrino[chain][network]
const connectFlag = whitelistPeers ? 'connect' : 'addpeer'
const feeUrl = 'https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json'

neutrinoArgs.push('--bitcoin.node=neutrino')
neutrinoArgs.push('--neutrino.useragentname=zap-desktop')
neutrinoArgs.push(`--neutrino.useragentversion=${getPackageDetails().version}`)
neutrinoArgs.push(`--neutrino.feeurl=${feeUrl}`)
neutrinoArgs.push(`--${chain}.${network}`)
nodes.forEach(node => neutrinoArgs.push(`--neutrino.${connectFlag}=${node}`))

Expand Down Expand Up @@ -478,12 +480,13 @@ class Neutrino extends EventEmitter {
}

/**
*
* notifyOnWalletUnlockerActivation - Update state if log line indicates WalletUnlocker gRPC became active.
*
* @param {string} line log output line
*/
notifyOnWalletUnlockerActivation(line) {
if (line.includes('RPC server listening on') && line.includes('password')) {
if (line.includes('RPC server listening on') && line.toLowerCase().includes('password')) {
this.isWalletUnlockerGrpcActive = true
this.isLightningGrpcActive = false
this.emit(NEUTRINO_WALLET_UNLOCKER_GRPC_ACTIVE)
Expand All @@ -496,7 +499,7 @@ class Neutrino extends EventEmitter {
* @param {string} line log output line
*/
notifyLightningActivation(line) {
if (line.includes('RPC server listening on') && !line.includes('password')) {
if (line.includes('RPC server listening on') && !line.toLowerCase().includes('password')) {
this.isLightningGrpcActive = true
this.isWalletUnlockerGrpcActive = false
this.emit(NEUTRINO_LIGHTNING_GRPC_ACTIVE)
Expand Down
2 changes: 1 addition & 1 deletion stories/containers/activity.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { storiesOf } from '@storybook/react'
import { action } from '@storybook/addon-actions'
import { boolean } from '@storybook/addon-knobs'
import lightningPayReq from 'bolt11'
import lightningPayReq from '@ln-zap/bolt11'
import { Modal } from 'components/UI'
import { InvoiceModal } from 'components/Activity/InvoiceModal'
import { PaymentModal } from 'components/Activity/PaymentModal'
Expand Down
2 changes: 1 addition & 1 deletion stories/containers/request/request.component.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react'
import { storiesOf } from '@storybook/react'
import { action } from '@storybook/addon-actions'
import lightningPayReq from 'bolt11'
import lightningPayReq from '@ln-zap/bolt11'
import { convert } from '@zap/utils/btc'
import { RequestSummary } from 'components/Request'
import { Provider } from '../../Provider'
Expand Down
2 changes: 1 addition & 1 deletion stories/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Box, Flex } from 'rebass/styled-components'
import lightningPayReq from 'bolt11'
import lightningPayReq from '@ln-zap/bolt11'
import { Bar, Heading, Page } from '@zap/renderer/components/UI'

export const Window = props => <Page height="calc(100vh - 40px)" {...props} />
Expand Down
27 changes: 14 additions & 13 deletions test/e2e/fixtures/tls.cert
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
-----BEGIN CERTIFICATE-----
MIICYTCCAgagAwIBAgIRAJMTFnc73j4iP6VAU/+nSOowCgYIKoZIzj0EAwIwPjEf
MB0GA1UEChMWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEbMBkGA1UEAxMSemFwLXRl
c3RuZXQ0LWxuZC0wMB4XDTE5MTAyMzEwMDIyNloXDTIwMTIxNzEwMDIyNlowPjEf
MB0GA1UEChMWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEbMBkGA1UEAxMSemFwLXRl
c3RuZXQ0LWxuZC0wMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEESndkptIDcgV
AdH7ulBVDPZNsKWgD12WJhII2VmbUN9IU1ZFFcv43kg/DyzCH0/158tDGqHp+Npy
f9JEQ++y4aOB5DCB4TAOBgNVHQ8BAf8EBAMCAqQwDwYDVR0TAQH/BAUwAwEB/zCB
vQYDVR0RBIG1MIGyghJ6YXAtdGVzdG5ldDQtbG5kLTCCCWxvY2FsaG9zdIIVdGVz
dG5ldDQtbG5kLnphcGhxLmlvgj56YXBuMzRxZmVlZHcybDV5MjZwM2hubmt1c3Fu
Ymh4Y3h3NjRscTVjb2ptdnE0NXl3NGJjM3NxZC5vbmlvboIEdW5peIIKdW5peHBh
Y2tldIcEfwAAAYcQAAAAAAAAAAAAAAAAAAAAAYcECjQEPocEIklopocECjf8YDAK
BggqhkjOPQQDAgNJADBGAiEAiBiCFmgYrgQyF/OKoZb/I47xnaZYTkdUNeajomMo
FKoCIQC6X3YEAMV2r1rbNs0faOUYS3hCTmFK75coXBJHHWFsFw==
MIICeDCCAh2gAwIBAgIQOMCEKNbMG26NQgqAOmsYoDAKBggqhkjOPQQDAjA+MR8w
HQYDVQQKExZsbmQgYXV0b2dlbmVyYXRlZCBjZXJ0MRswGQYDVQQDExJ6YXAtdGVz
dG5ldDQtbG5kLTAwHhcNMjAxMjE2MTMzMTI4WhcNMjIwMjEwMTMzMTI4WjA+MR8w
HQYDVQQKExZsbmQgYXV0b2dlbmVyYXRlZCBjZXJ0MRswGQYDVQQDExJ6YXAtdGVz
dG5ldDQtbG5kLTAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARvFglyFQ1Jn2qT
26K+/OWBT86ZanV6mHjbx1eia4UEsdL2fE2FiD2yyJx56OeY+YdXqXNDM+kNiELc
f0me4JxAo4H8MIH5MA4GA1UdDwEB/wQEAwICpDATBgNVHSUEDDAKBggrBgEFBQcD
ATAPBgNVHRMBAf8EBTADAQH/MIHABgNVHREEgbgwgbWCEnphcC10ZXN0bmV0NC1s
bmQtMIIJbG9jYWxob3N0ghV0ZXN0bmV0NC1sbmQuemFwaHEuaW+CPnphcG4zNHFm
ZWVkdzJsNXkyNnAzaG5ua3VzcW5iaHhjeHc2NGxxNWNvam12cTQ1eXc0YmMzc3Fk
Lm9uaW9uggR1bml4ggp1bml4cGFja2V0ggdidWZjb25uhwR/AAABhxAAAAAAAAAA
AAAAAAAAAAABhwQKNAFbhwQiSWimMAoGCCqGSM49BAMCA0kAMEYCIQD/aVOTXMfz
tJ54IIOs+d99H8OtYkRNeYcXQBOVuKWnSQIhAKB+U7Jt8d1qn23RDc85e8tDqJos
dPv6QS1cN1SwpxPv
-----END CERTIFICATE-----
12 changes: 6 additions & 6 deletions utils/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import get from 'lodash/get'
import config from 'config'
import range from 'lodash/range'
import { address } from 'bitcoinjs-lib'
import lightningRequestReq from 'bolt11'
import lightningRequestReq from '@ln-zap/bolt11'
import bip21 from 'bip21'
import coininfo from 'coininfo'
import { CoinBig } from '@zap/utils/coin'
Expand All @@ -23,10 +23,10 @@ export const networks = {

export const coinTypes = {
bitcoin: {
mainnet: 'bitcoin',
testnet: 'testnet',
regtest: 'regtest',
simnet: 'simnet',
mainnet: 'bc',
testnet: 'tb',
regtest: 'bcrt',
simnet: 'sb',
},
}

Expand Down Expand Up @@ -180,7 +180,7 @@ export const isBolt11 = (input, chain = 'bitcoin', network = 'mainnet') => {
}
try {
const decoded = lightningRequestReq.decode(input)
if (decoded.coinType !== get(coinTypes, `${chain}.${network}`)) {
if (decoded.network.bech32 !== get(coinTypes, `${chain}.${network}`)) {
throw new Error('Invalid coin type')
}
return true
Expand Down
2 changes: 1 addition & 1 deletion webpack/webpack.config.dll.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default merge.smart(baseConfig, {
mode: 'development',
externals: [
'@grpc/grpc-js',
'@ln-zap/proto-loader',
'@grpc/proto-loader',
'config',
'electron',
'electron-is-dev',
Expand Down
Loading