Title: [BUG] Possible Double Spend Post by: zellfaze on August 16, 2011, 10:31:02 PM I think I found a situation where the Bitcoin Client will double spend.
BACKGROUND: I sent all my Bitcoins to myself so that I would stop having to pay the 0.005 BTC transaction fee (my money was in very small amounts throughout several addresses). By consolidating all my money into one address I would not have to pay the fee because my transaction wouldn't be over the size limit. REPRODUCE: Send all your coins to several addresses until your forced to pay the 0.005 transaction fee for any transaction. Send all your coins to a new address in the same client. (Paying the fee) Before the transaction has 6 confirms (it only has 2 for me) send money to a new address. It should ask you to pay a transaction fee. MY UNDERSTANDING: I believe that this is because it is trying to send money from the old addresses because the new address has less than 6 confirmations. I think it still see the money in your wallet balance and therefore it is willing to overlook the fact that you have already sent that money. Of course I could be entirely wrong, but I would like it if someone could look into it a bit more. At least to give me an explanation of why it happens if I am wrong. Title: Re: [BUG] Possible Double Spend Post by: SgtSpike on August 16, 2011, 10:33:36 PM I think I found a situation where the Bitcoin Client will double spend. I don't see a double spend here. What you've done is....BACKGROUND: I sent all my Bitcoins to myself so that I would stop having to pay the 0.005 BTC transaction fee (my money was in very small amounts throughout several addresses). By consolidating all my money into one address I would not have to pay the fee because my transaction wouldn't be over the size limit. REPRODUCE: Send all your coins to several addresses until your forced to pay the 0.005 transaction fee for any transaction. Send all your coins to a new address in the same client. (Paying the fee) Before the transaction has 6 confirms (it only has 2 for me) send money to a new address. It should ask you to pay a transaction fee. MY UNDERSTANDING: I believe that this is because it is trying to send money from the old addresses because the new address has less than 6 confirmations. I think it still see the money in your wallet balance and therefore it is willing to overlook the fact that you have already sent that money. Of course I could be entirely wrong, but I would like it if someone could look into it a bit more. At least to give me an explanation of why it happens if I am wrong. Send coins from A to B Send coins from B to C (tx fee of 0.005) Send coins from C to D (tx fee of 0.005) The reason it requests a transaction fee is because of the "newness" of the coins. Title: Re: [BUG] Possible Double Spend Post by: zellfaze on August 16, 2011, 10:36:08 PM The newness? I didn't realize the client put a transaction fee on new coins.
I thought it wouldn't even let you send coins until they had 6 confirms (12 for fresh minted coins). Title: Re: [BUG] Possible Double Spend Post by: jackjack on August 16, 2011, 10:42:29 PM You can spend your coins with 0 confirmation
Title: Re: [BUG] Possible Double Spend Post by: SgtSpike on August 16, 2011, 10:50:13 PM The newness? I didn't realize the client put a transaction fee on new coins. Well, it's a complex formula. It won't always put a transaction fee on new coins, but it often will. If you send a large amount, that helps to avoid a fee.I thought it wouldn't even let you send coins until they had 6 confirms (12 for fresh minted coins). Title: Re: [BUG] Possible Double Spend Post by: zellfaze on August 16, 2011, 11:00:45 PM What file is the formula in. I would like to see it for myself (just so I can understand when I will and when I won't have to pay a fee).
Thank you guys for your help. Title: Re: [BUG] Possible Double Spend Post by: SgtSpike on August 16, 2011, 11:06:28 PM I tried to find the same thing, but it's a very convoluted piece of code. I don't even remember where it was in the github, but even when I did see it, I didn't really fully understand what was happening or how I could determine when I would pay a fee and when I would not.
Anyway, maybe someone else will chime in with the dozens of lines of code that determine the fee so you can take a look for yourself. Title: Re: [BUG] Possible Double Spend Post by: vector76 on August 17, 2011, 05:59:41 PM It looks like
Code: // Priority is sum(valuein * age) / txsize Code: static bool AllowFree(double dPriority) Code: // Free transaction area Code: // To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if any output is less than 0.01 So, if I'm reading this correctly, if the priority is high enough and the block it's going into is small enough, then the transaction can be free, as long as none of the outputs are too small, in which case the base fee is charged instead. Edit: COIN is the number of satoshis in one bitcoin, which is 100,000,000. The valuein for the purpose of priority is measured in satoshis. Title: Re: [BUG] Possible Double Spend Post by: zellfaze on August 17, 2011, 06:13:25 PM I think I understand this.
So here is how we determine if we get a fee:
My C++ isn't very sharp (I am a PHP coder) and I am getting this all out of context, so if someone could correct me where I am wrong, I would appreciate it. |