Пример #1
0
def softreset():
    """Displays startup screen and deletes fiat amount
    """
    config.SATS = 0
    config.FIAT = 0
    display.update_startup_screen()
    logger.info("Softreset executed")
Пример #2
0
def softreset():
    """Displays startup screen and deletes fiat amount
    """
    global led
    config.SATS = 0
    config.FIAT = 0
    # Turn off button LED
    GPIO.output(13, GPIO.LOW)
    led = "off"

    display.update_startup_screen()
    logger.info("Softreset executed")
Пример #3
0
def button_pushed():
    """Actions button pushes by number
    """
    if config.PUSHES == 1:
        if config.FIAT == 0:
            display.update_nocoin_screen()
            time.sleep(3)
            display.update_startup_screen()
        else:
            display.update_qr_request(config.SATS)
            config.INVOICE = qr.scan()
            while config.INVOICE is False:
                display.update_qr_failed()
                time.sleep(1)
                display.update_qr_request(config.SATS)
                config.INVOICE = qr.scan()
            update_payout_screen()

    if config.PUSHES == 2:
        if config.FIAT == 0:
            display.update_nocoin_screen()
            time.sleep(3)
            display.update_startup_screen()
        else:
            lntxbot.process_using_lnurl(config.SATS)

    if config.PUSHES == 3:
        display.update_lntxbot_scan()
        lntxcreds = lntxbot.scan_creds()
        utils.update_config("LNTXBOTCRED", lntxcreds)
        importlib.reload(config)
        balance = lntxbot.get_lnurl_balance()
        display.update_lntxbot_balance(balance)
        GPIO.cleanup()
        os.execv("/home/pi/LightningATM/app.py", [""])

    if config.PUSHES == 4:
        logger.info("Button pushed three times (add coin)")
        print("Button pushed three times (add coin)")
        config.PULSES = 2

    if config.PUSHES == 5:
        logger.warning("Button pushed three times (restart)")
        print("Button pushed three times (restart)")
        GPIO.cleanup()
        os.execv("/home/pi/LightningATM/app.py", [""])

    if config.PUSHES == 6:
        display.update_shutdown_screen()
        GPIO.cleanup()
        logger.info("ATM shutdown (5 times button)")
        os.system("sudo shutdown -h now")
    config.PUSHES = 0
Пример #4
0
def main():
    utils.check_epd_size()

    logger.info("Application started")

    check_dangermode()

    # Display startup startup_screen
    display.update_startup_screen()

    setup_coin_acceptor()

    while True:
        monitor_coins_and_button()
Пример #5
0
def main():
    utils.check_epd_size()
    logger.info("Application started")

    # Checks dangermode and start scanning for credentials
    # Only activate once software ready for it
    # check_dangermode()

    # Display startup startup_screen
    display.update_startup_screen()

    setup_coin_acceptor()

    while True:
        monitor_coins_and_button()
Пример #6
0
def main():
    #utils.check_epd_size()
    logger.info("Application started")

    # Checks dangermode and start scanning for credentials
    # Only activate once software ready for it
    # check_dangermode()

    t = threading.Thread(target=run_graphic_app, args=(graphic_app, ))
    t.start()

    print('before startup_screen')

    time.sleep(1)
    # Display startup startup_screen
    display.update_startup_screen()

    setup_coin_acceptor()

    while True:
        monitor_coins_and_button()
Пример #7
0
def main():
    global FIAT
    global SATS
    global PULSES
    global PUSHES
    global INVOICE

    ## Initiating logging instance
    logging.basicConfig(filename='/home/pi/LightningATM/resources/debug.log',
                            format='%(asctime)s %(name)s %(levelname)s %(message)s',
                            datefmt='%Y/%m/%d %I:%M:%S %p',
                            level=logging.INFO)

    logging.info('Application started')

    ## Display startup startup_screen
    display.update_startup_screen()

    ## Defining GPIO BCM Mode
    GPIO.setmode(GPIO.BCM)

    ## Setup GPIO Pins for coin acceptor and button
    GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    GPIO.setup(6,GPIO.IN, pull_up_down=GPIO.PUD_UP)

    ## Setup coin interrupt channel (bouncetime for switch bounce)
    GPIO.add_event_detect(5, GPIO.RISING,callback=buttonevent, bouncetime=200)
    GPIO.add_event_detect(6,GPIO.FALLING,callback=coinevent)

    while True:
        time.sleep(0.5)
        ## Detect when coins are being inserted
        if((time.time() - LASTIMPULSE > 0.5) and (PULSES > 0)):
            if (PULSES == 2):
                FIAT += 0.02
                SATS = FIAT * 100 * SATPRICE
                logging.info('2 cents added')
                update_amount_screen(PAPIRUS)
            if (PULSES == 3):
                FIAT += 0.05
                SATS = FIAT * 100 * SATPRICE
                logging.info('5 cents added')
                update_amount_screen(PAPIRUS)
            if (PULSES == 4):
                FIAT += 0.1
                SATS = FIAT * 100 * SATPRICE
                logging.info('10 cents added')
                update_amount_screen(PAPIRUS)
            if (PULSES == 5):
                FIAT += 0.2
                SATS = FIAT * 100 * SATPRICE
                logging.info('20 cents added')
                update_amount_screen(PAPIRUS)
            if (PULSES == 6):
                FIAT += 0.5
                SATS = FIAT * 100 * SATPRICE
                logging.info('50 cents added')
                update_amount_screen(PAPIRUS)
            if (PULSES == 7):
                FIAT += 1
                SATS = FIAT * 100 * SATPRICE
                logging.info('100 cents added')
                update_amount_screen(PAPIRUS)
            PULSES = 0

        ## Detect if the buttons has been pushed
        if((time.time() - LASTPUSHES > 0.5) and (PUSHES > 0)):
            if (PUSHES == 1):
                if FIAT == 0:
                    display.update_nocoin_screen()
                    time.sleep(3)
                    display.update_startup_screen()
                else:
                    display.update_qr_request()
                    INVOICE = qr.scan()
                    while INVOICE == False:
                        display.update_qr_failed()
                        time.sleep(1)
                        display.update_qr_request()
                        INVOICE = qr.scan()
                    update_payout_screen(PAPIRUS)

            if (PUSHES == 2):
                logging.info('Button pushed twice (add coin)')
                print('Button pushed twice (add coin)')
                PULSES = 2

            if (PUSHES == 3):
                logging.warning('Button pushed three times (restart)')
                print('Button pushed three times (restart)')
                os.execv('/home/pi/LightningATM/app.py', [''])
                GPIO.cleanup()

            if (PUSHES == 4):
                display.update_shutdown_screen()
                GPIO.cleanup()
                logging.info('ATM shutdown (4 times button)')
                os.system('sudo shutdown -h now')
            PUSHES = 0
Пример #8
0
def button_pushed():
    """Actions button pushes by number
    """
    if config.PUSHES == 1:
        """If no coins inserted, update the screen.
        If coins inserted, scan a qr code for the exchange amount
        """
        if config.FIAT == 0:
            display.update_nocoin_screen()
            time.sleep(3)
            display.update_startup_screen()
        else:
            display.update_qr_request()
            qrcode = qr.scan()
            config.INVOICE = lndrest.evaluate_scan(qrcode)
            while config.INVOICE is False:
                display.update_qr_failed()
                time.sleep(1)
                display.update_qr_request()
                qrcode = qr.scan()
                config.INVOICE = lndrest.evaluate_scan(qrcode)
            display.update_payout_screen()
            lndrest.handle_invoice()
            softreset()

    if config.PUSHES == 2:
        """If no coins inserted, update the screen.
        If coins are inserted, return a lnurl for the exchange amount
        """
        if config.FIAT == 0:
            display.update_nocoin_screen()
            time.sleep(3)
            display.update_startup_screen()
        else:
            lntxbot.process_using_lnurl(config.SATS)
            # Softreset and startup screen
            softreset()

    if config.PUSHES == 3:
        """Store new lntxbot credential via a QR code scan
        """
        display.update_lntxbot_scan()

        # scan the credentials
        lntxcreds = lntxbot.scan_creds()

        # save them to the current config and reload config file
        config.update_config("lntxbot", "creds", lntxcreds)
        if config.check_dangermode():
            importlib.reload(config)

        # return the current balance to the user on the screen
        balance = lntxbot.get_lnurl_balance()
        display.update_lntxbot_balance(balance)
        softreset()

    if config.PUSHES == 4:
        """Simulates adding a coin
        """
        logger.info("Button pushed four times (add coin)")
        print("Button pushed four times (add coin)")
        config.PULSES = 2

    if config.PUSHES == 5:
        """Restarts the application
        """
        logger.warning("Button pushed five times (restart)")
        print("Button pushed five times (restart)")
        utils.softreset()

    if config.PUSHES == 6:
        """Shutdown the host machine
        """
        display.update_shutdown_screen()
        GPIO.cleanup()
        logger.warning("ATM shutdown (6 times button)")
        os.system("sudo shutdown -h now")
    config.PUSHES = 0
Пример #9
0
def button_pushed():
    """Actions button pushes by number
    """
    if config.PUSHES == 1:
        """If no coins inserted, update the screen.
        If coins inserted, scan a qr code for the exchange amount
        """
        if config.FIAT == 0:
            display.update_nocoin_screen()
            time.sleep(3)
            display.update_startup_screen()

        if not config.conf["atm"]["activewallet"]:
            logger.error("No wallet has been configured for the ATM.")
            # Softreset and startup screen
            softreset()

        if config.conf["atm"]["activewallet"] == "btcpay_lnd":
            display.update_qr_request()
            qrcode = qr.scan()
            config.INVOICE = lndrest.evaluate_scan(qrcode)
            while config.INVOICE is False:
                display.update_qr_failed()
                time.sleep(1)
                display.update_qr_request()
                qrcode = qr.scan()
                config.INVOICE = lndrest.evaluate_scan(qrcode)
            display.update_payout_screen()
            lndrest.handle_invoice()
            softreset()
        elif config.conf["atm"]["activewallet"] == "lntxbot":
            lntxbot.process_using_lnurl(config.SATS)
            # Softreset and startup screen
            softreset()
            # lntxbot.payout(config.SATS, config.INVOICE)
        else:
            pass

    if config.PUSHES == 3:
        """Scan and store new wallet credentials
        """
        # Delete current wallet flag and credentials
        config.update_config("atm", "activewallet", "")
        config.update_config("lntxbot", "creds", "")
        config.update_config("lnd", "macaroon", "")

        display.update_wallet_scan()
        qr.scan_credentials()
        importlib.reload(config)

        if config.conf["atm"]["activewallet"] == "btcpay_lnd":
            display.update_btcpay_lnd()
        elif config.conf["atm"]["activewallet"] == "lntxbot":
            balance = lntxbot.get_lnurl_balance()
            display.update_lntxbot_balance(balance)
        else:
            logger.error("Saving of wallet credentials failed.")

        # scan the credentials
        # lntxcreds = lntxbot.scan_creds()

        # save them to the current config and reload config file
        # config.update_config("lntxbot", "creds", lntxcreds)
        # if config.check_dangermode():
        #     importlib.reload(config)

        # return the current balance to the user on the screen

        softreset()

    if config.PUSHES == 4:
        """Simulates adding a coin
        """
        logger.info("Button pushed four times (add coin)")
        print("Button pushed four times (add coin)")
        config.PULSES = 2

    if config.PUSHES == 6:
        """Shutdown the host machine
        """
        display.update_shutdown_screen()
        GPIO.cleanup()
        logger.warning("ATM shutdown (6 times button)")
        os.system("sudo shutdown -h now")
    config.PUSHES = 0
Пример #10
0
def main():
    global FIAT
    global SATS
    global PULSES
    global PUSHES
    global INVOICE

    ## Display startup startup_screen
    display.update_startup_screen()

    ## Defining GPIO BCM Mode
    GPIO.setmode(GPIO.BCM)

    ## Setup GPIO Pins for coin acceptor and button
    GPIO.setup(5, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    GPIO.setup(6, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    ## Setup coin interrupt channel (bouncetime for switch bounce)
    GPIO.add_event_detect(5, GPIO.RISING, callback=buttonevent, bouncetime=200)
    GPIO.add_event_detect(6, GPIO.FALLING, callback=coinevent)

    while True:
        time.sleep(0.5)
        ## Detect when coins are being inserted
        if ((time.time() - LASTIMPULSE > 0.5) and (PULSES > 0)):
            if (PULSES == 1):
                FIAT += 0.02
                SATS = FIAT * 100 * SATPRICE
                update_amount_screen(PAPIRUS)
            if (PULSES == 2):
                FIAT += 0.05
                SATS = FIAT * 100 * SATPRICE
                update_amount_screen(PAPIRUS)
            if (PULSES == 3):
                FIAT += 0.1
                SATS = FIAT * 100 * SATPRICE
                update_amount_screen(PAPIRUS)
            if (PULSES == 4):
                FIAT += 0.2
                SATS = FIAT * 100 * SATPRICE
                update_amount_screen(PAPIRUS)
            if (PULSES == 5):
                FIAT += 0.5
                SATS = FIAT * 100 * SATPRICE
                update_amount_screen(PAPIRUS)
            PULSES = 0

        ## Detect if the buttons has been pushed
        if ((time.time() - LASTPUSHES > 0.5) and (PUSHES > 0)):
            if (PUSHES == 1):
                display.update_qr_request()
                INVOICE = qr.scan()
                update_payout_screen(PAPIRUS)
            if (PUSHES == 2):
                FIAT += 0.05
                SATS = FIAT * 100 * SATPRICE
                update_amount_screen(PAPIRUS)
            if (PUSHES == 3):
                os.execv('/home/pi/LightningATM/app.py', [''])
                GPIO.cleanup()
            PUSHES = 0