bitcoin-tx sign testcase wrong #6389

issue paveljanik opened this issue on July 7, 2015
  1. paveljanik commented at 3:04 PM on July 7, 2015: contributor

    The last testcase in src/test/data/bitcoin-util-test.json is:

      { "exec": "./bitcoin-tx",
        "args":
        ["-create",
         "in=4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485:0",
         "set=privatekeys:[\"5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf\"]",
         "set=prevtxs:[{\"txid\":\"4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485\",\"vout\":0,\"scriptPubKey\":\"4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485\"}]",
         "sign=ALL",
         "outaddr=0.001:193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7"],
        "output_cmp": "txcreatesign.hex"
      }
    

    The resulting hex file decoded is:

    $ btc decoderawtransaction `cat src/test/data/txcreatesign.hex`
    {
      "txid": "5d2d5f9a8e295bf7f92787a18a0c273728d774faac14b6884c885cbb9b66e31e",
      "version": 1,
      "locktime": 0,
      "vin": [
        {
          "txid": "4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485",
          "vout": 0,
          "scriptSig": {
            "asm": "",
            "hex": ""
          },
          "sequence": 4294967295
        }
      ],
      "vout": [
        {
          "value": 0.00100000,
          "n": 0,
          "scriptPubKey": {
            "asm": "OP_DUP OP_HASH160 5834479edbbe0539b31ffd3a8f8ebadc2165ed01 OP_EQUALVERIFY OP_CHECKSIG",
            "hex": "76a9145834479edbbe0539b31ffd3a8f8ebadc2165ed0188ac",
            "reqSigs": 1,
            "type": "pubkeyhash",
            "addresses": [
              "193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7"
            ]
          }
        }
      ]
    }
    

    Ie. not signed. How is bitcoin-tx sign supposed to work at all? The test seems to be invalid. The tx hash 4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485 is used 3x there!!! @ers35 can you shed some light to it?

  2. laanwj added the label Tests on Jul 7, 2015
  3. laanwj commented at 3:49 PM on July 7, 2015: member

    Nice catch.

  4. laanwj commented at 4:04 PM on July 7, 2015: member

    I've investigated a bit and it appears that the SignSignature in MutateTxSign fails. Its return value is not checked, which could be improved. But that's not the root cause.

    The Solver is failing on the scriptPubKey of the previous transaction, 4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485. This makes sense as this doesn't look like a scriptPubKey at all.

  5. laanwj commented at 4:19 PM on July 7, 2015: member

    If you change it to "scriptPubKey":"76a91491b24bf9f5288532960ac687abb035127b1d28a588ac" it works. Will submit a pull.

  6. ers35 commented at 5:01 PM on July 7, 2015: contributor

    The test case was originally created to test pull #5528. I incorrectly assumed that the test case was valid if bitcoin-tx returned without error.

  7. laanwj commented at 12:52 PM on July 10, 2015: member

    FIxed by #6390

  8. laanwj closed this on Jul 10, 2015

  9. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 18:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me