ergoplatform / ergo-appkit

Appkit: A Library for Java/Scala/Kotlin Development of Ergo Applications
MIT License
38 stars 27 forks source link

Tokens get burned if input box contains 2 entries for the same token #199

Closed Luivatra closed 1 year ago

Luivatra commented 1 year ago

In some cases boxes can be created with 2 entries for the same token, for example on entry with 2k migoreng and one entry with 6k migoreng.

The appkit seems to only count one of these entries when creating the change box, causing the rest to be burned.

An example of a box with duplicate token entries can be seen in the output of this tx: https://explorer.ergoplatform.com/en/transactions/02b425ed91ca655cb39f83febbcd0efed6114a05f8b7eb69324042b2372060c5

MrStahlfelge commented 1 year ago

I've added a test case demonstrating the issue. The latest appkit version won't burn a token, but throw a error. The input box is unspendable. When all tokens should be spent, a NotEnoughTokensException is thrown. Error originates from DefaultBoxSelector