<p>What you want is the code for Florincoin's wallet's coin selection. This is found in the <a href="https://github.com/floblockchain/flo/blob/flo-master/src/wallet/wallet.cpp#L2615" rel="nofollow noreferrer"><code>CreateTransaction</code></a> function. Within <code>CreateTransaction</code>, the wallet also calls <a href="https://github.com/floblockchain/flo/blob/flo-master/src/wallet/wallet.cpp#L2458" rel="nofollow noreferrer"><code>SelectCoins</code></a> and that calls <a href="https://github.com/floblockchain/flo/blob/flo-master/src/wallet/wallet.cpp#L2352" rel="nofollow noreferrer"><code>SelectCoinsMinConf</code></a>. The coins are actually selected with <code>SelectCoinsMinConf</code> but <code>SelectCoins</code> and <code>CreateTransaction</code> are all involved with coin selection.</p>

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

CC BY-SA 3.0
2018-04-10T02:44:42.863Z
So what would be the first step in case I want to achieve the goal?
Rishav Raj
CC BY-SA 3.0
2018-04-10T03:51:14.650Z
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.
Ava Chow
CC BY-SA 3.0
2018-04-15T15:50:22.843Z
can you please tell me which function deals with the UTXO timings??If theres one  @AndrewChow
Rishav Raj
CC BY-SA 3.0
2018-04-15T17:21:38.887Z
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.
Ava Chow
CC BY-SA 3.0
2018-04-09T15:07:42.837Z
2018-04-09T15:07:42.837Z
Ava Chow
<p>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.</p>

CC BY-SA 3.0
2018-04-09T06:28:30.520Z
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"?
Ava Chow
CC BY-SA 3.0
2018-04-09T06:46:37.227Z
@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
CC BY-SA 3.0
2018-04-09T06:47:11.313Z
By FIFO here I mean,  one that was received first in the wallet should be used first in the transaction.
Rishav Raj
<utxo>
get the location of UTXO data
Rishav Raj
# get the location of UTXO data

(Asked by: username_0 on 2018-04-09)

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.

**Tags:** utxo

> **Comments:**
> **username_1**: 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"?  
> **username_0**: @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.  
> **username_0**: By FIFO here I mean,  one that was received first in the wallet should be used first in the transaction.  

---

## 1 answers

### Answer by username_1 on 2018-04-09. Score: 0 | Accepted answer

What you want is the code for Florincoin's wallet's coin selection. This is found in the [`CreateTransaction`](https://github.com/floblockchain/flo/blob/flo-master/src/wallet/wallet.cpp#L2615) function. Within `CreateTransaction`, the wallet also calls [`SelectCoins`](https://github.com/floblockchain/flo/blob/flo-master/src/wallet/wallet.cpp#L2458) and that calls [`SelectCoinsMinConf`](https://github.com/floblockchain/flo/blob/flo-master/src/wallet/wallet.cpp#L2352). 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).

> **Comments:**
> **username_0**: So what would be the first step in case I want to achieve the goal?  
> **username_1**: 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.  
> **username_0**: can you please tell me which function deals with the UTXO timings??If theres one  @AndrewChow  
> **username_1**: 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.  

---

