Available in line 59 is made a reference , so contents of the coin can be modified
While generating transactions we select ancestors from available_coins ,in case we exhaust all the outputs of an entry in available_coins
then we need to remove it from available_coins before the next iteration of choosing a potential ancestor , it is now implemented with
this patch by ,As the index of the entry is randomly chosen from available_coins , In order to remove it from the vector if index of the
selected entry is not at the end of available_coins vector, it is swapped with the entry at the back of the vector , then the entry at the
end of available_coins is popped out.
Code generating outputs for the transaction is moved out of the loop, as it needs to be done only once before adding the transaction to ordered_coins