feat: allow restore from nsec
This commit is contained in:
parent
3b021eb5ea
commit
2acce94fe9
4 changed files with 59 additions and 28 deletions
|
|
@ -106,5 +106,4 @@
|
|||
<div v-if="stall"></div>
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -21,19 +21,6 @@
|
|||
</template>
|
||||
</q-input>
|
||||
</div>
|
||||
<!-- <div class="col-auto">
|
||||
<q-btn outline color="grey" label="...">
|
||||
<q-menu auto-close>
|
||||
<q-list style="min-width: 100px">
|
||||
<q-item clickable>
|
||||
<q-item-section @click="exportrelayCSV"
|
||||
>Export to CSV</q-item-section
|
||||
>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<q-table
|
||||
|
|
@ -63,14 +50,6 @@
|
|||
{{props.row.name}}</a
|
||||
>
|
||||
</q-td>
|
||||
<!-- <q-td key="toggle" :props="props">
|
||||
<q-toggle
|
||||
size="sm"
|
||||
color="secodary"
|
||||
v-model="props.row.active"
|
||||
@input="showToggleStallDialog(props.row)"
|
||||
></q-toggle>
|
||||
</q-td> -->
|
||||
|
||||
<q-td key="description" :props="props">
|
||||
{{props.row.config.description}}
|
||||
|
|
|
|||
|
|
@ -15,15 +15,41 @@ const merchant = async () => {
|
|||
return {
|
||||
merchant: {},
|
||||
shippingZones: [],
|
||||
showKeys: false
|
||||
showKeys: false,
|
||||
importKeyDialog: {
|
||||
show: false,
|
||||
data: {
|
||||
privateKey: null
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
generateKeys: async function () {
|
||||
const privkey = nostr.generatePrivateKey()
|
||||
const pubkey = nostr.getPublicKey(privkey)
|
||||
|
||||
const payload = {private_key: privkey, public_key: pubkey, config: {}}
|
||||
const privateKey = nostr.generatePrivateKey()
|
||||
await this.createMerchant(privateKey)
|
||||
},
|
||||
importKeys: async function () {
|
||||
this.importKeyDialog.show = false
|
||||
let privateKey = this.importKeyDialog.data.privateKey
|
||||
if (!privateKey) {
|
||||
return
|
||||
}
|
||||
if (privateKey.toLowerCase().startsWith('nsec')) {
|
||||
privateKey = nostr.nip19.decode(privateKey)
|
||||
}
|
||||
await this.createMerchant(privateKey.data)
|
||||
},
|
||||
showImportKeysDialog: async function () {
|
||||
this.importKeyDialog.show = true
|
||||
},
|
||||
createMerchant: async function (privateKey) {
|
||||
const pubkey = nostr.getPublicKey(privateKey)
|
||||
const payload = {
|
||||
private_key: privateKey,
|
||||
public_key: pubkey,
|
||||
config: {}
|
||||
}
|
||||
try {
|
||||
const {data} = await LNbits.api.request(
|
||||
'POST',
|
||||
|
|
@ -54,6 +80,7 @@ const merchant = async () => {
|
|||
}
|
||||
},
|
||||
created: async function () {
|
||||
console.log('### nostr', nostr)
|
||||
await this.getMerchant()
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
<div class="row">
|
||||
<div class="col-12">
|
||||
<q-btn
|
||||
disabled
|
||||
@click="showImportKeysDialog"
|
||||
label="Import Key"
|
||||
color="primary"
|
||||
class="float-left"
|
||||
|
|
@ -113,6 +113,32 @@
|
|||
</q-card-section>
|
||||
</q-card>
|
||||
</div>
|
||||
<div>
|
||||
<q-dialog v-model="importKeyDialog.show" position="top">
|
||||
<q-card class="q-pa-lg q-pt-xl" style="width: 500px">
|
||||
<q-form @submit="importKeys" class="q-gutter-md">
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="importKeyDialog.data.privateKey"
|
||||
label="Private Key (hex or nsec)"
|
||||
></q-input>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
unelevated
|
||||
color="primary"
|
||||
:disable="!importKeyDialog.data.privateKey"
|
||||
type="submit"
|
||||
>Import</q-btn
|
||||
>
|
||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
||||
>Cancel</q-btn
|
||||
>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock%}{% block scripts %} {{ window_vars(user) }}
|
||||
<!-- todo: serve locally -->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue