From 0d637e370cfd4918f91172fa251e37b3cdc7a754 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sun, 20 Dec 2020 18:26:16 +0000 Subject: [PATCH 1/7] chore(deps): update lnd-grpc to v0.4.7-beta.1 --- package.json | 2 +- webpack/webpack.config.dll.js | 2 +- yarn.lock | 82 ++++++++++++++++++++++------------- 3 files changed, 54 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 15dbe7087df..a3e41774a32 100644 --- a/package.json +++ b/package.json @@ -351,7 +351,7 @@ "is-electron-renderer": "2.0.1", "jstimezonedetect": "1.0.7", "keytar": "5.6.0", - "lnd-grpc": "0.4.6", + "lnd-grpc": "0.4.7-beta.1", "lndconnect": "0.2.10", "lodash": "4.17.20", "new-github-issue-url": "0.2.1", diff --git a/webpack/webpack.config.dll.js b/webpack/webpack.config.dll.js index 90d43bb85cf..0f7eea649df 100644 --- a/webpack/webpack.config.dll.js +++ b/webpack/webpack.config.dll.js @@ -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', diff --git a/yarn.lock b/yarn.lock index ce8da7a72eb..4fd3a1c0b16 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1373,26 +1373,22 @@ tslib "^2.0.1" typescript "^4.0" -"@grpc/grpc-js@^1.1.7": - version "1.1.7" - resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.1.7.tgz#d3d71c6da95397e2d63895ccc4a05e7572f7b7e6" - integrity sha512-EuxMstI0u778dp0nk6Fe3gHXYPeV6FYsWOe0/QFwxv1NQ6bc5Wl/0Yxa4xl9uBlKElL6AIxuASmSfu7KEJhqiw== +"@grpc/grpc-js@^1.2.0": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.2.2.tgz#ee4a7417fe15a686a8e369c36ec4c80678445c67" + integrity sha512-iK/T984Ni6VnmlQK/LJdUk+VsXSaYIWkgzJ0LyOcxN2SowAmoRjG28kS7B1ui/q/MAv42iM3051WBt5QorFxmg== dependencies: - "@grpc/proto-loader" "^0.6.0-pre14" "@types/node" "^12.12.47" - google-auth-library "^6.0.0" + google-auth-library "^6.1.1" semver "^6.2.0" -"@grpc/proto-loader@^0.6.0-pre14": - version "0.6.0-pre9" - resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.6.0-pre9.tgz#0c6fe42f6c5ef9ce1b3cef7be64d5b09d6fe4d6d" - integrity sha512-oM+LjpEjNzW5pNJjt4/hq1HYayNeQT+eGrOPABJnYHv7TyNPDNzkQ76rDYZF86X5swJOa4EujEMzQ9iiTdPgww== +"@grpc/proto-loader@^0.5.5": + version "0.5.5" + resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.5.5.tgz#6725e7a1827bdf8e92e29fbf4e9ef0203c0906a9" + integrity sha512-WwN9jVNdHRQoOBo9FDH7qU+mgfjPc8GygPYms3M+y3fbQLfnCe/Kv/E01t7JRgnrsOHH8euvSbed3mIalXhwqQ== dependencies: - "@types/long" "^4.0.1" lodash.camelcase "^4.3.0" - long "^4.0.0" - protobufjs "^6.9.0" - yargs "^15.3.1" + protobufjs "^6.8.6" "@hot-loader/react-dom@16.13.0": version "16.13.0" @@ -1609,14 +1605,6 @@ resolved "https://registry.yarnpkg.com/@ln-zap/prettier-config/-/prettier-config-0.1.0.tgz#d42cd49c9d675da26d56ecfe58f5304c43471d84" integrity sha512-L9OHuzQ2XscNCWCyqWMYLxZhGc6hQLDjkDTa9aywkGYVAKctlGpHIj43OeuZnaacxZWA+vgiSUNsKT94BxfX6g== -"@ln-zap/proto-loader@0.5.4": - version "0.5.4" - resolved "https://registry.yarnpkg.com/@ln-zap/proto-loader/-/proto-loader-0.5.4.tgz#4be409f6d0448fe81e71918e440bf902168f576f" - integrity sha512-6zK9sgYrUwz+vd5Tt97rrKwKiFBe8r4+sQdO+MLZO2odiapLuiwUBB5mjEG/zb0c9nDgU6ZW+Pqye7Gye00VcA== - dependencies: - lodash.camelcase "^4.3.0" - protobufjs "^6.8.6" - "@marionebl/sander@^0.6.0": version "0.6.1" resolved "https://registry.yarnpkg.com/@marionebl/sander/-/sander-0.6.1.tgz#1958965874f24bc51be48875feb50d642fc41f7b" @@ -9829,6 +9817,17 @@ gaxios@^3.0.0, gaxios@^3.2.0: is-stream "^2.0.0" node-fetch "^2.3.0" +gaxios@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/gaxios/-/gaxios-4.1.0.tgz#e8ad466db5a4383c70b9d63bfd14dfaa87eb0099" + integrity sha512-vb0to8xzGnA2qcgywAjtshOKKVDf2eQhJoiL6fHhgW5tVN7wNk7egnYIO9zotfn3lQ3De1VPdf7V5/BWfCtCmg== + dependencies: + abort-controller "^3.0.0" + extend "^3.0.2" + https-proxy-agent "^5.0.0" + is-stream "^2.0.0" + node-fetch "^2.3.0" + gcp-metadata@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/gcp-metadata/-/gcp-metadata-4.2.0.tgz#3b424355ccdc240ee07c5791e2fd6a60a283d89a" @@ -9837,6 +9836,14 @@ gcp-metadata@^4.1.0: gaxios "^3.0.0" json-bigint "^1.0.0" +gcp-metadata@^4.2.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/gcp-metadata/-/gcp-metadata-4.2.1.tgz#31849fbcf9025ef34c2297c32a89a1e7e9f2cd62" + integrity sha512-tSk+REe5iq/N+K+SK1XjZJUrFPuDqGZVzCy2vocIHIGmPlTGsa8owXMJwGkrXr73NO0AzhPW4MF2DEHz7P2AVw== + dependencies: + gaxios "^4.0.0" + json-bigint "^1.0.0" + gensync@^1.0.0-beta.1: version "1.0.0-beta.1" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.1.tgz#58f4361ff987e5ff6e1e7a210827aa371eaac269" @@ -10208,6 +10215,21 @@ google-auth-library@^6.0.0: jws "^4.0.0" lru-cache "^6.0.0" +google-auth-library@^6.1.1: + version "6.1.3" + resolved "https://registry.yarnpkg.com/google-auth-library/-/google-auth-library-6.1.3.tgz#39d868140b70d0c4b32c6f6d8f4ccc1400d84dca" + integrity sha512-m9mwvY3GWbr7ZYEbl61isWmk+fvTmOt0YNUfPOUY2VH8K5pZlAIWJjxEi0PqR3OjMretyiQLI6GURMrPSwHQ2g== + dependencies: + arrify "^2.0.0" + base64-js "^1.3.0" + ecdsa-sig-formatter "^1.0.11" + fast-text-encoding "^1.0.0" + gaxios "^4.0.0" + gcp-metadata "^4.2.0" + gtoken "^5.0.4" + jws "^4.0.0" + lru-cache "^6.0.0" + google-p12-pem@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/google-p12-pem/-/google-p12-pem-3.0.3.tgz#673ac3a75d3903a87f05878f3c75e06fc151669e" @@ -12563,13 +12585,13 @@ lnd-binary@0.3.18: "true-case-path" "^2.2.1" unzip-stream "^0.3.0" -lnd-grpc@0.4.6: - version "0.4.6" - resolved "https://registry.yarnpkg.com/lnd-grpc/-/lnd-grpc-0.4.6.tgz#5ef3e6429531a3f814a5ec4cfadc5d5c2dd7d4a0" - integrity sha512-dzHpS9lLyJE6xzGrqs/nCFkBOT3edqFibK+nL1ibCx9fuG5PXs7QBFrhwYgu4vbWva44xrxkz/JSHifPEBUH7A== +lnd-grpc@0.4.7-beta.1: + version "0.4.7-beta.1" + resolved "https://registry.yarnpkg.com/lnd-grpc/-/lnd-grpc-0.4.7-beta.1.tgz#a897e5911f69cdb68d69f083f7bd60b379294717" + integrity sha512-8xMge64IwYHIrYiN/3zYp86aK05uN60v09fC7ORyqLBMSgVLuLYcGpKVWjnL6bP9QYCXuaYa+YyZ+N4YyVUr6Q== dependencies: - "@grpc/grpc-js" "^1.1.7" - "@ln-zap/proto-loader" "0.5.4" + "@grpc/grpc-js" "^1.2.0" + "@grpc/proto-loader" "^0.5.5" debug "^4.2.0" get-port "5.1.1" javascript-state-machine "3.1.0" @@ -14952,7 +14974,7 @@ proto-list@~1.2.1: resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849" integrity sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk= -protobufjs@^6.8.6, protobufjs@^6.9.0: +protobufjs@^6.8.6: version "6.10.1" resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.10.1.tgz#e6a484dd8f04b29629e9053344e3970cccf13cd2" integrity sha512-pb8kTchL+1Ceg4lFd5XUpK8PdWacbvV5SK2ULH2ebrYtl4GjJmS24m6CKME67jzV53tbJxHlnNOSqQHbTsR9JQ== @@ -19683,7 +19705,7 @@ yargs@^13.3.2: y18n "^4.0.0" yargs-parser "^13.1.2" -yargs@^15.3.1, yargs@^15.4.1: +yargs@^15.4.1: version "15.4.1" resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.4.1.tgz#0d87a16de01aee9d8bec2bfbf74f67851730f4f8" integrity sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A== From e46ef82f2c5071b933f84cc6fbcf9e430101d5b6 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sun, 20 Dec 2020 18:27:18 +0000 Subject: [PATCH 2/7] fix(lnd): case insensitive parsing of lnd debug log --- services/neutrino/neutrino.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/neutrino/neutrino.js b/services/neutrino/neutrino.js index def6b2dc3c8..5ff6b5de14b 100644 --- a/services/neutrino/neutrino.js +++ b/services/neutrino/neutrino.js @@ -478,12 +478,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) @@ -496,7 +497,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) From 8940f8155c4fb038bc566e448600c91a0e81b484 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sun, 20 Dec 2020 18:27:33 +0000 Subject: [PATCH 3/7] fix(lnd): implementing neutrino.feeurl --- services/neutrino/neutrino.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/neutrino/neutrino.js b/services/neutrino/neutrino.js index 5ff6b5de14b..29380aa65e6 100644 --- a/services/neutrino/neutrino.js +++ b/services/neutrino/neutrino.js @@ -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}`)) From c599c8382ce9fbb14f003a171f7feeb3d925a223 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Thu, 28 Jan 2021 12:53:11 +0000 Subject: [PATCH 4/7] feat(lnd): update to 0.12.0-beta --- package.json | 5 +++-- yarn.lock | 59 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index a3e41774a32..ef16dcd9ea4 100644 --- a/package.json +++ b/package.json @@ -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" } }, @@ -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", @@ -351,7 +352,7 @@ "is-electron-renderer": "2.0.1", "jstimezonedetect": "1.0.7", "keytar": "5.6.0", - "lnd-grpc": "0.4.7-beta.1", + "lnd-grpc": "0.4.7", "lndconnect": "0.2.10", "lodash": "4.17.20", "new-github-issue-url": "0.2.1", diff --git a/yarn.lock b/yarn.lock index 4fd3a1c0b16..89902ff06ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1373,19 +1373,19 @@ tslib "^2.0.1" typescript "^4.0" -"@grpc/grpc-js@^1.2.0": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.2.2.tgz#ee4a7417fe15a686a8e369c36ec4c80678445c67" - integrity sha512-iK/T984Ni6VnmlQK/LJdUk+VsXSaYIWkgzJ0LyOcxN2SowAmoRjG28kS7B1ui/q/MAv42iM3051WBt5QorFxmg== +"@grpc/grpc-js@1.2.5": + version "1.2.5" + resolved "https://registry.yarnpkg.com/@grpc/grpc-js/-/grpc-js-1.2.5.tgz#d1ef9ae8b99c3b46bb6cc8c82be1aa80080b7300" + integrity sha512-CBCNwedw8McnEBq9jvoiJikws16WN0OiHFejQPovY71XkFWSiIqgvydYiDwpvIYDJmhPQ7qZNzW9BPndhXbx1Q== dependencies: "@types/node" "^12.12.47" google-auth-library "^6.1.1" semver "^6.2.0" -"@grpc/proto-loader@^0.5.5": - version "0.5.5" - resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.5.5.tgz#6725e7a1827bdf8e92e29fbf4e9ef0203c0906a9" - integrity sha512-WwN9jVNdHRQoOBo9FDH7qU+mgfjPc8GygPYms3M+y3fbQLfnCe/Kv/E01t7JRgnrsOHH8euvSbed3mIalXhwqQ== +"@grpc/proto-loader@0.5.6": + version "0.5.6" + resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.5.6.tgz#1dea4b8a6412b05e2d58514d507137b63a52a98d" + integrity sha512-DT14xgw3PSzPxwS13auTEwxhMMOoz33DPUKNtmYK/QYbBSpLXJy78FGGs5yVoxVobEqPm4iW9MOIoz0A3bLTRQ== dependencies: lodash.camelcase "^4.3.0" protobufjs "^6.8.6" @@ -1592,6 +1592,20 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" +"@ln-zap/bolt11@1.2.8-beta.3": + version "1.2.8-beta.3" + resolved "https://registry.yarnpkg.com/@ln-zap/bolt11/-/bolt11-1.2.8-beta.3.tgz#201b080c0113932fba482df14573403ff8a8b0cf" + integrity sha512-K9mnrVRpqmWu8nlpZod2yrWj3MN22rKOOkmxOqgC2uoRAq8zPlT/1FPDwKmkqAtnVsRFCPxKo+KKvZBqMsW+Aw== + dependencies: + "@types/bn.js" "^4.11.3" + bech32 "^1.1.2" + bitcoinjs-lib "^3.3.1" + bn.js "^4.11.8" + create-hash "^1.2.0" + lodash "^4.17.11" + safe-buffer "^5.1.1" + secp256k1 "^3.4.0" + "@ln-zap/eslint-config@0.3.2": version "0.3.2" resolved "https://registry.yarnpkg.com/@ln-zap/eslint-config/-/eslint-config-0.3.2.tgz#e6d54f5e2104fb405b1c67871fbdb5f185cb1a50" @@ -7246,7 +7260,7 @@ debug@2.6.9, debug@^2.1.0, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6. dependencies: ms "2.0.0" -debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.2.0: +debug@4, debug@4.2.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/debug/-/debug-4.2.0.tgz#7f150f93920e94c58f5574c2fd01a3110effe7f1" integrity sha512-IX2ncY78vDTjZMFUdmsvIRFY2Cf4FnD0wRs+nQwJU8Lu99/tPFdb0VybiiMTPe3I6rQmwsqQqRBvxU+bZ/I8sg== @@ -12585,21 +12599,21 @@ lnd-binary@0.3.18: "true-case-path" "^2.2.1" unzip-stream "^0.3.0" -lnd-grpc@0.4.7-beta.1: - version "0.4.7-beta.1" - resolved "https://registry.yarnpkg.com/lnd-grpc/-/lnd-grpc-0.4.7-beta.1.tgz#a897e5911f69cdb68d69f083f7bd60b379294717" - integrity sha512-8xMge64IwYHIrYiN/3zYp86aK05uN60v09fC7ORyqLBMSgVLuLYcGpKVWjnL6bP9QYCXuaYa+YyZ+N4YyVUr6Q== +lnd-grpc@0.4.7: + version "0.4.7" + resolved "https://registry.yarnpkg.com/lnd-grpc/-/lnd-grpc-0.4.7.tgz#a69de1d0a9238c3baf14cedc1e9f1896db1e081d" + integrity sha512-/hzdQr5eDwjHAZ5Tcqt5VzzT5loHFZyVWbu9GtqXrBA6BuSN6YNtiaOy0rlLH0+8zEVQcUJPUfFhvAndB0o3QA== dependencies: - "@grpc/grpc-js" "^1.2.0" - "@grpc/proto-loader" "^0.5.5" - debug "^4.2.0" + "@grpc/grpc-js" "1.2.5" + "@grpc/proto-loader" "0.5.6" + debug "4.2.0" get-port "5.1.1" javascript-state-machine "3.1.0" lndconnect "0.2.10" lodash.defaultsdeep "4.6.1" - semver "^7.1.3" + semver "7.1.3" untildify "4.0.0" - validator "^13.1.17" + validator "13.1.17" lndconnect@0.2.10: version "0.2.10" @@ -16579,7 +16593,12 @@ semver@7.0.0: resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== -semver@7.3.2, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2: +semver@7.1.3: + version "7.1.3" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.1.3.tgz#e4345ce73071c53f336445cfc19efb1c311df2a6" + integrity sha512-ekM0zfiA9SCBlsKa2X1hxyxiI4L3B6EbVJkkdgQXnSEEaHlGdvyodMruTiulSRWMMB4NeIuYNMC9rTKTz97GxA== + +semver@7.3.2, semver@^7.2.1, semver@^7.3.2: version "7.3.2" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== @@ -19021,7 +19040,7 @@ validate-npm-package-license@^3.0.1: spdx-correct "^3.0.0" spdx-expression-parse "^3.0.0" -validator@13.1.17, validator@^13.1.17: +validator@13.1.17: version "13.1.17" resolved "https://registry.yarnpkg.com/validator/-/validator-13.1.17.tgz#ad677736950adddd3c37209484a6b2e0966579ad" integrity sha512-zL5QBoemJ3jYFb2/j38y7ljhwYGXVLUp8H6W1nVxadnAOvUOytec+L7BHh1oBQ82/TzWXHd+GSaxUWp4lROkLg== From bd8cb54ba084d4bac561e203f0698f0fa6d47eb7 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Thu, 28 Jan 2021 12:54:20 +0000 Subject: [PATCH 5/7] fix(lnd): support paying to invoices with payment secret --- renderer/reducers/payment/reducer.js | 19 ++++++++++++++++--- renderer/reducers/payment/utils.js | 3 +++ stories/containers/activity.stories.js | 2 +- .../request/request.component.stories.js | 2 +- stories/helpers.js | 2 +- utils/crypto.js | 12 ++++++------ 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/renderer/reducers/payment/reducer.js b/renderer/reducers/payment/reducer.js index 0e578159627..0fd6472a0c7 100644 --- a/renderer/reducers/payment/reducer.js +++ b/renderer/reducers/payment/reducer.js @@ -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' @@ -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) } diff --git a/renderer/reducers/payment/utils.js b/renderer/reducers/payment/utils.js index 2fbed5dbc99..8f9e59d4ccb 100644 --- a/renderer/reducers/payment/utils.js +++ b/renderer/reducers/payment/utils.js @@ -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, @@ -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: Buffer.from(paymentAddress, 'hex'), } } diff --git a/stories/containers/activity.stories.js b/stories/containers/activity.stories.js index 8b5c9c61ba9..deacd2e65a8 100644 --- a/stories/containers/activity.stories.js +++ b/stories/containers/activity.stories.js @@ -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' diff --git a/stories/containers/request/request.component.stories.js b/stories/containers/request/request.component.stories.js index 7dbcaa05246..bc0861692c2 100644 --- a/stories/containers/request/request.component.stories.js +++ b/stories/containers/request/request.component.stories.js @@ -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' diff --git a/stories/helpers.js b/stories/helpers.js index 1bf41976ad0..9e22edea1c5 100644 --- a/stories/helpers.js +++ b/stories/helpers.js @@ -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 => diff --git a/utils/crypto.js b/utils/crypto.js index dd5fdcc6b0e..6e0c7cac3fa 100644 --- a/utils/crypto.js +++ b/utils/crypto.js @@ -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' @@ -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', }, } @@ -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 From bab0c4ee80e41746a6e2e64244a248a68c240158 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Thu, 28 Jan 2021 13:15:54 +0000 Subject: [PATCH 6/7] chore(deps): update lnd-grpc to 0.4.8 --- package.json | 2 +- renderer/reducers/payment/utils.js | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index ef16dcd9ea4..cd5ab9f4a3d 100644 --- a/package.json +++ b/package.json @@ -352,7 +352,7 @@ "is-electron-renderer": "2.0.1", "jstimezonedetect": "1.0.7", "keytar": "5.6.0", - "lnd-grpc": "0.4.7", + "lnd-grpc": "0.4.8", "lndconnect": "0.2.10", "lodash": "4.17.20", "new-github-issue-url": "0.2.1", diff --git a/renderer/reducers/payment/utils.js b/renderer/reducers/payment/utils.js index 8f9e59d4ccb..8f90c210c23 100644 --- a/renderer/reducers/payment/utils.js +++ b/renderer/reducers/payment/utils.js @@ -193,7 +193,7 @@ export const prepareBolt11Probe = (payReq, feeLimit) => { finalCltvDelta: getTag(invoice, 'min_final_cltv_expiry') || DEFAULT_CLTV_DELTA, routeHints: [{ hopHints }], paymentHash: generateProbeHash(paymentHash), - paymentAddr: Buffer.from(paymentAddress, 'hex'), + paymentAddr: paymentAddress && Buffer.from(paymentAddress, 'hex'), } } diff --git a/yarn.lock b/yarn.lock index 89902ff06ea..c979e56c142 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12599,10 +12599,10 @@ lnd-binary@0.3.18: "true-case-path" "^2.2.1" unzip-stream "^0.3.0" -lnd-grpc@0.4.7: - version "0.4.7" - resolved "https://registry.yarnpkg.com/lnd-grpc/-/lnd-grpc-0.4.7.tgz#a69de1d0a9238c3baf14cedc1e9f1896db1e081d" - integrity sha512-/hzdQr5eDwjHAZ5Tcqt5VzzT5loHFZyVWbu9GtqXrBA6BuSN6YNtiaOy0rlLH0+8zEVQcUJPUfFhvAndB0o3QA== +lnd-grpc@0.4.8: + version "0.4.8" + resolved "https://registry.yarnpkg.com/lnd-grpc/-/lnd-grpc-0.4.8.tgz#84e079f127682e157071dfae25695223da97a9cd" + integrity sha512-wu10CB+ANiXysXOCLrvpm7PLdsHAepgcxa7HTPcMYVRoU8I8aH8oLaxUvIWJQMBiHfS2vdOrfWTx1Cj/qGc6gQ== dependencies: "@grpc/grpc-js" "1.2.5" "@grpc/proto-loader" "0.5.6" From 40dfb578251f53886a625e30530a218718b9b48f Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sat, 30 Jan 2021 23:13:46 +0000 Subject: [PATCH 7/7] test(fixtures): update testnet node tls cert --- test/e2e/fixtures/tls.cert | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/test/e2e/fixtures/tls.cert b/test/e2e/fixtures/tls.cert index 8fcb22f8c9d..270d04a5ee6 100644 --- a/test/e2e/fixtures/tls.cert +++ b/test/e2e/fixtures/tls.cert @@ -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-----