RPC: bad character in bip125-replaceable in listtransactions #10334

issue kewde opened this issue on May 3, 2017
  1. kewde commented at 11:11 PM on May 3, 2017: contributor

    Describe the issue

    listtransactions returns a JSON key with the name bip125-replaceable, which turns out to be a bad choice for naming. When you run listtransactions through the JSON parser (written in a language such as JavaScript) that maps it to an object then it will try to create a variable with a '-' in it.

    It will crash the application since '-' is not a valid character for a variable name as it is also a mathematical operator. However the JSON RFC manual does not explicitly forbid the usage of '-' in the key names so technically it is completely valid JSON. The blame is with the people who write the JSON parsers, but I do think it's worth bringing it up as an issue such that this character is prevented in the future.

  2. kewde renamed this:
    RPC: bip125-replaceable in listtransactions
    RPC: bad character in bip125-replaceable in listtransactions
    on May 3, 2017
  3. luke-jr commented at 11:35 PM on May 3, 2017: member

    IMO close as invalid, since '-' is a valid character. If your parser is broken, fix your parser.

    Javascript can parse JSON with eval() (it's not secure, but neither is a broken parser trying to evaluate the '-' as a subtraction...)

  4. kewde commented at 11:54 PM on May 3, 2017: contributor

    I agree that this issue is doesn't share much relevance to Core, it fully confirms with the RFC specifications but I do think we should avoid the usage of this character in the future.

  5. dcousens commented at 12:06 AM on May 4, 2017: contributor

    @luke-jr or he could use JSON.parse... which does support - in keys... in any engine I know.

    JSON.parse(JSON.stringify({ 'bip125-replaceable': 'what' }))
    // > Object {bip125-replaceable: "what"}
    

    ACK to close.

  6. kewde commented at 12:34 AM on May 4, 2017: contributor

    @dcousens JSON.parse indeed supports the '-', which is what I currently use.

  7. kewde closed this on May 4, 2017

  8. DrahtBot 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-29 03:15 UTC

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