Bitcoin Forum
May 02, 2024, 09:54:13 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: The Tech Behind Building a Bitcoin LNpos  (Read 43 times)
Accardo (OP)
Hero Member
*****
Offline Offline

Activity: 1078
Merit: 509


Leading Crypto Sports Betting & Casino Platform


View Profile
October 10, 2023, 03:07:05 PM
Merited by DaveF (5), Pmalek (2)
 #1

I followed how to set up a bitcoin pos using lnbit and figured out that it's an interesting process. Read through some libraries that formed the executing plans of the Lnpos. So, I delve into the crucial tools, which helps the functionality of a bitcoin Lnpos. I'll be looking at the engine of an Lnpos. Arduino and auduino esp32 board. These two programs serve as the Processor of the pos. Every other Library is downloaded to them.


How they work?

The Arduino gets connected to the board via USB, and configure the board's processor, using different lnbit libraries. These Lnbit compatible libraries get installed to the Arduino through the IDE library manager. They're multipurpose. It can be used to set up new unique projects other than bitcoin. But it might execute single purposes like "autoconnect" which purpose is for the Lnpos to easily connect to wifi through the "autoconnect menu" here is an example of its root URL http://{localIP}/_ac Eight libraries were installed to the Auduino IDE library to power the lnpos functionality. With M5stack kit pocket computer and a detachable charger. Autoconnect collaborate with two other libraries, page builder and Json to effectively execute its purpose on the lnpos.

The autoconnect menu controls the settings; disconnect, resetting etc of the Lnpos wifi connection. Autoconnect saves the SSID and password into the flash of ESP module to maintain an automatic connection of the Pos to the Wifi. Hence, with the help of autoconnect the POS don't need to submit password to a specific wifi connection all the time.

Page builder is an additional library responsible for creating HTML for ESP8266WebServer. It inherits request handler from the ESP8266WebServer or Webserver library. Page builder is invoked from ESP8266WebServer/WebServer in response to HTTP request. Hence autoconnect is united with these Esp8266webserver and webserver class for ESP32. Which facilitates the implementation of the web interface constituting of the WLAN for ESP8266/ESP32 WiFi connection. The Pos operator can use his smartphone to input wifi password on the web interface at run time.

Arduino Json With Json custom webpages can be embedded into autoconnect. The custom webpage can be embedded in the sketch as a fixed string or can store in an external file such as spiff.

These three Libraries above controls the internet operation of the Lnpos. Below we'll be looking at more Libraries and how they contribute to the operation of the bitcoin pos.

QR CODE is a library for generating Qr codes to be scanned on the screen of the M5stack Arduino compatible device used as the POS machine. For this library to work on your program you'll have to install or attach it to the arduino library directories.

Base64 library encodes the partially signed bitcoin transactions. Looking at the code, Arcbtc included all the characters that makes up Base64; 0-9 A-z upper and lower case

Code:
const char PROGMEM _Base64AlphabetTable[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";

Ubitcoin or micro-bitcoin controls the transactions, private keys, public keys, parsing and signing PSBT etc. Everything needed to set up a hardware wallet is contained in this library. Including hashing algorithms. WIth this library you can build your own hardware wallet using the appropriate esp32 board. After scanning the QR code on the bitcoin pos, deposited fund is under the control of this library. Using this example You'll see how it generates private keys from the recovery seed, generate a random recovery seed on https://iancoleman.io/bip39/ and check the master key, the account private key and public key.

keypad is a library incharge of the keys used to operate the LNpos. It can be found on the Arduino IDE library manager for easy installation of the library into your arduino. Search for Keypad on "manage library" then install. Below is how the keypad is constructed.

Code:
const byte rows = 4; //four rows
const byte cols = 3; //three columns
char keys[rows][cols] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[rows] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[cols] = {8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );


Some important lines of codes that connects these libraries to work together in achieving the goal of a bitcoin based Lnpos.


At the begining of the LNpos settings he mentioned about the wifi password "Go to settings to lanch USB config mode or wifi access point If using access opint the device SSID default password is "ToTheMoon1""

It can be found under pos configuration
Code:
{
      "name": "password",
      "type": "ACInput",
      "label": "Password for PoS AP WiFi",
      "value": "ToTheMoon1"
    },

Reading further the code, you'll notice that this code works in line with the keypad, autoconnect, arduino Json and probably page builder to help the POS connect successfully to the Wifi network.

On the onchain payment method down to request invoice

Code:
// request invoice
      processing("FETCHING INVOICE");
      if (!getInvoice()) {
        unConfirmed = false;
        error("ERROR FETCHING INVOICE");
        delay(3000);
        break;
      }

      // show QR
      qrShowCodeln();

I could notice the relationship between the Qrcode and the Ubitcoin or micro bitcoin library in channeling, securing and publishing transactions on chain.

These libraries listed above thought me that building a bitcoin compatible hardware project is also easy to achieve, just like putting them together to achieve a specific goal. Like I said earlier, they can be used for different purpose, projects etc. Below are the links to the libraries used by Arcbtc to set up this bitcoin Lnpos.

https://github.com/lnbits/lnpos/tree/main/lnPoSTdisplay/libraries

A link to the set up github repo

https://github.com/lnbits/lnpos

The coding style

https://github.com/lnbits/lnpos/blob/main/lnPoSTdisplay/lnPoSTdisplay.ino

I missed one library hope some one helps me with that Grin

..Stake.com..   ▄████████████████████████████████████▄
   ██ ▄▄▄▄▄▄▄▄▄▄            ▄▄▄▄▄▄▄▄▄▄ ██  ▄████▄
   ██ ▀▀▀▀▀▀▀▀▀▀ ██████████ ▀▀▀▀▀▀▀▀▀▀ ██  ██████
   ██ ██████████ ██      ██ ██████████ ██   ▀██▀
   ██ ██      ██ ██████  ██ ██      ██ ██    ██
   ██ ██████  ██ █████  ███ ██████  ██ ████▄ ██
   ██ █████  ███ ████  ████ █████  ███ ████████
   ██ ████  ████ ██████████ ████  ████ ████▀
   ██ ██████████ ▄▄▄▄▄▄▄▄▄▄ ██████████ ██
   ██            ▀▀▀▀▀▀▀▀▀▀            ██ 
   ▀█████████▀ ▄████████████▄ ▀█████████▀
  ▄▄▄▄▄▄▄▄▄▄▄▄███  ██  ██  ███▄▄▄▄▄▄▄▄▄▄▄▄
 ██████████████████████████████████████████
▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
█  ▄▀▄             █▀▀█▀▄▄
█  █▀█             █  ▐  ▐▌
█       ▄██▄       █  ▌  █
█     ▄██████▄     █  ▌ ▐▌
█    ██████████    █ ▐  █
█   ▐██████████▌   █ ▐ ▐▌
█    ▀▀██████▀▀    █ ▌ █
█     ▄▄▄██▄▄▄     █ ▌▐▌
█                  █▐ █
█                  █▐▐▌
█                  █▐█
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀█
▄▄█████████▄▄
▄██▀▀▀▀█████▀▀▀▀██▄
▄█▀       ▐█▌       ▀█▄
██         ▐█▌         ██
████▄     ▄█████▄     ▄████
████████▄███████████▄████████
███▀    █████████████    ▀███
██       ███████████       ██
▀█▄       █████████       ▄█▀
▀█▄    ▄██▀▀▀▀▀▀▀██▄  ▄▄▄█▀
▀███████         ███████▀
▀█████▄       ▄█████▀
▀▀▀███▄▄▄███▀▀▀
..PLAY NOW..
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!