electrum icon indicating copy to clipboard operation
electrum copied to clipboard

ValueError: Can't parse 'name[:]length' token '_pos'.

Open TARS-bot opened this issue 10 months ago • 4 comments

Crash Report

This crash report was reported through the automatic crash reporting system 🤖

Traceback

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/bitstring/bitarray_.py", line 126, in __setattr__
    super().__setattr__(attribute, value)
AttributeError: 'BitArray' object has no attribute '_pos'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/electrum/gui/qt/request_list.py", line 114, in item_changed
    self.receive_tab.update_current_request()
  File "/usr/lib/python3.11/site-packages/electrum/gui/qt/receive_tab.py", line 255, in update_current_request
    self.lnaddr = self.wallet.get_bolt11_invoice(req) if not help_texts.ln_is_error else ''
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/electrum/wallet.py", line 2767, in get_bolt11_invoice
    lnaddr, invoice = self.lnworker.get_bolt11_invoice(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/electrum/lnworker.py", line 2187, in get_bolt11_invoice
    invoice = lnencode(lnaddr, self.node_keypair.privkey)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/electrum/lnaddr.py", line 188, in lnencode
    data += tagged_bytes('p', addr.paymenthash)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/electrum/lnaddr.py", line 142, in tagged_bytes
    return tagged(char, bitstring.BitArray(l))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/electrum/lnaddr.py", line 136, in tagged
    return bitstring.pack("uint:5, uint:5, uint:5",
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/bitstring/bitstream.py", line 189, in __add__
    s._pos = 0
    ^^^^^^
  File "/usr/lib/python3.11/site-packages/bitstring/bitarray_.py", line 128, in __setattr__
    dtype = bitstring.dtypes.Dtype(attribute)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/bitstring/dtypes.py", line 63, in __new__
    x = cls._new_from_token(token, scale)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/bitstring/dtypes.py", line 142, in _new_from_token
    return dtype_register.get_dtype(*utils.parse_name_length_token(token), scale=scale)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/bitstring/utils.py", line 94, in parse_name_length_token
    raise ValueError(f"Can't parse 'name[:]length' token '{fmt}'.")
ValueError: Can't parse 'name[:]length' token '_pos'.

ValueError: Can't parse 'name[:]length' token '_pos'.

Reporter

This issue was reported by 7 user(s):

Electrum Version Python Version Operating System Wallet Type Locale Stack
4.5.4 3.11.9 (main, Apr 6 2024, 16:32:42) [GCC 13.2.1 20240210] Linux-6.8.7-gentoo-dist-x86_64-Intel-R-_Core-TM-i7-7700K_CPU@_4.20GHz-with-glibc2.39 standard en_GB
4.5.4 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] Linux-5.15.0-105-generic-x86_64-with-glibc2.35 standard pt_BR
4.5.4 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] Linux-5.15.0-91-generic-x86_64-with-glibc2.35 standard en_US
4.5.4 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] Linux-5.15.0-102-generic-x86_64-with-glibc2.35 standard en_US
4.5.4 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] Linux-5.15.0-102-generic-x86_64-with-glibc2.35 standard en_US
4.5.4 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] Linux-6.5.0-28-generic-x86_64-with-glibc2.35 standard en_US
4.5.4 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] Linux-6.5.0-28-generic-x86_64-with-glibc2.35 standard en_US

Additional Information

The reporting user(s) did not provide additional information.

TARS-bot avatar Apr 28 '24 07:04 TARS-bot

Reported by me. Error happens every time I click on a created Receive address.

CocolinoFan avatar Apr 28 '24 07:04 CocolinoFan

This is because you recently upgraded bitstring; the latest version is incompatibe with Electrum. To fix this, we have removed bitstring from our dependencies, see #9020 If you want to keep using Electrum with your current python environment, you would need to use the git repo. Otherwise, you can also use our latest Appimage.

ecdsa avatar Apr 28 '24 10:04 ecdsa

I see, makes sense, Gentoo life :> Maybe new release soon Electrum 4.5.5 ?

CocolinoFan avatar Apr 28 '24 11:04 CocolinoFan

Alternatively you can just downgrade bitstring for now.

SomberNight avatar Apr 29 '24 13:04 SomberNight

The fix from master (https://github.com/spesmilo/electrum/pull/9020) is now backported to the 4.5.x branch as https://github.com/spesmilo/electrum/commit/c9ed717beaeefe0ee639fc2ca0b202f0d7a8727b.

SomberNight avatar May 28 '24 15:05 SomberNight