LedgerHQ/ledger-live-common

Bug on `send` CLI command

emmanuelm41 opened this issue · 4 comments

Description

If you try to execute a send command with no sender id and the first scanned account has been used before (has some txs on the blockchain or has a balance not equal to 0), the command will fail. It tries to keep scanning for new addresses (after the first one, which has been used) while at the same time it tries to sign the tx with the first address it found (the one that has been already used).

How to reproduce it

I executed the following command with filecoin cryptocurrency (it is actually on PR here #1365). However, I tested it with polkadot and it happens too). In order to reproduce it with filecoin, you will to execute yarn ci-setup-cli.

Command:
ledger-live send --currency filecoin --recipient t1d2xrzcslx7xlbbylc5c3d5lvandqw4iwl6epxba --amount 1

Output:

info: scanning filecoin on derivationMode=filecoin
debug: start getAddress process
debug: => 0600000000
debug: <= 0000120500311000049000
debug: => 06010000142c000080cd010080000000800000000000000000
debug: <= 041e10b3a453db1e7324cd37e78820d7d150c13ba3bf784be204c91afe495816a19a836e85cb89b0e4ff36d06a71a9ca02947de79e16e66dacc645e46dcdf7d9091501cdf9b117d00fa23e938e52feb25da9a32e4ecdd02966317a78343363663671623672643565346f6b6c376c65786e6a756d786535746f716a3676747233699000
debug: getAddress filecoin on 44'/461'/0'/0/0 {"path":"44'/461'/0'/0/0","address":"f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i","publicKey":"041e10b3a453db1e7324cd37e78820d7d150c13ba3bf784be204c91afe495816a19a836e85cb89b0e4ff36d06a71a9ca02947de79e16e66dacc645e46dcdf7d909"}
debug: start scanning account process. MandatoryEmptyAccountSkip 0 / StartsAt: 0 - StopAt: 255
debug: start to scan a new account. Index: 0
http: get http://127.0.0.1:8888/blockchain/filecoin/network/status {}
http: 200 get http://127.0.0.1:8888/blockchain/filecoin/network/status (744ms)
info: http://127.0.0.1:8888/blockchain/filecoin/network/status
http: get http://127.0.0.1:8888/blockchain/filecoin/addresses/f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i/balance {}
http: 200 get http://127.0.0.1:8888/blockchain/filecoin/addresses/f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i/balance (1713ms)
info: http://127.0.0.1:8888/blockchain/filecoin/addresses/f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i/balance
http: get http://127.0.0.1:8888/blockchain/filecoin/addresses/f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i/transactions {}
http: 200 get http://127.0.0.1:8888/blockchain/filecoin/addresses/f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i/transactions (1275ms)
info: http://127.0.0.1:8888/blockchain/filecoin/addresses/f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i/transactions
info: scanning filecoin at 44'/461'/0'/0/0: f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i resulted of Account with 0 txs
debug: Emit 'discovered' event for a new account found. AccountUsed: true - showNewAccount: false
→ FROM filecoin 1: 1,000,000,000,000,000,000,000 FIL (0ops) (f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i on 44'/461'/0'/0/0) filecoin#0  (! sum of ops 0 FIL)
debug: start createTransaction process
debug: start to scan a new account. Index: 1
debug: start getAddress process
debug: => 0600000000
debug: start prepareTransaction process
http: post http://127.0.0.1:8888/blockchain/filecoin/fees/estimate {"data":"{\"to\":\"t1d2xrzcslx7xlbbylc5c3d5lvandqw4iwl6epxba\",\"from\":\"f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i\"}"}
debug: <= 0000120500311000049000
debug: => 06010000142c000080cd010080000000800000000001000000
http: 200 post http://127.0.0.1:8888/blockchain/filecoin/fees/estimate (558ms)
info: http://127.0.0.1:8888/blockchain/filecoin/fees/estimate
debug: start getTransactionStatus process
debug: String Address: t1d2xrzcslx7xlbbylc5c3d5lvandqw4iwl6epxba --> Network:t - Protocol:1 - PkHash:1eaf1c8a4bbfeeb0870b1745b1f57503470b7116 - CkSum: 5f88fb84
debug: String Address: f1zx43cf6qb6rd5e4okl7lexnjumxe5toqj6vtr3i --> Network:f - Protocol:1 - PkHash:cdf9b117d00fa23e938e52feb25da9a32e4ecdd0 - CkSum: 4fab38ed
✔️ transaction 
SEND 1 FIL
TO t1d2xrzcslx7xlbbylc5c3d5lvandqw4iwl6epxba
STATUS 
  amount: 1 FIL
  estimated fees: 0.00000008010420464 FIL
  total spent: 1.00000008010420464 FIL
info: open-hid failed. 4 retry remain. TypeError: cannot open device with path IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS04@14400000/USB2.1 Hub@14400000/AppleUSB20Hub@14400000/AppleUSB20HubPort@14420000/Nano S@14420000/Nano S@0/AppleUserUSBHostHIDDevice
info: open-hid failed. 3 retry remain. TypeError: cannot open device with path IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS04@14400000/USB2.1 Hub@14400000/AppleUSB20Hub@14400000/AppleUSB20HubPort@14420000/Nano S@14420000/Nano S@0/AppleUserUSBHostHIDDevice
debug: <= 04b481eeff158ba0044fa075b2a53cb34de11193699e0fd0ee8abb10fa2acd9bc32147af05001b01bf6341c9e78b7a8244d0d3fd2a424e361dab346de6aeee251515018003fd987489d8855f1f4486d85db219497bb346296631716162373367647572686d696b7879376973646e71786e7364666578786d32676f6d34376f70699000
debug: getAddress filecoin on 44'/461'/0'/0/1 {"path":"44'/461'/0'/0/1","address":"f1qab73gdurhmikxy7isdnqxnsdfexxm2gom47opi","publicKey":"04b481eeff158ba0044fa075b2a53cb34de11193699e0fd0ee8abb10fa2acd9bc32147af05001b01bf6341c9e78b7a8244d0d3fd2a424e361dab346de6aeee2515"}
http: get http://127.0.0.1:8888/blockchain/filecoin/network/status {}
info: open-hid failed. 2 retry remain. TypeError: cannot open device with path IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS04@14400000/USB2.1 Hub@14400000/AppleUSB20Hub@14400000/AppleUSB20HubPort@14420000/Nano S@14420000/Nano S@0/AppleUserUSBHostHIDDevice
http: 200 get http://127.0.0.1:8888/blockchain/filecoin/network/status (485ms)
info: http://127.0.0.1:8888/blockchain/filecoin/network/status
http: get http://127.0.0.1:8888/blockchain/filecoin/addresses/f1qab73gdurhmikxy7isdnqxnsdfexxm2gom47opi/balance {}
info: open-hid failed. 1 retry remain. TypeError: cannot open device with path IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS04@14400000/USB2.1 Hub@14400000/AppleUSB20Hub@14400000/AppleUSB20HubPort@14420000/Nano S@14420000/Nano S@0/AppleUserUSBHostHIDDevice
Error
    at new CustomError (/Users/emmanuelmurano/Documents/Work/Zondax/Git/ledger-live-common/cli/node_modules/@ledgerhq/errors/lib/helpers.js:30:22)
    at /Users/emmanuelmurano/Documents/Work/Zondax/Git/ledger-live-common/cli/node_modules/@ledgerhq/live-common/lib/hw/deviceAccess.js:179:23 {
  name: 'CantOpenDevice',
  message: 'cannot open device with path IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/XHC1@14/XHC1@14000000/HS04@14400000/USB2.1 Hub@14400000/AppleUSB20Hub@14400000/AppleUSB20HubPort@14420000/Nano S@14420000/Nano S@0/AppleUserUSBHostHIDDevice'
}
gre commented

can you try to give -i 0? this only select one account (the first). otherwise it's going to both scan accounts and do txs time which enters into a weird lock problem of trying to open the device twice.

Yes, that is exactly what I saw on log. As you said, using that option the issue is gone. Thanks a lot!

gre commented

i'll reopen this just to keep it in mind we have to improve this

Great! I agree with you.