muntorg / munt-official

Munt is a witness-secured decentralized network for payments, digital assets, finance and more
https://www.munt.org
Other
135 stars 46 forks source link

Opening an 'Ended' witness account freezes the application #205

Closed orobio closed 4 years ago

orobio commented 4 years ago

When an 'Ended' (no longer locked but with a positive balance), witness account is opened, the application freezes. This also happens when said witness account is active during start-up of the application. In that case, the wallet user interface is never shown and the application only shows 'Done'.

Version: v2.2.0.5

Debug info The following code results in an infinite loop: https://github.com/Gulden/gulden-official/blob/209bdbd9884087dd62ebbc720f207ccc6cca96ae/src/qt/_Gulden/witnessdialog.cpp#L582-L593

This is due to that infoForAccount.nOriginWeight equals 0, resulting in nEstimatedWitnessBlockPeriodOrigin to be 0, which makes the loop increment 0.

infoForAccount.nOriginWeight is set here: https://github.com/Gulden/gulden-official/blob/209bdbd9884087dd62ebbc720f207ccc6cca96ae/src/qt/_Gulden/witnessdialog.cpp#L521-L522 Instead of the original weight it reflects the current weight of the account, which is 0 because the lock period has passed.

I guess this could use a similar fix as is done for infoForAccount.nOriginNetworkWeight (see first snippet), where the weight is set to a default value if it equals 0, but I'm not very familiar with the code so there might be a better solution.

mjmacleod commented 4 years ago

Thanks for the detailed report, will look into it and implement a fix

mjmacleod commented 4 years ago

I've pushed a proposed fix to 2.2_development branch https://github.com/Gulden/gulden-official/commit/50cf025d1d6bf971105cdd9c664bbdb1153c950c

If you are able to test this and check if it will work for you that would be useful. If not then the next builds will likely contain it so you can give it a try then.

If you urgently need to empty the account in the interim, its possible to work around this by using the move command via RPC or debug window.

orobio commented 4 years ago

Fix looks good to me. I can probably find some time to test it in the next few days and will report back.

orobio commented 4 years ago

I see the issue is already closed, but just FYI, I tested with v2.2.0.6 and it looks good. Thanks for taking this up so quickly.