Author

Topic: [BUG] Possible Double Spend (Read 1161 times)

full member
Activity: 141
Merit: 101
Security Enthusiast
August 17, 2011, 01:13:25 PM
#9
I think I understand this.

So here is how we determine if we get a fee:
  • First we computer the first part of the priority by taking the value of the each transaction input and multiplying that by its age.
  • We then sum the values we just computed for each input and multiply by the transaction size to get our priority
  • A fee is then required if the variable (COIN [what is the value of this?] multiplied by 144 divided by 250) is more than 0.05
  • The fee is then dismissed if the block still has a lot of free room
  • But potentially re-added (or added to begin with) if we are sending less than 0.01 BTC.

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.
member
Activity: 70
Merit: 18
August 17, 2011, 12:59:41 PM
#8
It looks like

Code:
// Priority is sum(valuein * age) / txsize
and
Code:
    static bool AllowFree(double dPriority)
    {
        // Large (in bytes) low-priority (new, small-coin) transactions
        // need a fee.
        return dPriority > COIN * 144 / 250;
    }
and
Code:
                // Free transaction area
                if (nNewBlockSize < 27000)
                    nMinFee = 0;
but
Code:
        // To limit dust spam, require MIN_TX_FEE/MIN_RELAY_TX_FEE if any output is less than 0.01
        if (nMinFee < nBaseFee)
            BOOST_FOREACH(const CTxOut& txout, vout)
                if (txout.nValue < CENT)
                    nMinFee = nBaseFee;

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.
legendary
Activity: 1400
Merit: 1005
August 16, 2011, 06:06:28 PM
#7
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.
full member
Activity: 141
Merit: 101
Security Enthusiast
August 16, 2011, 06:00:45 PM
#6
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.
legendary
Activity: 1400
Merit: 1005
August 16, 2011, 05:50:13 PM
#5
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).
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.
legendary
Activity: 1176
Merit: 1280
May Bitcoin be touched by his Noodly Appendage
August 16, 2011, 05:42:29 PM
#4
You can spend your coins with 0 confirmation
full member
Activity: 141
Merit: 101
Security Enthusiast
August 16, 2011, 05:36:08 PM
#3
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).
legendary
Activity: 1400
Merit: 1005
August 16, 2011, 05:33:36 PM
#2
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.
I don't see a double spend here.  What you've done is....

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.
full member
Activity: 141
Merit: 101
Security Enthusiast
August 16, 2011, 05:31:02 PM
#1
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.
Jump to: