From 35b8f56527171a79b2ada4acaedefc597c7857a1 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 22 Jan 2024 17:08:28 +0000 Subject: [PATCH] Add public view of devfund donations script --- scripts/get_devfund_donations.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 scripts/get_devfund_donations.py diff --git a/scripts/get_devfund_donations.py b/scripts/get_devfund_donations.py new file mode 100644 index 000000000..c7466a141 --- /dev/null +++ b/scripts/get_devfund_donations.py @@ -0,0 +1,27 @@ +import os +import json +import requests +import base64 + +devfund_data_path = os.path.normpath(os.path.join("..", "devfund_pubkey.json")) + +with open(devfund_data_path, "r") as f: + devfund_data = json.load(f) + +macaroon = devfund_data["mainnet_invoices_readonly_macaroon_hex"] +url = f'https://{devfund_data["mainnet_rpcserver"]}:8080' +headers = {"Grpc-Metadata-macaroon": macaroon} +method = "/v1/invoices" + +r = requests.get(url + method, headers=headers) + +response_data = r.json() + +for invoice in response_data["invoices"]: + if invoice["is_keysend"] and invoice["htlcs"][0]["custom_records"]["34349334"]: + print(f"Index {invoice['add_index']}") + print( + f"{base64.b64decode(invoice['htlcs'][0]['custom_records']['34349334']).decode('utf-8')}" + ) + print(f"Amount {invoice['amt_paid_sat']} Sats") + print("----------------------")