From b2a896052a8e68645ef49b59f8434a201cff610b Mon Sep 17 00:00:00 2001 From: Michael Schmoock Date: Sun, 13 Dec 2020 01:51:36 +0100 Subject: [PATCH] donations: fix flake8 nits --- donations/donations.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/donations/donations.py b/donations/donations.py index 7748136..ce8b736 100755 --- a/donations/donations.py +++ b/donations/donations.py @@ -1,12 +1,12 @@ #!/usr/bin/env python3 """ A small donation service so that users can request ln invoices -This plugin spins up a small flask server that provides a form to +This plugin spins up a small flask server that provides a form to users who wish to donate some money to the owner of the lightning -node. The server can run on an arbitrary port and returns an invoice. +node. The server can run on an arbitrary port and returns an invoice. Also a list of previously paid invoices (only those that used this service) will be displayed. Displaying paid invoices could be made -optionally in a future version. +optionally in a future version. Author: Rene Pickhardt (https://ln.rene-pickhardt.de) @@ -16,21 +16,17 @@ you can see a demo of the plugin (and leave a tip) directly at: LICENSE: MIT / APACHE """ import base64 -import json import multiprocessing import qrcode -import sys from flask import Flask, render_template from flask_bootstrap import Bootstrap from flask_wtf import FlaskForm from io import BytesIO -from pyln.client import LightningRpc, Plugin -from os.path import join +from pyln.client import Plugin from random import random -from time import time -from wtforms import StringField, SubmitField, IntegerField +from wtforms import StringField, SubmitField, IntegerField from wtforms.validators import Required, NumberRange @@ -81,8 +77,7 @@ def donation_form(): amount = form.amount.data description = form.description.data label = "ln-plugin-donation-{}".format(random()) - invoice = plugin.rpc.invoice( - int(amount)*1000, label, description) + invoice = plugin.rpc.invoice(int(amount) * 1000, label, description) b11 = invoice["bolt11"] qr = make_base64_qr_code(b11) @@ -93,7 +88,7 @@ def donation_form(): # FIXME: change to paid after debugging if invoice["status"] == "paid": bolt11 = plugin.rpc.decodepay(invoice["bolt11"]) - satoshis = int(bolt11["msatoshi"])//1000 + satoshis = int(bolt11["msatoshi"]) // 1000 description = bolt11["description"] ts = bolt11["created_at"] donations.append((ts, satoshis, description)) @@ -111,7 +106,7 @@ def worker(port): app.add_url_rule('/donation', 'donation', donation_form, methods=["GET", "POST"]) app.add_url_rule('/is_invoice_paid/