Update __init__.py

This commit is contained in:
Arc 2020-01-16 12:39:46 +00:00 committed by GitHub
parent cab3279f17
commit 15f527fa39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -305,17 +305,17 @@ def api_transactions():
else: else:
# actually send the payment # actually send the payment
r = WALLET.pay_invoice(data["payment_request"]) r = WALLET.pay_invoice(data["payment_request"])
print(r)
if not r.ok or r.json().get("error"): if not r.raw_response:
return jsonify({"ERROR": "UNEXPECTED PAYMENT ERROR"}), 500 return jsonify({"ERROR": "UNEXPECTED PAYMENT ERROR"}), 500
data = r.json() data = r.raw_response.json()
data["fee_msat"] = data["data"]["amount"] #opennode hack
print(data) print(data)
if r.ok and "error" in data: if r.raw_response and "error" in data:
# payment didn't went through, delete it here # payment didn't went through, delete it here
# (these guarantees specific to lntxbot) # (these guarantees specific to lntxbot)
db.execute("DELETE FROM apipayments WHERE payhash = ?", (invoice.payment_hash,)) db.execute("DELETE FROM apipayments WHERE payhash = ?", (invoice.payment_hash,))
@ -324,7 +324,7 @@ def api_transactions():
# payment went through, not pending anymore, save actual fees # payment went through, not pending anymore, save actual fees
db.execute( db.execute(
"UPDATE apipayments SET pending = 0, fee = ? WHERE payhash = ? AND wallet = ?", "UPDATE apipayments SET pending = 0, fee = ? WHERE payhash = ? AND wallet = ?",
(data["fee_msat"], invoice.payment_hash, wallet["id"]), (invoice.amount_msat, invoice.payment_hash, wallet["id"]),
) )
return jsonify({"PAID": "TRUE", "payment_hash": invoice.payment_hash}), 200 return jsonify({"PAID": "TRUE", "payment_hash": invoice.payment_hash}), 200