Merge branch 'bensbits' into ext-boltcards-2

This commit is contained in:
ben 2022-08-27 17:26:28 +01:00
commit 77ecc5a1d2
2 changed files with 17 additions and 18 deletions

View file

@ -33,7 +33,7 @@ from .crud import (
create_hit,
get_card,
get_card_by_otp,
get_card_by_uid,
get_card,
get_hit,
get_hits_today,
spend_hit,
@ -47,8 +47,8 @@ from .nxp424 import decryptSUN, getSunMAC
###############LNURLWITHDRAW#################
# /boltcards/api/v1/scan?p=00000000000000000000000000000000&c=0000000000000000
@boltcards_ext.get("/api/v1/scan/{card_uid}")
async def api_scan(p, c, request: Request, card_uid: str = None):
@boltcards_ext.get("/api/v1/scan/{card_id}")
async def api_scan(p, c, request: Request, card_id: str = None):
# some wallets send everything as lower case, no bueno
p = p.upper()
c = c.upper()
@ -66,7 +66,7 @@ async def api_scan(p, c, request: Request, card_uid: str = None):
if card == None:
return {"status": "ERROR", "reason": "Unknown card."}
if c != getSunMAC(card_uid, counter, bytes.fromhex(card.k2)).hex().upper():
if c != getSunMAC(card_id, counter, bytes.fromhex(card.k2)).hex().upper():
return {"status": "ERROR", "reason": "CMAC does not check."}
ctr_int = int.from_bytes(counter, "little")

View file

@ -9,6 +9,7 @@ const mapCards = obj => {
return obj
}
new Vue({
el: '#vue',
mixins: [windowMixin],
@ -18,7 +19,6 @@ new Vue({
cards: [],
hits: [],
refunds: [],
lnurlLink: location.hostname + '/boltcards/api/v1/scan/',
cardDialog: {
show: false,
data: {
@ -44,10 +44,10 @@ new Vue({
field: 'counter'
},
{
name: 'uid',
name: 'withdraw',
align: 'left',
label: 'Card ID',
field: 'uid'
label: 'Withdraw ID',
field: 'withdraw'
}
],
pagination: {
@ -66,7 +66,7 @@ new Vue({
name: 'refund_amount',
align: 'left',
label: 'Refund Amount',
field: 'oldrefund_amount_ctr'
field: 'refund_amount'
},
{
name: 'time',
@ -140,13 +140,12 @@ new Vue({
.request(
'GET',
'/boltcards/api/v1/cards?all_wallets=true',
this.g.user.wallets[0].adminkey
this.g.user.wallets[0].inkey
)
.then(function (response) {
self.cards = response.data.map(function (obj) {
return mapCards(obj)
})
console.log(self.cards)
})
},
getHits: function () {
@ -162,7 +161,6 @@ new Vue({
obj.card_name = self.cards.find(d => d.id == obj.card_id).card_name
return mapCards(obj)
})
console.log(self.hits)
})
},
getRefunds: function () {
@ -175,10 +173,8 @@ new Vue({
)
.then(function (response) {
self.refunds = response.data.map(function (obj) {
obj.card_name = self.cards.find(d => d.id == obj.card_id).card_name
return mapCards(obj)
})
console.log(self.hits)
})
},
openQrCodeDialog(cardId) {
@ -252,7 +248,6 @@ new Vue({
},
updateCardDialog: function (formId) {
var card = _.findWhere(this.cards, {id: formId})
console.log(card.id)
this.cardDialog.data = _.clone(card)
this.cardDialog.temp.k0 = this.cardDialog.data.k0
@ -274,8 +269,6 @@ new Vue({
data.prev_k2 = this.cardDialog.temp.k2
}
console.log(data)
LNbits.api
.request(
'PUT',
@ -320,7 +313,13 @@ new Vue({
},
exportCardsCSV: function () {
LNbits.utils.exportCSV(this.cardsTable.columns, this.cards)
}
},
exportHitsCSV: function () {
LNbits.utils.exportCSV(this.hitsTable.columns, this.hits)
},
exportRefundsCSV: function () {
LNbits.utils.exportCSV(this.refundsTable.columns, this.refunds)
},
},
created: function () {
if (this.g.user.wallets.length) {