What changed, and why it matters
This commit is a user-interface redesign of the on-chain Bitcoin receive dialog. It splits the dialog into two screens: one to enter an amount and note, and another to display the QR code. The changes are purely cosmetic and do not alter how payments are processed or how funds are secured.
No security action required. Treat as a routine UI/UX improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors the Vue.js on-chain wallet receive dialog. It introduces a receiveQr flag and a showReceiveQr() method to toggle from the input form to the QR preview. Validation rules, address notes, and amount handling remain functionally the same; the layout is reorganized and a test is added to confirm draft values are preserved until the user explicitly saves. No backend, cryptographic, or authorization logic is changed.
Changed components
lnbits/static/js/components/onchain/wallet.jslnbits/templates/components/onchain/wallet.vuelnbits/static/bundle-components.min.jstests/onchain/wallet-setup.test.cjsInspect captured patch +144 / −80
### lnbits/static/bundle-components.min.js
[binary or diff unavailable]
### lnbits/static/js/components/onchain/wallet.js
@@ -17,6 +17,7 @@ window.app.component('lnbits-onchain-wallet', {
selectedWalletId: null,
receiving: false,
receiveAmount: null,
+ receiveQr: false,
lastSynced: null,
lastBroadcastTxId: null,
liveUpdates: null,
@@ -377,6 +378,10 @@ window.app.component('lnbits-onchain-wallet', {
}
},
+ showReceiveQr() {
+ this.receiveQr = true
+ },
+
//################### ADDRESS HISTORY ###################
addressHistoryFromTxs: function (addressData, txs) {
const addressHistory = []
@@ -677,6 +682,7 @@ window.app.component('lnbits-onchain-wallet', {
},
openQrCodeDialog: function (addressData) {
this.receiveAmount = null
+ this.receiveQr = false
this.currentAddress = addressData
this.addressNote = addressData.note || ''
this.showAddress = true
### lnbits/templates/components/onchain/wallet.vue
@@ -533,106 +533,113 @@
<slot v-if="isConfigured" name="wallet-tools"></slot>
</div>
<q-dialog v-model="showAddress" position="top">
- <q-card class="q-pa-lg lnbits__dialog-card">
- <h5 class="text-subtitle1 q-my-none" v-text="'Receive bitcoin'"></h5>
- <q-separator></q-separator><br />
-
- <div class="q-mx-xl q-mb-md">
+ <q-card v-if="!receiveQr" class="q-pa-lg q-pt-xl lnbits__dialog-card">
+ <q-form @submit="showReceiveQr">
+ <div class="row q-col-gutter-md">
+ <q-input
+ filled
+ dense
+ class="col-12"
+ v-model.number="receiveAmount"
+ type="number"
+ min="1"
+ step="1"
+ label="Amount in sats"
+ hint="Optional"
+ :rules="[
+ v =>
+ !v ||
+ (Number.isSafeInteger(+v) &&
+ +v > 0 &&
+ +v <= 2100000000000000) ||
+ 'Enter a whole number of sats'
+ ]"
+ ></q-input>
+ <q-input
+ v-if="currentAddress"
+ class="col-12"
+ filled
+ dense
+ v-model.trim="addressNote"
+ type="text"
+ :label="$t('onchain.note')"
+ hint="Optional"
+ ></q-input>
+ </div>
+ <div class="row q-mt-lg">
+ <q-btn
+ unelevated
+ color="primary"
+ type="submit"
+ label="Show QR code"
+ :disable="!currentAddress"
+ ></q-btn>
+ <q-btn
+ v-close-popup
+ flat
+ color="grey"
+ class="q-ml-auto"
+ :label="$t('cancel')"
+ ></q-btn>
+ </div>
+ </q-form>
+ </q-card>
+ <q-card v-else class="lnbits__dialog-card column no-wrap">
+ <q-card-section class="col scroll q-pa-lg q-pb-none">
+ <p v-if="currentAddress" class="text-center text-wrap q-mb-lg">
+ <a
+ :href="mempoolHostname + '/address/' + currentAddress.address"
+ target="_blank"
+ rel="noopener noreferrer"
+ v-text="currentAddress.address"
+ ></a>
+ </p>
<lnbits-qrcode
v-if="currentAddress"
:value="receiveUri"
+ :max-width="280"
></lnbits-qrcode>
- </div>
- <p v-if="currentAddress">
- <q-btn
- flat
- dense
- size="ms"
- icon="content_copy"
- @click="copyText(currentAddress.address)"
- class="q-ml-sm"
- ></q-btn>
- <span v-text="currentAddress.address"></span>
- <q-btn
- flat
- dense
- size="ms"
- icon="launch"
- type="a"
- :href="mempoolHostname + '/address/' + currentAddress.address"
- target="_blank"
- ></q-btn>
- </p>
- <q-input
- filled
- class="q-mb-md"
- v-model.number="receiveAmount"
- type="number"
- min="1"
- step="1"
- label="Amount in sats (optional)"
- :rules="[
- v =>
- !v ||
- (Number.isSafeInteger(+v) && +v > 0 && +v <= 2100000000000000) ||
- 'Enter a whole number of sats'
- ]"
- ></q-input>
- <q-btn
- v-if="currentAddress"
- outline
- color="primary"
- label="Copy payment link"
- class="q-mb-md"
- @click="copyText(receiveUri)"
- ></q-btn>
- <p class="text-caption">
- Send only bitcoin on
- <span
- v-text="config.network === 'Testnet' ? 'Testnet3' : config.network"
- ></span>
- to this address.
- </p>
- <p v-if="currentAddress">
- <q-input
- filled
- dense
- v-model.trim="addressNote"
- type="text"
- :label="$t('onchain.note')"
- ></q-input>
- </p>
- <div v-if="currentAddress && currentAddress.gapLimitExceeded">
- <q-badge
- color="yellow"
- text-color="black"
- v-text="$t('onchain.gap_limit_exceeded')"
- ></q-badge>
- </div>
- <div class="row q-mt-lg q-gutter-sm">
+ <p v-if="receiveAmount" class="text-h5 text-center q-my-lg">
+ <span v-text="receiveAmount"></span> sats
+ </p>
+ <p class="text-caption text-center q-mb-none">
+ Send only bitcoin on
+ <span
+ v-text="
+ config.network === 'Testnet' ? 'Testnet3' : config.network
+ "
+ ></span>
+ to this address.
+ </p>
+ <div v-if="currentAddress && currentAddress.gapLimitExceeded">
+ <q-badge
+ color="yellow"
+ text-color="black"
+ v-text="$t('onchain.gap_limit_exceeded')"
+ ></q-badge>
+ </div>
+ </q-card-section>
+ <q-card-actions class="col-auto q-pa-lg" align="between">
<q-btn
v-if="currentAddress"
- outline
+ unelevated
v-close-popup
- color="grey"
+ color="primary"
@click="
updateNoteForAddress({
addressId: currentAddress.id,
note: addressNote
})
"
- class="q-ml-sm"
:label="$t('onchain.save_note')"
></q-btn>
<q-btn
v-close-popup
flat
color="grey"
- class="q-ml-auto"
:label="$t('onchain.close')"
></q-btn>
- </div>
- <div class="row q-mt-lg q-gutter-sm"></div>
+ </q-card-actions>
</q-card>
</q-dialog>
### tests/onchain/wallet-setup.test.cjs
@@ -320,3 +320,54 @@ test('hot wallets require backup confirmation from metadata before transacting',
await instance.updateAccounts([{...account, onchain_wallet_kind: 'watch'}])
assert.equal(instance.canTransact, true)
})
+
+test('receive preview preserves draft values without saving and reopening resets the form', async t => {
+ const {app, instance, calls} = harness()
+ t.after(() => app.unmount())
+ const address = {id: 'address-1', address: 'bc1qexample', note: 'Old note'}
+ instance.openQrCodeDialog(address)
+ assert.equal(instance.receiveQr, false)
+ instance.addressNote = 'New note'
+ instance.receiveAmount = 12345
+ await instance.showReceiveQr()
+ assert.equal(instance.receiveQr, true)
+ assert.equal(instance.receiveUri, 'bitcoin:bc1qexample?amount=0.00012345')
+ assert.equal(instance.addressNote, 'New note')
+ assert.equal(address.note, 'Old note')
+ assert.deepEqual(calls, [])
+ instance.openQrCodeDialog(address)
+ assert.equal(instance.receiveQr, false)
+ assert.equal(instance.receiveAmount, null)
+ assert.equal(instance.addressNote, 'Old note')
+ await instance.showReceiveQr()
+ assert.equal(instance.receiveUri, 'bitcoin:bc1qexample')
+})
+
+test('explicit note save leaves the original note intact on failure and allows retry', async t => {
+ const {app, instance, context} = harness()
+ t.after(() => app.unmount())
+ const error = new Error('Permission denied')
+ const errors = []
+ context.LNbits.utils.notifyApiError = e => errors.push(e)
+ context.LNbits.api.request = async () => {
+ throw error
+ }
+ const address = {id: 'address-1', address: 'bc1qexample', note: 'Old note'}
+ instance.addresses = [address]
+ instance.openQrCodeDialog(address)
+ instance.addressNote = 'New note'
+ await instance.showReceiveQr()
+ await instance.updateNoteForAddress({
+ addressId: address.id,
+ note: instance.addressNote
+ })
+ assert.equal(address.note, 'Old note')
+ assert.equal(instance.addressNote, 'New note')
+ assert.deepEqual(errors, [error])
+ context.LNbits.api.request = async () => ({})
+ await instance.updateNoteForAddress({
+ addressId: address.id,
+ note: instance.addressNote
+ })
+ assert.equal(address.note, 'New note')
+})Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.