generate keys on frontend
This commit is contained in:
parent
70a051a413
commit
dd09eac2a5
1 changed files with 8 additions and 18 deletions
|
|
@ -243,6 +243,8 @@
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %} {% block scripts %}
|
{% endblock %} {% block scripts %}
|
||||||
|
<script src="https://github.com/paulmillr/noble-secp256k1/releases/download/1.7.0/noble-secp256k1.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const mapChatMsg = msg => {
|
const mapChatMsg = msg => {
|
||||||
let obj = {}
|
let obj = {}
|
||||||
|
|
@ -253,6 +255,7 @@
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
Vue.component(VueQrcode.name, VueQrcode)
|
Vue.component(VueQrcode.name, VueQrcode)
|
||||||
|
const secp = window.nobleSecp256k1
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#vue',
|
el: '#vue',
|
||||||
mixins: [windowMixin],
|
mixins: [windowMixin],
|
||||||
|
|
@ -342,28 +345,15 @@
|
||||||
this.user = null
|
this.user = null
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async generateKeys() {
|
generateKeys() {
|
||||||
//check if the keys are set
|
//check if the keys are set
|
||||||
if ('publickey' in this.user.keys && 'privatekey' in this.user.keys)
|
if ('publickey' in this.user.keys && 'privatekey' in this.user.keys)
|
||||||
return
|
return
|
||||||
|
|
||||||
return await LNbits.api
|
const privkey = secp.utils.bytesToHex(secp.utils.randomPrivateKey())
|
||||||
.request('GET', `/shop/api/v1/keys`, null)
|
const pubkey = secp.utils.bytesToHex(secp.schnorr.getPublicKey(privKey))
|
||||||
.then(response => {
|
|
||||||
if (response.data) {
|
this.user.keys = {privatekey: privkey, publickey: pubkey}
|
||||||
let data = {
|
|
||||||
keys: {
|
|
||||||
privatekey: response.data.privkey,
|
|
||||||
publickey: response.data.pubkey
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.user.keys = data.keys
|
|
||||||
return
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
async getMessages(room_name, all = false) {
|
async getMessages(room_name, all = false) {
|
||||||
await LNbits.api
|
await LNbits.api
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue