mimblewimble / grin-wallet

Grin Wallet
Apache License 2.0
183 stars 135 forks source link

UTXO Selection Strategy #94

Open garyyu opened 5 years ago

garyyu commented 5 years ago

I feel it's a good time to consider more about the selection_strategy, better to have the updated one in 1.1.0 milestone to avoid another incompatibility in the future.

Currently our selection_strategy support 2: all and smallest:

        - selection_strategy:
            help: Coin/Output selection strategy.
            short: s
            long: selection
            possible_values:
              - all
              - smallest
            default_value: all
            takes_value: true

And current API use a bool type for this selection_strategy:

"selection_strategy_is_use_all": false

The explain of this parameter:

I would propose to add a new one: biggest, the meaning of this biggest strategy:

The use case is for splitting, in case we want to have more UTXO sets for paying out (for example miners payout in a pool), to avoid locking the whole wallet, the better way is to start selection from biggest value outputs, instead of from smallest.

Do you have more selection_strategy to be requested in this version? before I start giving a PR on this feature.

0xmichalis commented 5 years ago

As far as the boolean is concerned (selection_strategy_is_use_all), I think it's fair to change it to use the actual type of the strategy for backwards compatibility reasons.

lehnberg commented 5 years ago

UTXO selection strategies are notoriously difficult and optimise for different objectives.

As a wallet developer, rather than being provided with a set of fixed strategies via the API, I'd much prefer to have full control of the strategies I choose to develop for my specific wallet and use cases. From my side, I think it would be more useful to provide a 'toolbox' via the API that wallet developers could use to design their own strategies. For example being able to select specific outputs from a user's wallet to build transactions with, or being able to select outputs according to certain criteria.

/grin-wallet could use the same API to build a couple of basic reference strategies, and 3rd party wallets would be free to experiment and use whatever strategies they feel like using.

garyyu commented 5 years ago

@lehnberg pls make it clear what's a 'toolbox' here?

I'm proposing to enhance this selection_strategy_is_use_all which is currently a boolean type. What's your 'toolbox' to apply in a selection strategy?

lehnberg commented 5 years ago

@garyyu

As a third party wallet developer, it would be nice if the API would allow me to obtain information about a user's UTXO set and allow me to send granular selection instructions (i.e. I'd like to build a transaction with output a, output b, output e and output g), so that I can devise my own selection strategies in my wallet rather than having the grin core development team doing so on my behalf.