/PET4L

PIVX Emergency Tool for Ledger - Spend PIV from a seemingly "Stuck" Ledger wallet

Primary LanguagePythonMIT LicenseMIT

PET4L

PET4L [PIVX Emergency Tool For Ledger] is a tool to spend PIVs that are "trapped inside" the Ledger Nano (either S or X) when Ledger Live acts crazy.

How does it work?

  1. it fetches addresses from the device
  2. asks to the block explorer the UTXOs related to each address
  3. it creates the raw TX and signs the new inputs on the Nano S device
  4. finally uses the sendrawtransaction RPC call of the Core wallet to broadcast the TX.

Installation

If you are using a binary version:

  • Linux - Mac OsX: no installation required. Simply extract the tar.gz archive and run the executable.
  • Windows: double-click the installer file and follow the instructions.

If you are running PET4L from the source-code instead, you will need Python3 and several libraries installed.
Needed libraries are listed in requirements.txt.
From the PET4L directory, launch the tool with:

python3 pet4l.py

To make binary versions from source, PyInstaller can be used with the specPet4l.spec file provided.

Setup

Setting up the RPC server

In order to interact with the PIVX blockchain, PET4L needs a local PIVX wallet running alongside (any empty pivx-cli wallet will do). Edit your local pivx.conf inserting rpcuser, rpcpassword, rpcport and rpcallowip. Example:

server=1
rpcuser=myUsername
rpcpassword=myPassword
rpcport=45458
rpcallowip=127.0.0.1

Configure the RPC server by clicking on the menu

and inserting the same data. You can leave ip 127.0.0.1 if the wallet is on the same machine as the pet4l.
Otherwise set the IP address of the machine running the Core PIVX wallet.

Connections

If the IP and the credentials of the PIVX wallet are correct, it should connect with pet4l instantly.
Otherwise use the Connect button next to "PIVX server: Local Wallet".
Connect the hardware device to USB and open the PIVX-App on it.
Click the button Connect next to "HW device: Ledger Nano S" to connect to the hardware device.

Once successfully connected, it gives a confirmation message and the led turns purple.

Usage

Loading Addresses And UTXOs

Adjust the fields as needed:

  • Account HW : insert the account number you wish to recover funds from (default: 0)
  • spath from : insert the n. of the first address to search (default: 0)
  • spath to : insert the n. of the last address to search (default: 10)
  • internal/external : insert 0 for normal addresses and 1 for change addresses (default: 0)

Click on Scan Ledger Device to retrieve the addresses and load the UTXOs


Open the menu to select an address and check related UTXOs

Spending UTXOs

Once loaded, select those UTXOs you wish to spend.
Insert the destination address.
Check the suggested fee and adjust as preferred.
Then click on Send


Verify the details of the TX both on screen and on the display of the Nano S. If everything checks out, click "yes" (right button) on the device.


The transaction is now assembled and signed.
Pet4l asks one more time to check the details before broadcasting the transaction (thus spending the selected UTXOs).


Click Yes to finally broadcast the transaction to the PIVX network.
Click Show Details to get the TX-id that identify the transaction.


It should appear on the Block Explorers after a few minutes.