Ephemeral wallet whose balance decays over time. More...
#include <Wallet.h>
Public Member Functions | |
Wallet (std::string owner, double balance) | |
Construct a wallet with an owner and initial balance. | |
double | getBalance () const |
Get the current balance (read-only). | |
void | deposit (double amount) |
Deposit funds into the wallet. | |
bool | withdraw (double amount) |
Attempt to withdraw funds from the wallet. |
Ephemeral wallet whose balance decays over time.
This wallet models a "melting" value system:
Conceptual purpose:
Wallet::Wallet | ( | std::string | owner, |
double | balance ) |
Construct a wallet with an owner and initial balance.
owner | Identifier of the wallet owner (safe string). |
balance | Initial balance at creation time. |
Records the current timestamp for decay tracking.
void Wallet::deposit | ( | double | amount | ) |
Deposit funds into the wallet.
amount | Positive amount to add. |
Internally updates balance according to time decay since the last activity, then applies the deposit, and resets last_activity_timestamp.
std::invalid_argument | if amount < 0. |
|
nodiscard |
Get the current balance (read-only).
bool Wallet::withdraw | ( | double | amount | ) |
Attempt to withdraw funds from the wallet.
amount | Positive amount requested. |
Internally updates balance with time decay, then checks availability. If enough, subtracts and updates last_activity_timestamp.