Coder Social home page Coder Social logo

nr-tools's Introduction

image

NR-TOOLS

Essential and Life-Saver Tools for Node Runners.

All these tools are helping me a lot with my Lightning Node Friendspool⚡🍻

image

Basic Setup

How to Setup Telegram Bot:

  1. Create a Telegram Bot: Open the Telegram app and search for the "BotFather" bot. Start a chat with BotFather and use the /newbot command to create a new bot. Follow the instructions to set up your bot and obtain the API token.
  2. Get Your Chat ID: Start a chat with your newly created bot. Visit the following URL in your web browser, replacing <YOUR_BOT_TOKEN> with the actual token you obtained: bash https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates Look for the "chat" object within the response. The "id" field in that object is your chat ID.
  3. Get your TELEGRAM USER ID (This is very important to ensure you are the only user authorized to use the bot Access https://t.me/userinfobot and this will return your TELEGRAM_USER_ID

Repository Installation:

  1. Git Clone the Repository: git clone https://github.com/jvxis/nr-tools.git

This script checks for pending stuck htlcs that are near expiration height (< 13 blocks). It collects peers of critical htlc and disconnects / reconnects them to reestablish the htlc. Sometimes htlcs are being resolved before expiration this way and thus costly force closes can be prevented.

How to Setup:

  1. open the code: cd nr-tools and nano htlcScan.sh
  2. Include your Bot Token and Chat ID to receive telegram messages
  3. Replace the line 26 _CMD_LNCLI="/path_to_umbrel/scripts/app compose lightning exec -T lnd lncli" with your Umbrel diretory Path
  4. Optionally set up the blocks_til_expiry=13 on line 75 to a higher number
  5. Save the Script - CTRL + O
  6. Leave the editor - CTRL + X
  7. Make the script an executable: sudo chmod +x htlcScan.sh
  8. Setup CRON to run the script every 30 minutes - sudo crontab -e
  9. Add the line: */30 * * * * /bin/bash /home/<USER>/nr-tools/htlcScan.sh
  10. CTRL + O to save and CTRL + X to leave editor

Done!

This script checks the LND database size and restarts the lND and other services if it is bigger than 12GB.

How to Setup:

  1. open the code: cd nr-tools and nano check_channelsdb_size.sh
  2. Include your Bot Token and Chat ID to receive telegram messages
  3. Replace on line 4 /path_to_umbrel with the path for your Umbrel Directory file_path="/path_to_umbrel/app-data/lightning/data/lnd/data/graph/mainnet/channel.db"
  4. Setup with the size that you usually restart LND on line 7 threshold_size="12000000000"
  5. Replace lines 41 and 48, where is /path_to_umbrel with path for your Umbrel Directory
  6. Save the Script - CTRL + O
  7. Leave the editor - CTRL + X
  8. Make the script an executable: sudo chmod +x check_channelsdb_size.sh
  9. Setup CRON to run the script every 1 hour - sudo crontab -e
  10. Add the line: 0 * * * * /bin/bash /home/<USER>/nr-tools/check_channelsdb_size.sh
  11. CTRL + O to save and CTRL + X to leave editor

Done!

This is a telegram bot to start, stop and restart Umbrel services. You can use /on name_of_service to start some services

How to Setup:

  1. open the code: cd nr-tools and nano service_on_off.py
  2. Include your Bot Token and your Telegram user Id to receive telegram messages
  3. Replace /path_to_umbrel with your path to Umbrel directorySCRIPT_PATH = "/path_to_umbrel/scripts/app"
  4. Save the Script - CTRL + O
  5. Leave the editor - CTRL + X
  6. Install Dependencies: pip3 install pyTelegramBotAPI
  7. Run the code: python3 service_on_off.py

You can also run it with a screen command to keep it executing in background: screen -S service-on-off python3 service_on_off.py

Usage: On your telegram app inside the BOT, you can type:

  • /on lightning - to turn on lnd
  • /off lightning - to turn off lnd
  • /boot lighting - to restart lnd The same can be done with any Umbrel Services. Like, bitcoin, lightning-terminal etc.

Done!

This script sells some info about your node every day, channels, and their capacity, and you get some SATs back as payment for this info

Portuguese Instructions by Redin: https://github.com/jvxis/nr-tools/blob/main/SATS4.txt

Pre-reqs

  1. You need to set up an account on https://sparkseer.space
  2. Then you need to get the API-KEY
  3. Click on Node and then Account and click on the button GENERATE APY KEY image
  4. Open the code: cd nr-tools and nano sats4plus.py
  5. Replace the line 12 with your API KEY: API_KEY = "SPARKEER_API_KEY"
  6. On line 55 replace /path_to_umbrel with the path to your Umbrel directory: ["/path_to_umbrel/scripts/app", "compose", "lightning", "exec", "lnd", "lncli", "querymc"],
  7. Save the Script - CTRL + O
  8. Leave the editor - CTRL + X
  9. Install Dependencies: pip3 install requests
  10. Run the code: python3 sats4plus.py

Recommended to execute this code as a Linux Service or with screen: screen -S sats4 python3 sats4plus.py

Done!

This code calculates how much on fees you will spend to send an on-chain transaction, considering your available UTXOs

Pre-reqs You need Balance of Satoshis (BOS) installed

Usage:

  1. Just run python3 onchain-fee-calc.py

image

Check out the Telegram Bot Version onchain-fee-calc-bot.py You only need to replace it with your Bot Token.

Done!

Generates a BOS Fund command to consolidate your unspent UTXOS.

Pre-reqs You need Balance of Satoshis (BOS) installed

Usage:

  1. Just run python3 utxo-consolidator.py

** This program only generates the command, so you should first check it, copy, paste and then RUN.

Done!

This code, generates a channel open command considering only your unspent UTXOs needed. It helps to save sats during this process. So you can open your channels like a PRO!

How to Setup:

  1. open the code: cd nr-tools and openchannel-pro.py
  2. Replace path_to_umbrel with your path to Umbrel directorypath_to_umbrel = "Your_Path_TO_Umbrel"
  3. Save the Script - CTRL + O
  4. Leave the editor - CTRL + X

Usage:

  1. Just run python3 openchannel-pro.py

** This program only generates the command, so you should first check it, copy, paste and then RUN.

Done!

This code runs with your crontab every day and saves your node balance, considering Forwards and Rebalances

Pre-reqs You need Balance of Satoshis (BOS) installed

How to Setup:

  1. open the code: cd nr-tools and get_node_daily_balance.py
  2. Replace NODE_NAME = "Your-node-name" with your Node Alias
  3. Replace FULL_PATH_BOS = "/home/<user>/.npm-global/lib/node_modules/balanceofsatoshis/"This is very important to set up right to run with Crontab
  4. Save the Script - CTRL + O
  5. Leave the editor - CTRL + X
  6. open crontab with the command crontab -e
  7. Add a line: 0 0 * * * /usr/bin/python3 /home/<user>/get_node_daily_balance.py >> /home/<user>/node-balance.log 2>&1 Please check if it is the right path in your system.
  8. Save the Script - CTRL + O
  9. Leave the editor - CTRL + X

** This code will save your node daily balance in the file /home/<user>/node-balance.log

** If you want to run adhoc for a specific date and month please run the code get_node_balance.py

Done!

Use these 2 scripts to execute a Peg-in process from BTC to L-BTC using your own node ONLY! Tutorial By EMTLL: https://emtll.substack.com/p/como-emitir-btc-na-liquid-network

nr-tools's People

Contributors

emtll avatar jvxis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.