From 6e405d1fc4073b34d880f6045c5c7ec3f2f7ccf0 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Wed, 21 Sep 2022 17:13:05 +0300 Subject: [PATCH 01/17] fix: output address on confirmation based on selected network --- lnbits/extensions/watchonly/models.py | 1 + .../watchonly/static/components/payment/payment.js | 6 ++++-- lnbits/extensions/watchonly/templates/watchonly/index.html | 1 + lnbits/extensions/watchonly/views_api.py | 4 +++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lnbits/extensions/watchonly/models.py b/lnbits/extensions/watchonly/models.py index cedaa210..622f5ec8 100644 --- a/lnbits/extensions/watchonly/models.py +++ b/lnbits/extensions/watchonly/models.py @@ -80,6 +80,7 @@ class CreatePsbt(BaseModel): class ExtractPsbt(BaseModel): psbtBase64 = "" # // todo snake case inputs: List[TransactionInput] + network = "Mainnet" class SignedTransaction(BaseModel): diff --git a/lnbits/extensions/watchonly/static/components/payment/payment.js b/lnbits/extensions/watchonly/static/components/payment/payment.js index f2cccbba..9f38df1d 100644 --- a/lnbits/extensions/watchonly/static/components/payment/payment.js +++ b/lnbits/extensions/watchonly/static/components/payment/payment.js @@ -11,7 +11,8 @@ async function payment(path) { 'mempool-endpoint', 'sats-denominated', 'serial-signer-ref', - 'adminkey' + 'adminkey', + 'network' ], watch: { immediate: true, @@ -279,7 +280,8 @@ async function payment(path) { this.adminkey, { psbtBase64, - inputs: this.tx.inputs + inputs: this.tx.inputs, + network: this.network } ) return data diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index 263f6d92..91577cd2 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -136,6 +136,7 @@ :adminkey="g.user.wallets[0].adminkey" :serial-signer-ref="$refs.serialSigner" :sats-denominated="config.sats_denominated" + :network="config.network" @broadcast-done="handleBroadcastSuccess" > diff --git a/lnbits/extensions/watchonly/views_api.py b/lnbits/extensions/watchonly/views_api.py index 77d28fee..750d46c9 100644 --- a/lnbits/extensions/watchonly/views_api.py +++ b/lnbits/extensions/watchonly/views_api.py @@ -4,6 +4,7 @@ from http import HTTPStatus import httpx from embit import finalizer, script from embit.ec import PublicKey +from embit.networks import NETWORKS from embit.psbt import PSBT, DerivationPath from embit.transaction import Transaction, TransactionInput, TransactionOutput from fastapi import Query, Request @@ -295,6 +296,7 @@ async def api_psbt_create( async def api_psbt_extract_tx( data: ExtractPsbt, w: WalletTypeInfo = Depends(require_admin_key) ): + network = NETWORKS["main"] if data.network == "Mainnet" else NETWORKS["test"] res = SignedTransaction() try: psbt = PSBT.from_base64(data.psbtBase64) @@ -316,7 +318,7 @@ async def api_psbt_extract_tx( for out in transaction.vout: tx["outputs"].append( - {"amount": out.value, "address": out.script_pubkey.address()} + {"amount": out.value, "address": out.script_pubkey.address(network)} ) res.tx_json = json.dumps(tx) except Exception as e: From 80a62569f9164c8fffe6ec33a04df38234dd44d1 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 22 Sep 2022 10:41:54 +0300 Subject: [PATCH 02/17] fix: wait for connection to init --- .../components/serial-signer/serial-signer.js | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js index 33d07d94..33261280 100644 --- a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js +++ b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js @@ -15,7 +15,7 @@ async function serialSigner(path) { receivedData: '', config: {}, decryptionKey: null, - sharedSecret: null, // todo: store in secure local storage + sharedSecret: null, hww: { password: null, @@ -57,13 +57,16 @@ async function serialSigner(path) { computed: { pairedDevices: { + cache: false, get: function () { + console.log('### get pairedDevices') return ( JSON.parse(window.localStorage.getItem('lnbits-paired-devices')) || [] ) }, set: function (devices) { + console.log('### set pairedDevices', devices) window.localStorage.setItem( 'lnbits-paired-devices', JSON.stringify(devices) @@ -81,6 +84,7 @@ async function serialSigner(path) { await this.openSerialPort(this.config) }, openSerialPort: async function (config = {baudRate: 9600}) { + console.log('### openSerialPort', config) if (!this.checkSerialPortSupported()) return false if (this.selectedPort) { this.$q.notify({ @@ -109,7 +113,10 @@ async function serialSigner(path) { // Wait for the serial port to open. await this.selectedPort.open(config) + // do not await this.startSerialPortReading() + // wait to init + sleep(1000) const textEncoder = new TextEncoderStream() this.writableStreamClosed = textEncoder.readable.pipeTo( @@ -307,7 +314,11 @@ async function serialSigner(path) { }, hwwPing: async function () { try { + console.log('### hwwPing 1', window.location.host) + // Send an empty ping. The serial port buffer might have some jubk data. Flush it. + await this.sendCommandClearText(COMMAND_PING) await this.sendCommandClearText(COMMAND_PING, [window.location.host]) + console.log('### hwwPing 2') } catch (error) { this.$q.notify({ type: 'warning', @@ -582,7 +593,7 @@ async function serialSigner(path) { hwwCheckPairing: async function () { const iv = window.crypto.getRandomValues(new Uint8Array(16)) const encrypted = await this.encryptMessage( - this.sharedSecret, + this.sharedSecret, // todo: revisit iv, PAIRING_CONTROL_TEXT.length + ' ' + PAIRING_CONTROL_TEXT ) @@ -724,6 +735,7 @@ async function serialSigner(path) { }, hwwHelp: async function () { try { + console.log('### cmd help') await this.sendCommandSecure(COMMAND_HELP) this.$q.notify({ type: 'positive', @@ -746,7 +758,7 @@ async function serialSigner(path) { } catch (error) { this.$q.notify({ type: 'warning', - message: 'Failed to ask for help!', + message: 'Failed to wipe!', caption: `${error}`, timeout: 10000 }) @@ -861,7 +873,13 @@ async function serialSigner(path) { sendCommandSecure: async function (command, attrs = []) { const message = [command].concat(attrs).join(' ') + console.log('### sendCommandSecure', message) const iv = window.crypto.getRandomValues(new Uint8Array(16)) + if (!this.sharedSecret || !this.sharedSecret.length) { + throw new Error( + `Secure connection not estabileshed. Tried to run command: ${command}` + ) + } const encrypted = await this.encryptMessage( this.sharedSecret, iv, @@ -874,6 +892,7 @@ async function serialSigner(path) { }, sendCommandClearText: async function (command, attrs = []) { const message = [command].concat(attrs).join(' ') + console.log('### sendCommandClearText', message) await this.writer.write(message + '\n') }, extractCommand: async function (value) { From d5f78e83d927c61071a709175a95692e06188c49 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Thu, 22 Sep 2022 10:42:27 +0300 Subject: [PATCH 03/17] chore: update `created by` --- .../watchonly/templates/watchonly/_api_docs.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lnbits/extensions/watchonly/templates/watchonly/_api_docs.html b/lnbits/extensions/watchonly/templates/watchonly/_api_docs.html index ba52c4fa..e40ca81f 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/_api_docs.html +++ b/lnbits/extensions/watchonly/templates/watchonly/_api_docs.html @@ -18,9 +18,21 @@ >directly from browser -
Created by, +
Created by Ben Arc, + Tiago Vasconcelos, + motorina0 (using, Date: Thu, 22 Sep 2022 10:58:19 +0300 Subject: [PATCH 04/17] fix: paired devices list --- .../serial-signer/serial-signer.html | 2 +- .../components/serial-signer/serial-signer.js | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.html b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.html index 2ed2d49c..a95a1906 100644 --- a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.html +++ b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.html @@ -49,7 +49,7 @@ diff --git a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js index 33261280..b27f2fa2 100644 --- a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js +++ b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js @@ -51,7 +51,8 @@ async function serialSigner(path) { }, tx: null, // todo: move to hww - showConsole: false + showConsole: false, + showPairedDevices: true } }, @@ -59,14 +60,12 @@ async function serialSigner(path) { pairedDevices: { cache: false, get: function () { - console.log('### get pairedDevices') return ( JSON.parse(window.localStorage.getItem('lnbits-paired-devices')) || [] ) }, set: function (devices) { - console.log('### set pairedDevices', devices) window.localStorage.setItem( 'lnbits-paired-devices', JSON.stringify(devices) @@ -84,7 +83,6 @@ async function serialSigner(path) { await this.openSerialPort(this.config) }, openSerialPort: async function (config = {baudRate: 9600}) { - console.log('### openSerialPort', config) if (!this.checkSerialPortSupported()) return false if (this.selectedPort) { this.$q.notify({ @@ -314,11 +312,9 @@ async function serialSigner(path) { }, hwwPing: async function () { try { - console.log('### hwwPing 1', window.location.host) // Send an empty ping. The serial port buffer might have some jubk data. Flush it. await this.sendCommandClearText(COMMAND_PING) await this.sendCommandClearText(COMMAND_PING, [window.location.host]) - console.log('### hwwPing 2') } catch (error) { this.$q.notify({ type: 'warning', @@ -735,7 +731,6 @@ async function serialSigner(path) { }, hwwHelp: async function () { try { - console.log('### cmd help') await this.sendCommandSecure(COMMAND_HELP) this.$q.notify({ type: 'positive', @@ -873,7 +868,6 @@ async function serialSigner(path) { sendCommandSecure: async function (command, attrs = []) { const message = [command].concat(attrs).join(' ') - console.log('### sendCommandSecure', message) const iv = window.crypto.getRandomValues(new Uint8Array(16)) if (!this.sharedSecret || !this.sharedSecret.length) { throw new Error( @@ -892,7 +886,6 @@ async function serialSigner(path) { }, sendCommandClearText: async function (command, attrs = []) { const message = [command].concat(attrs).join(' ') - console.log('### sendCommandClearText', message) await this.writer.write(message + '\n') }, extractCommand: async function (value) { @@ -968,6 +961,11 @@ async function serialSigner(path) { devices.splice(deviceIndex, 1) } this.pairedDevices = devices + this.showPairedDevices = false + setTimeout(() => { + // force UI refresh + this.showPairedDevices = true + }) }, addPairedDevice: function (deviceId, sharedSecretHex, config) { const devices = this.pairedDevices @@ -979,6 +977,11 @@ async function serialSigner(path) { config }) this.pairedDevices = devices + this.showPairedDevices = false + setTimeout(() => { + // force UI refresh + this.showPairedDevices = true + }) }, updatePairedDeviceConfig(deviceId, config) { const device = this.getPairedDevice(deviceId) From 649c653836502a9cc29ec468874e2f9d3860a305 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 27 Sep 2022 17:19:32 +0300 Subject: [PATCH 05/17] fix: do not show command data in logs --- .../static/components/serial-signer/serial-signer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js index b27f2fa2..67268eeb 100644 --- a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js +++ b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js @@ -230,8 +230,9 @@ async function serialSigner(path) { while (true) { const {value, done} = await readStringUntil('\n') if (value) { - this.handleSerialPortResponse(value) - this.updateSerialPortConsole(value) + const {command, commandData} = await this.extractCommand(value) + this.handleSerialPortResponse(command, commandData) + this.updateSerialPortConsole(command) } if (done) return } @@ -245,8 +246,7 @@ async function serialSigner(path) { } } }, - handleSerialPortResponse: async function (value) { - const {command, commandData} = await this.extractCommand(value) + handleSerialPortResponse: async function (command, commandData) { this.logPublicCommandsResponse(command, commandData) switch (command) { @@ -287,7 +287,7 @@ async function serialSigner(path) { ) break default: - console.log(` %c${value}`, 'background: #222; color: red') + console.log(` %c${command}`, 'background: #222; color: red') } }, logPublicCommandsResponse: function (command, commandData) { From f1670c3153d990aea8060b5305bc0861d2712573 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 27 Sep 2022 17:20:33 +0300 Subject: [PATCH 06/17] chore: version bump --- lnbits/extensions/watchonly/templates/watchonly/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lnbits/extensions/watchonly/templates/watchonly/index.html b/lnbits/extensions/watchonly/templates/watchonly/index.html index 91577cd2..67f89810 100644 --- a/lnbits/extensions/watchonly/templates/watchonly/index.html +++ b/lnbits/extensions/watchonly/templates/watchonly/index.html @@ -150,7 +150,7 @@
{{SITE_TITLE}} Onchain Wallet (watch-only) Extension - (v0.2) + (v0.3)
From a8b90bd5952601577f6aa5b4c9ff8e4b499d361c Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 27 Sep 2022 17:35:27 +0300 Subject: [PATCH 07/17] fix: close serial port when re-pairing fails --- .../components/serial-signer/serial-signer.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js index 67268eeb..8d3c1fec 100644 --- a/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js +++ b/lnbits/extensions/watchonly/static/components/serial-signer/serial-signer.js @@ -610,10 +610,10 @@ async function serialSigner(path) { } }, handleCheckPairingResponse: async function (res = '') { - const [statusCode, encryptedMessage] = res.split(' ') + const [statusCode, message] = res.split(' ') switch (statusCode) { case '0': - const controlText = await this.decryptData(encryptedMessage) + const controlText = await this.decryptData(message) if (controlText == PAIRING_CONTROL_TEXT) { this.$q.notify({ type: 'positive', @@ -629,6 +629,16 @@ async function serialSigner(path) { }) } break + case '1': + this.closeSerialPort() + this.$q.notify({ + type: 'warning', + message: + 'Re-pairing failed. Remove (forget) device and try again!', + caption: `Error: ${message}`, + timeout: 10000 + }) + break default: // noting to do here yet break From 19b1374d51ffe333c1862e8dbcb8332704f5b8cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Tue, 27 Sep 2022 17:44:52 +0200 Subject: [PATCH 08/17] fixing tests for new poetry version ^1.2 --- .github/workflows/formatting.yml | 13 ++++++++++++- .github/workflows/migrations.yml | 8 ++++++-- .github/workflows/mypy.yml | 8 ++++++-- .github/workflows/regtest.yml | 24 ++++++++++++++++++------ .github/workflows/tests.yml | 19 ++++++++++++++----- 5 files changed, 56 insertions(+), 16 deletions(-) diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml index e106ace3..e3d0fd35 100644 --- a/.github/workflows/formatting.yml +++ b/.github/workflows/formatting.yml @@ -9,9 +9,20 @@ on: jobs: checks: runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9"] + poetry-version: ["1.2.1"] steps: - uses: actions/checkout@v2 - - uses: abatilo/actions-poetry@v2.1.3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Set up Poetry ${{ matrix.poetry-version }} + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} - name: Install packages run: poetry install - name: Check black diff --git a/.github/workflows/migrations.yml b/.github/workflows/migrations.yml index 90006d2a..c280ad7d 100644 --- a/.github/workflows/migrations.yml +++ b/.github/workflows/migrations.yml @@ -22,14 +22,18 @@ jobs: --health-retries 5 strategy: matrix: - python-version: [3.9] + python-version: ["3.9"] + poetry-version: ["1.2.1"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: abatilo/actions-poetry@v2.1.3 + - name: Set up Poetry ${{ matrix.poetry-version }} + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} - name: Install dependencies run: | poetry install diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 61601731..d80da678 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -7,14 +7,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: ["3.9"] + poetry-version: ["1.2.1"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: abatilo/actions-poetry@v2.1.3 + - name: Set up Poetry ${{ matrix.poetry-version }} + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} - name: Install dependencies run: | poetry install diff --git a/.github/workflows/regtest.yml b/.github/workflows/regtest.yml index 6572ccdb..2d7aae6b 100644 --- a/.github/workflows/regtest.yml +++ b/.github/workflows/regtest.yml @@ -7,14 +7,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: ["3.9"] + poetry-version: ["1.2.1"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: abatilo/actions-poetry@v2.1.3 + - name: Set up Poetry ${{ matrix.poetry-version }} + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} - name: Setup Regtest run: | docker build -t lnbitsdocker/lnbits-legend . @@ -46,14 +50,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: ["3.9"] + poetry-version: ["1.2.1"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: abatilo/actions-poetry@v2.1.3 + - name: Set up Poetry ${{ matrix.poetry-version }} + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} - name: Setup Regtest run: | docker build -t lnbitsdocker/lnbits-legend . @@ -86,14 +94,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: ["3.9"] + poetry-version: ["1.2.1"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: abatilo/actions-poetry@v2.1.3 + - name: Set up Poetry ${{ matrix.poetry-version }} + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} - name: Setup Regtest run: | docker build -t lnbitsdocker/lnbits-legend . diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 298d7ff0..5d368fbb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: ["3.9"] + poetry-version: ["1.2.1"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} @@ -29,14 +30,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: ["3.9"] + poetry-version: ["1.2.1"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: abatilo/actions-poetry@v2.1.3 + - name: Set up Poetry ${{ matrix.poetry-version }} + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} - name: Install dependencies env: VIRTUAL_ENV: ./venv @@ -64,14 +69,18 @@ jobs: --health-retries 5 strategy: matrix: - python-version: [3.9] + python-version: ["3.9"] + poetry-version: ["1.2.1"] steps: - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - uses: abatilo/actions-poetry@v2.1.3 + - name: Set up Poetry ${{ matrix.poetry-version }} + uses: abatilo/actions-poetry@v2 + with: + poetry-version: ${{ matrix.poetry-version }} - name: Install dependencies run: | poetry install From 463941ec94cee61814a3f0714f2a76247175a6bc Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Wed, 28 Sep 2022 10:33:43 +0300 Subject: [PATCH 09/17] fix: always include change output for fee --- .../extensions/watchonly/static/components/payment/payment.html | 2 +- .../watchonly/static/components/serial-signer/serial-signer.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lnbits/extensions/watchonly/static/components/payment/payment.html b/lnbits/extensions/watchonly/static/components/payment/payment.html index cde65ca2..6e1d94c7 100644 --- a/lnbits/extensions/watchonly/static/components/payment/payment.html +++ b/lnbits/extensions/watchonly/static/components/payment/payment.html @@ -5,7 +5,7 @@ Date: Thu, 29 Sep 2022 10:31:10 +0100 Subject: [PATCH 10/17] Added Caddy --- docs/guide/installation.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index 2b058754..e77e301d 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -292,6 +292,41 @@ Save the file and run the following commands: sudo systemctl enable lnbits.service sudo systemctl start lnbits.service ``` +## Running using Caddy reverse proxy with automatic https + +Point your domain at the IP of the server you're running LNbits on, by making an `A` record. + +Install Caddy on the server +https://caddyserver.com/docs/install#debian-ubuntu-raspbian + +``` +sudo caddy stop +``` +Create a Caddyfile +``` +sudo nano Caddyfile +``` +Assuming your LNbits is running on port `5000`: +``` +yourdomain.com { + handle /api/v1/payments/sse* { + reverse_proxy 0.0.0.0:5000 { + header_up X-Forwarded-Host legend.lnbits.com + transport http { + keepalive off + compression off + } + } + } + reverse_proxy 0.0.0.0:5000 { + header_up X-Forwarded-Host legend.lnbits.com + } +} +``` +Save and exit `CTRL + x` +``` +sudo caddy start +``` ## Running behind an apache2 reverse proxy over https Install apache2 and enable apache2 mods From 55b0814d932bda58545ba25cf95f5cac02477039 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 29 Sep 2022 10:34:03 +0100 Subject: [PATCH 11/17] added intro --- docs/guide/installation.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index e77e301d..21ee307a 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -292,7 +292,9 @@ Save the file and run the following commands: sudo systemctl enable lnbits.service sudo systemctl start lnbits.service ``` -## Running using Caddy reverse proxy with automatic https +## Setting up a Caddy reverse proxy with automatic https + +USe Caddy to easily make your LNbits install accessible over clearnet with a domain and https cert. Point your domain at the IP of the server you're running LNbits on, by making an `A` record. From 7de17485d39e262f81e0dfd0cbc61b22cab3f1dc Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 29 Sep 2022 10:34:53 +0100 Subject: [PATCH 12/17] typo --- docs/guide/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index 21ee307a..d79363af 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -294,7 +294,7 @@ sudo systemctl start lnbits.service ``` ## Setting up a Caddy reverse proxy with automatic https -USe Caddy to easily make your LNbits install accessible over clearnet with a domain and https cert. +Use Caddy to make your LNbits install accessible over clearnet with a domain and https cert. Point your domain at the IP of the server you're running LNbits on, by making an `A` record. From 9c575b7d3a46f355ec01dad4b27de70b9be4c440 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 29 Sep 2022 10:37:16 +0100 Subject: [PATCH 13/17] typo --- docs/guide/installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index d79363af..7f2aefdc 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -292,7 +292,7 @@ Save the file and run the following commands: sudo systemctl enable lnbits.service sudo systemctl start lnbits.service ``` -## Setting up a Caddy reverse proxy with automatic https +## Reverse proxy with automatic https using Caddy Use Caddy to make your LNbits install accessible over clearnet with a domain and https cert. @@ -308,7 +308,7 @@ Create a Caddyfile ``` sudo nano Caddyfile ``` -Assuming your LNbits is running on port `5000`: +Assuming your LNbits is running on port `5000` add: ``` yourdomain.com { handle /api/v1/payments/sse* { From 07293e7d5ce765807f753c7ef0f0e6723f95f4a4 Mon Sep 17 00:00:00 2001 From: Arc <33088785+arcbtc@users.noreply.github.com> Date: Thu, 29 Sep 2022 10:45:09 +0100 Subject: [PATCH 14/17] Update installation.md --- docs/guide/installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/installation.md b/docs/guide/installation.md index 7f2aefdc..87679ed5 100644 --- a/docs/guide/installation.md +++ b/docs/guide/installation.md @@ -313,7 +313,7 @@ Assuming your LNbits is running on port `5000` add: yourdomain.com { handle /api/v1/payments/sse* { reverse_proxy 0.0.0.0:5000 { - header_up X-Forwarded-Host legend.lnbits.com + header_up X-Forwarded-Host yourdomain.com transport http { keepalive off compression off @@ -321,7 +321,7 @@ yourdomain.com { } } reverse_proxy 0.0.0.0:5000 { - header_up X-Forwarded-Host legend.lnbits.com + header_up X-Forwarded-Host yourdomain.com } } ``` From 325139066c309d4080ab7c2e94ad01ede63cdba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dni=20=E2=9A=A1?= Date: Thu, 29 Sep 2022 20:40:58 +0200 Subject: [PATCH 15/17] fix service-worker.js issue #1009 (#1017) * service-worker.js fix for issue #1009 fixup * remove weird comment --- lnbits/core/static/js/service-worker.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lnbits/core/static/js/service-worker.js b/lnbits/core/static/js/service-worker.js index 041b9f32..98ae497e 100644 --- a/lnbits/core/static/js/service-worker.js +++ b/lnbits/core/static/js/service-worker.js @@ -3,7 +3,11 @@ const CACHE_VERSION = 1 const CURRENT_CACHE = `lnbits-${CACHE_VERSION}-` const getApiKey = request => { - return request.headers.get('X-Api-Key') || 'none' + let api_key = request.headers.get('X-Api-Key') + if (!api_key || api_key == 'undefined') { + api_key = 'no_api_key' + } + return api_key } // on activation we clean up the previously registered service workers @@ -26,8 +30,10 @@ self.addEventListener('activate', evt => // If no response is found, it populates the runtime cache with the response // from the network before returning it to the page. self.addEventListener('fetch', event => { - // Skip cross-origin requests, like those for Google Analytics. if ( + !event.request.url.startsWith( + self.location.origin + '/api/v1/payments/sse' + ) && event.request.url.startsWith(self.location.origin) && event.request.method == 'GET' ) { From b2a26b0a7abf5cc2b8d855bcefb02c44e4db4e2a Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Fri, 30 Sep 2022 12:41:35 +0100 Subject: [PATCH 16/17] add small description in UI (#1023) --- .../extensions/scrub/templates/scrub/index.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lnbits/extensions/scrub/templates/scrub/index.html b/lnbits/extensions/scrub/templates/scrub/index.html index c063c858..5a1cae58 100644 --- a/lnbits/extensions/scrub/templates/scrub/index.html +++ b/lnbits/extensions/scrub/templates/scrub/index.html @@ -68,6 +68,21 @@
{{SITE_TITLE}} Scrub extension
+

+ Automatically forward funds (Scrub) that get paid to the LNbits + wallet, to an LNURLpay or Lightning Address. +
+ More info in Scrub's +
readme. +

+

+ Important: wallet will need a float to account for + any fees, before being able to push a payment +

From 4ad3c841528de3efafefe48f667e6800eb7074e3 Mon Sep 17 00:00:00 2001 From: calle <93376500+callebtc@users.noreply.github.com> Date: Fri, 30 Sep 2022 13:55:46 +0200 Subject: [PATCH 17/17] downgrade pyln from 0.12.0 to 0.11.1 (#1021) --- poetry.lock | 36 ++++++++++++++++++++++++++++-------- pyproject.toml | 2 +- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/poetry.lock b/poetry.lock index ea83e25e..2a57a5c1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -118,6 +118,9 @@ category = "main" optional = false python-versions = ">=2.7" +[package.dependencies] +setuptools = "*" + [[package]] name = "certifi" version = "2021.5.30" @@ -206,7 +209,7 @@ python-versions = ">=3.6" cffi = ">=1.12" [package.extras] -docs = ["sphinx (>=1.6.5,!=1.8.0,!=3.1.0,!=3.1.1)", "sphinx-rtd-theme"] +docs = ["sphinx (>=1.6.5,!=1.8.0,!=3.1.0,!=3.1.1)", "sphinx_rtd_theme"] docstest = ["pyenchant (>=1.6.11)", "sphinxcontrib-spelling (>=4.0.1)", "twine (>=1.12.0)"] pep8test = ["black", "flake8", "flake8-import-order", "pep8-naming"] sdist = ["setuptools_rust (>=0.11.4)"] @@ -638,7 +641,7 @@ python-versions = ">=3.7,<4.0" [[package]] name = "pyln-client" -version = "0.12.0.post1" +version = "0.11.1" description = "Client library and plugin library for Core Lightning" category = "main" optional = false @@ -707,7 +710,7 @@ pathlib2 = "*" six = "*" [[package]] -name = "pysocks" +name = "PySocks" version = "1.7.1" description = "A Python SOCKS client module. See https://github.com/Anorov/PySocks for more information." category = "main" @@ -823,6 +826,19 @@ python-versions = "*" [package.dependencies] cffi = ">=1.3.0" +[[package]] +name = "setuptools" +version = "65.4.0" +description = "Easily download, build, install, upgrade, and uninstall Python packages" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"] +testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "mock", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] +testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] + [[package]] name = "shortuuid" version = "1.0.1" @@ -860,7 +876,7 @@ mssql = ["pyodbc"] mssql_pymssql = ["pymssql"] mssql_pyodbc = ["pyodbc"] mysql = ["mysqlclient"] -oracle = ["cx-oracle"] +oracle = ["cx_oracle"] postgresql = ["psycopg2"] postgresql_pg8000 = ["pg8000 (<1.16.6)"] postgresql_psycopg2binary = ["psycopg2-binary"] @@ -1024,7 +1040,7 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=4.6)", "pytest-black ( [metadata] lock-version = "1.1" python-versions = "^3.10 | ^3.9 | ^3.8 | ^3.7" -content-hash = "d0556d4a307864ba04a1e5da517884e523396c98a00ae09d9192c37b1d2c555b" +content-hash = "72e4462285d0bc5e2cb83c88c613726beced959b268bd30b984d8baaeff178ea" [metadata.files] aiofiles = [ @@ -1661,8 +1677,8 @@ pyln-bolt7 = [ {file = "pyln_bolt7-1.0.246-py3-none-any.whl", hash = "sha256:54d48ec27fdc8751762cb068b0a9f2757a58fb57933c6d8f8255d02c27eb63c5"}, ] pyln-client = [ - {file = "pyln-client-0.12.0.post1.tar.gz", hash = "sha256:c80338e8e9f435720c0e5f552dc4016fc8fba16d4b79764f881067e0fcd5d5c7"}, - {file = "pyln_client-0.12.0.post1-py3-none-any.whl", hash = "sha256:cfe3404eb88f294015145e668d774dd754b3baec36b44fe773fa354f1e1e48c1"}, + {file = "pyln-client-0.11.1.tar.gz", hash = "sha256:f5ea648840b030e2bbcf8c66ee72d25a5817f89854434a28d30e887547138c8e"}, + {file = "pyln_client-0.11.1-py3-none-any.whl", hash = "sha256:497db443406b80c98c0434e2938eb1b2a17e88fd9aa63b018124068198df6141"}, ] pyln-proto = [ {file = "pyln-proto-0.11.1.tar.gz", hash = "sha256:9bed240f41917c4fd526b767218a77d0fbe69242876eef72c35a856796f922d6"}, @@ -1682,7 +1698,7 @@ pyqrcode = [ pyscss = [ {file = "pyScss-1.4.0.tar.gz", hash = "sha256:8f35521ffe36afa8b34c7d6f3195088a7057c185c2b8f15ee459ab19748669ff"}, ] -pysocks = [ +PySocks = [ {file = "PySocks-1.7.1-py27-none-any.whl", hash = "sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299"}, {file = "PySocks-1.7.1-py3-none-any.whl", hash = "sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5"}, {file = "PySocks-1.7.1.tar.gz", hash = "sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0"}, @@ -1767,6 +1783,10 @@ secp256k1 = [ {file = "secp256k1-0.14.0-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:c9e7c024ff17e9b9d7c392bb2a917da231d6cb40ab119389ff1f51dca10339a4"}, {file = "secp256k1-0.14.0.tar.gz", hash = "sha256:82c06712d69ef945220c8b53c1a0d424c2ff6a1f64aee609030df79ad8383397"}, ] +setuptools = [ + {file = "setuptools-65.4.0-py3-none-any.whl", hash = "sha256:c2d2709550f15aab6c9110196ea312f468f41cd546bceb24127a1be6fdcaeeb1"}, + {file = "setuptools-65.4.0.tar.gz", hash = "sha256:a8f6e213b4b0661f590ccf40de95d28a177cd747d098624ad3f69c40287297e9"}, +] shortuuid = [ {file = "shortuuid-1.0.1-py3-none-any.whl", hash = "sha256:492c7402ff91beb1342a5898bd61ea953985bf24a41cd9f247409aa2e03c8f77"}, {file = "shortuuid-1.0.1.tar.gz", hash = "sha256:3c11d2007b915c43bee3e10625f068d8a349e04f0d81f08f5fa08507427ebf1f"}, diff --git a/pyproject.toml b/pyproject.toml index 7f833aa5..864500f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,7 +62,7 @@ cffi = "1.15.0" websocket-client = "1.3.3" grpcio = "^1.49.1" protobuf = "^4.21.6" -pyln-client = "^0.12.0" +pyln-client = "0.11.1" [tool.poetry.dev-dependencies] isort = "^5.10.1"