Cryptonite API

From Mini-blockchain Project
Jump to: navigation, search

The Cryptonite API is similar to the Bitcoin API, containing a few additions and subtractions, some changed arguments, and some use restrictions. Almost all commands returning anything more than a hash will return different JSON objects as compared to bitcoin. You can use the help command to get more information about any command.

New commands:

  • addmultisigaddress - Generates a multisig destination address from a list of signers
  • getblockheader - Gets header component of block only
  • setlimit - set withdrawal limit for an address

Modified commands:

  • listunspent is now listbalances
  • decoderawtransaction - Now has optional arguments to support successful decoding of partially signed multisignature transactions
  • sendtoaddress,sendmany,sendfrom - The two comment fields have been replaced by a single message field that is actually included in the transaction
  • signrawtransaction - Extra parameters allowed to help with signing of partially unsigned multisignature addresses
  • createrawtransaction - Added an optional parameter after all other arguments, used for setting message field like sendtoaddress
  • setaccount - Added an optional parameter after all other arguments, used to disable the automatic generation of new addresses

Restricted commands:

  • getblock - May fail if block is more than 10k blocks from tip.
  • gettransaction/getrawtransaction - Transactions older then 10k blocks may not be locatable.

Removed commands:

  • getrawchangeaddress
  • decodescript
  • lockunspent
  • listlockedunspent

A note about EP amounts

Since Cryptonite uses 64-bit's worth of coin units, it is not safe to treat amounts as double precision floating point values unless they are smaller than about 32 million XCN. To prevent old code designed for use with bitcoin daemon from trying to parse Cryptonite amounts, all RPC calls use strings to represent amounts. We call this encoding the extended-precision encoding, or EP for short.

EP numbers are strings in JSON, and must always have 10 digits after the decimal point followed by "ep". An example of a valid RPC command using an ep number would be:

./cryptonited sendtoaddress mvqH4czVQg2HdGpkV7PWVZJpRXVwLnMXpN "0.0100000000ep"

All amounts returned in RPC results are also EP numbers, and you must take care to parse them, do not use floating point to represent them unless you are really sure of what you are doing.