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>
|
<div v-if="stall"></div>
|
||||||
</q-tab-panel>
|
</q-tab-panel>
|
||||||
</q-tab-panels>
|
</q-tab-panels>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -21,19 +21,6 @@
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
<q-table
|
<q-table
|
||||||
|
|
@ -63,14 +50,6 @@
|
||||||
{{props.row.name}}</a
|
{{props.row.name}}</a
|
||||||
>
|
>
|
||||||
</q-td>
|
</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">
|
<q-td key="description" :props="props">
|
||||||
{{props.row.config.description}}
|
{{props.row.config.description}}
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,41 @@ const merchant = async () => {
|
||||||
return {
|
return {
|
||||||
merchant: {},
|
merchant: {},
|
||||||
shippingZones: [],
|
shippingZones: [],
|
||||||
showKeys: false
|
showKeys: false,
|
||||||
|
importKeyDialog: {
|
||||||
|
show: false,
|
||||||
|
data: {
|
||||||
|
privateKey: null
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
generateKeys: async function () {
|
generateKeys: async function () {
|
||||||
const privkey = nostr.generatePrivateKey()
|
const privateKey = nostr.generatePrivateKey()
|
||||||
const pubkey = nostr.getPublicKey(privkey)
|
await this.createMerchant(privateKey)
|
||||||
|
},
|
||||||
const payload = {private_key: privkey, public_key: pubkey, config: {}}
|
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 {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'POST',
|
'POST',
|
||||||
|
|
@ -54,6 +80,7 @@ const merchant = async () => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: async function () {
|
created: async function () {
|
||||||
|
console.log('### nostr', nostr)
|
||||||
await this.getMerchant()
|
await this.getMerchant()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<q-btn
|
<q-btn
|
||||||
disabled
|
@click="showImportKeysDialog"
|
||||||
label="Import Key"
|
label="Import Key"
|
||||||
color="primary"
|
color="primary"
|
||||||
class="float-left"
|
class="float-left"
|
||||||
|
|
@ -113,6 +113,32 @@
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
{% endblock%}{% block scripts %} {{ window_vars(user) }}
|
{% endblock%}{% block scripts %} {{ window_vars(user) }}
|
||||||
<!-- todo: serve locally -->
|
<!-- todo: serve locally -->
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue