mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-06 06:06:49 +00:00
if the tx has change and thus so 2 outputs, try having at least 2 inputs as well (in order to not be slowed down by dust patch) (#2254)
This commit is contained in:
parent
a0149cd8d0
commit
0819244ba1
@ -135,7 +135,11 @@ func (s *server) selectUTXOs(spendAmount uint64, isSendAll bool, feePerInput uin
|
|||||||
|
|
||||||
fee := feePerInput * uint64(len(selectedUTXOs))
|
fee := feePerInput * uint64(len(selectedUTXOs))
|
||||||
totalSpend := spendAmount + fee
|
totalSpend := spendAmount + fee
|
||||||
if !isSendAll && totalValue >= totalSpend {
|
// Two break cases (if not send all):
|
||||||
|
// 1. totalValue == totalSpend, so there's no change needed -> number of outputs = 1, so a single input is sufficient
|
||||||
|
// 2. totalValue > totalSpend, so there will be change and 2 outputs, therefor in order to not struggle with new dust
|
||||||
|
// rules we try and find at least 2 inputs (even though the next one is not necessary in terms of spend value)
|
||||||
|
if !isSendAll && (totalValue == totalSpend || (totalValue > totalSpend && len(selectedUTXOs) > 1)) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user