Moved amount update to cb in lnurlw
This commit is contained in:
parent
9db327d5db
commit
edc533e902
2 changed files with 11 additions and 28 deletions
|
|
@ -19,14 +19,8 @@ async def api_lnurl_response(unique_hash):
|
||||||
if not link:
|
if not link:
|
||||||
return jsonify({"status": "ERROR", "reason": "LNURL-withdraw not found."}), HTTPStatus.OK
|
return jsonify({"status": "ERROR", "reason": "LNURL-withdraw not found."}), HTTPStatus.OK
|
||||||
|
|
||||||
if link.is_unique == 1:
|
if link.is_spent:
|
||||||
return jsonify({"status": "ERROR", "reason": "LNURL-withdraw not found."}), HTTPStatus.OK
|
return jsonify({"status": "ERROR", "reason": "Withdraw is spent."}), HTTPStatus.OK
|
||||||
|
|
||||||
usescsv = ""
|
|
||||||
for x in range(1, link.uses - link.used):
|
|
||||||
usescsv += "," + str(1)
|
|
||||||
usescsv = usescsv[1:]
|
|
||||||
link = await update_withdraw_link(link.id, usescsv=usescsv)
|
|
||||||
|
|
||||||
return jsonify(link.lnurl_response.dict()), HTTPStatus.OK
|
return jsonify(link.lnurl_response.dict()), HTTPStatus.OK
|
||||||
|
|
||||||
|
|
@ -41,24 +35,9 @@ async def api_lnurl_multi_response(unique_hash, id_unique_hash):
|
||||||
if not link:
|
if not link:
|
||||||
return jsonify({"status": "ERROR", "reason": "LNURL-withdraw not found."}), HTTPStatus.OK
|
return jsonify({"status": "ERROR", "reason": "LNURL-withdraw not found."}), HTTPStatus.OK
|
||||||
|
|
||||||
useslist = link.usescsv.split(",")
|
if link.is_spent:
|
||||||
usescsv = ""
|
return jsonify({"status": "ERROR", "reason": "Withdraw is spent."}), HTTPStatus.OK
|
||||||
found = False
|
|
||||||
if link.is_unique == 0:
|
|
||||||
for x in range(link.uses - link.used):
|
|
||||||
usescsv += "," + str(1)
|
|
||||||
else:
|
|
||||||
for x in useslist:
|
|
||||||
tohash = link.id + link.unique_hash + str(x)
|
|
||||||
if id_unique_hash == shortuuid.uuid(name=tohash):
|
|
||||||
found = True
|
|
||||||
else:
|
|
||||||
usescsv += "," + x
|
|
||||||
if not found:
|
|
||||||
return jsonify({"status": "ERROR", "reason": "LNURL-withdraw not found."}), HTTPStatus.OK
|
|
||||||
|
|
||||||
usescsv = usescsv[1:]
|
|
||||||
link = await update_withdraw_link(link.id, usescsv=usescsv)
|
|
||||||
return jsonify(link.lnurl_response.dict()), HTTPStatus.OK
|
return jsonify(link.lnurl_response.dict()), HTTPStatus.OK
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -92,7 +71,11 @@ async def api_lnurl_callback(unique_hash):
|
||||||
extra={"tag": "withdraw"},
|
extra={"tag": "withdraw"},
|
||||||
)
|
)
|
||||||
|
|
||||||
changes = {"open_time": link.wait_time + now, "used": link.used + 1}
|
usescsv = ""
|
||||||
|
for x in range(1, link.uses - link.used):
|
||||||
|
usescsv += "," + str(1)
|
||||||
|
usescsv = usescsv[1:]
|
||||||
|
changes = {"open_time": link.wait_time + now, "used": link.used + 1, "usescsv": usescsv}
|
||||||
|
|
||||||
await update_withdraw_link(link.id, **changes)
|
await update_withdraw_link(link.id, **changes)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ new Vue({
|
||||||
simpleformDialog: {
|
simpleformDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
data: {
|
data: {
|
||||||
is_unique: false,
|
is_unique: true,
|
||||||
title: 'Vouchers',
|
title: 'Vouchers',
|
||||||
min_withdrawable: 0,
|
min_withdrawable: 0,
|
||||||
wait_time: 1
|
wait_time: 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue