Calculator for estimated TX-Fees First of all, this refers to 


How to calculate transaction size before sending
What is the exact formula for calculating transaction fees?


I want to estimate the TX-Fee I would have to pay in a simple scenario where my wallet contains only 1 address Z that has received X payments.

I then want to pay all the wallets balance to Y different addresses at once.

Because I want to spent all of its balance, it would be great to know the transaction-fee, so that I can reduce Y, or pay the fee to Z in advance.

Since I prefer a worst-case-calculation, is it legit to count every incoming payment to my address as Input?

Is the following calculation correct?

normal_fee := 0.0005                            // Taken from Bitcoin-QT
size := X * 148 + Y * 34 + 10 +- X
fee := normal_fee / (1 - size / 500kB)
https://en.bitcoin.it/wiki/Transaction_fees


A fee may not be required at all, if the priority of the transaction is high enough. Generally 1 BTC, one day old, is enough age and balance that you can send without a fee.
If any of the individual payments are below 0.01 BTC, a minimum fee will always be required.
The minimum fee, when required, is 0.0005 BTC per 1000 bytes of total transaction.
The contribution of each input and each output to the total size is somewhat consistent, it only varies largely if there are compressed keys (standard for newly generated addresses on a recent client version), some examples:


A) 1 input/1 output (sending exact balance of one input) = 191 bytes
B) 1 input/2 output (sending money from single input with some change) = 258 bytes
C) 2 input/1 output (consolidating two address balances to one output) = 404 bytes
D) 12 input/2 output (sending from many inputs with change) = 1851 bytes

The easiest way to empty a wallet is to attempt to spend the entire balance with the transaction you desire, attempt to send it, and look at the "exceeds your balance after a 0.0xxx fee is included" message. Subtract the fee from the amount you are sending, and you should now be sending the entire wallet balance including the fee.