Utils

From ArdorDocs
Jump to: navigation, search

Decode QR Code

Decodes a base64-encoded jpeg to a UTF-8 string. POST only. Javadoc

Request:

  • requestType is decodeQRCode
  • qrCodeBase64 is a base64-encoded jpeg string to be decoded

Response

  • qrCodeData (S) is a UTF-8 string containing the decoded data from the base64 string
  • requestProcessingTime (N) is the API request processing time (in millisec)

Decode QR Code Example

http://localhost:27876/nxt?
  requestType=decodeQRCode&
  qrCodeBase64=/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRo...
{
 "qrCodeData": "ARDOR-7A48-47JL-T7LD-D5FS3",
 "requestProcessingTime": 15
}


Detect Mime Type

Gets the mime type of uploaded file or data. Javadoc

Request:

  • requestType is detectMimeType
  • data is the data (optional)
  • file is the pathname of a data file to upload (optional if data provided)
  • filename is a filename to associate with data (optional if file uploaded in which case the uploaded filename is always used)
  • isText is false if data is a hex string (optional)

Response

  • type (S) is the mime type
  • requestProcessingTime (N) is the API request processing time (in millisec)

Detect Mime Type Example

http://localhost:27876/nxt?
  requestType=detectMimeType&
  data=/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRo...&
  isText=false
{
 "requestProcessingTime": 348,
 "type": "image/png"
}


Encode QR Code

Encodes a UTF-8 string to a base64-encoded jpeg. POST only. Javadoc

Request:

  • requestType is encodeQRCode
  • qrCodeData is a UTF-8 text string to be encoded
  • width is the width of the output image (optional)
  • height is the height of the output image (optional)

Response

  • qrCodeBase64 (S) is a base64 string encoding a jpeg image of the QR code
  • requestProcessingTime (N) is the API request processing time (in millisec)

Encode QR Code Example

http://localhost:27876/nxt?
  requestType=encodeQRCode&
  qrCodeData=ARDOR-7A48-47JL-T7LD-D5FS3&
  width=100&
  height=100
{
 "qrCodeBase64": "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UH...",
 "requestProcessingTime": 15
}


Evaluate Expression

Evaluates an approval composite phasing model based on one or more approval models. Javadoc

Request:

  • requestType is evaluateExpression
  • expression is the logical expresion to be evaluated
  • checkOptimality if set to true it performs an analysis of the expression (optional)
  • evaluate if set to true then it evaluates the following key pairs vars, values
  • vars variable
  • values values of the variables

Response

  • variables (A) is an array that contains the variables evaluated
  • literalsCount (N) is the count of variables in the expression
  • requestProcessingTime (N) is the API request processing time (in millisec)

Evaluate Expression Example

http://localhost:27876/nxt?
  requestType=evaluateExpression&
  expression=DMS|!DMS&
{
 "variables": [
  "DMS"
 ],
 "literalsCount": 2,
 "requestProcessingTime": 0
}


Full Hash To Id

Converts a full hash to an ID. Javadoc

Request:

  • requestType is fullHashToId
  • fullHash is the full hash 64-digit (32-byte) hex string

Response:

  • stringId (S) is the ID corresponding to the hash, in the form of an decimal string
  • longId (S) is the signed long integer (8-bytes) representation of the ID used internally, returned as a string
  • requestProcessingTime (N) is the API request processing time (in millisec)

Full Hash To Id Example

http://localhost:27876/nxt?
  requestType=fullHashToId&
  fullHash=c34af8f1509e3be79c4562e24125ff2a8f026871fdd1a0366ad315bf8fab76b9
{
 "stringId": "16662085316881435331",
 "requestProcessingTime": 0,
 "longId": "-1784658756828116285"
}


Hash

Calculates the hash of a secret for use in phased transactions with voting model 5 (Vote By Secret). Javadoc

Request:

  • requestType is hash
  • hashAlgorithm is the hash function used: 2 for SHA256, 3 for SHA3, 5 for SCRYPT, 6 for RIPEMD160, 25 for Keccack25 and 62 for SHA256 followed by RIPEMD160, according to Get Constants
  • secret is a secret phrase in text form or hex string form
  • secretIsText is true if secret is text, false if it is a hex string (optional)

Note: secret is converted from a hex string to a byte array, which is what the hash algorithm expects, unless secretIsText is true, in which case secret is first converted from text to a UTF-8 hex string as by Hex Convert.

Response:

  • hash (S) is the hash of the secret, in the form of a hex string
  • requestProcessingTime (N) is the API request processing time (in millisec)

Hash Example

Note: 74657374 is the UTF-8 hex string for the secret phrase "test".

http://localhost:27876/nxt?
  requestType=hash&
  hashAlgorithm=2&
  secret=74657374
{
 "requestProcessingTime": 1,
 "hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
}


Hex Convert

Converts a text string into a UTF-8 hex string and if the text input is already a hex string, also into text. Javadoc

Request:

  • requestType is hexConvert
  • string is a text string, possibly a hex string

Response:

  • binary (S) is the converted UTF-8 hex string
  • text (S) is a text string converted from string if it is a valid UTF-8 hex string
  • requestProcessingTime (N) is the API request processing time (in millisec)

Hex Convert Example

http://localhost:27876/nxt?
  requestType=hexConvert&
  string=616263
{
 "binary": "363136323633",
 "text": "abc",
 "requestProcessingTime": 1
}


Long Convert

Converts an ID to the signed long integer representation used internally. Javadoc

Request:

  • requestType is longConvert
  • id is a numerical ID, in decimal form but equivalent to an 8-byte unsigned integer as produced by SHA-256 hashing

Response:

  • stringId (S) is the numerical ID
  • longId (S) is the signed long integer (8-bytes) representation of the ID used internally, returned as a string
  • requestProcessingTime (N) is the API request processing time (in millisec)

Note: Java does not support unsigned integers, so any unsigned ID (such as a block ID) visible in the NRS client is represented internally as a signed integer.

Long Convert Example

http://localhost:27876/nxt?
  requestType=longConvert&
  id=15323192282528158131
{
 "stringId": "15323192282528158131",
 "requestProcessingTime": 0,
 "longId": "-3123551791181393485"
}


RS Convert

Get both the Reed-Solomon account address and the account number given an account ID. Javadoc

Request:

  • requestType is rsConvert
  • account is an account ID (either RS address or number)

Response:

  • accountRS (S) is the Reed-Solomon address of the account
  • requestProcessingTime (N) is the API request processing time (in millisec)
  • account (S) is the account number

RS Convert Example

http://localhost:27876/nxt?
  requestType=rsConvert&
  account=ARDOR-L6FM-89WK-VK8P-FCRBB
{
 "accountRS": "ARDOR-L6FM-89WK-VK8P-FCRBB",
 "requestProcessingTime": 1,
 "account": "15323192282528158131"
}