1

By default, UTXOs are picked randomly in ElectrumX. I want to change this behaviour and spend UTXOs on 'FIFO' basis. What changes do I need to make?

2
  • 3
    "By default, UTXOs are picked randomly." That may be true for some software, but definitely not all. What wallet software are you using? – Murch Apr 15 '18 at 23:55
  • Yes, I get it now. I am using Electrumx and I want to change the coin selection behaviour for that. – Shahr_96 Apr 16 '18 at 9:54
7

By default, UTXOs are picked randomly.

You mean in Bitcoin Core's wallet? No, they're not picked randomly. There are a number of strategies, but in general the aim is to avoid change if possible, avoid transaction outputs with few confirms if possible, and otherwise create a match close to the amount intended to be sent.

My want to change this behaviour and spend UTXOs on 'FIFO' basis. What changes do i need to make?

That's possible - the wallet already knows the timestamp when transaction outputs were created, so you don't need to make any changes besides changing the coin selection algorithm. In particular, you don't need to add timestamps to UTXOs.

However, FIFO isn't known to be a very good strategy. Mark Erhardt's thesis does a comparative study to analyse various coin selection strategies. There is ongoing work in Bitcoin Core to adopt some of the outcomes of this research, some of which is already completed. In particular, the master branch as of writing (April 2018) includes the Branch and Bound strategy for change avoidance.

0
-2

Transactions and utxos (in Bitcoin) do not have timestamps.

What changes do i need to make?

Change your aim.

2
  • 1
    But the wallet (which is what does coin selection) already knows the timestamps that UTXOs were created, because it knows the transactions that created them. It's unclear to me why you would want FIFO coin selection though; research ib this area shows this is not a very good strategy. – Pieter Wuille Apr 15 '18 at 21:19
  • I agree that it is not a very good strategy but I need to implement it. – Shahr_96 Apr 15 '18 at 21:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.