Bitcoin Forum
July 05, 2024, 10:30:50 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Fixing TRON issues in Ledger Live - no more OUT OF ENERGY  (Read 35 times)
xbtcl (OP)
Newbie
*
Offline Offline

Activity: 3
Merit: 0


View Profile
December 07, 2022, 09:43:21 PM
Last edit: December 07, 2022, 09:54:39 PM by xbtcl
 #1

Issue: Ledger Live for some reason imposes a limit of 10 TRX on the maximum fee that a transaction can spend in the Tron blockchain instead of letting users change the maximum fee themselves.

Transactions work as follows: when sending a TRC-20 token, for example USDT, the transaction spends units of energy. If there is not enough energy, TRX coins are burned. The calculator can be found here https://tronstation.io/calculator. 1 TRX = 2,380 energy. If the account has no energy at all, one USDT transaction, which currently needs ~30000 energy units, should burn ~12.5 TRX. Previously such transactions spent 2-4-6-8 TRX, no more, and there was no problem. But when the fee became higher than 10 TRX, the transactions fails with an "OUT OF ENERGY" error due to the 10 TRX limit. And the user paying that fee for a failed transaction.

Instead of fixing the obvious bug the company wrote an article suggesting users:
1) Freeze TRX for energy, which is ~1300 TRX per transaction in USDT, and you can not do anything with a frozen TRX for three days
2) Wait for lower fees Smiley
3) Use Tronscan explorer, which has a hardware wallet connection feature and has no 10 TRX limit

Of all the options, the third one is the only adequate one, except that Tronscan does not know how to work with the second, third and further Ledger accounts. That is, if you use additional accounts, there are no options at all, which Ledger chose to keep silent about.

Second issue: Ledger Live will not let you send USDT to an account that is not activated in the Tron blockchain. The protocol itself doesn't prohibit this, and such transactions work fine. Instead of fixing the problem, as in the first case, Ledger offers to send 0.1 TRX to a non-activated account, i.e. to activate someone else's account from your pocket.

I decided to fix this bullshit and share it with the community. Here you can download ready to use files for Windows and Linux https://github.com/e4p1k0/ledger-live/releases/tag/v2.50.0

The fix itself consists of changing the fee_limit value and removing the code that prevented signing the transaction to a non-activated account https://github.com/e4p1k0/ledger-live/commit/35b9b989561566f5b30f00fa75c37e9be66bcac9. As you can see, everything is very simple.

Well, below are instructions on how you can do it yourself, so you do not have to trust a dude from the Internet Smiley The difficulty here is not in the compiling itself, but in the installation of the necessary tools.

Windows 10

Open Power Shell as administrator and install the necessary dependencies.

1. Install Chocolatey package manager
Copy installation command to the shell from chocolatey.org Get Started section

Code:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

2. Install Ruby on Rails and Git
Code:
choco install ruby git -y

3. Install Node.js
Download from https://nodejs.org/dist/latest-v16.x/ node-v16.18.1-x64.msi. In the installation dialog check "Automatically install the necessary tools", do not change the rest. After installation the command line window will appear, press the spacebar, the Power Shell window will open and begins looong installation process of dependencies for the correct operation of Node.js, just wait. When the installation is completed the Power Shell window will ask you to press Enter.

4. Install pnpm
Copy installation command to the shell from https://pnpm.io/installation
Code:
iwr https://get.pnpm.io/install.ps1 -useb | iex

5. Install Bundler
Close the Power Shell window and run it again as administrator.
Code:
gem install bundler

6. Building Ledger Live
Close the Power Shell window and run it again, but without administrator rights.
Code:
# install node-gyp
npm install -g node-gyp

# clone official Ledger Live repo
git clone https://github.com/LedgerHQ/ledger-live

# change directory
cd .\ledger-live\

# make the necessary changes in the code according to the commit
# https://github.com/e4p1k0/ledger-live/commit/35b9b989561566f5b30f00fa75c37e9be66bcac9
# fee_limit: 100000000 = 100 TRX
# lines to be deleted are highlighted in red
notepad libs/ledger-live-common/src/api/Tron.ts
notepad libs/ledger-live-common/src/families/tron/bridge/js.ts

# build
pnpm i
pnpm build:lld:deps
pnpm desktop build

That's it! Compiled file will be located in C:\Users\User_Name\ledger-live\apps\ledger-live-desktop\dist\

Linux

Using Ubuntu 20.04.
Code:
# install Git, Bundler
sudo apt update
sudo apt install git bundler

# install nvm
# https://github.com/nvm-sh/nvm#install--update-script
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

# install Node.js
nvm install v16

# install pnpm
npm install -g pnpm

# clone official Ledger Live repo
git clone https://github.com/LedgerHQ/ledger-live

# change directory
cd ledger-live

# make the necessary changes in the code according to the commit
# https://github.com/e4p1k0/ledger-live/commit/35b9b989561566f5b30f00fa75c37e9be66bcac9
# fee_limit: 100000000 - этo 100 TRX
# lines to be deleted are highlighted in red
nano libs/ledger-live-common/src/api/Tron.ts
nano libs/ledger-live-common/src/families/tron/bridge/js.ts
# to search for the necessary values in the nano editor use ctrl+W
# save changes: sequentially press ctrl+X, Y, Enter

# build
pnpm i
pnpm build:lld:deps
pnpm desktop build

That's it! Compiled file will be located in apps/ledger-live-desktop/dist/
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!