xcash-wallet-rpc
Use X-Cash RPC Wallet (xcash-wallet-rpc) to interact with a wallet through JSON-RPC commands
This is a list of the xcash-wallet-rpc calls, their inputs and outputs, and examples of each. The program xcash-wallet-rpc replaced the rpc interface that was in simplewallet and then xcash-wallet-rpc.
All xcash-wallet-rpc methods use the same JSON RPC interface. For example:
IP=127.0.0.1PORT=18082METHOD="make_integrated_address"PARAMS="{\"payment_id\":\"1234567890123456789012345678900012345678901234567890123456789000\"}"curl \ -X POST http://$IP:$PORT/json_rpc \ -d '{"jsonrpc":"2.0","id":"0","method":"'$METHOD'","params":'"$PARAMS"'}' \ -H 'Content-Type: application/json'
If the xcash-wallet-rpc was executed with the
--rpc-login
argument as username:password
, then follow this example:IP=127.0.0.1PORT=18082METHOD="make_integrated_address"PARAMS="{\"payment_id\":\"1234567890123456789012345678900012345678901234567890123456789000\"}"curl \ -u username:password --digest \ -X POST http://$IP:$PORT/json_rpc \ -d '{"jsonrpc":"2.0","id":"0","method":"'$METHOD'","params":'"$PARAMS"'}' \ -H 'Content-Type: application/json'
Note: "atomic units" refer to the smallest fraction of 1 XCASH according to the xcashd implementation. 1 XCASH = 1e6 atomic units**.**
Return the wallet's balance.
Alias: getbalance.
**Inputs:**
- account_index - unsigned int; Return balance for this account.
- address_indices - array of unsigned int; (Optional) Return balance detail for those subaddresses.
**Outputs:**
- balance - unsigned int; The total balance of the current xcash-wallet-rpc in session.
- unlocked_balance - unsigned int; Unlocked funds are those funds that are sufficiently deep enough in the X-Cash blockchain to be considered safe to spend.
- multisig_import_needed - boolean; True if importing multisig data is needed for returning a correct balance.
- per_subaddress - array of subaddress information; Balance information for each subaddress in an account.
- address_index - unsigned int; Index of the subaddress in the account.
- address - string; Address at this index. Base58 representation of the public keys.
- balance - unsigned int; Balance for the subaddress (locked or unlocked).
- unlocked_balance - unsigned int; Unlocked balance for the subaddress.
- label - string; Label for the subaddress.
- num_unspent_outputs - unsigned int; Number of unspent outputs available for the subaddress.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_balance"}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"balance": 562072541031,
"multisig_import_needed": false,
"per_subaddress": [
{
"address": "XCA1kzoR3ZLNg5zxNmxrY8FYKtgEvPZqC2xoRpm1axCpQcrrZfoKTSkSNsASDspdt3j1WcEnQJyuuB5VPSB56WWy36A4sQtQhe",
"address_index": 0,
"balance": 562072541031,
"label": "Primary account",
"num_unspent_outputs": 3,
"unlocked_balance": 562072541031
}
],
"unlocked_balance": 562072541031
}
}
Return the wallet's addresses for an account. Optionally filter for specific set of subaddresses.
Alias: getaddress.
**Inputs:**
- account_index - unsigned int; Return subaddresses for this account.
- address_index - array of unsigned int; (Optional) List of subaddresses to return from an account.
**Outputs:**
- address - string; The 95-character hex address string of the xcash-wallet-rpc in session.
- addresses array of addresses informations
- address string; The 95-character hex (sub)address string.
- label string; Label of the (sub)address
- address_index unsigned int; index of the subaddress
- used boolean; states if the (sub)address has already received funds
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_address"}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"address": "XCA1kzoR3ZLNg5zxNmxrY8FYKtgEvPZqC2xoRpm1axCpQcrrZfoKTSkSNsASDspdt3j1WcEnQJyuuB5VPSB56WWy36A4sQtQhe",
"addresses": [
{
"address": "XCA1kzoR3ZLNg5zxNmxrY8FYKtgEvPZqC2xoRpm1axCpQcrrZfoKTSkSNsASDspdt3j1WcEnQJyuuB5VPSB56WWy36A4sQtQhe",
"address_index": 0,
"label": "Primary account",
"used": true
}
]
}
}
Get account and address indexes from a specific (sub)address
Alias: None.
**Inputs:**
- address - String; (sub)address to look for.
**Outputs:**
- index - subaddress informations
- major unsigned int; Account index.
- minor unsigned int; Address index.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_address_index","params":{"address":"83nWyFM8HtqikdcFPXhfj3Z7Jvh1LDjfe7B1Fo6bUNUZMjm1JTXcnyzb3iiqUHLkcAQ5t6b5u8WhgTFNuzEpL27C3CvD1d8"}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"index": {
"major": 0,
"minor": 1
}
}
}
Create a new address for an account. Optionally, label the new address.
Alias: None.
**Inputs:**
- account_index - unsigned int; Create a new address for this account.
- label - string; (Optional) Label for the new address.
**Outputs:**
- address - string; Newly created address. Base58 representation of the public keys.
- address_index - unsigned int; Index of the new address under the input account.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"create_address","params":{"account_index":0,"label":"new-sub"}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"address": "83nWyFM8HtqikdcFPXhfj3Z7Jvh1LDjfe7B1Fo6bUNUZMjm1JTXcnyzb3iiqUHLkcAQ5t6b5u8WhgTFNuzEpL27C3CvD1d8",
"address_index": 1
}
}
Label an address.
Alias: None.
**Inputs:**
- index - subaddress index; JSON Object containing the major & minor address index:
- major - unsigned int; Account index for the subaddress.
- minor - unsigned int; Index of the subaddress in the account.
- label - string; Label for the address.
Outputs: None.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"label_address","params":{"index":{"major":0,"minor":1},"label":"myLabel"}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {}
}
Get all accounts for a wallet. Optionally filter accounts by tag.
Alias: None.
Inputs:
- tag - string; (Optional) Tag for filtering accounts.
Outputs:
- subaddress_accounts - array of subaddress account information:
- account_index - unsigned int; Index of the account.
- balance - unsigned int; Balance of the account (locked or unlocked).
- base_address - string; Base64 representation of the first subaddress in the account.
- label - string; (Optional) Label of the account.
- tag - string; (Optional) Tag for filtering accounts.
- unlocked_balance - unsigned int; Unlocked balance for the account.
- total_balance - unsigned int; Total balance of the selected accounts (locked or unlocked).
- total_unlocked_balance - unsigned int; Total unlocked balance of the selected accounts.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_accounts","params":{"tag":"myTag"}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"subaddress_accounts": [
{
"account_index": 0,
"balance": 100000000000,
"base_address": "XCA1kzoR3ZLNg5zxNmxrY8FYKtgEvPZqC2xoRpm1axCpQcrrZfoKTSkSNsASDspdt3j1WcEnQJyuuB5VPSB56WWy36A4sQtQhe",
"label": "Primary account",
"tag": "myTag",
"unlocked_balance": 100000000000
},
{
"account_index": 1,
"balance": 0,
"base_address": "83nWyFM8HtqikdcFPXhfj3Z7Jvh1LDjfe7B1Fo6bUNUZMjm1JTXcnyzb3iiqUHLkcAQ5t6b5u8WhgTFNuzEpL27C3CvD1d8",
"label": "Secondary account",
"tag": "myTag",
"unlocked_balance": 0
}
],
"total_balance": 100000000000,
"total_unlocked_balance": 100000000000
}
}
Create a new account with an optional label.
Alias: None.
Inputs:
- label - string; (Optional) Label for the account.
Outputs:
- account_index - unsigned int; Index of the new account.
- address - string; Address for this account. Base58 representation of the public keys.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"create_account","params":{"label":"Secondary account"}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"account_index": 1,
"address": "83nWyFM8HtqikdcFPXhfj3Z7Jvh1LDjfe7B1Fo6bUNUZMjm1JTXcnyzb3iiqUHLkcAQ5t6b5u8WhgTFNuzEpL27C3CvD1d8"
}
}
Label an account.
Alias: None.
Inputs:
- account_index - unsigned int; Apply label to account at this index.
- label - string; Label for the account.
Outputs: None.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"label_account","params":{"account_index":0,"label":"Primary account"}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"account_tags": [
{
"accounts": [
0,
1
],
"label": "",
"tag": "label"
}
]
}
}
Get a list of user-defined account tags.
Alias: None.
Inputs: None.
Outputs:
- account_tags - array of account tag information:
- tag - string; Filter tag.
- label - string; Label for the tag.
- accounts - array of int; List of tagged account indices.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"label_account","params":{"account_index":0,"label":"Primary account"}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"account_tags": [
{
"accounts": [
0,
1
],
"label": "",
"tag": "myTag"
}
]
}
}
Apply a filtering tag to a list of accounts.
Alias: None.
Inputs:
- tag - string; Tag for the accounts.
- accounts - array of unsigned int; Tag this list of accounts.
Outputs: None.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"tag_accounts","params":{"tag":"myTag","accounts":[0,1]}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {}
}
Remove filtering tag from a list of accounts.
Alias: None.
Inputs:
- accounts - array of unsigned int; Remove tag from this list of accounts.
Outputs: None.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"untag_accounts","params":{"accounts":[1]}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {}
}
Set description for an account tag.
Alias: None.
Inputs:
- tag - string; Set a description for this tag.
- description - string; Description for the tag.
Outputs: None.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"set_account_tag_description","params":{"tag":"myTag","description":"Test tag"}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {}
}
Returns the wallet's current block height.
Alias: _getheight_
Inputs: None.
Outputs:
- height - unsigned int; The current xcash-wallet-rpc's blockchain height. If the wallet has been offline for a long time, it may need to catch up with the daemon.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_height"}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"height": 425000
}
}
Send XCASH to a number of recipients.
Alias: None.
Inputs:
- destinations - array of destinations to receive XCASH:
- address - string; Destination public address.
- account_index - unsigned int; (Optional) Transfer from this account index. (Defaults to 0)
- subaddr_indices - array of unsigned int; (Optional) Transfer from this set of subaddresses. (Defaults to empty - all indices)
- priority - unsigned int; Set a priority for the transaction. Accepted Values are: 0-3 for: default, unimportant, normal, elevated, priority.
- mixin - unsigned int; Number of outputs from the blockchain to mix with (0 means no mixing).
- ring_size - unsigned int; Number of outputs to mix in the transaction (this output + N decoys from the blockchain).
- unlock_time - unsigned int; Number of blocks before the XCASH can be spent (0 to not add a lock).
- payment_id - string; (Optional) Random 32-byte/64-character hex string to identify a transaction.
- get_tx_key - boolean; (Optional) Return the transaction key after sending.
- do_not_relay - boolean; (Optional) If true, the newly created transaction will not be relayed to the X-Cash network. (Defaults to false)
- get_tx_hex - boolean; Return the transaction as hex string after sending (Defaults to false)
- get_tx_metadata - boolean; Return the metadata needed to relay the transaction. (Defaults to false)
Outputs:
- amount - Amount transferred for the transaction.
- fee - Integer value of the fee charged for the txn.
- multisig_txset - Set of multisig transactions in the process of being signed (empty for non-multisig).
- tx_blob - Raw transaction represented as hex string, if get_tx_hex is true.
- tx_hash - String for the publically searchable transaction hash.
- tx_key - String for the transaction key if get_tx_key is true, otherwise, blank string.
- tx_metadata - Set of transaction metadata needed to relay this transfer later, if get_tx_metadata is true.
- unsigned_txset - String. Set of unsigned tx for cold-signing purposes.
Example:
$ curl -X POST http://localhost:18285/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"transfer","params":{"destinations":[{"amount":100000000000,"address":"XCA1kzoR3ZLNg5zxNmxrY8FYKtgEvPZqC2xoRpm1axCpQcrrZfoKTSkSNsASDspdt3j1WcEnQJyuuB5VPSB56WWy36A4sQtQhe"}],"ring_size":21,"get_tx_keys": true}}' -H 'Content-Type: application/json'
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"amount": 100000000000,
"fee": 1348040,
"multisig_txset": "",
"tx_hash": "cd97adf7372e620cda46ed623f89fca1411873f5d7251359ab468c287d8f9fee",
"tx_key": "8037f31fd7b9c76d432e6c0c14b549ea68fdd84537f75c6e9a066890f7840d0b",
"unsigned_txset": ""
}
}
Same as transfer, but can split into more than one tx if necessary.
Alias: None.
Inputs:
- destinations - array of destinations to receive XCASH:
- address - string; Destination public address.
- account_index - unsigned int; (Optional) Transfer from this account index. (Defaults to 0)
- subaddr_indices - array of unsigned int; (Optional) Transfer from this set of subaddresses. (Defaults to empty - all indices)
- mixin - unsigned int; Number of outputs from the blockchain to mix with (0 means no mixing).
- ring_size - unsigned int; Sets ringsize to n (mixin + 1).
- unlock_time - unsigned int; Number of blocks before the XCASH can be spent (0 to not add a lock).
- payment_id - string; (Optional) Random 32-byte/64-character hex string to identify a transaction.
- get_tx_keys - boolean; (Optional) Return the transaction keys after sending.
- priority - unsigned int; Set a priority for the transactions. Accepted Values are: 0-3 for: default, unimportant, normal, elevated, priority.
- do_not_relay - boolean; (Optional) If true, the newly created transaction will not be relayed to the X-Cash network. (Defaults to false)
- get_tx_hex - boolean; Return the transactions as hex string after sending
- new_algorithm - boolean; True to use the new transaction construction algorithm, defaults to false.
- get_tx_metadata - boolean; Return list of transaction metadata needed to relay the transfer later.