Exemple #1
0
def handle_invoice(draw, image):
    """Decode a BOLT11 invoice. Ensure that amount is correct or 0, then attempt to
    make the payment.
    """
    decode_req = lightning.decode_request(config.INVOICE)
    if decode_req == str(round(config.SATS)) or str(0):
        lightning.payout(config.SATS, config.INVOICE)
        result = lightning.last_payment(config.INVOICE)

        draw.text(
            (15, 70),
            str(result),
            fill=config.BLACK,
            font=utils.create_font("freemono", 15),
        )

        config.PAPIRUS.display(image)
        config.PAPIRUS.partial_update()
        time.sleep(1)

        if result is True:
            display.update_thankyou_screen()
        else:
            display.update_payment_failed()
            time.sleep(120)

        logger.info("Initiating restart...")
        os.execv("/home/pi/LightningATM/app.py", [""])
    else:
        print("Please show correct invoice")
Exemple #2
0
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')
Exemple #3
0
def handle_invoice():
    """Decode a BOLT11 invoice. Ensure that amount is correct or 0, then attempt to
    make the payment.
    """
    decode_req = decode_request(config.INVOICE)
    if decode_req in (math.floor(config.SATS), 0):
        payout(config.SATS, config.INVOICE)
        result = last_payment(config.INVOICE)

        if result is True:
            display.update_thankyou_screen()
        else:
            display.update_payment_failed()
            time.sleep(120)

        logger.info("Initiating softreset...")
    else:
        print("Please show correct invoice")