Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force HTTP over Tor for CLNRest #1133

Closed
wants to merge 2 commits into from
Closed
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
12 changes: 10 additions & 2 deletions lib/cln.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ import https from 'https'
import crypto from 'crypto'

export const createInvoice = async ({ socket, rune, cert, label, description, msats, expiry }) => {
const agent = cert ? new https.Agent({ ca: Buffer.from(cert, 'base64') }) : undefined
const url = 'https://' + socket + '/v1/invoice'
let scheme = 'https:'
if (/\.onion(:[0-9]+)?$/.test(socket)) {
// we force HTTP because we don't support HTTPS over Tor yet
ekzyis marked this conversation as resolved.
Show resolved Hide resolved
scheme = 'http:'
}
let agent
if (scheme === 'https:' && cert) {
agent = new https.Agent({ ca: Buffer.from(cert, 'base64') })
}
const url = `${scheme}//${socket}/v1/invoice`
const res = await fetch(url, {
method: 'POST',
headers: {
Expand Down
10 changes: 9 additions & 1 deletion pages/settings/wallets/cln.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@ export default function CLN ({ ssrData }) {
}}
>
<Input
label='rest host and port'
label={
<div className='d-flex align-items-center'>rest host and port
<Info>
<Text>
{'If you use tor, you need to run CLNRest over HTTP:\n\n```lightningd --clnrest-port 3010 --clnrest-protocol http```'}
</Text>
</Info>
</div>
}
name='socket'
hint='tor or clearnet'
placeholder='55.5.555.55:3010'
Expand Down
Loading