spesmilo / electrum

Electrum Bitcoin Wallet
https://electrum.org
MIT License
7.49k stars 3.1k forks source link

InvoiceError: amount is out-of-bounds: 9999999900000000000 msat #8582

Closed TARS-bot closed 1 year ago

TARS-bot commented 1 year ago

Crash Report

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

Traceback

Traceback (most recent call last):
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/qml/qedaemon.py", line 189, in loadWallet
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/qml/qewalletdb.py", line 126, in verify
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/qml/qewalletdb.py", line 184, in _load_db
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet_db.py", line 97, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet_db.py", line 129, in load_data
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet_db.py", line 237, in _after_upgrade_tasks
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/util.py", line 470, in do_profile
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet_db.py", line 1535, in _load_transactions
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/json_db.py", line 79, in __init__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/json_db.py", line 44, in wrapper
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/json_db.py", line 97, in __setitem__
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet_db.py", line 1578, in _convert_dict
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/wallet_db.py", line 1578, in <genexpr>
  File "<attrs generated init electrum.invoices.Invoice>", line 11, in __init__
    __attr_validator_amount_msat(self, __attr_amount_msat, self.amount_msat)
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/invoices.py", line 180, in _validate_amount
electrum.util.InvoiceError: amount is out-of-bounds: 9999999900000000000 msat

InvoiceError: amount is out-of-bounds: 9999999900000000000 msat

Reporter

This issue was reported by 11 user(s):

Electrum Version Python Version Operating System Wallet Type Locale Stack
4.4.6 3.8.15 (default, Aug 17 2023, 15:47:24) [Clang 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315d Android 10 on lge mdh30lm (QKQ1.200730.002) 1of2,standard en_US ℹ
4.4.6 3.8.15 (default, Aug 17 2023, 15:47:24) [Clang 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315d Android 10 on lge mdh30lm (QKQ1.200730.002) 1of2,standard en_US ℹ
4.4.6 3.8.15 (default, Aug 17 2023, 15:47:24) [Clang 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315d Android 10 on lge mdh30lm (QKQ1.200730.002) 1of2,standard en_US ℹ
4.4.6 3.8.15 (default, Aug 17 2023, 15:47:24) [Clang 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315d Android 13 on samsung m13 (TP1A.220624.014.M135FUXXS4CWJ1) imported en_US ℹ
4.5.4 3.8.18 (default, Mar 13 2024, 14:09:52) [Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d Android 13 on samsung m12 (TP1A.220624.014.M127GXXS7DWL1) imported en_US ℹ
4.5.5 3.8.18 (default, May 29 2024, 15:14:46) [Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d Android 14 on google husky (AP1A.240505.005) standard en_US ℹ
4.5.5 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:20:04) [MSC v.1929 32 bit (Intel)] Windows-10-10.0.22631-SP0 imported es_MX ℹ
4.5.5 3.8.18 (default, May 29 2024, 15:14:46) [Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d Android 14 on samsung a15 (UP1A.231005.007.A155FXXU2BXE4) imported en_US ℹ
4.5.5 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:20:04) [MSC v.1929 32 bit (Intel)] Windows-10-10.0.19045-SP0 standard,imported en_US ℹ
4.5.5 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:20:04) [MSC v.1929 32 bit (Intel)] Windows-10-10.0.19045-SP0 imported en_US ℹ
4.5.5 3.8.18 (default, May 29 2024, 15:14:46) [Clang 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d Android 10 on TECNO TECNO-LC8 (LC8-H6215ABCD-Q-GL-220215V345) imported en_US ℹ

Additional Information

Kan inte spara min transaktion


https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-8670884776365868&output=html&adk=1812271804&adf=3025194257&abgtt=6&lmt=1723153041&plat=1:8,2:16777224,3:65536,4:65536,9:134250504,16:8388608,17:32,24:32,25:32,30:1048576,32:32,41:32,42:32&format=0x0&url=https://live.blockcypher.com/btc/address/bc1qdaw8xn30gv5xmmg03urdgls4308u6l6ymy7frs/&pra=5&wgl=1&easpi=0&aihb=0&asro=0&ailel=32~27~1~2~4~6~7~8~9~10~11~12~13~14~15~16~17~18~19~20~21~24~30~34&aiael=32~27~1~2~4~6~7~8~9~10~11~12~13~14~15~16~17~18~19~20~21~24~30~34&aifxl=32_7~27_9~30_19&aiixl=32_9~27_3~30_6&aslmct=0.7&asamct=0.7&itsi=0&uach=WyJXaW5kb3dzIiwiMTAuMC4wIiwieDg2IiwiIiwiMTI3LjAuMjY1MS44NiIsbnVsbCwwLG51bGwsIjY0IixbWyJOb3QpQTtCcmFuZCIsIjk5LjAuMC4wIl0sWyJNaWNyb3NvZnQgRWRnZSIsIjEyNy4wLjI2NTEuODYiXSxbIkNocm9taXVtIiwiMTI3LjAuNjUzMy44OSJdXSwwXQ..&dt=1723153040632&bpp=16&bdt=2954&idt=842&shv=r20240801&mjsv=m202408050101&ptt=9&saldr=aa&abxe=1&cookie=ID=b1ce893da543f885:T=1723152089:RT=1723152089:S=ALNI_MaV7IL-B3QMLs1r4NdFEWRJ3GjcOw&eo_id_str=ID=d3e44133646af090:T=1723152089:RT=1723152089:S=AA-AfjbXskkN6_dycLjseqXdhFMM&nras=1&correlator=907172369845&frm=20&pv=2&u_tz=-360&u_his=6&u_h=900&u_w=1600&u_ah=860&u_aw=1600&u_cd=24&u_sd=1&dmc=4&adx=-12245933&ady=-12245933&biw=949&bih=776&scr_x=0&scr_y=0&eid=44759875,44759926,44759837,44795921,95334526,95334830,95337868,95335245,95339224,95336266,95339400,31078663,31078668,31078670&oid=2&pvsid=2158044142970915&tmod=2081556466&wsm=1&uas=0&nvt=1&fsapi=1&ref=https://live.blockcypher.com/btc/address/bc1q9kjc0ed4lusxc802h673xvvt37c8udvr0yln5f/&fc=1920&brdim=61,9,61,9,1600,0,1543,867,964,776&vis=1&rsz=||s|&abl=NS&fu=32768&bc=31&bz=1.6&psd=W251bGwsbnVsbCxudWxsLDNd&nt=1&ifi=1&uci=a!1&fsb=1&dtd=906


electrum cli payto (15mxwaoZfvX7SQ2PttY6RCqDeAQ6UqVjuM,+2000.00031 bc1q9kjc0ed4lusxc802h673xvvt37c8udvr0yln5f,+23000.2323230 bc1qx9t2l3pyny2spqpqlye8svce70nppwtaxwdrp4,-25000.24)


SomberNight commented 1 year ago

Normally https://github.com/spesmilo/electrum/pull/7041 should have prevented the creation of an invoice for >21M BTC (and old invoices were deleted from the db in a wallet db upgrade, same PR).

However, the qml gui is mutating invoices by directly setting the amount_msat field, and it looks like attrs validators only run during init. https://github.com/spesmilo/electrum/blob/724576292237600b5de6982f0d1843c8afbffa09/electrum/gui/qml/qeinvoice.py#L632 https://github.com/spesmilo/electrum/blob/724576292237600b5de6982f0d1843c8afbffa09/electrum/invoices.py#L175-L176

The attrs docs say that if we used attr.define instead of attr.s, the validator would run in this case too:

attrs.define Differences to the classic attr.s that it uses underneath: [...] If frozen is False, run converters and validators when setting an attribute by default.

^ but that did not seem to work when I was testing this just now.

Nevertheless, we could use on_setattr (if we required attrs>=20.1.0).

TARS-bot commented 5 months ago

Good morning @SomberNight,

I just received another crash report related to this issue. The crash occured on Electrum 4.5.4. I'm not sure which versions of Electrum include the fix but this is the first report from anything newer than 4.4.6 since you closed the issue.

Could you please check if this issue really is resolved? Here is the traceback that I just collected:

Traceback (most recent call last):
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/qml/qeinvoice.py", line 664, in saveInvoice
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/invoices.py", line 196, in set_amount_msat
  File "/home/user/wspace/electrum/.buildozer/android/app/packages/attr/_make.py", line 1055, in __setattr__
  File "/home/user/wspace/electrum/.buildozer/android/app/packages/attr/setters.py", line 52, in validate
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/invoices.py", line 204, in _validate_amount
electrum.util.InvoiceError: amount is out-of-bounds: 9875463200000000000 msat

InvoiceError: amount is out-of-bounds: 9875463200000000000 msat

~ With robotic wishes

TARS-bot commented 5 months ago

Good evening @SomberNight,

I just received another crash report related to this issue. The crash occured on Electrum 4.5.5. I'm not sure which versions of Electrum include the fix but this is the first report from anything newer than 4.5.4 since you closed the issue.

Could you please check if this issue really is resolved? Here is the traceback that I just collected:

Traceback (most recent call last):
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/gui/qml/qeinvoice.py", line 663, in saveInvoice
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/invoices.py", line 196, in set_amount_msat
  File "/home/user/wspace/electrum/.buildozer/android/app/packages/attr/_make.py", line 1055, in __setattr__
  File "/home/user/wspace/electrum/.buildozer/android/app/packages/attr/setters.py", line 52, in validate
  File "/home/user/wspace/electrum/.buildozer/android/app/electrum/invoices.py", line 204, in _validate_amount
electrum.util.InvoiceError: amount is out-of-bounds: 3477559183100000000 msat

InvoiceError: amount is out-of-bounds: 3477559183100000000 msat

~ With robotic wishes