Address Functions

int wally_addr_segwit_from_bytes(const unsigned char *bytes, size_t bytes_len, const char *addr_family, uint32_t flags, char **output)

Create a segwit native address from a v0 witness program.

Parameters:
  • bytes – Witness program bytes, including the version and data push opcode.
  • bytes_len – Length of bytes in bytes. Must be 20 or 32 if script_version is 0.
  • addr_family – Address family to generate, e.g. “bc” or “tb”.
  • flags – For future use. Must be 0.
  • output – Destination for the resulting segwit native address string.
Returns:

WALLY_OK or an error code.

Return type:

int

int wally_addr_segwit_to_bytes(const char *addr, const char *addr_family, uint32_t flags, unsigned char *bytes_out, size_t len, size_t *written)

Get a witness program from a segwit native address.

Parameters:
  • addr – Address to fetch the witness program from.
  • addr_family – Address family to generate, e.g. “bc” or “tb”.
  • flags – For future use. Must be 0.
  • bytes_out – Destination for the resulting witness program bytes.
  • len – Length of bytes_out in bytes.
  • written – Destination for the number of bytes written to bytes_out.
Returns:

WALLY_OK or an error code.

Return type:

int

int wally_wif_from_bytes(const unsigned char *priv_key, size_t priv_key_len, uint32_t prefix, uint32_t flags, char **output)

Convert a private key to Wallet Import Format.

Parameters:
  • priv_key – Private key bytes.
  • priv_key_len – The length of priv_key in bytes. Must be EC_PRIVATE_KEY_LEN.
  • prefix – Prefix byte to use, e.g. 0x80, 0xef.
  • flags – Pass WALLY_WIF_FLAG_COMPRESSED if the corresponding pubkey is compressed, otherwise WALLY_WIF_FLAG_UNCOMPRESSED.
  • output – Destination for the resulting Wallet Import Format string.
Returns:

WALLY_OK or an error code.

Return type:

int

int wally_wif_to_bytes(const char *wif, uint32_t prefix, uint32_t flags, unsigned char *bytes_out, size_t len)

Convert a Wallet Import Format string to a private key.

Parameters:
  • wif – Private key in Wallet Import Format.
  • prefix – Prefix byte to use, e.g. 0x80, 0xef.
  • flags – Pass WALLY_WIF_FLAG_COMPRESSED if the corresponding pubkey is compressed, otherwise WALLY_WIF_FLAG_UNCOMPRESSED.
  • bytes_out – Destination for the private key.
  • len – The length of bytes_out in bytes. Must be EC_PRIVATE_KEY_LEN.
Returns:

WALLY_OK or an error code.

Return type:

int

int wally_wif_is_uncompressed(const char *wif, size_t *written)

Determine if a private key in Wallet Import Format corresponds to an uncompressed public key.

Parameters:
  • wif – Private key in Wallet Import Format to check.
  • written – 1 if the corresponding public key is uncompressed, 0 if compressed.
Returns:

WALLY_OK or an error code.

Return type:

int

int wally_wif_to_public_key(const char *wif, uint32_t prefix, unsigned char *bytes_out, size_t len, size_t *written)

Create a public key corresponding to a private key in Wallet Import Format.

Parameters:
  • wif – Private key in Wallet Import Format.
  • prefix – Prefix byte to use, e.g. 0x80, 0xef.
  • bytes_out – Destination for the resulting public key.
  • len – The length of bytes_out.
  • written – Destination for the number of bytes written to bytes_out.
Returns:

WALLY_OK or an error code.

Return type:

int

int wally_wif_to_address(const char *wif, uint32_t prefix, uint32_t version, char **output)

Create a P2PKH address corresponding to a private key in Wallet Import Format.

Parameters:
  • wif – Private key in Wallet Import Format.
  • prefix – Prefix byte to use, e.g. 0x80, 0xef.
  • version – Version byte to generate address, e.g. 0x00, 0x6f.
  • output – Destination for the resulting address string.
Returns:

WALLY_OK or an error code.

Return type:

int

int wally_confidential_addr_to_addr(const char *address, uint32_t prefix, char **output)

Extract the address from a confidential address.

Parameters:
  • address – The base58 encoded confidential address to extract the address from.
  • prefix – The confidential address prefix byte, e.g. WALLY_CA_PREFIX_LIQUID.
  • output – Destination for the resulting address string.
Returns:

WALLY_OK or an error code.

Return type:

int

int wally_confidential_addr_to_ec_public_key(const char *address, uint32_t prefix, unsigned char *bytes_out, size_t len)

Extract the blinding public key from a confidential address.

Parameters:
  • address – The base58 encoded confidential address to extract the public key from.
  • prefix – The confidential address prefix byte, e.g. WALLY_CA_PREFIX_LIQUID.
  • bytes_out – Destination for the public key.
  • len – The length of bytes_out in bytes. Must be EC_PUBLIC_KEY_LEN.
Returns:

WALLY_OK or an error code.

Return type:

int

int wally_confidential_addr_from_addr(const char *address, uint32_t prefix, const unsigned char *pub_key, size_t pub_key_len, char **output)

Create a confidential address from an address and blinding public key.

Parameters:
  • address – The base58 encoded address to make confidential.
  • prefix – The confidential address prefix byte, e.g. WALLY_CA_PREFIX_LIQUID.
  • pub_key – The blinding public key to associate with address.
  • pub_key_len – The length of pub_key in bytes. Must be EC_PUBLIC_KEY_LEN.
  • output – Destination for the resulting address string.
Returns:

WALLY_OK or an error code.

Return type:

int