3

Let's say I have 50 addresses which have an average of 0.5 BTC. Some have two or three times the average balance, while others have less than 0.1% of the average. Many times per day an address is selected to either receive or send some amount of coins, fueling the inequality.

What's an efficient, cost-effective method of rebalancing a large number of addresses such that each contains roughly the average balance?

(Assume the algorithm to select a keypair with which to transact is fixed and cannot be modified for argument sake.)

  • I am wondering whether this is an XY-Problem. At least it makes me curious, why you would want to do that. – Murch Aug 19 '14 at 19:02
  • I don't believe it's an XY problem. The reason is that I would like to keep coins spread across 50 addresses roughly evenly, and sometimes I might transact with a given address without checking its balance in relation to the other 50 for performance reasons. – Chris Cashwell Aug 19 '14 at 19:04
  • @Chris You still haven't answered the base question: Why do you want to keep your balance spread across 50 addresses instead of any other way (e.g. in one wallet, in whatever addresses they happen to go in)? – Tim S. Aug 19 '14 at 20:18
  • @TimS. I don't really see how the reasoning is relevant. The point here is that I have N addresses and want to occasionally make their balances roughly equally. Assume there's a good reason why without needing to understand that specific reason. – Chris Cashwell Aug 19 '14 at 20:21
  • Better yet, assume I don't know the reason why many addresses are desirable. Assume that the parameters are set and I'm simply looking for a solution within those parameters. – Chris Cashwell Aug 19 '14 at 20:24
1

Once a day, take the addresses with balances more than some multiple (say, twice) of the average, and create a transaction that sends money to the lowest-value addresses. E.g. let's say the average is 0.5 and call the addresses A-Z:

  • A: 2.0 BTC
  • B: 1.5 BTC
  • C: 1.0 BTC
  • ...[other addresses with under 1 BTC]
  • X: 0.1 BTC
  • Y: 0.05 BTC
  • Z: 0 BTC

Transaction would send from A, B, and C to X, Y, and Z so that each has the same amount (0.775 BTC).

1

Another solution might be to rebalance during the regular use of the addresses:

Whenever one of the addresses is selected to spend from, check whether an above average balance would remain.

If that is the case, additionally to the planned transaction, redistribute the excess to underfunded addresses, where excess = remainder - average_balance.

You could pick recipient addresses for the redistribution by performing a greedy algorithm such as for example a knapsack problem solver, optimizing for minimal sum of squared distances from the average over all addresses. You could restrain the number of recipient addresses by only allowing an additional recipient address if all previous recipient addresses will be raised to the average.

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.