decodescript does not parse the correct asm, show it as -123928979 #13505

issue passionofvc opened this issue on June 19, 2018
  1. passionofvc commented at 3:02 PM on June 19, 2018: none

    decodescript/decoderawtransaction does not show the correct asm, parse it as -123928979.

    What behavior did you expect? asm should be (asm:"1 62 OP_ADD 63 OP_EQUAL”)

    What was the actual behavior (provide screenshots if the issue is GUI-related)? "asm": "1 98 -123928979",

    How reliably can you reproduce the issue, what are the steps to do so?

    $ decodescript 5101620493016387
    {
     "asm": "1 98 -123928979",
     "type": "nonstandard",
     "p2sh": "2MvPLsDfmrW1repgmEdL51ZR4Vhc1LDxRVS",
     "segwit": {
       "asm": "0 389cb2613fb2c5c5b950ef80402abf9ac87e4a6da117bb5d5058489be3f5037c",
       "hex": "0020389cb2613fb2c5c5b950ef80402abf9ac87e4a6da117bb5d5058489be3f5037c",
       "reqSigs": 1,
       "type": "witness_v0_scripthash",
       "addresses": [
         "tb1q8zwtycflktzutw2sa7qyq24lnty8ujnd5ytmkh2stpyfhcl4qd7qqvz4c8"
       ],
       "p2sh-segwit": "2NBfsvWRZLuJhWhJ8TZM89FSwZeT82xCxkR"
     }
    }
    
    decoderawtransaction 0100000001e2d4fe69fbfa62beac61da2a07ae84d96e3e1c14cdee348cf3c84efd20eda37d00000000085101620493016387ffffffff0160ceab070000000017a9143f58b4f7b14847a9083694b9b3b52a4cea2569ed8700000000
    {
      "txid": "e8a9df4f3b5f5ff454ab96083fca8f8375359df26051ef2831bbc07e93788b27",
      "hash": "e8a9df4f3b5f5ff454ab96083fca8f8375359df26051ef2831bbc07e93788b27",
      "version": 1,
      "size": 91,
      "vsize": 91,
      "weight": 364,
      "locktime": 0,
      "vin": [
        {
          "txid": "7da3ed20fd4ec8f38c34eecd141c3e6ed984ae072ada61acbe62fafb69fed4e2",
          "vout": 0,
          "scriptSig": {
            "asm": "1 98 -123928979",
            "hex": "5101620493016387"
          },
          "sequence": 4294967295
        }
      ],
      "vout": [
        {
          "value": 1.28700000,
          "n": 0,
          "scriptPubKey": {
            "asm": "OP_HASH160 3f58b4f7b14847a9083694b9b3b52a4cea2569ed OP_EQUAL",
            "hex": "a9143f58b4f7b14847a9083694b9b3b52a4cea2569ed87",
            "reqSigs": 1,
            "type": "scripthash",
            "addresses": [
              "2My2ApqGcoNXYceZC4d7fipBu4GodkbefHD"
            ]
          }
        }
      ]
    }
    

    What version of Bitcoin Core are you using, where did you get it (website, self-compiled, etc)?

    $ ./bitcoind --version
    Bitcoin Core Daemon version v0.16.99.0-e4082d59f
    Copyright (C) 2009-2018 The Bitcoin Core developers
    

    What type of machine are you observing the error on (OS/CPU and disk type)?

    $ uname -a
    Darwin MacBook-Pro.local 17.5.0 Darwin Kernel Version 17.5.0: Fri Apr 13 19:32:32 PDT 2018; root:xnu-4570.51.2~1/RELEASE_X86_64 x86_64
    
    
  2. ken2812221 commented at 6:15 PM on June 21, 2018: contributor

    What you want is 51013e93013f87.

  3. passionofvc commented at 1:37 AM on June 24, 2018: none

    hi @ken2812221

    according to https://en.bitcoin.it/wiki/Script below table, I expect it is translated to [ 51 62 OP_ADD 63 87] or something human can understand not just garbage minus integer.

    | 1 | OP_CODE | description |:---:|:---------:|:----------------------------------------------------------------| |51 | OP_1 | The number 1 is pushed onto the stack. |01 | 0x01 | The next opcode bytes is data to be pushed onto the stack
    |62 | data | 0x62 |04 | OP_4 | The next opcode bytes is data to be pushed onto the stack(4bytes) |93 | OP_ADD | a is added to b. |01 | OP_1 | The number 1 is pushed onto the stack |63 | data | 0x63 is pushed onto the stack. |87 | OP_EQUAL| Returns 1 if the inputs are exactly equal, 0 otherwise.

  4. jb55 commented at 2:11 AM on June 24, 2018: member

    0x62 is 98 in decimal, the assembly is showing the decimal scriptnum value

    OP_4 is going to treat the next 4 bytes (OP_ADD OP_1 0x63 OP_EQUAL) as data which happens to be scriptnum -123928979

    perhaps you want 51016293016387 ?

  5. passionofvc commented at 3:02 AM on June 24, 2018: none

    use bx to decode it

    $ ./bx script-decode 5101620493016387
    1 [62] [93016387]
    $ ./bx script-decode 93016387
    add [63] equal
    
    

    I expect it is decode to [93016387] not and decode to [-123928979]

  6. sipa commented at 3:06 AM on June 24, 2018: member

    You're confusing hexadecimal with decimal. The numbers outputed by bx are in hex, decodescript outputs in decimal. Hex 93016387 is -123928979 decimal.

  7. sipa closed this on Jun 24, 2018

  8. passionofvc commented at 3:38 AM on June 24, 2018: none

    hi @sipa thanks you for your answer.

    $decodescript 5101620493016387
    >>"asm": "1 98 -123928979",
    $decodescript -123928979 
    >>argument must be hexadecimal string (not '-123928979')
    

    OK because -123928979 mean 93016387

    >>"asm": "OP_ADD 99 OP_EQUAL",
    

    why don't directly give user below output

    $decodescript 5101620493016387
    >>"asm": "1 98 OP_ADD 99 OP_EQUAL",
    
  9. jb55 commented at 3:46 AM on June 24, 2018: member

    @passionofvc read my comment. you have an extra 0x04 byte

  10. 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 15:15 UTC

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