Currently, UnsignedTransactionBuilderImpl uses DefaultBoxSelector internally. The implementation has some major and some minor drawbacks that should be solved by changing the implementation:
DefaultBoxSelector is part of ergo-wallet dependency, bugfixes/enhancements/behaviour changes are hard to do
the current implementation expects the input boxes list in a prepared way: it does not accept "unnecessary" boxes as input, while it defines "unnecessary" in a very special way.
The second issue is especially restricting client code. For example, building the following transaction fails:
Input1: 1 ERG
Input2: 1 ERG
Output1: .5 ERG
=> Fails because second input is not needed. This is true, but when client code wants to build a transaction in this way, this should be accepted by the transaction builder and the unnecessary amount shoud be added to the changebox.
To add up to the confusion, it is even possible to add unnecessary boxes to the input list, some are accepted:
Input1: 1 ERG
Input2: 1 ERG + token1
Output1: .5ERG + token1
=> accepted
That means that every client code must all DefaultBoxSelector manually on an input box list to make sure the input boxes list satisfies the needs. This is done in appkit's BoxOperations loadTop method as well, which calls BoxSelectorsJavaHelpers.selectBoxes which is using DefaultBoxSelector internally, and must be done by client code on every transaction build.
Currently,
UnsignedTransactionBuilderImpl
usesDefaultBoxSelector
internally. The implementation has some major and some minor drawbacks that should be solved by changing the implementation:DefaultBoxSelector
is part of ergo-wallet dependency, bugfixes/enhancements/behaviour changes are hard to doThe second issue is especially restricting client code. For example, building the following transaction fails:
=> Fails because second input is not needed. This is true, but when client code wants to build a transaction in this way, this should be accepted by the transaction builder and the unnecessary amount shoud be added to the changebox.
To add up to the confusion, it is even possible to add unnecessary boxes to the input list, some are accepted:
=> accepted
That means that every client code must all
DefaultBoxSelector
manually on an input box list to make sure the input boxes list satisfies the needs. This is done in appkit's BoxOperationsloadTop
method as well, which callsBoxSelectorsJavaHelpers.selectBoxes
which is usingDefaultBoxSelector
internally, and must be done by client code on every transaction build.