Closed TARS-bot closed 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
).
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
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
Crash Report
This crash report was reported through the automatic crash reporting system 🤖
Traceback
Reporter
This issue was reported by 11 user(s):
Additional Information