1

Is there an API call to transfer Monero from a specific sub-account?

"Transfer" API (https://getmonero.org/resources/developer-guides/wallet-rpc.html#transfer) does not appear to ask for a sub-account index/tag.

For example, I have 3 sub-accounts and want to send Monero from the 3rd one only, so that the other 2 sub-accounts have their balances remain unlocked.

1

Alas, the developer guides are, at the time of writing, a bit outdated. Fortunately, however, a number of people are working on ensuring they will be up to date soon. One of those people is oneiric and I'll use the example from his repository to answer your question. See below for an updated guide on the Transfer RPC command:

Transfer

Send monero to a number of recipients.

Inputs:

  • destinations - array of destinations to receive XMR:
    • amount - unsigned int; Amount to send to each destination, in atomic units.
    • address - string; Destination public address.
  • account_index - unsigned int; Transfer from this account index.
  • subaddr_indices - array of unsigned int; Transfer from this set of subaddresses.
  • fee - unsigned int; Ignored, will be automatically calculated.
  • mixin - unsigned int; Number of outpouts from the blockchain to mix with (0 means no mixing).
  • unlock_time - unsigned int; Number of blocks before the monero 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.
  • priority - unsigned int; Set a priority for the transaction. 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 monero network. (Defaults to false)
  • get_tx_hex - boolean; Return the transaction as hex string after sending
  • get_tx_metadata - boolean; Return the transaction metadata.

Outputs:

  • fee - Integer value of the fee charged for the txn.
  • 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.
  • amount_keys - List of strings for the amount keys.
  • amount - Amount transferred for the transaction.
  • tx_blob - Transaction as hex string if get_tx_hex is true
  • tx_metadata - Transaction metadata string if get_tx_metadata is true.
  • multisig_txset - Set of signing keys used in a multisig transaction (empty for non-multisig).

Example:

$ curl -X POST http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"transfer","params":{"destinations":[{"amount":100000000,"address":"9wNgSYy2F9qPZu7KBjvsFgZLTKE2TZgEpNFbGka9gA5zPmAXS35QzzYaLKJRkYTnzgArGNX7TvSqZC87tBLwtaC5RQgJ8rm"},{"amount":200000000,"address":"9vH5D7Fv47mbpCpdcthcjU34rqiiAYRCh1tYywmhqnEk9iwCE9yppgNCXAyVHG5qJt2kExa42TuhzQfJbmbpeGLkVbg8xit"}],"mixin":4,"get_tx_key": true}}' -H 'Content-Type: application/json'

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "fee": 48958481211,
    "tx_hash": "985180f468637bc6d2f72ee054e1e34b8d5097988bb29a2e0cb763e4464db23c",
    "tx_key": "8d62e5637f1fcc9a8904057d6bed6c697618507b193e956f77c31ce662b2ee07",
    "amount_keys":[],
    "amount": 300000000,
    "tx_blob": "",
    "tx_metadata": "",
    "multisig_txset": ""
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.