forked from fekt/hush-android-wallet-sdk
Hush SDK for Android lite wallets
https://hush.is
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1016 B
29 lines
1016 B
2 years ago
|
package cash.z.ecc.android.sdk.model
|
||
|
|
||
|
/**
|
||
|
* Data structure to hold the total and available balance of the wallet. This is what is
|
||
|
* received on the balance channel.
|
||
|
*
|
||
|
* @param total the total balance, ignoring funds that cannot be used.
|
||
|
* @param available the amount of funds that are available for use. Typical reasons that funds
|
||
|
* may be unavailable include fairly new transactions that do not have enough confirmations or
|
||
|
* notes that are tied up because we are awaiting change from a transaction. When a note has
|
||
|
* been spent, its change cannot be used until there are enough confirmations.
|
||
|
*/
|
||
|
data class WalletBalance(
|
||
|
val total: Zatoshi,
|
||
|
val available: Zatoshi
|
||
|
) {
|
||
|
init {
|
||
|
require(total.value >= available.value) { "Wallet total balance must be >= available balance" }
|
||
|
}
|
||
|
|
||
|
val pending = total - available
|
||
|
|
||
|
operator fun plus(other: WalletBalance): WalletBalance =
|
||
|
WalletBalance(
|
||
|
total + other.total,
|
||
|
available + other.available
|
||
|
)
|
||
|
}
|