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) {
|
if (!privateKey) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (privateKey.toLowerCase().startsWith('nsec')) {
|
try {
|
||||||
privateKey = nostr.nip19.decode(privateKey)
|
if (privateKey.toLowerCase().startsWith('nsec')) {
|
||||||
|
privateKey = nostr.nip19.decode(privateKey).data
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'negative',
|
||||||
|
message: `${error}`
|
||||||
|
})
|
||||||
}
|
}
|
||||||
await this.createMerchant(privateKey.data)
|
await this.createMerchant(privateKey)
|
||||||
},
|
},
|
||||||
showImportKeysDialog: async function () {
|
showImportKeysDialog: async function () {
|
||||||
this.importKeyDialog.show = true
|
this.importKeyDialog.show = true
|
||||||
},
|
},
|
||||||
createMerchant: async function (privateKey) {
|
createMerchant: async function (privateKey) {
|
||||||
const pubkey = nostr.getPublicKey(privateKey)
|
|
||||||
const payload = {
|
|
||||||
private_key: privateKey,
|
|
||||||
public_key: pubkey,
|
|
||||||
config: {}
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
const pubkey = nostr.getPublicKey(privateKey)
|
||||||
|
const payload = {
|
||||||
|
private_key: privateKey,
|
||||||
|
public_key: pubkey,
|
||||||
|
config: {}
|
||||||
|
}
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'POST',
|
'POST',
|
||||||
'/nostrmarket/api/v1/merchant',
|
'/nostrmarket/api/v1/merchant',
|
||||||
|
|
@ -60,10 +67,13 @@ const merchant = async () => {
|
||||||
this.merchant = data
|
this.merchant = data
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
message: 'Keys generated!'
|
message: 'Merchant Created!'
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
LNbits.utils.notifyApiError(error)
|
this.$q.notify({
|
||||||
|
type: 'negative',
|
||||||
|
message: `${error}`
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getMerchant: async function () {
|
getMerchant: async function () {
|
||||||
|
|
@ -80,7 +90,6 @@ const merchant = async () => {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: async function () {
|
created: async function () {
|
||||||
console.log('### nostr', nostr)
|
|
||||||
await this.getMerchant()
|
await this.getMerchant()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue