pub struct Wallet {
pub address: String,
pub private_key: String,
pub public_key: String,
pub balance: f64,
pub transaction_history: VecDeque<Transaction>,
pub pending_transactions: VecDeque<Transaction>,
}Expand description
Struct Wallet.
It includes address, keys,
balance and transaction history.
Fields§
§address: String§private_key: String§public_key: String§balance: f64§transaction_history: VecDeque<Transaction>§pending_transactions: VecDeque<Transaction>Implementations§
Source§impl Wallet
Functions for Struct Wallet.
impl Wallet
Functions for Struct Wallet.
pub fn new(address: String, private_key: String, public_key: String) -> Self
Sourcepub fn add_pending_transaction(&mut self, tx: Transaction)
pub fn add_pending_transaction(&mut self, tx: Transaction)
Process a new transaction.
Sourcepub fn add_transaction(&mut self, tx: Transaction)
pub fn add_transaction(&mut self, tx: Transaction)
Process a new transaction.
Sourcepub fn update_balance(&mut self, amount: f64)
pub fn update_balance(&mut self, amount: f64)
Update wallet balance.
Sourcepub fn get_balance(&self) -> f64
pub fn get_balance(&self) -> f64
Get wallet balance.
Sourcepub fn get_pending_transaction_history(&self) -> &VecDeque<Transaction>
pub fn get_pending_transaction_history(&self) -> &VecDeque<Transaction>
Get the transaction history of the wallet.
Sourcepub fn get_transaction_history(&self) -> &VecDeque<Transaction>
pub fn get_transaction_history(&self) -> &VecDeque<Transaction>
Get the transaction history of the wallet.
Sourcepub fn transfer_txn(&mut self, tx_id: String)
pub fn transfer_txn(&mut self, tx_id: String)
Transfer txn from pending to transactions.
Sourcepub fn load_from_file(filename: &str) -> Wallet
pub fn load_from_file(filename: &str) -> Wallet
Load wallet data from database.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Wallet
impl<'de> Deserialize<'de> for Wallet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Wallet
impl RefUnwindSafe for Wallet
impl Send for Wallet
impl Sync for Wallet
impl Unpin for Wallet
impl UnwindSafe for Wallet
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
Mutably borrows from an owned value. Read more