|
@ -19,7 +19,7 @@ class OpenNodeWallet(Wallet): |
|
|
|
|
|
|
|
|
key = getenv("OPENNODE_KEY") or getenv("OPENNODE_ADMIN_KEY") or getenv("OPENNODE_INVOICE_KEY") |
|
|
key = getenv("OPENNODE_KEY") or getenv("OPENNODE_ADMIN_KEY") or getenv("OPENNODE_INVOICE_KEY") |
|
|
self.auth = {"Authorization": key} |
|
|
self.auth = {"Authorization": key} |
|
|
|
|
|
|
|
|
def status(self) -> StatusResponse: |
|
|
def status(self) -> StatusResponse: |
|
|
try: |
|
|
try: |
|
|
r = httpx.get( |
|
|
r = httpx.get( |
|
@ -102,17 +102,13 @@ class OpenNodeWallet(Wallet): |
|
|
yield value |
|
|
yield value |
|
|
|
|
|
|
|
|
async def webhook_listener(self): |
|
|
async def webhook_listener(self): |
|
|
text: str = await request.get_data() |
|
|
data = await request.form |
|
|
data = json.loads(text) |
|
|
if "status" not in data or data["status"] != "paid": |
|
|
if type(data) is not dict or "event" not in data or data["event"].get("name") != "wallet_receive": |
|
|
|
|
|
return "", HTTPStatus.NO_CONTENT |
|
|
return "", HTTPStatus.NO_CONTENT |
|
|
|
|
|
|
|
|
charge_id = data["id"] |
|
|
charge_id = data["id"] |
|
|
if data["status"] != "paid": |
|
|
x = hmac.new(self.auth["Authorization"].encode("ascii"), digestmod="sha256") |
|
|
return "", HTTPStatus.NO_CONTENT |
|
|
x.update(charge_id.encode("ascii")) |
|
|
|
|
|
|
|
|
x = hmac.new(self.auth["Authorization"], digestmod="sha256") |
|
|
|
|
|
x.update(charge_id) |
|
|
|
|
|
if x.hexdigest() != data["hashed_order"]: |
|
|
if x.hexdigest() != data["hashed_order"]: |
|
|
print("invalid webhook, not from opennode") |
|
|
print("invalid webhook, not from opennode") |
|
|
return "", HTTPStatus.NO_CONTENT |
|
|
return "", HTTPStatus.NO_CONTENT |
|
|