Skip to content

RPC: reals as strings #247

@mikegogulski

Description

@mikegogulski

I'm using Jan-Klaas Kollhof's JSON-RPC implementation for Python.

My app tracks amounts using the Decimal class, in order to avoid floating point representation errors.

I should be able to do:

'{"params":["15DTr7vBr9VA52cEh2k7ywPeHL9WVFadwk","3.22","comment"],"method":"sendtoaddress","id":"1305920532.77"}'

but bitcoind returns a "got string, expected real" error because "3.22" is quoted.

If I convert the value to a float, it goes like this:

'{"params":["15DTr7vBr9VA52cEh2k7ywPeHL9WVFadwk",3.219999999,"comment"],"method":"sendtoaddress","id":"1305920532.77"}'

which is a mess.

Right now, I'm hacking around this by altering the json string after building it, using the value as a string and then stripping the double quotes to change its JSON representation to a real.

Is there a reason why a string value can't be cast into a real inside bitcoind?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions