Coin Daemon


Daemon JSON RPC API

Daemon JSON RPC is a HTTP server which provides JSON 2.0 RPC interface for interacting with Daemon and Block Explorer.

Interacting with the API

To start the Daemon JSON RPC API server at http://localhost:43000/json_rpc run:

./ultranoteid --rpc-bind-port=43000

To make the server accessible from another computer, use the --rpc-bind-ip 0.0.0.0 switch.

./ultranoteid --rpc-bind-ip=0.0.0.0 --rpc-bind-port=43000

To make a JSON RPC request to your Daemon RPC you should use a POST request that looks like this:

http://localhost:43000/json_rpc

Parameter Description

service address

IP of Daemon RPC, if it is located on local machine it is either 127.0.0.1 or localhost

Using PHP

Configuration and instantiation

Once the rpc service is installed you should be able to send post requests to the and address looking like:

http://<service address>:<service port>/json_rpc

Now, to install the php library, download it and put it in the according folder, then include where needed :

Then, To start using the offered functions, you need to create an object as follows:

require_once( 'ultranote-rpc-php.php' ); $config = [ 'rpcUrl' => 'http://localhost:8060/json_rpc', 'rpcUser' => 'theusername', 'rpcPassword' => 'thepassword' ]; $coin = new XuniCoin($config);

Parameter Description

$config['rpcUrl']

The link to the RPC service

$config['rpcUser']

The username of the RPC service (leave empty if none)

$config['rpcPassword']

The Password of the RPC service (leave empty if none)

getStatus()

Returns the blockCount of the deamon, usefull to check if the daemon is syncronized. $coin->getStatus()->blockCount;

Expected output:

39375

createAddress()

Create a new wallet. $coin->createAddress();

Expected output:

'Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3'

deleteAddress($address)

Create a new wallet. $address = ''Xuniik72MxR2Cn29BzvV...'; $coin->deleteAddress($address);

Expected output:

true
Parameter Description

$address

The address to delete

getBalance($address)

Returns the balance of the given address $address = 'Xuniik72MxR2Cn29BzvV...'; $coin->deleteAddress($address);

Expected output:

135.32
Parameter Description

$address

The address to check

getUnconfirmedTransactionHashes($address)

Returns the unconfirmed transactions concerning the given address, can be used to check if there are new transactions in the pool. $address = 'Xuniik72MxR2Cn29BzvV...'; $coin->getUnconfirmedTransactionHashes($address);

Expected output:

{'7031309d4a0d87241c3700cafaeeefc04b226dc3387cedef4e93226aa76f21cb', '7031309d4a0d87241c3700cafaeeefc04b226dc3387cedef4e93226aa76f21cb'}
Parameter Description

$address

The address to check

getTransactions($firstBlockIndex,$blockCount)

Returns all the 'N' transactions that happened starting a given block. $firstBlockIndex = 39075; $blockCount=2; $coin->getTransactions($firstBlockIndex,$blockCount);

Expected output:

{( [blockHash] => '5acd33b287a2ed31f7a15e34f06a199739577c5cd83ce593170c6c2b034662d2' [transactions] => {} ), ( [blockHash] => '327e11cec4ffc46bb669477fba434e3c60f36c9ffc0c223c52f30d7b3ff96e73' [transactions] => {} )}
Parameter Description

$firstBlockIndex

The first block to start from

$blockCount

The number of blocks to analyse for transactions

getTransaction($transactionHash)

Returns the details of a given transaction. $transactionHash = '9fb36d4bb905ef360c877ce8eba9c9dafc81da27cae85bd4727af46c5ba75ef7'; $coin->getTransaction($transactionHash);

Expected output:

( [amount] => -1100000 [blockIndex] => 356658 [confirmations] => 87 [extra] => '0184fc63971f7a884edd6c79d30bf96b1958bcae9b9413fa29da9d033b187fe275' [fee] => 100000 [isBase] => [paymentId] => [state] => 0 [timestamp] => 1556123357 [transactionHash] => '4730d061536e6333dcfcc983b11dd87b1412101f139ca60a5c459032b0efc643' [transfers] =>{( [address] => 'Xuniik72MxR2Cn29BzvV...' [amount] => 1000000 [type] => 0 ),( [address] => 'Xuniik72MxR2Cn29BzvV...' [amount] => 5900000 [type] => 2 ),( [address] => 'Xuniik72MxR2Cn29BzvV...' [amount] => -7000000 [type] => 0 ) )} [unlockTime] => 0 )
Parameter Description

$transactionHash

The hash of the transaction you are interested in

sendTransaction($from,$to,$ammount)

Sends an ammount of Xun from one address to an other. $from = 'Xuniik72MxR2Cn29BzvV...'; $to='Xuniik72MxR2Cn29BzvV...'; $ammount=1100000; $coin->sendTransaction($from,$to,$ammount);

Expected output:

'a599cbd0616c60e0ea75aaaac1c79dd8ba23e1ab50eeed6fc48206ec13fd8828'
Parameter Description

$from

The address of the sender of the currency

$to

The address of the recipient of the currency

$ammount

Ammount of currency to send

sendTransactionAdvanced($params)

Same as the sendTransaction function, with more options. $params = [ "addresses"=>["Xuniik72MxR2Cn29BzvV..."], "anonymity"=> 2, "fee"=> 100000, "transfers"=>[ [ "amount"=>1000000, "address"=>"Xuniik72MxR2Cn29BzvV..." ], [ "amount"=>3000000, "address"=>"Xun3cs87FJL5r..." ] ]]; $coin->sendTransactionAdvanced($params);

Expected output:

'a599cbd0616c60e0ea75aaaac1c79dd8ba23e1ab50eeed6fc48206ec13fd8828'
Parameter Description

$params['addresses']

Array of Addresses, Addresses which should be charged. Be careful, If you didn't specify addresses the daemon can charge all wallets to collets needed amount.

$params['anonymity']

The anonymity level of the transaction

$params['fee']

The fee that you are willing to pay for the transaction

$params['transfers']

Array of Arrays, Contains couples [ammount, address] of all the transfers you want to execute within the transaction

reset()

Re-sync cointainer starting from 0 block.

save()

Save current container state. Do it before making reserve copies or reboots.

Using Bash

Configuration and instantiation

Once the rpc service is installed you should be able to send post requests to the and address looking like:

http://<service address>:<service port>/json_rpc

getStatus

Returns the blockCount of the deamon, usefull to check if the daemon is syncronized. curl -d '{"method":"getStatus", "params": {},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc

Expected output:

{ "id":"1", "jsonrpc":"2.0", "result":{ "blockCount":30375, "knownBlockCount":30375, "lastBlockHash":"ffa6dda0facc4a7ea903b0cededd897d2f281ac09eb6f50b9fed840dfe5073b5", "peerCount":22 } }

createAddress

Create a new wallet. curl -d '{"method":"createAddress","params": {},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc

Expected output:

{ "id":"1", "jsonrpc":"2.0", "result":{ "address":"Xuniik72MxR2Cn29BzvV..." } }

deleteAddress

Delete wallet. curl -d '{"method":"deleteAddress","params": {"address":"Xuniik72MxR2Cn29BzvV..."},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc

Expected output:

{ "id":"1", "jsonrpc":"2.0", "result":{} }
Parameter Description

address

The address to delete

getBalance

Create a new wallet. curl -d '{"method":"getBalance","params": {"address":"Xuniik72MxR2Cn29BzvV..."},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc

Expected output:

{ "id":"1", "jsonrpc":"2.0", "result":{ "availableBalance":0, "lockedAmount":0 } }
Parameter Description

address

The address to check

getUnconfirmedTransactionHashes

Returns the unconfirmed transactions concerning the given address, can be used to check if there are new transactions in the pool. curl -d '{"method":"getUnconfirmedTransactionHashes","params": {"address":"Xuniik72MxR2Cn29BzvV..."},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc

Expected output:

{ "id":"1", "jsonrpc":"2.0", "result":{ "transactionHashes":[ "7031309d4a0d87241c3700cafaeeefc04b226dc3387cedef4e93226aa76f21cb", "7031309d4a0d87241c3700cafaeeefc04b226dc3387cedef4e93226aa76f21cb" ] } }
Parameter Description

address

The address to check

getTransactions

Returns all the 'N' transactions that happened starting a given block. curl -d '{"method":"getTransactions","params": {"firstBlockIndex": 53888, "blockCount": 5},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc

Expected output:

{ "id":"1", "jsonrpc":"2.0", "result":{ "items":[ {"blockHash":"ca9179c4e02017adcd538efb3874b1857b4121814c7d15ec15f8fc0a93481466","transactions":[{}]}, {"blockHash":"ca9179c4e02017adcd538efb3874b1857b4121814c7d15ec15f8fc0a93481466","transactions":[{}]} ] } }
Parameter Description

firstBlockIndex

The first block to start from

blockCount

The number of blocks to analyse for transactions

getTransaction

Returns the details of a given transaction. curl -d '{"method":"getTransaction","params": {"transactionHash":"9fb36d4bb905ef360c877ce8eba9c9dafc81da27cae85bd4727af46c5ba75ef7"},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc

Expected output:

{ "id":"1", "jsonrpc":"2.0", "result":{ "transaction":{ "amount":-1000, "blockIndex":4294967295, "extra":"015371f8a3cdae5b7ec5fd8e79e3f1d524f8f4d9d884d6c74b81d63e4076b04b1201", "fee":0, "isBase":false, "paymentId":"", "state":2, "timestamp":0, "transactionHash":"9fb36d4bb905ef360c877ce8eba9c9dafc81da27cae85bd4727af46c5ba75ef7", "transfers":[ { "address":"Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3", "amount":1000, "type":0 }, { "address":"Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3", "amount":899000, "type":2 }, { "address":"Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3", "amount":-900000, "type":0 } ], "unlockTime":0 } } }
Parameter Description

transactionHash

The hash of the transaction you are interested in

sendTransaction

Sends an ammount of Xun from one address to an other. curl -d '{ "method":"sendTransaction", "params": { "addresses":["XuniiZtBPE7e..."], "anonymity": 2, "fee": 10000, "transfers":[ { "amount":900000, "address":"XuniiqFybMCT..." } ] }, "jsonrpc": "2.0", "id": "1" }' http://"username":"password"@localhost:8070/json_rpc

Expected output:

{ "id":"1", "jsonrpc":"2.0", "result":{ "transactionhash":"a599cbd0616c60e0ea75aaaac1c79dd8ba23e1ab50eeed6fc48206ec13fd8828..." } }
Parameter Description

addresses

Array of Addresses, Addresses which should be charged. Be careful, If you didn't specify addresses the daemon can charge all wallets to collets needed amount.

anonymity

The anonymity level of the transaction

fee

The fee that you are willing to pay for the transaction

transfers

Array of Arrays, Contains couples [ammount, address] of all the transfers you want to execute within the transaction

reset

Re-sync cointainer starting from 0 block.

curl -d '{"jsonrpc":"2.0","id":1, "method":"reset","params":{"scanHeight":100000}}' http://localhost:8070/json_rpc

Expected output:

{ "id":1, "jsonrpc":"2.0", "result":{} }

save

Save current container state. Do it before making reserve copies or reboots.

curl -d '{"jsonrpc":"2.0","id":1, "method":"save","params":{}}' http://localhost:8070/json_rpc

Expected output:

{ "id":1, "jsonrpc":"2.0", "result":{} }

getViewKey

Returns your view key.

curl -d '{"jsonrpc":"2.0","id":1,"method":"getViewKey","params":{}}' http://localhost:8070/json_rpc

Expected output:

{ "id":1, "jsonrpc":"2.0", "result":{ "viewSecretKey":"xxxxx..." } }

getSpendKeys

Returns your spend keys.

curl -d '{"jsonrpc":"2.0","id":1,"params":{"address":"Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3"}}' http://localhost:8070/json_rpc

Expected output:

{ "id":1, "jsonrpc":"2.0", "result":{ "spendSecretKey":"xxxxx...", "spendPublicKey":"xxxxx..." } }

getBlockHashes

Returns an array of block hashes for a specified block range.

curl -d '{"jsonrpc":"2.0","id":1,"method":"getBlockHashes","params":{"firstBlockIndex":0,"blockCount":3}}' http://localhost:8070/json_rpc

Expected output:

{ "id":1, "jsonrpc":"2.0", "result":{ "blockHashes":[ "7fb97...", "8c973...", "2ef06..." ] } }

sendFusionTransaction

sendFusionTransaction method allows you to send a fusion transaction, by taking funds from selected addresses and transferring them to the destination address

If there aren't any outputs that can be optimized, sendFusionTransaction will return an error.

You can use estimateFusion to check the outputs, available for the optimization.

curl -d '{"jsonrpc":"2.0","id":1,"method":"sendFusionTransaction","params":{"threshold":1000,"anonymity":2,"address":["XuniihE4LneQDtUjFTiP..."],"destinationAddress":"XuniihE4LneQDtUjFTiP..."}}' http://localhost:8070/json_rpc

Expected output:

{ "id":1, "jsonrpc":"2.0", "result":{ "transactionHash":"93faed..." } }

createIntegrated

Create integrated address method takes an address and a payment ID and returns an integrated address.

curl -d '{"jsonrpc":"2.0","id":1,"method":"createIntegrated","params":{"payment_id":"29e1125740cbf6ccd2ab4e71b42fb33a5797ed08ddd19e26e3d3ce0bf4626242", "address":"Xuniikm29PG7RWxMvRtKH5hZGNT3aERYFaKkG2onUpa7hWmbYMQsMHrdAML7tmJS8qaCg7dNBowTDcw56uYPMcLxN4WQHxGEdGu"}}' http://localhost:8070/json_rpc

Expected output:

{ "id":1, "jsonrpc":"2.0", "result":{ "integrated_address": "XuniigATLWt9EGKD4ZBwwXJ6b9ru1m4do9mJSjyjzDvmHRfTTTfsparHxd9UH2kdexAbomLAmAeVYHdG11GkbzDPA4mfmjJaCpA7RWxMvRtKH5hZGNT3aERYFaKkG2onUpa7hWmbYMQsMHrdAML7tmJS8qaCg7dNBowTDcw56uYPMcLxN4WQHyZVqMi" } }

Didn't find an answer to your question?