feat: import private key
This commit is contained in:
parent
2acce94fe9
commit
5ad070684d
1 changed files with 21 additions and 12 deletions
|
|
@ -35,22 +35,29 @@ const merchant = async () => {
|
|||
if (!privateKey) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
if (privateKey.toLowerCase().startsWith('nsec')) {
|
||||
privateKey = nostr.nip19.decode(privateKey)
|
||||
privateKey = nostr.nip19.decode(privateKey).data
|
||||
}
|
||||
await this.createMerchant(privateKey.data)
|
||||
} catch (error) {
|
||||
this.$q.notify({
|
||||
type: 'negative',
|
||||
message: `${error}`
|
||||
})
|
||||
}
|
||||
await this.createMerchant(privateKey)
|
||||
},
|
||||
showImportKeysDialog: async function () {
|
||||
this.importKeyDialog.show = true
|
||||
},
|
||||
createMerchant: async function (privateKey) {
|
||||
try {
|
||||
const pubkey = nostr.getPublicKey(privateKey)
|
||||
const payload = {
|
||||
private_key: privateKey,
|
||||
public_key: pubkey,
|
||||
config: {}
|
||||
}
|
||||
try {
|
||||
const {data} = await LNbits.api.request(
|
||||
'POST',
|
||||
'/nostrmarket/api/v1/merchant',
|
||||
|
|
@ -60,10 +67,13 @@ const merchant = async () => {
|
|||
this.merchant = data
|
||||
this.$q.notify({
|
||||
type: 'positive',
|
||||
message: 'Keys generated!'
|
||||
message: 'Merchant Created!'
|
||||
})
|
||||
} catch (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
this.$q.notify({
|
||||
type: 'negative',
|
||||
message: `${error}`
|
||||
})
|
||||
}
|
||||
},
|
||||
getMerchant: async function () {
|
||||
|
|
@ -80,7 +90,6 @@ const merchant = async () => {
|
|||
}
|
||||
},
|
||||
created: async function () {
|
||||
console.log('### nostr', nostr)
|
||||
await this.getMerchant()
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue