get the location of UTXO data

0

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.

Rishav Raj

Posted 2018-04-09T02:21:10.457

Reputation: 3

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 2018-04-09T06:28:30.520

@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 Raj 2018-04-09T06:46:37.227

By FIFO here I mean, one that was received first in the wallet should be used first in the transaction.Rishav Raj 2018-04-09T06:47:11.313

Answers

0

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).

Andrew Chow

Posted 2018-04-09T02:21:10.457

Reputation: 40 910

So what would be the first step in case I want to achieve the goal?Rishav Raj 2018-04-10T02:44:42.863

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 2018-04-10T03:51:14.650

can you please tell me which function deals with the UTXO timings??If theres one @AndrewChowRishav Raj 2018-04-15T15:50:22.843

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 2018-04-15T17:21:38.887