def update_payout_screen(papirus): # global INVOICE ## initially set all white background image = Image.new('1', PAPIRUS.size, WHITE) ## Set width and heigt of screen width, height = image.size ## prepare for drawing draw = ImageDraw.Draw(image) draw.rectangle((2, 2, width - 2, height - 2), fill=WHITE, outline=BLACK) draw.text((15, 30), str(round(SATS)) + ' sats', fill=BLACK, font=createfont('freemono', 20)) draw.text((15, 50), 'on the way!', fill=BLACK, font=createfont('freemono', 15)) PAPIRUS.display(image) PAPIRUS.update() # INVOICE = qr.scan() decodreq = lightning.decoderequest(INVOICE) print(decodreq, round(SATS)) if (decodreq == str(round(SATS))) or (decodreq == True): lightning.payout(SATS, INVOICE) result = lightning.lastpayment(INVOICE) draw.text((15, 70), str(result), fill=BLACK, font=createfont('freemono', 15)) PAPIRUS.display(image) PAPIRUS.partial_update() time.sleep(1) if result == 'Success': display.update_thankyou_screen() else: display.update_payment_failed() time.sleep(120) logging.info('Initiating restart...') os.execv('/home/pi/LightningATM/app.py', ['']) else: print('Please show correct invoice')
def update_payout_screen(papirus, size): global INVOICE # initially set all white background image = Image.new('1', papirus.size, WHITE) # Set width and heigt of screen width, height = image.size # prepare for drawing draw = ImageDraw.Draw(image) # set font sizes font = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMono.ttf', 20) font1 = ImageFont.truetype( '/usr/share/fonts/truetype/freefont/FreeMono.ttf', 15) # set btc and sat price # btcprice = price.getbtcprice(CURRENCY) # satprice = round((1 / btcprice) * 10e5, 2) draw.rectangle((2, 2, width - 2, height - 2), fill=WHITE, outline=BLACK) draw.text((15, 30), str(round(SATS)) + ' sats', fill=BLACK, font=font) draw.text((15, 50), 'on the way!', fill=BLACK, font=font1) papirus.display(image) papirus.update() INVOICE = qr.scan() print(INVOICE) decodreq = lightning.decoderequest(INVOICE) print(decodreq, round(SATS)) if (decodreq == str(round(SATS))) or (decodreq == True): lightning.payout(SATS, INVOICE) # time.sleep(5) result = lightning.lastpayment(INVOICE) draw.text((15, 70), str(result), fill=BLACK, font=font1) papirus.display(image) papirus.partial_update() else: print('Please show correct invoice')
def update_payout_screen(papirus): global INVOICE ## initially set all white background image = Image.new('1', PAPIRUS.size, WHITE) ## Set width and heigt of screen width, height = image.size ## prepare for drawing draw = ImageDraw.Draw(image) draw.rectangle((2, 2, width - 2, height - 2), fill=WHITE, outline=BLACK) draw.text((15, 30), str(round(SATS)) + ' sats', fill=BLACK, font=createfont('freemono', 20)) draw.text((15, 50), 'on the way!', fill=BLACK, font=createfont('freemono', 15)) PAPIRUS.display(image) PAPIRUS.update() INVOICE = qr.scan() print(INVOICE) decodreq = lightning.decoderequest(INVOICE) print(decodreq, round(SATS)) if (decodreq == str(round(SATS))) or (decodreq == True): lightning.payout(SATS, INVOICE) result = lightning.lastpayment(INVOICE) draw.text((15, 70), str(result), fill=BLACK, font=createfont('freemono', 15)) PAPIRUS.display(image) PAPIRUS.partial_update() else: print('Please show correct invoice')