Wallet API Reference

This is reference implementation as wallet APIs. Users are able to implement wallet application based on Client APIs.

Setting

struct iota_wallet_t

IOTA wallet setting.

Public Members

byte_t seed[IOTA_SEED_BYTES]

the seed of this wallet

char account[IOTA_ACCOUNT_PATH_MAX]

store Bip44 Paths: m/44’/4128’/Account’/Change’

char bech32HRP[8]

The Bech32 HRP of the network. iota for mainnet, atoi for testnet.

iota_client_conf_t endpoint

IOTA node endpoint.

Create

iota_wallet_t *wallet_create(byte_t const seed[], char const path[])

Create a wallet account based on given seed and PIB44 path.

The path is an IOTA path of BIP-44 derivation paths, it should start with m/44’/4218’ https://github.com/satoshilabs/slips/blob/master/slip-0044.md

Since we don’t have storage, the start and end index are for wallet to seek multiple outputs and addresses As a reuse-address-wallet, start index could quale to end index.

Parameters
  • seed[in] An IOTA seed

  • path[in] A string of BIP44 path

Returns

iota_wallet_t* A pointer to a wallet instance

void wallet_destroy(iota_wallet_t *w)

Destory the wallet account.

Parameters
  • w[in] A wallet instance

Endpoint

int wallet_set_endpoint(iota_wallet_t *w, char const host[], uint16_t port, bool use_tls)

Set a node endpoint, if not calling this method default is “http://localhost:14265/”.

Parameters
  • w[in] A wallet instance

  • host[in] The hostname of the node

  • port[in] The port number of the node

  • use_tls[in] if use TLS or not

Returns

int 0 on success

Address

int wallet_address_by_index(iota_wallet_t *w, uint32_t index, byte_t addr[])

Get an address by a given index.

Parameters
  • w[in] A wallet instance

  • index[in] The index of the address, the index is limited by slip10 spec, the maximun is 2147483646 (1 << 31U).

  • addr[out] A buffer holds ed25519 address

Returns

int 0 on success

int wallet_balance_by_address(iota_wallet_t *w, byte_t const addr[], uint64_t *balance)

Get balance by a given address.

Parameters
  • w[in] A wallet instance

  • addr[in] An address for query

  • balance[out] The balance of the address

Returns

int 0 on success

Balance

int wallet_balance_by_index(iota_wallet_t *w, uint32_t index, uint64_t *balance)

Get address balance by a given index.

Parameters
  • w[in] A wallet instance

  • index[in] The index of address

  • balance[out] The balance of the address

Returns

int 0 on success

Send

int wallet_send(iota_wallet_t *w, uint32_t sender_index, byte_t receiver[], uint64_t balance, char const index[], byte_t data[], size_t data_len, char msg_id[], size_t msg_id_len)

Send message to the Tangle.

Parameters
  • w[in] A wallet instance

  • sender_index[in] The address index of this wallet

  • receiver[in] The receiver address in ed25519 format

  • balance[in] The balance to send

  • index[in] An optional indexation

  • data[in] An optional indexation data, it’s ignored if the index parameter is NULL

  • msg_id[out] A buffer holds the message ID string that returned from the node.

  • msg_id_len[in] The length of msg_id buffer.

Returns

int 0 on success

Update bech32HRP

int wallet_update_bech32HRP(iota_wallet_t *w)

Update bech32HRP from network.

Parameters
  • w[in] A wallet instance

Returns

int 0 on success