mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-20 13:37:28 +02:00
[wallet] randomly generate change targets
If the wallet always chooses 1 million sats as its change target, it is easier to fingerprint transactions created by the Core wallet.
This commit is contained in:
parent
1e52e6bd0a
commit
a44236addd
4 changed files with 47 additions and 4 deletions
|
|
@ -398,6 +398,17 @@ CAmount GetSelectionWaste(const std::set<COutput>& inputs, CAmount change_cost,
|
|||
return waste;
|
||||
}
|
||||
|
||||
CAmount GenerateChangeTarget(CAmount payment_value, FastRandomContext& rng)
|
||||
{
|
||||
if (payment_value <= CHANGE_LOWER / 2) {
|
||||
return CHANGE_LOWER;
|
||||
} else {
|
||||
// random value between 50ksat and min (payment_value * 2, 1milsat)
|
||||
const auto upper_bound = std::min(payment_value * 2, CHANGE_UPPER);
|
||||
return rng.randrange(upper_bound - CHANGE_LOWER) + CHANGE_LOWER;
|
||||
}
|
||||
}
|
||||
|
||||
void SelectionResult::ComputeAndSetWaste(CAmount change_cost)
|
||||
{
|
||||
m_waste = GetSelectionWaste(m_selected_inputs, change_cost, m_target, m_use_effective);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue