Documentation SWAP API

Public nodes:

node.getswap.eu:19950

213.59.157.221:19950

This is a list of the swap-wallet-rpc calls, their inputs and outputs, and examples of each. All swap-wallet-rpc methods use the same JSON RPC interface. Note: "atomic-units" refer to the smallest fraction of 1 XWP according to the swapd implementation. 1 XWP = 1e12 atomic-units.

create_wallet

Create a new wallet. You need to have set the argument "--wallet-dir" when launching swap-wallet-rpc to make this work.

Alias: None.

Inputs:

filename - string; Wallet file name.

password - string; (Optional) password to protect the wallet.

language - string; Language for your wallets' seed.

Outputs: None.

Example:

$ curl -X POST http://127.0.0.1:18088/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"create_wallet","params":{"filename":"mytestwallet","password":"mytestpassword","language":"English"}}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
  }
}

create_address

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.

count - unsigned int; (Optional) Number of addresses to create (Defaults to 1).

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.

address_indices - array of unsigned int; List of address indices.

addresses - array of string; list of addresses.

Example:


get_balance

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.

all_accounts - boolean; (Defaults to false)

trict - boolean; (Defaults to false) all changes go to 0-th subaddress (in the current subaddress account)

Outputs:

balance - unsigned int; The total balance of the current swap-wallet-rpc in session.

unlocked_balance - unsigned int; Unlocked funds are those funds that are sufficiently deep enough in the Swap blockchain to be considered safe to spend.

multisig_import_needed - boolean; True if importing multisig data is needed for returning a correct balance.

time_to_unlock - unsigned int; Time (in seconds) before balance is safe to spend.

blocks_to_unlock - unsigned int; Number of blocks before balance is safe to spend.

per_subaddress - array of subaddress information; Balance information for each subaddress in an account. account_index - unsigned int;

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. time_to_unlock - unsigned int;

blocks_to_unlock - unsigned int;

Example:


transfer

Send swap to a number of recipients.

Alias: None.

Inputs:

destinations - array of destinations to receive XWP:

amount - unsigned int; Amount to send to each destination, in atomic-units.

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)

subtract_fee_from_outputs - array of unsigned int; (Optional) Choose which destinations to fund the tx fee from instead of the change output. The fee will be subtracted evenly from each destination (regardless of amount). Do not use this if recipient requires an exact amount.

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). (Unless dealing with pre rct outputs, this field is ignored on mainnet).

unlock_time - unsigned int; Number of blocks before the swap can be spent (0 to not add a lock). 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 swap 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.

amounts_by_dest - Amounts transferred per destination.

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:


get_transfer_by_txid

Show information about a transfer to/from this address.

Warning

The destinations fields are only available when this wallet cache was the one to construct the transaction. If you restore your wallet from scratch, you will lose this information.

Alias: None.

Inputs:

txid - string; Transaction ID used to find the transfer.

account_index - unsigned int; (Optional) Index of the account to query for the transfer.

Outputs:

transfer - JSON object containing payment information:

address - string; Address that transferred the funds. Base58 representation of the public keys.

amount - unsigned int; Amount of this transfer.

amounts - list; Individual amounts if multiple where received.

confirmations - unsigned int; Number of block mined since the block containing this transaction (or block height at which the transaction should be added to a block if not yet confirmed).

destinations - array of JSON objects containing transfer destinations: (only for outgoing transactions) amount - unsigned int; Amount transferred to this destination.

address - string; Address for this destination. Base58 representation of the public keys. double_spend_seen - boolean; True if the key image(s) for the transfer have been seen before.

fee - unsigned int; Transaction fee for this transfer.

height - unsigned int; Height of the first block that confirmed this transfer.

locked - boolean;

note - string; Note about this transfer.

payment_id - string; Payment ID for this transfer.

subaddr_index - JSON object containing the major & minor subaddress index:

major - unsigned int; Account index for the subaddress.

minor - unsigned int; Index of the subaddress under the account.

suggested_confirmations_threshold - unsigned int; Number of confirmations needed for the amount received to be lower than the accumulated block reward (or close to that).

timestamp - unsigned int; POSIX timestamp for the block that confirmed this transfer (or timestamp submission if not mined yet).

txid - string; Transaction ID of this transfer (same as input TXID).

type - string; Type of transfer, one of the following: "in", "out", "pending", "failed", "pool"

unlock_time - unsigned int; Number of blocks until transfer is safely spendable.

transfers - list; If the list length is > 1 then multiple outputs where received in this transaction, each of which has its own transfer JSON object.

In the example below, a single output was received at 1 address (note how it is duplicated in transfers:

In the example below, 2 outputs where sent to 2 addresses in the same transaction. Note that transfer contains only one of them, but transfers contains both. If the length of transfers is != 1 then we have received multiple outputs in one transaction and must loop the transfers list accordingly.

Last updated