Author

Topic: Blocktester question (Read 759 times)

hero member
Activity: 836
Merit: 1030
bits of proof
February 23, 2013, 03:09:15 PM
#1
Edit: Solved.
Mike Hearn pointed me to the relevant comment in bitcoinj.


While adapting the bitcoinj block tester to bitsofproof. I struggle to get the meaning of the following comment:

FullBlocktestGenerator.java (line 715)
// Exploit the SigHash.SINGLE bug to avoid having to make more than one signature

Would you please elaborate? What bug?

I see that the transaction generated has two inputs and only only output e.g.:
Code:
{ "hash" : "1b4ef446fa472102ceac746719776b763dd7738034345f601258a57e00bc91f1",
  "inputs" : [ { "script" : "OP_1",
        "sequence" : 4294967295,
        "sourceHash" : "725c65ff90a83606f33928761603c9d9f07eb521f5c464b1ddc45dda8ead07f7",
        "sourceIx" : 2
      },
      { "script" : "0x01ac 0x47304402203fde73d126d8e09349e49d5ed17e18e43c85e9a3a56bfd3a0ccd4da891e0e93102203d5f66ab7886e783ddd7d48b16c85a2ff4a4f9fd32c504ad87dc8928a1c7740103 0x2d21022433dcb55ce46f18d3dd17d66893a7670a4bc059f21897a55af959c75b0717c26ead6ead6ead6ead6eadac",
        "sequence" : 4294967295,
        "sourceHash" : "b13e5c58e43e3bb2c59d0dccddbf4713c142552bdcca5fcfcb851eab3f86703e",
        "sourceIx" : 0
      }
    ],
  "lockTime" : 0,
  "outputs" : [ { "script" : "OP_1",
        "value" : 1
      } ],
  "version" : 1
}

Reading the Satoshi code I would assume that this does not evaluate to true for input 1 since:

script.cpp:
Code:
else if ((nHashType & 0x1f) == SIGHASH_SINGLE)
    {
        // Only lock-in the txout payee at same index as txin
        unsigned int nOut = nIn;
        if (nOut >= txTmp.vout.size())
        {
            printf("ERROR: SignatureHash() : nOut=%d out of range\n", nOut);
            return 1;
        }

but apparently it does. Why?
Jump to: