I need to find the location of the code which deals with UTXO, and then implement FIFO on UTXO storage. I aint able to find the location of UTXO code and also where it is stored.
-
Deals with UTXOs in what way? In your wallet or for the node to verify transactions? What do you mean by "FIFO on UTXO storage"?– Andrew Chow ♦Apr 9, 2018 at 6:28
-
@AndrewChow A feature in the FLO core wallet called as coin control allows the users to select the UTXOs which should be used as inputs for the transactions. Currently by default, the coin control selects the UTXOs automatically from the wallet.But the required default behavior is that, the UTXOs should be selected based on the FIFO. So I am supposed to find a way to extract the received date from the UTXOs data and pass them to the wallet.cpp accordingly so that the wallet selects the UTXOs based on FIFO instead of random selection.– Rishav RajApr 9, 2018 at 6:46
-
By FIFO here I mean, one that was received first in the wallet should be used first in the transaction.– Rishav RajApr 9, 2018 at 6:47
1 Answer
What you want is the code for Florincoin's wallet's coin selection. This is found in the CreateTransaction
function. Within CreateTransaction
, the wallet also calls SelectCoins
and that calls SelectCoinsMinConf
. The coins are actually selected with SelectCoinsMinConf
but SelectCoins
and CreateTransaction
are all involved with coin selection.
Also, because Florincoin's wallet is based on Bitcoin Core, it does not use FIFO for coin selection. Rather it uses Bitcoin Core's special algorithm for selecting coins which is difficult to understand (it tries to solve the knapsack problem by selecting exactly the amount you want to spend, but then it does some weird things to handle fees and change).
-
So what would be the first step in case I want to achieve the goal? Apr 10, 2018 at 2:44
-
You modify
SelectCoinsMinConf
to do whatever coin selection algorithm that you want. You will probably have to change the data types to include the time because they are not necessarily there.– Andrew Chow ♦Apr 10, 2018 at 3:51 -
can you please tell me which function deals with the UTXO timings??If theres one @AndrewChow Apr 15, 2018 at 15:50
-
Time is mostly irrelevant for UTXOs. The objects for coin selection itself do not have time fields, so you will need to add one. CWalletTx has a time field and that is used to create the CInputCoins and COutputs used for coin selection.– Andrew Chow ♦Apr 15, 2018 at 17:21