WIP added keys to merchant
This commit is contained in:
parent
e80daf2795
commit
aadb567712
2 changed files with 50 additions and 13 deletions
|
|
@ -253,28 +253,32 @@
|
||||||
>
|
>
|
||||||
</q-select>
|
</q-select>
|
||||||
<!-- NOSTR -->
|
<!-- NOSTR -->
|
||||||
<!-- <div class="row">
|
<div class="row">
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<q-btn unelevated @onclick="generateKeys" color="primary">Generate keys</q-btn>
|
<q-btn unelevated @click="generateKeys" color="primary"
|
||||||
|
>Generate keys</q-btn
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-5">
|
<div class="col-5">
|
||||||
<q-btn unelevated @onclick="restoreKeys" color="primary">Restore keys</q-btn>
|
<q-btn unelevated @click="restoreKeys" color="primary"
|
||||||
|
>Restore keys</q-btn
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<q-input
|
<q-input
|
||||||
v-if="stallDialog.restorekeys"
|
v-if="keys"
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
v-model.trim="stallDialog.data.publickey"
|
v-model.trim="stallDialog.data.publickey"
|
||||||
label="Public Key"
|
label="Public Key"
|
||||||
></q-input>
|
></q-input>
|
||||||
<q-input
|
<q-input
|
||||||
v-if="stallDialog.restorekeys"
|
v-if="keys"
|
||||||
filled
|
filled
|
||||||
dense
|
dense
|
||||||
v-model.trim="stallDialog.data.privatekey"
|
v-model.trim="stallDialog.data.privatekey"
|
||||||
label="Private Key"
|
label="Private Key"
|
||||||
></q-input> -->
|
></q-input>
|
||||||
<q-select
|
<q-select
|
||||||
:options="zoneOptions"
|
:options="zoneOptions"
|
||||||
filled
|
filled
|
||||||
|
|
@ -863,6 +867,7 @@
|
||||||
</div> -->
|
</div> -->
|
||||||
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
||||||
<script src="https://cdn.jsdelivr.net/npm/pica@6.1.1/dist/pica.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/pica@6.1.1/dist/pica.min.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
Vue.component(VueQrcode.name, VueQrcode)
|
Vue.component(VueQrcode.name, VueQrcode)
|
||||||
|
|
||||||
|
|
@ -918,6 +923,7 @@
|
||||||
mixins: [windowMixin],
|
mixins: [windowMixin],
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
|
keys: null,
|
||||||
products: [],
|
products: [],
|
||||||
orders: [],
|
orders: [],
|
||||||
stalls: [],
|
stalls: [],
|
||||||
|
|
@ -1197,24 +1203,43 @@
|
||||||
this[dialog].show = false
|
this[dialog].show = false
|
||||||
this[dialog].data = {}
|
this[dialog].data = {}
|
||||||
},
|
},
|
||||||
generateKeys: function () {
|
generateKeys() {
|
||||||
var self = this
|
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request(
|
||||||
'GET',
|
'GET',
|
||||||
'/diagonalley/api/v1/keys',
|
'/diagonalley/api/v1/keys',
|
||||||
self.g.user.wallets[0].adminkey
|
this.g.user.wallets[0].adminkey
|
||||||
)
|
)
|
||||||
.then(function (response) {
|
.then(response => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
self.keys = response.data.map(mapKeys)
|
this.keys = response.data
|
||||||
|
this.stallDialog.data.publickey = this.keys.pubkey
|
||||||
|
this.stallDialog.data.privatekey = this.keys.privkey
|
||||||
|
this.$q.localStorage.set(
|
||||||
|
`lnbits.diagonalley.${this.g.user.id}`,
|
||||||
|
this.keys
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
LNbits.utils.notifyApiError(error)
|
LNbits.utils.notifyApiError(error)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
restoreKeys: function () {},
|
restoreKeys() {
|
||||||
|
let keys = this.$q.localStorage.getItem(
|
||||||
|
`lnbits.diagonalley.${this.g.user.id}`
|
||||||
|
)
|
||||||
|
if (keys) {
|
||||||
|
this.keys = keys
|
||||||
|
this.stallDialog.data.publickey = this.keys.pubkey
|
||||||
|
this.stallDialog.data.privatekey = this.keys.privkey
|
||||||
|
} else {
|
||||||
|
this.$q.notify({
|
||||||
|
type: 'warning',
|
||||||
|
message: 'No keys found.'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
capitalizeFirstLetter: function (string) {
|
capitalizeFirstLetter: function (string) {
|
||||||
return string.charAt(0).toUpperCase() + string.slice(1)
|
return string.charAt(0).toUpperCase() + string.slice(1)
|
||||||
},
|
},
|
||||||
|
|
@ -1827,7 +1852,6 @@
|
||||||
'cb4c0164fe03fcdadcbfb4f76611c71620790944c24f21a1cd119395cdedfe1b',
|
'cb4c0164fe03fcdadcbfb4f76611c71620790944c24f21a1cd119395cdedfe1b',
|
||||||
'a9c17358a6dc4ceb3bb4d883eb87967a66b3453a0f3199f0b1c8eef8070c6a07'
|
'a9c17358a6dc4ceb3bb4d883eb87967a66b3453a0f3199f0b1c8eef8070c6a07'
|
||||||
]
|
]
|
||||||
console.log(_.pick(this.g.user, 'id'))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ from fastapi import Request
|
||||||
from fastapi.param_functions import Query
|
from fastapi.param_functions import Query
|
||||||
from fastapi.params import Depends
|
from fastapi.params import Depends
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
from secp256k1 import PrivateKey, PublicKey
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
|
|
||||||
from lnbits.core.crud import get_user
|
from lnbits.core.crud import get_user
|
||||||
|
|
@ -467,3 +468,15 @@ async def api_diagonalley_stall_create(
|
||||||
await create_diagonalley_market_stalls(market_id=market.id, data=data.stalls)
|
await create_diagonalley_market_stalls(market_id=market.id, data=data.stalls)
|
||||||
|
|
||||||
return market.dict()
|
return market.dict()
|
||||||
|
|
||||||
|
## KEYS
|
||||||
|
|
||||||
|
@diagonalley_ext.get("/api/v1/keys")
|
||||||
|
async def api_diagonalley_generate_keys(wallet: WalletTypeInfo = Depends(require_admin_key)):
|
||||||
|
private_key = PrivateKey()
|
||||||
|
public_key = private_key.pubkey.serialize().hex()
|
||||||
|
while not public_key.startswith("02"):
|
||||||
|
private_key = PrivateKey()
|
||||||
|
public_key = private_key.pubkey.serialize().hex()
|
||||||
|
return {"privkey": private_key.serialize(), "pubkey": public_key[2:]}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue