RPC API Reference

Complete documentation for Suacoin's RPC API

RPC API Reference

addmultisigaddress

addmultisigaddress nrequired ["key",...] ( "label" "address_type" )

Add an nrequired-to-sign multisignature address to the wallet. Requires a new wallet backup.

Each key is a Suacoin address or hex-encoded public key.

This functionality is only intended for use with non-watchonly addresses.

If 'label' is specified, assign address to that label.

Arguments

1. nrequired (numeric, required)
The number of required signatures out of the n keys or addresses.
2. keys (json array, required)
The suacoin addresses or hex-encoded public keys
[ "key", (string) suacoin address or hex - encoded public key ... ]
3. label (string, optional)
A label to assign the addresses to.
4. address_type (string, optional, default=set by -addresstype)
The address type to use. Options are "legacy", "p2sh-segwit", and "bech32".

Result

{ (json object) "address" : "str", (string) The value of the new multisig address "redeemScript" : "hex", (string) The string value of the hex-encoded redemption script "descriptor" : "str" (string) The descriptor for this multisig }

Examples

suacoind addmultisigaddress 2 "[\"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl\",\"bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3\"]"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "addmultisigaddress", "params": [2, "[\"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl\",\"bc1q02ad21edsxd23d32dfgqqsz4vv4nmtfzuklhy3\"]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

addnode

addnode "node" "command"

Attempts to add or remove a node from the addnode list.

Or try a connection to a node once.

Nodes added using addnode (or -connect) are protected from DoS disconnection and are not required to be full nodes/support SegWit as other outbound peers are (though such peers will not be synced from).

Arguments

1. node (string, required)
The node (see getpeerinfo for nodes)
2. command (string, required)
'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once

Result

null (json null)

Examples

suacoind addnode "192.168.0.7:8444" add

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "addnode", "params": ["192.168.0.7:8444", "add"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

backupwallet

backupwallet "destination"

Safely copies current wallet file to destination, which can be a directory or a path with filename.

Arguments

1. destination (string, required)
The destination directory or file

Result

null (json null)

Examples

suacoind backupwallet "mybackup.dat"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "backupwallet", "params": ["mybackup.dat"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

createmultisig

createmultisig nrequired ["key",...] ( "address_type" )

Creates a multi-signature address with n signature of m keys required.

It returns a json object with the address and redeemScript.

Arguments

1. nrequired (numeric, required)
The number of required signatures out of the n keys.
2. keys (json array, required)
The hex-encoded public keys
[ "key", (string) The hex-encoded public key ... ]
3. address_type (string, optional, default=legacy)
The address type to use. Options are "legacy", "p2sh-segwit", and "bech32".

Result

{ (json object) "address" : "str", (string) The value of the new multisig address "redeemScript" : "hex", (string) The string value of the hex-encoded redemption script "descriptor" : "str" (string) The descriptor for this multisig }

Examples

suacoind createmultisig 2 "[\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\",\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\"]"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createmultisig", "params": [2, "[\"03789ed0bb717d88f7d321a368d905e7430207ebbd82bd342cf11ae157a7ace5fd\",\"03dbc6764b8884a92e871274b87583e6d5c2a58819473e17e107ef3f6aa5a61626\"]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

createrawtransaction

createrawtransaction [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount},{"data":"hex"},...] ( locktime replaceable )

Create a transaction spending the given inputs and creating new outputs.

Outputs can be addresses or data.

Returns hex-encoded raw transaction.

Note that the transaction's inputs are not signed, and it is not stored in the wallet or transmitted to the network.

Arguments

1. inputs (json array, required)
The inputs
[ (json array of json objects) { "txid": "hex", (string, required) The transaction id "vout": n, (numeric, required) The output number "sequence": n (numeric, optional, default=depends on the value of the 'replaceable' and 'locktime' arguments) The sequence number }, ... ]
2. outputs (json array, required)
The outputs (key-value pairs), where none of the keys are duplicated. That is, each address can only appear once and there can only be one 'data' object. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also accepted as second parameter.
[ (json array of json objects) { "address": amount, (numeric or string, required) A key-value pair. The key (string) is the suacoin address, the value (float or string) is the amount in SUA }, { "data": "hex", (string, required) A key-value pair. The key must be "data", the value is hex-encoded data }, ... ]
3. locktime (numeric, optional, default=0)
Raw locktime. Non-0 value also locktime-activates inputs
4. replaceable (boolean, optional, default=false)
Marks this transaction as BIP125-replaceable. Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.

Result

"hex" (string) hex string of the transaction

Examples

suacoind createrawtransaction "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"address\":0.01}]"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createrawtransaction", "params": ["[{\"txid\":\"myid\",\"vout\":0}]", "[{\"address\":0.01}]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

decoderawtransaction

decoderawtransaction "hexstring"

Return a JSON object representing the serialized, hex-encoded transaction.

Arguments

1. hexstring (string, required)
The transaction hex string

Result

{ (json object) "txid" : "88e70c0f336d99e3e2bbccb99e87773e53441c838b716855800ce91707efe273", (string) The transaction id "version" : 1, (numeric) The version "locktime" : 0, (numeric) The lock time "vin" : [ (array) Array of transaction inputs { "coinbase" : "0359bc00027c0c062f503253482f", (string) The coinbase "sequence" : 4294967295 (numeric) The script sequence number } ], "vout" : [ (array) Array of transaction outputs { "value" : 50.00000000, (numeric) The value in SUA "n" : 0, (numeric) Index "scriptPubKey" : { (json object) "asm" : "02a99660b235d50a1da2d335ea7d162047fb7c6b7cf2eb23db53fb2e4bd2acc747 OP_CHECKSIG", (string) The asm "hex" : "2102a99660b235d50a1da2d335ea7d162047fb7c6b7cf2eb23db53fb2e4bd2acc747ac", (string) The hex "reqSigs" : 1, (numeric) The required signatures "type" : "pubkey", (string) The type, eg 'pubkeyhash' "addresses" : [ (json array) Array of suacoin addresses "1Pc28jAYv7cDG2gkvL7HFgdcGjctJDGuXG" (string) suacoin address ] } } ] }

Examples

suacoind decoderawtransaction "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0e0359bc00027c0c062f503253482fffffffff0100f2052a01000000232102a99660b235d50a1da2d335ea7d162047fb7c6b7cf2eb23db53fb2e4bd2acc747ac00000000"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "decoderawtransaction", "params": ["01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0e0359bc00027c0c062f503253482fffffffff0100f2052a01000000232102a99660b235d50a1da2d335ea7d162047fb7c6b7cf2eb23db53fb2e4bd2acc747ac00000000"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

dumpprivkey

dumpprivkey "address"

Reveals the private key corresponding to 'address'.

Then the importprivkey can be used with this output

Arguments

1. address (string, required)
The suacoin address for the private key

Result

"str" (string) The private key

Examples

suacoind dumpprivkey "myaddress"
suacoind importprivkey "mykey"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "dumpprivkey", "params": ["myaddress"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

encryptwallet

encryptwallet "passphrase"

Encrypts the wallet with 'passphrase'. This is for first time encryption.

After this, any calls that interact with private keys such as sending or signing will require the passphrase to be set prior to making these calls.

Arguments

1. passphrase (string, required)
The pass phrase to encrypt the wallet with. It must be at least 1 character, but should be long.

Result

"str" (string) A string with further instructions

Examples

suacoind encryptwallet "my pass phrase"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "encryptwallet", "params": ["my pass phrase"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

getaccount

getaccount "address"

Returns the account associated with the given address.

Arguments

1. address (string, required)
The suacoin address

Result

"str" (string) The account label

Examples

suacoind getaccount 1KWzk6m4qq4fc2Dhy4ZZmq5WEaquYtqkoo

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getaccount", "params": ["1KWzk6m4qq4fc2Dhy4ZZmq5WEaquYtqkoo"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

getaccountaddress

getaccountaddress "account"

Returns the current Suacoin address for receiving payments to this account.

Arguments

1. account (string, required)
The account label

Result

"str" (string) The suacoin address

Examples

suacoind getaccountaddress "abcd xyz"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getaccountaddress", "params": ["abcd xyz"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

getaddednodeinfo

getaddednodeinfo dns "node"

Returns information about the given added node, or all added nodes (note that onetry addnodes are not listed here)

If dns is false, only a list of added nodes will be provided, otherwise connected information will also be available.

Arguments

1. dns (boolean, required)
If DNS to be used
2. node (string, optional)
Specific node to get information about. If omitted, returns information about all added nodes.

Result

[ (json array) Array of added node information { (json object) "addednode" : "str", (string) The node IP address or name (as provided to addnode) "connected" : true|false, (boolean) If connected "addresses" : [ (json array) Only when connected = true { (json object) "address" : "str", (string) The suacoin server IP and port we're connected to "connected" : "str" (string) connection, inbound or outbound } ] } ]

Examples

suacoind getaddednodeinfo true "192.168.0.172"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getaddednodeinfo", "params": [true, "192.168.0.172"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

getaddressesbyaccount

getaddressesbyaccount "account"

Returns the list of addresses for the given account.

Arguments

1. account (string, required)
The account label

Result

[ (json array) "address", (string) suacoin address ... ]

Examples

suacoind getaddressesbyaccount "my account label"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getaddressesbyaccount", "params": ["my account label"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

getbalance

getbalance ( "account" minconf )

Returns the total available balance.

If [account] is not specified, returns the server's total available balance.

If [account] is specified, returns the balance in the account.

Arguments

1. account (string, optional)
The account label
2. minconf (numeric, optional, default=0)
Only include transactions confirmed at least this many times.

Result

n (numeric) The total amount in SUA received for this wallet

Examples

suacoind getbalance "my account label" 6

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getbalance", "params": ["my account label", 6]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

getblock

getblock "blockhash"

Returns details of a block with given block-hash.

Arguments

1. blockhash (string, required)
The block hash

Result

{ (json object) "hash": "hex", (string) The block hash "confirmations": n, (numeric) The number of confirmations "size": n, (numeric) The block size "height": n, (numeric) The block height "version": n, (numeric) The block version "merkleroot": "hex", (string) The merkle root "tx": [ (json array) "hex", (string) The transaction ids ... ], "time": n, (numeric) The block time "nonce": n, (numeric) The nonce "bits": "hex", (string) The bits "difficulty": n, (numeric) The difficulty "previousblockhash": "hex" (string) The hash of the previous block }

Examples

suacoind getblock "000000000068818838f8ec1bdad8976b7fca3cb0b8a2ea46a7d8a714ba7a85b2"

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblock", "params": ["000000000068818838f8ec1bdad8976b7fca3cb0b8a2ea46a7d8a714ba7a85b2"]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

getblockcount

getblockcount

Returns the height of the most-work fully-validated chain.

The genesis block has height 0.

Result

n (numeric) The current block count

Examples

suacoind getblockcount

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblockcount", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8442

getblockhash

getblockhash height

Returns hash of block in best-block-chain at height provided.

Arguments

1. height (numeric, required)
The height index

Result

"str" (string) The block hash

Examples

suacoind getblockhash 1000

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblockhash", "params": [1000]}' -H 'content-type: text/plain;' http://127.0.0.1:8442

getblocktemplate

getblocktemplate ( "template_request" )

Returns data needed to construct a block to work on.

For full specification, see BIPs 22, 23, 9, and 145:

https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki

https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki

https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes

https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki

Arguments

1. template_request (json object, optional, default={})
Format of the template
{ (json object) "mode" : "str", (string, optional) This must be set to "template" or omitted "capabilities" : [ (json array, optional) A list of strings "str", (string) client side supported feature, 'longpoll', 'coinbasevalue', 'proposal', 'serverlist', 'workid' ... ], "rules" : [ (json array, required) A list of strings "segwit", (string, required) (literal) indicates client side segwit support "str", (string) other client side supported softfork deployment ... ] }

Result

{ (json object) "version" : n, (numeric) The preferred block version "rules" : [ (json array) specific block rules that are to be enforced "str", (string) name of a rule the client must understand to some extent; see BIP 9 for format ... ], "vbavailable" : { (json object) "rulename" : n, (numeric) identifies the bit number as indicating acceptance and readiness for the named softfork rule ... }, "vbrequired" : n, (numeric) bit mask of versionbits the server requires set in submissions "previousblockhash" : "str", (string) The hash of current highest block "transactions" : [ (json array) contents of non-coinbase transactions that should be included in the next block { (json object) "data" : "hex", (string) transaction data encoded in hexadecimal (byte-for-byte) "txid" : "hex", (string) transaction id encoded in little-endian hexadecimal "hash" : "hex", (string) hash encoded in little-endian hexadecimal (including witness data) "depends" : [ (json array) array of numbers n, (numeric) transactions before this one (by 1-based index in 'transactions' list) that must be present in the final block if this one is ... ], "fee" : n, (numeric) difference in value between transaction inputs and outputs (in satoshis) "sigops" : n, (numeric) total SigOps cost, as counted for purposes of block limits; if key is not present, sigop cost is unknown and clients MUST NOT assume it is zero "weight" : n (numeric) total transaction weight, as counted for purposes of block limits }, ... ], "coinbaseaux" : { (json object) data that should be included in the coinbase's scriptSig content "key" : "hex", (string) values must be in the coinbase (keys may be ignored) ... }, "coinbasevalue" : n, (numeric) maximum allowable input to coinbase transaction, including the generation award and transaction fees (in satoshis) "longpollid" : "str", (string) an id to include with a request to longpoll on an update to this template "target" : "str", (string) The hash target "mintime" : xxx, (numeric) The minimum timestamp appropriate for the next block time, expressed in UNIX epoch time "mutable" : [ (json array) list of ways the block template may be changed "str", (string) A way the block template may be changed, e.g. 'time', 'transactions', 'prevblock' ... ], "noncerange" : "hex", (string) A range of valid nonces "sigoplimit" : n, (numeric) limit of sigops in blocks "sizelimit" : n, (numeric) limit of block size "weightlimit" : n, (numeric) limit of block weight "curtime" : xxx, (numeric) current timestamp in UNIX epoch time "bits" : "str", (string) compressed target of next block "height" : n, (numeric) The height of the next block "default_witness_commitment" : "str" (string, optional) a valid witness commitment for the unmodified block template }

Examples

suacoind getblocktemplate '{"rules": ["segwit"]}'

As a JSON-RPC call:

curl --user user:pass --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblocktemplate", "params": [{"rules": ["segwit"]}]}' -H 'content-type: text/plain;' http://127.0.0.1:8442