Skip to content

Commit

Permalink
update C header
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Mar 14, 2022
1 parent 8b73054 commit a9657a7
Showing 1 changed file with 2 additions and 200 deletions.
202 changes: 2 additions & 200 deletions bindings/wallet-c/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,15 @@ typedef struct Proposal

typedef struct Proposal *ProposalPtr;

typedef struct Settings *SettingsPtr;

typedef struct Wallet
{

} Wallet;

typedef struct Wallet *WalletPtr;

typedef struct Settings *SettingsPtr;

typedef struct Conversion
{

} Conversion;

typedef struct Conversion *ConversionPtr;

typedef struct PerCertificateFee
{
uint64_t certificate_pool_registration;
Expand Down Expand Up @@ -308,102 +301,6 @@ ErrorPtr iohk_jormungandr_vote_proposal_new_public(const uint8_t *vote_plan_id,
uint8_t num_choices,
ProposalPtr *proposal_out);

/**
* once funds have been retrieved with `iohk_jormungandr_wallet_retrieve_funds`
* it is possible to convert all existing funds to the new wallet.
*
* The returned arrays are transactions to send to the network in order to do the
* funds conversion.
*
* Don't forget to call `iohk_jormungandr_wallet_delete_conversion` to
* properly free the memory
*
* # Errors
*
* On error the function returns a `ErrorPtr`. On success `NULL` is returned.
* The `ErrorPtr` can then be observed to gathered details of the error.
* Don't forget to call `iohk_jormungandr_wallet_delete_error` to free
* the `ErrorPtr` from memory and avoid memory leaks.
*
* # Safety
*
* This function dereference raw pointers. Even though
* the function checks if the pointers are null. Mind not to put random values
* in or you may see unexpected behaviors
*
*/
ErrorPtr iohk_jormungandr_wallet_convert(WalletPtr wallet,
SettingsPtr settings,
struct BlockDate valid_until,
ConversionPtr *conversion_out);

/**
* get the total value ignored in the conversion
*
* value_out: will returns the total value lost into dust inputs
* ignored_out: will returns the number of dust utxos
*
* these returned values are informational only and this show that
* there are UTxOs entries that are unusable because of the way they
* are populated with dusts.
*
* # Errors
*
* On error the function returns a `ErrorPtr`. On success `NULL` is returned.
* The `ErrorPtr` can then be observed to gathered details of the error.
* Don't forget to call `iohk_jormungandr_wallet_delete_error` to free
* the `ErrorPtr` from memory and avoid memory leaks.
*
* # Safety
*
* This function dereference raw pointers. Even though
* the function checks if the pointers are null. Mind not to put random values
* in or you may see unexpected behaviors
*
*/
ErrorPtr iohk_jormungandr_wallet_convert_ignored(ConversionPtr conversion,
uint64_t *value_out,
uintptr_t *ignored_out);

/**
* retrieve the index-nth transactions in the conversions starting from 0
* and finishing at `size-1` where size is retrieved from
* `iohk_jormungandr_wallet_convert_transactions_size`.
*
* the memory allocated returned is not owned and should not be kept
* for longer than potential call to `iohk_jormungandr_wallet_delete_conversion`
*
* # Errors
*
* On error the function returns a `ErrorPtr`. On success `NULL` is returned.
* The `ErrorPtr` can then be observed to gathered details of the error.
* Don't forget to call `iohk_jormungandr_wallet_delete_error` to free
* the `ErrorPtr` from memory and avoid memory leaks.
*
* # Safety
*
* This function dereference raw pointers. Even though
* the function checks if the pointers are null. Mind not to put random values
* in or you may see unexpected behaviors
*
*/
ErrorPtr iohk_jormungandr_wallet_convert_transactions_get(ConversionPtr conversion,
uintptr_t index,
const uint8_t **transaction_out,
uintptr_t *transaction_size);

/**
* get the number of transactions built to convert the retrieved wallet
*
* # Safety
*
* This function dereference raw pointers. Even though
* the function checks if the pointers are null. Mind not to put random values
* in or you may see unexpected behaviors
*
*/
uintptr_t iohk_jormungandr_wallet_convert_transactions_size(ConversionPtr conversion);

/**
* Delete a binary buffer that was returned by this library alongside with its
* length.
Expand All @@ -416,18 +313,6 @@ uintptr_t iohk_jormungandr_wallet_convert_transactions_size(ConversionPtr conver
*/
void iohk_jormungandr_wallet_delete_buffer(uint8_t *ptr, uintptr_t length);

/**
* delete the pointer
*
* # Safety
*
* This function dereference raw pointers. Even though
* the function checks if the pointers are null. Mind not to put random values
* in or you may see unexpected behaviors
*
*/
void iohk_jormungandr_wallet_delete_conversion(ConversionPtr conversion);

/**
* delete the pointer and free the allocated memory
*
Expand Down Expand Up @@ -599,89 +484,6 @@ ErrorPtr iohk_jormungandr_wallet_import_keys(const uint8_t *account_key,
uintptr_t utxo_keys_len,
WalletPtr *wallet_out);

/**
* retrieve a wallet from the given mnemonics, password and protocol magic
*
* this function will work for all yoroi, daedalus and other wallets
* as it will try every kind of wallet anyway
*
* You can also use this function to recover a wallet even after you have
* transferred all the funds to the new format (see the _convert_ function)
*
* The recovered wallet will be returned in `wallet_out`.
*
* # parameters
*
* * mnemonics: a null terminated utf8 string (already normalized NFKD) in english;
* * password: pointer to the password (in bytes, can be UTF8 string or a bytes of anything);
* this value is optional and passing a null pointer will result in no password;
* * password_length: the length of the password;
* * wallet_out: a pointer to a pointer. The recovered wallet will be allocated on this pointer;
*
* # errors
*
* The function may fail if:
*
* * the mnemonics are not valid (invalid length or checksum);
* * the `wallet_out` is null pointer
*
* On error the function returns a `ErrorPtr`. On success `NULL` is returned.
* The `ErrorPtr` can then be observed to gathered details of the error.
* Don't forget to call `iohk_jormungandr_wallet_delete_error` to free
* the `ErrorPtr` from memory and avoid memory leaks.
*
* # Safety
*
* This function dereference raw pointers. Even though
* the function checks if the pointers are null. Mind not to put random values
* in or you may see unexpected behaviors
*
*/
ErrorPtr iohk_jormungandr_wallet_recover(const char *mnemonics,
const uint8_t *password,
uintptr_t password_length,
WalletPtr *wallet_out);

/**
* retrieve funds from daedalus or yoroi wallet in the given block0 (or
* any other blocks).
*
* Execute this function then you can check who much funds you have
* retrieved from the given block.
*
* this function may take sometimes so it is better to only call this
* function if needed.
*
* # Parameters
*
* * wallet: the recovered wallet (see recover function);
* * block0: the pointer to the bytes of the block0;
* * block0_length: the length of the block0 byte string;
* * settings_out: the settings that will be parsed from the given
* block0;
*
* # Errors
*
* * this function may fail if the wallet pointer is null;
* * the block is not valid (cannot be decoded)
*
* On error the function returns a `ErrorPtr`. On success `NULL` is returned.
* The `ErrorPtr` can then be observed to gathered details of the error.
* Don't forget to call `iohk_jormungandr_wallet_delete_error` to free
* the `ErrorPtr` from memory and avoid memory leaks.
*
* # Safety
*
* This function dereference raw pointers. Even though
* the function checks if the pointers are null. Mind not to put random values
* in or you may see unexpected behaviors
*
*/
ErrorPtr iohk_jormungandr_wallet_retrieve_funds(WalletPtr wallet,
const uint8_t *block0,
uintptr_t block0_length,
SettingsPtr *settings_out);

/**
* update the wallet account state
*
Expand Down

0 comments on commit a9657a7

Please sign in to comment.