pub struct Sdk { /* private fields */ }
Expand description
Struct representing the SDK and its core components including configuration, user management, and storage options.
Implementations§
Source§impl Sdk
impl Sdk
Sourcepub async fn start_kyc_verification_for_postident(
&mut self,
) -> Result<NewCaseIdResponse>
pub async fn start_kyc_verification_for_postident( &mut self, ) -> Result<NewCaseIdResponse>
Start kyc verification for postident
§Returns
Returns a Result
containing the NewCaseIdResponse
if successful, or a crate::Error
if an error occurs.
§Errors
crate::Error::UserRepoNotInitialized
if the repository fails to initialize.- [
crate::Error::UserNotInitialized)
] if the user fails to initialize. crate::Error::UserAlreadyKycVerified
if the user is already KYC verified.
Sourcepub async fn get_kyc_details_for_postident(&self) -> Result<CaseDetailsResponse>
pub async fn get_kyc_details_for_postident(&self) -> Result<CaseDetailsResponse>
Get case details for postident
§Returns
Returns a Result
containing the CaseDetailsResponse
if successful, or a crate::Error
if an error occurs.
§Errors
- [
crate::Error::UserNotInitialized)
] if the user fails to initialize.
Sourcepub async fn update_kyc_status_for_postident(&self, case_id: &str) -> Result<()>
pub async fn update_kyc_status_for_postident(&self, case_id: &str) -> Result<()>
Update case status for postident
§Arguments
case_id
: The ID of the case to update.
§Errors
Returns a Result
containing ()
if successful, or a crate::Error
if an error occurs.
§Returns
Returns Ok(())
if the case status is updated successfully.
Source§impl Sdk
impl Sdk
Sourcepub async fn create_purchase_request(
&self,
receiver: &str,
amount: CryptoAmount,
product_hash: &str,
app_data: &str,
purchase_type: &str,
) -> Result<String>
pub async fn create_purchase_request( &self, receiver: &str, amount: CryptoAmount, product_hash: &str, app_data: &str, purchase_type: &str, ) -> Result<String>
Create purchase request
§Arguments
receiver
- The receiver’s username.amount
- The amount of the purchase.product_hash
- The hash of the product.app_data
- The application data.purchase_type
- The type of the purchase.
§Returns
The purchase ID. This is an internal index used to reference the transaction in etopay
§Errors
Returns an error if the user or wallet is not initialized, or if there is an error creating the transaction.
Sourcepub async fn get_purchase_details(
&self,
purchase_id: &str,
) -> Result<PurchaseDetails>
pub async fn get_purchase_details( &self, purchase_id: &str, ) -> Result<PurchaseDetails>
Sourcepub async fn confirm_purchase_request(
&mut self,
pin: &EncryptionPin,
purchase_id: &str,
) -> Result<()>
pub async fn confirm_purchase_request( &mut self, pin: &EncryptionPin, purchase_id: &str, ) -> Result<()>
Confirm purchase request
§Arguments
pin
- The PIN of the user.purchase_id
- The ID of the purchase request.
§Returns
Returns Ok(())
if the purchase request is confirmed successfully.
§Errors
Returns an error if the user or wallet is not initialized, if there is an error verifying the PIN, if there is an error getting the transaction details, or if there is an error committing the transaction.
Sourcepub async fn send_amount(
&mut self,
pin: &EncryptionPin,
address: &str,
amount: CryptoAmount,
data: Option<Vec<u8>>,
) -> Result<String>
pub async fn send_amount( &mut self, pin: &EncryptionPin, address: &str, amount: CryptoAmount, data: Option<Vec<u8>>, ) -> Result<String>
Send amount to receiver address
§Arguments
pin
- The PIN of the user.address
- The receiver’s address.amount
- The amount to send.data
- The associated data with the tag. Optional.
§Returns
Returns Ok(String)
containing the transaction hash if the amount is sent successfully.
§Errors
Returns an error if the user or wallet is not initialized, if there is an error verifying the PIN, or if there is an error sending the amount.
Sourcepub async fn estimate_gas(
&mut self,
pin: &EncryptionPin,
address: &str,
amount: CryptoAmount,
data: Option<Vec<u8>>,
) -> Result<GasCostEstimation>
pub async fn estimate_gas( &mut self, pin: &EncryptionPin, address: &str, amount: CryptoAmount, data: Option<Vec<u8>>, ) -> Result<GasCostEstimation>
Estimate gas for sending amount to receiver
§Arguments
pin
- The PIN of the user.address
- The receiver’s address.amount
- The amount to send.data
- The associated data with the tag. Optional.
§Returns
Returns the gas estimation.
§Errors
Returns an error if the user or wallet is not initialized, if there is an error verifying the PIN, or if there is an error estimating the gas.
Source§impl Sdk
impl Sdk
Sourcepub async fn get_user(&self) -> Result<UserEntity>
pub async fn get_user(&self) -> Result<UserEntity>
Sourcepub async fn create_new_user(&mut self, username: &str) -> Result<()>
pub async fn create_new_user(&mut self, username: &str) -> Result<()>
Sourcepub async fn delete_user(&mut self, pin: Option<&EncryptionPin>) -> Result<()>
pub async fn delete_user(&mut self, pin: Option<&EncryptionPin>) -> Result<()>
Delete the currently active user and their wallet
§Arguments
pin
- The PIN of the user to be deleted.
§Returns
Returns Ok(())
if the user is deleted successfully, or an Error
if an error occurs.
§Errors
Returns an Error
if there is an issue verifying the PIN, initializing the repository, initiliazing the user, deleting the user, or deleting the wallet.
Sourcepub async fn init_user(&mut self, username: &str) -> Result<()>
pub async fn init_user(&mut self, username: &str) -> Result<()>
Initialize an user
§Arguments
username
- The username of the user to initialize.
§Returns
Returns Ok(())
if the user is initialized successfully, or an Error
if an error occurs.
§Errors
Returns an Error
if there is an issue validating the configuration, initializing the repository, or checking the KYC status.
Sourcepub async fn refresh_access_token(
&mut self,
access_token: Option<AccessToken>,
) -> Result<()>
pub async fn refresh_access_token( &mut self, access_token: Option<AccessToken>, ) -> Result<()>
Sourcepub async fn is_kyc_status_verified(&mut self, username: &str) -> Result<bool>
pub async fn is_kyc_status_verified(&mut self, username: &str) -> Result<bool>
Check if KYC status is verified.
§Arguments
username
- The username of the user to check KYC status for.
§Returns
Returns Ok(true)
if the KYC status is verified, or Ok(false)
if it is not verified.
§Errors
Returns an Error
if there is an issue validating the configuration, initializing the repository, or checking the KYC status.
Sourcepub async fn set_preferred_network(
&mut self,
network_key: Option<String>,
) -> Result<()>
pub async fn set_preferred_network( &mut self, network_key: Option<String>, ) -> Result<()>
Set the user preferred network
Sourcepub async fn get_preferred_network(&self) -> Result<Option<String>>
pub async fn get_preferred_network(&self) -> Result<Option<String>>
Get the user preferred network
Source§impl Sdk
impl Sdk
Sourcepub async fn get_iban_for_viviswap(&mut self) -> Result<ViviswapAddressDetail>
pub async fn get_iban_for_viviswap(&mut self) -> Result<ViviswapAddressDetail>
Get current iban of viviswap user
§Arguments
None
§Returns
Result<ViviswapAddressDetail>
- The current IBAN of the viviswap user.
§Errors
- [
crate::Error::ViviswapInvalidState
] - If the viviswap state is invalid. crate::Error::UserRepoNotInitialized
- If the repository initialization fails.- [
crate::Error::ViviswapApi
] - If there is an error in the viviswap API. - [
crate::Error::UserStatusUpdateError
] - If there is an error updating the user status.
Sourcepub async fn update_iban_for_viviswap(
&mut self,
pin: &EncryptionPin,
address: String,
) -> Result<ViviswapAddressDetail>
pub async fn update_iban_for_viviswap( &mut self, pin: &EncryptionPin, address: String, ) -> Result<ViviswapAddressDetail>
Update IBAN of viviswap user.
§Arguments
pin
- The user’s PIN.address
- The new IBAN address.
§Returns
Result<ViviswapAddressDetail>
- The updated Viviswap address detail.
§Errors
crate::Error::UserRepoNotInitialized
- If the repository initialization fails.- [
crate::Error::ViviswapMissingUserError
] - If the viviswap user is missing. - [
crate::Error::UserStatusUpdateError
] - If there is an error updating the user status.
Sourcepub async fn create_deposit_with_viviswap(
&mut self,
pin: &EncryptionPin,
) -> Result<ViviswapDeposit>
pub async fn create_deposit_with_viviswap( &mut self, pin: &EncryptionPin, ) -> Result<ViviswapDeposit>
create deposit for viviswap user
§Returns
Result<ViviswapDeposit>
- The created Viviswap deposit.
§Errors
crate::Error::UserRepoNotInitialized
- If the repository initialization fails.- [
crate::Error::ViviswapMissingUserError
] - If the viviswap user is missing. - [
crate::Error::ViviswapInvalidState
] - If the viviswap state is invalid. - [
crate::Error::ViviswapApi
] - If there is an error with the Viviswap API.
Sourcepub async fn create_detail_for_viviswap(
&mut self,
pin: &EncryptionPin,
) -> Result<ViviswapAddressDetail>
pub async fn create_detail_for_viviswap( &mut self, pin: &EncryptionPin, ) -> Result<ViviswapAddressDetail>
Sourcepub async fn create_withdrawal_with_viviswap(
&mut self,
amount: CryptoAmount,
pin: Option<&EncryptionPin>,
data: Option<Vec<u8>>,
) -> Result<ViviswapWithdrawal>
pub async fn create_withdrawal_with_viviswap( &mut self, amount: CryptoAmount, pin: Option<&EncryptionPin>, data: Option<Vec<u8>>, ) -> Result<ViviswapWithdrawal>
create withdrawal for viviswap user
§Arguments
amount
- The amount of the withdrawal.pin
- The optional PIN for verification.tag
- The transactions tag. Optional.data
- The associated data with the tag. Optional.message
- The transactions message. Optional.
§Returns
Result<ViviswapWithdrawal>
- The created Viviswap withdrawal.
§Errors
- [
crate::Error::ViviswapMissingUserError
] - If the viviswap user is missing. - [
crate::Error::ViviswapInvalidState
] - If the viviswap state is invalid. - [
crate::Error::ViviswapApi
] - If there is an error with the Viviswap API.
Sourcepub async fn get_swap_list(&self, start: u32, limit: u32) -> Result<OrderList>
pub async fn get_swap_list(&self, start: u32, limit: u32) -> Result<OrderList>
Get the list of swaps for the viviswap user.
§Returns
Returns a Result
containing a vector of Swap
if successful, or a crate::Error
if an error occurs.
§Errors
Returns an Err
variant of crate::Error
if any of the following conditions are met:
- Repository initialization error.
- Viviswap API error.
Source§impl Sdk
impl Sdk
Sourcepub async fn start_kyc_verification_for_viviswap(
&mut self,
mail: &str,
terms_accepted: bool,
) -> Result<NewViviswapUser>
pub async fn start_kyc_verification_for_viviswap( &mut self, mail: &str, terms_accepted: bool, ) -> Result<NewViviswapUser>
Create new viviswap user and initialize kyc verification
§Arguments
mail
- The email address of the user.terms_accepted
- A boolean indicating whether the terms have been accepted.
§Returns
Returns a Result
containing a NewViviswapUser
if successful, or a crate::Error
if an error occurs.
§Errors
Returns an Err
variant of crate::Error
if any of the following conditions are met:
- Repository initialization error.
- User already exists.
- Viviswap API error.
- User status update error.
Sourcepub async fn get_kyc_details_for_viviswap(
&mut self,
) -> Result<ViviswapKycStatus>
pub async fn get_kyc_details_for_viviswap( &mut self, ) -> Result<ViviswapKycStatus>
Get current kyc status of viviswap
§Returns
Returns a Result
containing a ViviswapKycStatus
if successful, or a crate::Error
if an error occurs.
§Errors
Returns an Err
variant of crate::Error
if any of the following conditions are met:
- Repository initialization error.
- Viviswap API error.
Sourcepub async fn submit_kyc_partially_status_for_viviswap(&mut self) -> Result<()>
pub async fn submit_kyc_partially_status_for_viviswap(&mut self) -> Result<()>
Submit the previously entered partial kyc details for viviswap.
§Errors
Returns a vector of crate::Error
if any of the following conditions are met:
- Repository initialization error.
- Viviswap missing user error.
- Viviswap invalid state error.
- Viviswap missing field error.
- Viviswap API error.
§Returns
Returns Ok(())
if the submission is successful.
Sourcepub async fn update_kyc_partially_status_for_viviswap(
&mut self,
is_individual: Option<bool>,
is_pep: Option<bool>,
is_us_citizen: Option<bool>,
is_regulatory_disclosure: Option<bool>,
country_of_residence: Option<String>,
nationality: Option<String>,
full_name: Option<String>,
date_of_birth: Option<String>,
) -> Result<ViviswapPartiallyKycDetails>
pub async fn update_kyc_partially_status_for_viviswap( &mut self, is_individual: Option<bool>, is_pep: Option<bool>, is_us_citizen: Option<bool>, is_regulatory_disclosure: Option<bool>, country_of_residence: Option<String>, nationality: Option<String>, full_name: Option<String>, date_of_birth: Option<String>, ) -> Result<ViviswapPartiallyKycDetails>
Update the kyc details for viviswap to be submitted
§Arguments
is_individual
- Whether the user is an individual.is_pep
- Whether the user is a politically exposed person.is_us_citizen
- Whether the user is a US citizen.is_regulatory_disclosure
- Whether the user has accepted the regulatory disclosure.country_of_residence
- The country of residence of the user.nationality
- The nationality of the user.full_name
- The full name of the user.date_of_birth
- The date of birth of the user.
§Returns
Returns a Result
containing the partially updated KYC details or a vector of errors.
§Errors
Returns a vector of errors if any validation errors occur during the update process.
Sourcepub async fn set_viviswap_kyc_identity_details(
&self,
official_document: IdentityOfficialDocumentData,
personal_document: IdentityPersonalDocumentData,
) -> Result<()>
pub async fn set_viviswap_kyc_identity_details( &self, official_document: IdentityOfficialDocumentData, personal_document: IdentityPersonalDocumentData, ) -> Result<()>
Set KYC identity details
§Arguments
official_document
- The official document that verifies the person (eg. ID-Card, Passport, Drivers License …).personal_document
- A 30 second video document that verifies that this person is willing to verify at viviswap and that the person really is the one they claim to be.
§Errors
- [[
crate::Error::UserNotInitialized)
]] - If the user is not initialized. - [[
crate::Error::ViviswapApiError
]] - If there is an error in the viviswap API.
Sourcepub async fn set_viviswap_kyc_residence_details(
&self,
country_code: String,
region: String,
zip_code: String,
city: String,
address_line_1: String,
address_line_2: String,
is_public_entry: bool,
public_entry_reference: Option<String>,
has_no_official_document: bool,
document_residence_proof: Option<File>,
) -> Result<()>
pub async fn set_viviswap_kyc_residence_details( &self, country_code: String, region: String, zip_code: String, city: String, address_line_1: String, address_line_2: String, is_public_entry: bool, public_entry_reference: Option<String>, has_no_official_document: bool, document_residence_proof: Option<File>, ) -> Result<()>
Set KYC residence details
§Arguments
country_code
,region
,zip_code
,city
,address_line_1
,address_line_2
- basic address data.is_public_entry
- Inidcates that a valid public entry of this clients address can be found.public_entry_reference
- ifis_public_entry
istrue
, then this must contain the resource link.has_no_official_document
- indicates if the client does not have any document verifying their address.document_residence_proof
- ifhas_no_official_document
isfalse
, then this must contain the document file that verifies that this person is currently living at the address submitted.
§Errors
- [[
crate::Error::UserNotInitialized)
]] - If the user is not initialized. - [[
crate::Error::ViviswapValidation
]] - If the input values are not valid. - [[
crate::Error::ViviswapApiError
]] - If there is an error in the viviswap API.
Sourcepub async fn get_viviswap_kyc_amla_open_questions(
&self,
) -> Result<Vec<KycAmlaQuestion>>
pub async fn get_viviswap_kyc_amla_open_questions( &self, ) -> Result<Vec<KycAmlaQuestion>>
Sourcepub async fn set_viviswap_kyc_amla_answer(
&self,
question_id: String,
answers: Vec<String>,
freetext_answer: Option<String>,
) -> Result<()>
pub async fn set_viviswap_kyc_amla_answer( &self, question_id: String, answers: Vec<String>, freetext_answer: Option<String>, ) -> Result<()>
Set the answer to an open AMLA KYC question
§Arguments
question_id
- The ID of the question to set the answer to.answers
- a list of the selected available answers for the question.freetext_answer
- an optional free-text answer.
§Errors
- [[
crate::Error::UserNotInitialized)
]] - If the user is not initialized. - [[
crate::Error::ViviswapApiError
]] - If there is an error in the viviswap API.
Sourcepub async fn get_viviswap_kyc_open_documents(
&self,
) -> Result<Vec<KycOpenDocument>>
pub async fn get_viviswap_kyc_open_documents( &self, ) -> Result<Vec<KycOpenDocument>>
Sourcepub async fn set_viviswap_kyc_document(
&self,
document_id: String,
expiration_date: String,
document_number: String,
front_image: Option<File>,
back_image: Option<File>,
) -> Result<()>
pub async fn set_viviswap_kyc_document( &self, document_id: String, expiration_date: String, document_number: String, front_image: Option<File>, back_image: Option<File>, ) -> Result<()>
Set / upload an open KYC document
§Arguments
document_id
- The ID of the document to upload.expiration_date
- the expiration date of this document.document_number
- the official document number.front_image
- the front image of the official document.back_image
- the back image of the official document.
§Errors
- [
crate::Error::ViviswapApiError
] - If there is an error in the viviswap API. - [
crate::Error::UserNotInitialized)
] - If the user is not initialized.
Source§impl Sdk
impl Sdk
Sourcepub async fn create_wallet_from_new_mnemonic(
&mut self,
pin: &EncryptionPin,
) -> Result<String>
pub async fn create_wallet_from_new_mnemonic( &mut self, pin: &EncryptionPin, ) -> Result<String>
Create and store a wallet from a new random mnemonic
§Arguments
pin
- The PIN for the wallet.
§Returns
The new random mnemonic.
§Errors
crate::Error::MissingConfig
- If the sdk config is missing.crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.
Sourcepub async fn create_wallet_from_existing_mnemonic(
&mut self,
pin: &EncryptionPin,
mnemonic: &str,
) -> Result<()>
pub async fn create_wallet_from_existing_mnemonic( &mut self, pin: &EncryptionPin, mnemonic: &str, ) -> Result<()>
Create and store a wallet from an existing mnemonic
§Arguments
pin
- The PIN for the wallet.mnemonic
- The mnemonic to use for the wallet.
§Errors
crate::Error::MissingConfig
- If the sdk config is missing.crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.
Sourcepub async fn create_wallet_from_backup(
&mut self,
pin: &EncryptionPin,
backup: &[u8],
backup_password: &PlainPassword,
) -> Result<()>
pub async fn create_wallet_from_backup( &mut self, pin: &EncryptionPin, backup: &[u8], backup_password: &PlainPassword, ) -> Result<()>
Create and store a wallet from an existing kdbx backup file
§Arguments
pin
- The PIN for the wallet.backup
- The bytes representing the backup file.backup_password
- The password used when creating the backup file.
§Errors
crate::Error::MissingConfig
- If the sdk config is missing.crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.
Sourcepub async fn create_wallet_backup(
&mut self,
pin: &EncryptionPin,
backup_password: &PlainPassword,
) -> Result<Vec<u8>>
pub async fn create_wallet_backup( &mut self, pin: &EncryptionPin, backup_password: &PlainPassword, ) -> Result<Vec<u8>>
Create a kdbx wallet backup from an existing wallet.
§Arguments
pin
- The PIN for the wallet.backup_password
- The password to use when creating the backup file.
§Returns
The bytes of the kdbx backup file.
§Errors
crate::Error::MissingConfig
- If the sdk config is missing.crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.
Sourcepub async fn verify_mnemonic(
&mut self,
pin: &EncryptionPin,
mnemonic: &str,
) -> Result<bool>
pub async fn verify_mnemonic( &mut self, pin: &EncryptionPin, mnemonic: &str, ) -> Result<bool>
Verify the mnemonic by checking if the mnemonic is the same as the one in the shares
§Arguments
pin
- The PIN for the wallet.mnemonic
- The mnemonic to verify.
§Returns
Returns Ok(true)
if the mnemonic is successfully verified, otherwise returns Ok(false)
,
or an Error
.
§Errors
crate::Error::MissingConfig
- If the sdk config is missing.crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.
Sourcepub async fn delete_wallet(&mut self, pin: &EncryptionPin) -> Result<()>
pub async fn delete_wallet(&mut self, pin: &EncryptionPin) -> Result<()>
Delete the currently active wallet
Deletes the currently active wallet, potentially resulting in loss of funds if the mnemonic or wallet is not backed up.
§Returns
Returns Ok(())
if the wallet is successfully deleted, otherwise returns an Error
.
§Errors
crate::Error::MissingConfig
- If the sdk config is missing.crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.
Sourcepub async fn verify_pin(&self, pin: &EncryptionPin) -> Result<()>
pub async fn verify_pin(&self, pin: &EncryptionPin) -> Result<()>
Verify pin
Verifies the pin for the wallet.
§Arguments
pin
- The pin to verify.
§Returns
Returns Ok(())
if the pin is verified successfully, otherwise returns an Error
.
§Errors
crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.WalletError::WalletNotInitialized
- If there is an error initializing the wallet.WalletError::WrongPinOrPassword
- If the pin or password is incorrect.
Sourcepub async fn change_pin(
&mut self,
old_pin: &EncryptionPin,
new_pin: &EncryptionPin,
) -> Result<()>
pub async fn change_pin( &mut self, old_pin: &EncryptionPin, new_pin: &EncryptionPin, ) -> Result<()>
Reset pin
Resets the pin for the wallet using the provided password and new pin.
§Arguments
old_pin
- The old wallet pin.new_pin
- The new pin to set for the wallet.
§Returns
Returns Ok(())
if the pin is changed successfully, otherwise returns an Error
.
§Errors
crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.WalletError::WalletNotInitialized
- If there is an error initializing the wallet.WalletError::WrongPinOrPassword
- If the pin or password is incorrect.
Sourcepub async fn set_wallet_password(
&mut self,
pin: &EncryptionPin,
new_password: &PlainPassword,
) -> Result<()>
pub async fn set_wallet_password( &mut self, pin: &EncryptionPin, new_password: &PlainPassword, ) -> Result<()>
Set the password to use for wallet operations. If the password was already set, this changes it.
§Arguments
pin
- The pin to encrypt the password with.new_password
- The new password to set for the wallet.
§Returns
Returns Ok(())
if the password is set successfully, otherwise returns an Error
.
§Errors
crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.
Sourcepub async fn is_wallet_password_set(&self) -> Result<bool>
pub async fn is_wallet_password_set(&self) -> Result<bool>
Check if the password to use for wallet operations is set. If this returns false
,
the password should be set with [set_wallet_password
], otherwise you need to use
[change_password
] to change it.
§Returns
Returns Ok(true)
if the password is set successfully, otherwise returns Ok(false)
.
§Errors
crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.
Sourcepub async fn generate_new_address(
&mut self,
pin: &EncryptionPin,
) -> Result<String>
pub async fn generate_new_address( &mut self, pin: &EncryptionPin, ) -> Result<String>
Generates a new receiver address (based on selected currency in the config) for the wallet.
§Returns
Returns the generated address as a String
if successful, otherwise returns an Error
.
§Errors
crate::Error::UserRepoNotInitialized
- If there is an error initializing the repository.crate::Error::UserNotInitialized
- If there is an error initializing the user.crate::Error::MissingConfig
- If the sdk config is missing.
Sourcepub async fn get_balance(&mut self, pin: &EncryptionPin) -> Result<CryptoAmount>
pub async fn get_balance(&mut self, pin: &EncryptionPin) -> Result<CryptoAmount>
Get the balance of the user
Fetches the balance of the user from the wallet.
§Returns
Returns the balance as a f64
if successful, otherwise returns an Error
.
§Errors
crate::Error::UserNotInitialized
- If there is an error initializing the user.WalletError::WalletNotInitialized
- If there is an error initializing the wallet.
Sourcepub async fn get_wallet_tx_list(
&mut self,
pin: &EncryptionPin,
start: usize,
limit: usize,
) -> Result<WalletTxInfoList>
pub async fn get_wallet_tx_list( &mut self, pin: &EncryptionPin, start: usize, limit: usize, ) -> Result<WalletTxInfoList>
wallet transaction list
Returns paginated list of wallet transaction list.
§Arguments
start
- The starting index of transactions to fetch.limit
- The number of transactions per page.
§Returns
Returns a WalletTxInfoList
containing paginated history of wallet transactions if the outputs are claimed successfully, otherwise returns an Error
.
§Errors
crate::Error::UserNotInitialized
- If there is an error initializing the user.WalletError::WalletNotInitialized
- If there is an error initializing the wallet.
Sourcepub async fn get_wallet_tx(
&mut self,
pin: &EncryptionPin,
tx_id: &str,
) -> Result<WalletTxInfo>
pub async fn get_wallet_tx( &mut self, pin: &EncryptionPin, tx_id: &str, ) -> Result<WalletTxInfo>
wallet transaction
Returns the wallet transaction details.
§Arguments
tx_id
- The transaction id of particular transaction.
§Returns
Returns WalletTxInfo
detailed report of particular wallet transaction if the outputs are claimed successfully, otherwise returns an Error
.
§Errors
crate::Error::UserNotInitialized
- If there is an error initializing the user.WalletError::WalletNotInitialized
- If there is an error initializing the wallet.
Source§impl Sdk
impl Sdk
Sourcepub async fn get_exchange_rate(&self) -> Result<Decimal>
pub async fn get_exchange_rate(&self) -> Result<Decimal>
Return the current exchange rate.
§Returns
Returns a Result
containing the exchange rate as a Decimal
type if successful, or a crate::Error
if an error occurs.
Source§impl Sdk
impl Sdk
Sourcepub async fn set_network(&mut self, network_key: String) -> Result<()>
pub async fn set_network(&mut self, network_key: String) -> Result<()>
Set network
Sourcepub fn set_networks(&mut self, networks: Vec<ApiNetwork>)
pub fn set_networks(&mut self, networks: Vec<ApiNetwork>)
Set networks
Sourcepub async fn get_networks(&mut self) -> Result<Vec<ApiNetwork>>
pub async fn get_networks(&mut self) -> Result<Vec<ApiNetwork>>
Get networks
Sourcepub fn get_build_info() -> String
pub fn get_build_info() -> String
A function that returns a multi-line String containing:
- Branch name (e.g. main)
- Commit hash (e.g. 92cedead),
- Build time (e.g. 2024-10-29 12:10:09 +00:00),
- Rust version (e.g. 1.80.1 (3f5fd8dd4 2024-08-06))
- Toolchain channel (e.g. stable-x86_64-unknown-linux-gnu)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sdk
impl !RefUnwindSafe for Sdk
impl Send for Sdk
impl Sync for Sdk
impl Unpin for Sdk
impl !UnwindSafe for Sdk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> ConvertTo<T> for Twhere
T: Send,
impl<T> ConvertTo<T> for Twhere
T: Send,
fn convert(self) -> Result<T, Error>
fn convert_unchecked(self) -> T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.