Esempio n. 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")
Esempio n. 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')
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')
Esempio n. 4
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()

    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')