-
Notifications
You must be signed in to change notification settings - Fork 192
JSON RPC API
JSON is a lightweight data-interchange format. It can represent numbers, strings, ordered sequences of values, and collections of name/value pairs.
JSON-RPC is a stateless, light-weight remote procedure call (RPC) protocol. Primarily this specification defines several data structures and the rules around their processing. It is transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments. It uses JSON (RFC 4627) as data format.
In order to work properly with Pascal Coin, you must follow these instructions:
We use (by default) pure JSON RPC 2.0 standard
This means that:
-
Every call MUST include 3 params: {"jsonrpc": "2.0", "method": "XXX", "id": YYY}
- jsonrpc : String value = "2.0"
- method : String value, name of the method to call
- id : Integer value
- Optionally can contain another param called "params" holding an object. Inside we will include params to send to the method
- {"jsonrpc": "2.0", "method": "XXX", "id": YYY, "params":{"p1":" ","p2":" "}}
- If JSON is not JSON RPC Standard 2.0 compliant, it will be rejected without a response.
- If JSON does not have a valid "id" value it will not be processed and rejected without a response.
All calls will be using HTTP protocol (HTTP 1.1) and passing JSON calls by POST at port 4003
- Protocol: HTTP v1.1
- Port: 4003
- Http method: POST
// Request to server at localhost. Method "getblockcount" (Returns block count of the PascalCoin network)
curl -X POST --data '{"jsonrpc":"2.0","method":"getblockcount","id":123}' http://localhost:4003
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": 26724
}RPC Calls could include/return these data types:
- Integers, strings, boolean (true or false) or null
- HEXASTRING: String that contains an hexadecimal value (ex. "4423A39C"). An hexadecimal string is always an even character length.
- PASCURRENCY: Pascal Coin currency is a maximum 4 decimal number (ex. 12.1234). Decimal separator is a "." (dot)
- JSON "specific" Objects: List of some objects returned by RPC calls and used for many methods: (See each method to know which object returns)
An "Account object" is a JSON object with information about an account. Fields are:
-
account: Integer - Account number -
enc_pubkey: HEXASTRING - Encoded public key value (See decodepubkey ) -
balance: PASCURRENCY - Account balance -
n_operation: Integer - Operations made by this account (Note: When an account receives a transaction, n_operation is not changed) -
updated_bInteger - Last block that updated this account. If equal to blockchain blocks count it means that it has pending operations to be included to the blockchain
A "Block object" is a JSON object with information about a Blockchain's block. Fields are:
-
block: Integer - Block number -
enc_pubkey: HEXASTRING - Encoded public key value used to init 5 created accounts of this block (See decodepubkey ) -
reward: PASCURRENCY - Reward of first account's block -
fee: PASCURRENCY - Fee obtained by operations -
ver: Integer - Pascal Coin protocol used -
ver_a: Integer - Pascal Coin protocol available by the miner -
timestamp: Integer - Unix timestamp -
target: Integer - Target used -
nonce: Integer - Nonce used -
payload: String - Miner's payload -
sbh: HEXASTRING - SafeBox Hash -
oph: HEXASTRING - Operations hash -
pow: HEXASTRING - Proof of work -
operations: Integer - Number of operations included in this block -
hashratekhs: Integer - Estimated network hashrate calculated by previous 50 blocks average -
maturation: Integer - Number of blocks in the blockchain higher than this
An "Operation object" is a JSON object with information about an operation. Fields are:
-
block: Integer - Block number -
opblock: Integer - Operation index inside a block (0..operations-1). Note: Ifopblock=-1 means that is a blockchain reward -
optype: Integer - Operation type. can be:- 0 = Blockchain reward
- 1 = Transaction
- 2 = Change key
- 3 = Recover founds (lost keys)
-
time: Integer - Block timestamp -
account: Integer - Account affected by this operation. Note: A transaction has 2 affected accounts. -
optxt: String - Human readable operation type -
amount: PASCURRENCY - Amount of coins transferred fromsender_accounttodest_account(Only apply whenoptype=1) -
fee: PASCURRENCY - Fee of this operation -
balance: PASCURRENCY - Balance ofaccountafter this block is introduced in the Blockchain- Note:
balanceis a calculation based on current safebox account balance and previous operations, it's only returned on pending operations and account operations
- Note:
-
sender_account: Integer - Sender account in a transaction (optype= 1) -
dest_account: Integer - Destination account in a transaction (optype= 1) -
enc_pubkey: HEXASTRING - Encoded public key in a change key operation (optype= 2). See decodepubkey -
ophash: HEXASTRING - Operation hash used to find this operation in the blockchain
A "Connection object" is a JSON object with a connection to other node information
-
server: Boolean - True if this connection is to a server node. False if this connection is a client node -
ip: String -
port: Integer -
secs: Integer - seconds of live of this connection -
sent: Integer - Bytes sent -
recv: Integer - Bytes received -
appver: String - Other node App version -
netvar: Integer - Net protocol of other node -
netvar_a: Integer - Net protocol available of other node
JSON-RPC Error codes will be in a JSON-Object in this format:
-
code: Integer - Error code -
message: String - Human readable error description
- 100 - Internal error
- 1001 - Method not found
- 1002 - Invalid account
- 1003 - Invalid block
- 1004 - Invalid operation
- 1005 - Invalid public key
- 1010 - Not found
- 1015 - Wallet is password protected
- 1016 - Invalid data
All calls will be using http transport protocol and JSON will be passed by POST
- addnode - Adds a node to connect
- getaccount - Get an account information
- getwalletaccounts - Get available wallet accounts information
- getwalletpubkeys - Get wallet public keys
- getblock - Get block information
- getblockcount - Get blockchain high in this node
- getblockoperation - Get an operation of the block information
- getblockoperations - Get all operations of specified block
- getaccountoperations - Get operations made to an account
- getpendings - Get pendings operations to be included in the blockchain
- findoperation - Finds an operation by "ophash"
- sendto - Executes a transaction
- changekey - Executes a change key over an account
- nodestatus - Returns node status
- encodepubkey - Encodes a public key
- decodepubkey - Decodes a public key
- payloadencrypt - Encrypts a text
- payloaddecrypt - Decrypts a text
- getconnections - Lists all active connections of this node
- addnewkey - Adds a new key to the Wallet
- unlock - Unlocks the Wallet
- setwalletpassword - Changes wallet password
- stopnode - Stops the node
- startnode - Starts the node
Add nodes to connect
-
nodesString containing 1 or multiple IP:port separated by ";"
Returns an integer with nodes added
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"addnode","params":{"nodes":"123.123.123.123:4004;7.7.7.7:4005"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": 2
}Returns a JSON Object with account information including pending operations not included in blockchain yet, but affecting this account.
Tip: To know if there are pending operations, must look at updated_b param. It tells last block that modified this account. If this number is equal to blockchain blocks then this account is affected by pending operations (send/receive or change key)
-
accountCardinal containing account number
Result is an Account Object
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getaccount","params":{"account":1920},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": {
"account":1920,
"enc_pubkey":"CA0220009D92DFA1D6F8B2CAE31194EE5433EE4AD457AE145C1C67E49A9196EE58A45B9F200046EAF20C0A26A80A7693E71C0222313A0187AFCA838209FF86FB740A4FFF7F0B",
"balance":29595.952,
"n_operation":0,
"updated_b":11973
}
}Returns a JSON array with all wallet accounts.
- none
Each JSON array item contains an Account Object
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getwalletaccounts","id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": [{
"account":1920,
"enc_pubkey":"CA0220009D92DFA1D6F8B2CAE31194EE5433EE4AD457AE145C1C67E49A9196EE58A45B9F200046EAF20C0A26A80A7693E71C0222313A0187AFCA838209FF86FB740A4FFF7F0B",
"balance":29595.952,
"n_operation":0,
"updated_b":11973
},
{
"account":1921,
"enc_pubkey":"CA0220009D92DFA1D6F8B2CAE31194EE5433EE4AD457AE145C1C67E49A9196EE58A45B9F200046EAF20C0A26A80A7693E71C0222313A0187AFCA838209FF86FB740A4FFF7F0B",
"balance":29.9521,
"n_operation":0,
"updated_b":11973
}
]
}Returns a JSON Array with all pubkeys of the Wallet (address)
(none)
Each array item is:
-
name: String with internal key name in the Wallet -
enc_pubkey: HEXASTRING with public key in encoded format (See decodepubkey ) -
can_use: Boolean indicating if we have this private key. (Note: A Wallet can contain pubkeys without private keys, so there will not be possible to operate with this address)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getwalletpubkeys","id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": [{
"name":"My key",
"enc_pubkey":"CA0220009D92DFA1D6F8B2CAE31194EE5433EE4AD457AE145C1C67E49A9196EE58A45B9F200046EAF20C0A26A80A7693E71C0222313A0187AFCA838209FF86FB740A4FFF7F0B",
"can_use":true
},
{
"name":"My key 2",
"enc_pubkey":"CA02200026D497C8982EC538BC06FCC1F5FACA39A2CA6DFAEC601122155F388A08FEF3812000E8FDAA2C8D8375D022510A12DC65641B5D904A36B1E913C9B96A0A40C645D2F2",
"can_use":true
}]
}Returns a JSON Object with a block information
-
block: Integer - Block number (0..blocks count-1)
Returns a JSON Object with a "Block Object"
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getblock","params":{"block":8888},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": {
"block":8888,
"enc_pubkey":"CA0220000E60B6F76778CFE8678E30369BA7B2C38D0EC93FC3F39E61468E29FEC39F13BF2000572EDE3C44CF00FF86AFF651474D53CCBDF86B953F1ECE5FB8FC7BB6FA16F114",
"reward":100,
"fee":0,
"ver":1,
"ver_a":0,
"timestamp":1473161258,
"target":559519020,
"nonce":131965022,
"payload":"New Node 9/4/2016 10:10:13 PM - Pascal Coin Miner & Explorer Build:1.0.2.0",
"sbh":"5B75D33D9EFBF560EF5DA9B4A603528808626FE6C1FCEC44F83AF2330C6607EF",
"oph":"81BE87831F03A2FE272C89BC6D2406DD57614846D9CEF30096BF574AB4AB3EE9",
"pow":"00000000213A39EBBAB6D1FAEAA1EE528E398A587848F81FF66F7DA6113FC754",
"operations":1
}
}Returns a JSON Array with blocks information from "start" to "end" (or "last" n blocks) Blocks are returned in DESCENDING order See getblock
-
last: Integer - Last n blocks in the blockchain (n>0 and n<=1000) -
start: Integer -
end: Integers Note: Must use paramlastalone, orstartandend
Returns an Integer with blockcount of node
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getblockcount","id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": 26724
}Returns a JSON Object with an operation inside a block
-
block: Integer - Block number -
opblock: Integer - Operation (0..operations-1) of this block
Returns a JSON Object with a "Operation Object"
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getblockoperation","params":{"block":8888,"opblock":0},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": {
"block":8888,
"opblock":0,
"optype":1,
"time":1473161258,
"account":43905,
"optxt":"Transaction Sent to 40511-95",
"amount":-100,
"fee":0,
"balance":0,
"payload":"",
"dest_account":40511,
"ophash":"B822000081AB0000010000003032333646444430344246334637414434413042"
}
}Returns a JSON Array with all operations of specified block Operations are returned in DESCENDING order
-
block: Integer - Block number
Returns a JSON Array with "Operation Object" items
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getblockoperations","params":{"block":8888},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": [{
"block":8888,
"opblock":0,
"optype":1,
"time":1473161258,
"account":43905,
"optxt":"Transaction Sent to 40511-95",
"amount":-100,
"fee":0,
"balance":0,
"payload":"",
"dest_account":40511,
"ophash":"B822000081AB0000010000003032333646444430344246334637414434413042"
}]
}Return a JSON Array with "Operation Object" items. Operations made over an account Operations are returned in DESCENDING order
-
account: Integer - Account number (0..accounts count-1) -
deep: Integer - (Optional, default value 100) Deep to search on blocks where this account has been affected
Returns an array holding operations made over account in "Operation Object" format
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getaccountoperations","params":{"account":101740},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": [
{"block":22647,
"opblock":0,
"optype":1, // Note: This is a transaction
"time":1476744324,
"account":101740,
"optxt":"Transaction Received from 103844-87",
"amount":20000, // Note: This is an incoming transaction, so "amount" is a positive number
"fee":0,
"balance":20000,
"payload":"",
"sender_account":103844,
"dest_account":101740,
"ophash":"77580000A4950100020000003238453136333441383439393046414632443332"
},{
"block":21555,
"opblock":0,
"optype":2, // Note: This is a change key operation
"time":1476466491,
"account":101740,
"optxt":"Change Key to secp256k1",
"amount":0,
"fee":0,
"balance":0,
"payload":"",
// This is the new public key due to change key operation
"enc_pubkey":"CA02200078D867C93D58C2C46C66667A139543DCF8420D9119B7A0E06197D22A5BBCE5542000EA2E492FD8B90E48AF3D9EF438C6FBEA57C8A8E75889807DE588B490B1D57187",
"ophash":"335400006C8D0100020000003330433034464446453130354434444445424141"
},{
"block":21255,
"opblock":0,
"optype":1,
"time":1476378864,
"account":101740,
"optxt":"Transaction Sent to 63553-29",
"amount":-100, // Note: This is an outgoing transaction, so "amount" is a negative number
"fee":0,
"balance":0,
"payload":"",
"sender_account":101740,
"dest_account":63553, // Note: Dest account is the receiver
"ophash":"075300006C8D0100010000003536463332393641383335344236323945464536"
},{
"block":20348,
"opblock":-1, // Note: This is a blockchain reward. No operation number included (-1)
"optype":0, // optype = 0 = Blockhain reward
"time":1476153843,
"account":101740,
"optxt":"Blockchain reward",
"amount":100,
"fee":0,
"balance":100,
"payload":"",
"ophash":"" // Note: A blockchain reward has no ophash operation
}
]
}Return a JSON Array with "Operation Object" items with operations pending to be included at the Blockchain.
(none)
Returns an array holding pending operations in "Operation Object" format
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"getpendings","id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": [] // Note: None pending = empty array
}Return a JSON Object in "Operation Object" format.
-
ophash: HEXASTRING - Valueophashreceived on an operation
Returns "Operation Object" format JSON object
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"findoperation","params":{"ophash":"075300006C8D0100010000003536463332393641383335344236323945464536"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": {
"block":21255,
"opblock":0,
"optype":1,
"time":1476378864,
"account":101740,
"optxt":"Transaction Sent to 63553-29",
"amount":-100,
"fee":0,
"balance":0,
"payload":"",
"sender_account":101740,
"dest_account":63553, // Note: Dest account is the receiver
"ophash":"075300006C8D0100010000003536463332393641383335344236323945464536"
}
}Executes a transaction operation from "sender" to "target"
-
sender: Integer - Sender account -
target: Integer - Destination account -
amount: PASCURRENCY - Coins to be transferred -
fee: PASCURRENCY - Fee of the operation -
payload: HEXASTRING - Payload "item" that will be included in this operation -
payload_method: String - Encode type of the item payload-
none: Not encoded. Will be visible for everybody -
dest(default) : Using Public key of "target" account. Only "target" will be able to decrypt this payload -
sender: Using sender Public key. Only "sender" will be able to decrypt this payload -
aes: Encrypted data usingpwdparam
-
-
pwd: String - Used to encrypt payload withaesas apayload_method. If none equals to empty password
If trasnaction is successfull will return a JSON Object in "Operation Object" format. Otherwise, will return a JSON-RPC error code with description
Correct example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"sendto","params":{"sender":1234,"target":5678,"amount":100000,"fee":0.0001,"payload":"444F444F444F","payload_method":"aes","pwd":"MyPassword"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": {
"block":0,
"opblock":0,
"optype":1,
"time":1476363846,
"account":1234,
"optxt":"Transaction Sent to 5678-55",
"amount":-100000,
"fee":0.0001,
"balance":150605.9999,
"payload":"842357F9C1842357F9C1842357F9C1842357F9C1",
"sender_account":1234,
"dest_account":5678,
"ophash":"000000006C8D0100010000003536463332393641383335344236323945464536"
}
}Error example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"sendto","params":{"sender":1234,"target":5678,"amount":100000,"fee":0.0001,"payload":"444F444F444F","payload_method":"aes","pwd":"MyPassword"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"error": {
"code":1002, // Note: See [Error codes](#error-codes)
"message":"Private key of sender account 1234 not found in wallet"
}
}Executes a change key operation, changing "account" public key for a new one.
Note that new one public key can be another Wallet public key, or none. When none, it's like a transaction, tranferring account owner to an external owner
-
account: Integer - Account number to change key -
new_enc_pubkey: HEXASTRING - New public key in encoded format -
fee: PASCURRENCY - Fee of the operation -
payload: HEXASTRING - Payload "item" that will be included in this operation -
payload_method: String - Encode type of the item payload-
none: Not encoded. Will be visible for everybody -
dest(default) : Using Public key of "target" account. Only "target" will be able to decrypt this payload -
sender: Using sender Public key. Only "sender" will be able to decrypt this payload -
aes: Encrypted data usingpwdparam
-
-
pwd: String - Used to encrypt payload withaesas apayload_method. If none equals to empty password
If operation is successfull will return a JSON Object in "Operation Object" format. Otherwise, will return a JSON-RPC error code with description
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"changekey","params":{"account":101740,"new_enc_pubkey":"CA02200078D867C93D58C2C46C66667A139543DCF8420D9119B7A0E06197D22A5BBCE5542000EA2E492FD8B90E48AF3D9EF438C6FBEA57C8A8E75889807DE588B490B1D57187","fee":0.0001,"payload":"","payload_method":"none"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": {
"block":21555,
"opblock":0,
"optype":2,
"time":1476466491,
"account":101740,
"optxt":"Change Key to secp256k1",
"amount":0,
"fee":0,
"balance":0,
"payload":"",
"enc_pubkey":"CA02200078D867C93D58C2C46C66667A139543DCF8420D9119B7A0E06197D22A5BBCE5542000EA2E492FD8B90E48AF3D9EF438C6FBEA57C8A8E75889807DE588B490B1D57187",
"ophash":"335400006C8D0100020000003330433034464446453130354434444445424141"
}
}Error example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"changekey","params":{"account":101740,"new_enc_pubkey":"CA02200078D867C93D58C2C46C66667A139543DCF8420D9119B7A0E06197D22A5BBCE5542000EA2E492FD8B90E48AF3D9EF438C6FBEA57C8A8E75889807DE588B490B1D57187","fee":0.0001,"payload":"","payload_method":"none"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"error": {
"code":1002, // Note: See [Error codes](#error-codes)
"message":"Private key account 101740 not found in wallet"
}
}Returns information of the Node in a JSON Object
(none)
-
ready: Boolean - Must be true, otherwise Node is not ready to execute operations -
ready_s: String - Human readable information about ready or not -
status_s: String - Human readable information about node status... Running, downloading blockchain, discovering servers... -
port: Integer - Server port -
locked: Boolean - True when this wallet is locked, false otherwise -
timestamp: Integer - Timestamp of the Node -
version: String - Server version -
netprotocol: JSON Object-
ver: Integer - Net protocol version -
ver_a: Integer - Net protocol available
-
- blocks : Integer - Blockchain blocks
- netstats : JSON Object with net information
- ndeservers : JSON Array with servers candidates
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"nodestatus","id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result":{
"ready":true,
"ready_s":"",
"status_s":"Running",
"port":4004,
"locked":false,
"timestamp":1478094204,
"version":"1.0.9",
"netprotocol":{
"ver":2,
"ver_a":3
},
"blocks":27547,
"netstats":{
"active":20,
"clients":17,
"servers":3,
"servers_t":3,
"total":147,
"tclients":142,
"tservers":5,
"breceived":2006753,
"bsend":1917264
},
"nodeservers":[
{"ip":"46.29.1.190",
"port":4004,
"lastcon":1478094198,
"attempts":0
},{
"ip":"144.27.2.76",
"port":4004,
"lastcon":1478094198,
"attempts":0
},{
"ip":"118.48.48.94",
"port":4004,
"lastcon":1478094198,
"attempts":0}
]
}
}Encodes a public key based on params information
-
ec_nid: Integer- 714 = secp256k1
- 715 = secp384r1
- 729 = secp283k1
- 716 = secp521r1
-
x: HEXASTRING with x value of public key -
y: HEXASTRING with y value of public key
Returns a HEXASTRING with encoded public key
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"encodepubkey","params":{"ec_nid":714,"x":"0E60B6F76778CFE8678E30369BA7B2C38D0EC93FC3F39E61468E29FEC39F13BF","y":"572EDE3C44CF00FF86AFF651474D53CCBDF86B953F1ECE5FB8FC7BB6FA16F114"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": "CA0220000E60B6F76778CFE8678E30369BA7B2C38D0EC93FC3F39E61468E29FEC39F13BF2000572EDE3C44CF00FF86AFF651474D53CCBDF86B953F1ECE5FB8FC7BB6FA16F114"
}Decodes an encoded public key
-
enc_pubkey: HEXASTRING with encoded public key
Returns a JSON Object with public key information:
-
ec_nid: Integer- 714 = secp256k1
- 715 = secp384r1
- 729 = secp283k1
- 716 = secp521r1
-
x: HEXASTRING with x value of public key -
y: HEXASTRING with y value of public key
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"decodepubkey","params":{"enc_pubkey":"CA0220000E60B6F76778CFE8678E30369BA7B2C38D0EC93FC3F39E61468E29FEC39F13BF2000572EDE3C44CF00FF86AFF651474D53CCBDF86B953F1ECE5FB8FC7BB6FA16F114","id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result": {
"ec_nid":714,
"x":"0E60B6F76778CFE8678E30369BA7B2C38D0EC93FC3F39E61468E29FEC39F13BF",
"y":"572EDE3C44CF00FF86AFF651474D53CCBDF86B953F1ECE5FB8FC7BB6FA16F114"
}
}Encrypt a text "paylad" using "payload_method"
-
payload: HEXASTRING - Text to encrypt in hexadecimal format -
payload_method: String - Can be one of:- none
- pubkey : Using a Publick Key. Only owner of this private key will be able to read it. Must provide
enc_pubkeyparam. See decodepubkey or encodepubkey-
enc_pubkey: HEXASTRING -
-
- aes : Using a Password. Must provide
pwdparam-
pwd: String
-
Returns a HEXASTRING with encrypted payload
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"payloadencrypt","params":{"payload":"444F444F","payload_method":"aes","pwd":"mypassword"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result":"53616C7465645F5F8312C92E9BFFD6068ADA9F2F7CEA90505B50CE2CAE995C28"
}Returns a HEXASTRING with decrypted text (a payload) using private keys in the wallet or a list of Passwords (used in "aes" encryption)
-
payload:HEXASTRING - Encrypted data -
pwds: JSON Array of Strings (optional)
-
result: Boolean -
enc_payload: HEXASTRING - Same value than parampayloadsent -
unenc_payload: String - Unencoded value in readable format (no HEXASTRING) -
payload_method: String - "key" or "pwd" -
enc_pubkey: HEXASTRING - Encoded public key used to decrypt when method = "key" -
pwd: String - String value used to decrypt when method = "pwd" Note: - If using one of private keys is able to decrypt
payloadthen returns value "key" inpayload_methodandenc_pubkeycontains encoded public key in HEXASTRING - If using one of passwords to decrypt
payloadthen returns value "pwd" inpayload_methodandpwdcontains password used
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"payloaddecrypt","params":{"payload":"53616C7465645F5F8312C92E9BFFD6068ADA9F2F7CEA90505B50CE2CAE995C28","pwds":["mypassword","otherpwd"]},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result":{
"result":true,
"enc_payload":"53616C7465645F5F8312C92E9BFFD6068ADA9F2F7CEA90505B50CE2CAE995C28",
"unenc_payload":"DODO",
"payload_method":"pwd",
"pwd":"mypassword"
}
}Returns a JSON Array with Connection Objects
Creates a new Private key and sotres it on the wallet, returning an enc_pubkey value
-
ec_nid: Integer - One of- 714 = secp256k1
- 715 = secp384r1
- 729 = secp283k1
- 716 = secp521r1
-
name: String - Name to alias this new private key
HEXASTRING containing an encoded public key (See decodepubkey )
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"addnewkey","params":{"ec_nid":729,"name":"My new key"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result":"D902240006ECEFF2AFDAF182F77BCC0E1316C99680C5221BE08A3AB58A43C52B298057FCE594CD33240003AEA36BBB9A82DFECA7D30CE33503FED96CC1AA16AF5F80BA0836CD4AF28F4716253237"
}Unlocks a locked Wallet using "pwd" param
-
pwd: String;
Returns a Boolean indicating if Wallet is unlocked after using pwd password
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"unlock","params":{"pwd":"mypassword"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result":true
}Changes the password of the Wallet. (Must be previously unlocked)
Note: If pwd param is empty string, then wallet will be not protected by password
-
pwd: String - New password
Returns a Boolean if Wallet password changed with new pwd password
Valid example
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"setwalletpassword","params":{"pwd":"myNEWpassword"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result":true
}Error example (Wallet password protected)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"setwalletpassword","params":{"pwd":"myNEWpassword"},"id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"error":{
"code":1015,
"message":"Wallet is password protected. Unlock first"
}
}Stops the node and the server. Closes all connections
(none)
Boolean "true"
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"stopnode","id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result":true
}Starts the node and the server. Starts connection process
(none)
Boolean "true"
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"startnode","id":123}'
// Result
{
"jsonrpc":"2.0",
"id":123,
"result":true
}