Ephemeral
An anti-hoarding currency that rewards circulation through natural decay.
Loading...
Searching...
No Matches
Chiffres::Wallet Class Reference

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.

Detailed Description

Ephemeral wallet whose balance decays over time.

This wallet models a "melting" value system:

  • Balance decreases continuously as time passes (entropy of money).
  • Any deposit or withdrawal first updates the balance to the current time, then applies the requested operation.

Conceptual purpose:

  • Encourage circulation: value loses strength if it is left unused.
  • Embed the flow of time directly into the monetary object.

Constructor & Destructor Documentation

◆ Wallet()

Wallet::Wallet ( std::string owner,
double balance )

Construct a wallet with an owner and initial balance.

Parameters
ownerIdentifier of the wallet owner (safe string).
balanceInitial balance at creation time.

Records the current timestamp for decay tracking.

Member Function Documentation

◆ deposit()

void Wallet::deposit ( double amount)

Deposit funds into the wallet.

Parameters
amountPositive amount to add.

Internally updates balance according to time decay since the last activity, then applies the deposit, and resets last_activity_timestamp.

Exceptions
std::invalid_argumentif amount < 0.

◆ getBalance()

double Wallet::getBalance ( ) const
nodiscard

Get the current balance (read-only).

Returns
Balance adjusted for decay up to now.
Note
This does not modify the internal state permanently. It queries the effective balance at the instant of the call.

◆ withdraw()

bool Wallet::withdraw ( double amount)

Attempt to withdraw funds from the wallet.

Parameters
amountPositive amount requested.
Returns
True if withdrawal succeeded, false if insufficient balance.

Internally updates balance with time decay, then checks availability. If enough, subtracts and updates last_activity_timestamp.


The documentation for this class was generated from the following files: