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

Commit

Permalink
fix(wallet): enable custom certs with btcpayserver
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Apr 22, 2019
1 parent 48555fc commit ba4f9a6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
13 changes: 8 additions & 5 deletions renderer/components/Onboarding/Steps/ConnectionConfirm.js
Expand Up @@ -81,14 +81,17 @@ class ConnectionConfirm extends React.Component {
} }


// Otherwise, process it as a BtcPayServer connection string. // Otherwise, process it as a BtcPayServer connection string.
const { host, port, macaroon } = parseConnectionString(connectionString) const { host, port, macaroon, cert } = parseConnectionString(connectionString)
const lndconnectUri = encode({
host: `${host}:${port}`,
macaroon,
cert,
})

return startLnd({ return startLnd({
type: 'custom', type: 'custom',
decoder: 'lnd.lndconnect.v1', decoder: 'lnd.lndconnect.v1',
lndconnectUri: encode({ lndconnectUri,
host: `${host}:${port}`,
macaroon,
}),
}) })
} }


Expand Down
8 changes: 5 additions & 3 deletions test/e2e/onboarding-connect-btcpay.spec.js
Expand Up @@ -38,14 +38,16 @@ test('should connect to an external wallet (btcpay)', async t => {
.click(onboarding.connectionDetailsTabs.string.button) .click(onboarding.connectionDetailsTabs.string.button)
.typeText( .typeText(
onboarding.connectionStringInput, onboarding.connectionStringInput,
/* eslint-disable max-len */
`{ `{
"configurations": [ "configurations": [
{ {
"type": "grpc", "type": "grpc",
"cryptoCode": "BTC", "cryptoCode": "BTC",
"host": "example.com", "host": "testnet1-lnd.zaphq.io:",
"port": "19000", "port": "10009",
"macaroon": "macaroon" "macaroon": "0201036c6e64028a01030a1091304f2d271c450ef775f3bbca0f64101201301a0f0a07616464726573731204726561641a0c0a04696e666f1204726561641a100a08696e766f696365731204726561641a0f0a076d6573736167651204726561641a100a086f6666636861696e1204726561641a0f0a076f6e636861696e1204726561641a0d0a05706565727312047265616400000620bbda8514cda095f98fbfc946efc0b83423e9e48e2cf410e9f27df45feec7a3cb",
"cert": "MIICLDCCAdGgAwIBAgIRAKYFvCWmEHf0pLfq2cjcLVowCgYIKoZIzj0EAwIwPjEfMB0GA1UEChMWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEbMBkGA1UEAxMSemFwLXRlc3RuZXQxLWxuZC0wMB4XDTE4MDkwMzA4MzI1OFoXDTE5MTAyOTA4MzI1OFowPjEfMB0GA1UEChMWbG5kIGF1dG9nZW5lcmF0ZWQgY2VydDEbMBkGA1UEAxMSemFwLXRlc3RuZXQxLWxuZC0wMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEh4X-3IFky-tnbyR7blabLYLLvuK4UXWqsh48_zuy2CaRZ96Ot-oaeMDjYkR4dEzxhAKIFMoBFvgkW0bL_qDRzKOBrzCBrDAOBgNVHQ8BAf8EBAMCAqQwDwYDVR0TAQH_BAUwAwEB_zCBiAYDVR0RBIGAMH6CEnphcC10ZXN0bmV0MS1sbmQtMIIJbG9jYWxob3N0ghV0ZXN0bmV0MS1sbmQuemFwaHEuaW-CBHVuaXiCCnVuaXhwYWNrZXSHBH8AAAGHEAAAAAAAAAAAAAAAAAAAAAGHBAo0C3mHEP6AAAAAAAAACBSL__7XNwaHBCPEVWswCgYIKoZIzj0EAwIDSQAwRgIhAPfhInyLkbnxYtqa3YTZPnvMWeg9Sp-Pzc_7SHG2TV2jAiEArflwta6DpWRdVm_-dsFiOudmKAYesrhPOy-FqGhv80g"
} }
] ]
}` }`
Expand Down
4 changes: 2 additions & 2 deletions utils/btcpayserver.js
Expand Up @@ -9,11 +9,11 @@ const parseConnectionString = (value, network = 'BTC') => {
} }
const allConfigs = get(config, 'configurations', []) const allConfigs = get(config, 'configurations', [])
const params = allConfigs.find(c => c.type === 'grpc' && c.cryptoCode === network) || {} const params = allConfigs.find(c => c.type === 'grpc' && c.cryptoCode === network) || {}
const { host, port, macaroon } = params const { host, port, macaroon, cert } = params
if (!host || !port || !macaroon) { if (!host || !port || !macaroon) {
throw new Error('Invalid connection string') throw new Error('Invalid connection string')
} }
return { host, port, macaroon } return { host, port, macaroon, cert }
} }


export default parseConnectionString export default parseConnectionString

0 comments on commit ba4f9a6

Please sign in to comment.