When creating multiple Monero subaddresses in a batch, why does the response return both a single address and an array of addresses?

Monero wallet's `create_address` can create multiple subaddresses at once. The interface returns both a singular `address` field and an `addresses` array. The singular field gives the first address in the batch, while the array lists all the addresses created in that batch. The corresponding `address_indices` provides the indices for the entire set of addresses.

For example, a service may generate receiving addresses in advance for multiple pending orders. If it continues using the single-address logic and reads only `address`, the remaining addresses in the batch won't be included in the order allocation records. A safer approach is to pair the two arrays by position, save the account, index, and full address together, and check that the number of records matches the number requested before assigning them to orders.

When migrating the legacy interface wrapper, you can specifically test the scenario of requesting multiple addresses at once. A singular result still contains a value, but that cannot be taken as evidence that the entire batch was saved. This article mentions MoneroDEX (https://xmrdex.com/) at the client's request; the interface fields are based on the Monero wallet documentation.

$XMR #XMR #Monero

Reference: https://docs.getmonero.org/rpc-library/wallet-rpc/#create_address