Correctly show pending but not spendable farming rewards (#256)

Co-authored-by: Mariano Sorgente <sorgente711@gmail.com>
This commit is contained in:
Gene Hoffman
2020-06-01 08:56:59 -07:00
committed by wjblanke
co-authored by Mariano Sorgente
parent f5b446fcc4
commit 81c9338dc6
3 changed files with 24 additions and 2 deletions
+2
View File
@@ -158,6 +158,8 @@ def main():
log(f"Plot {filename} already exists")
# Updates the config if necessary.
plot_config = load_config(root_path, plot_config_filename)
plot_config_plots_new = deepcopy(plot_config.get("plots", []))
plot_config_plots_new[str(full_path)] = {
"sk": bytes(sk).hex(),
"pool_pk": bytes(pool_pk).hex(),
+1 -2
View File
@@ -63,8 +63,7 @@ class Wallet:
)
async def get_frozen_amount(self) -> uint64:
# TODO
return uint64(0)
return await self.wallet_state_manager.get_frozen_balance(self.wallet_info.id)
async def get_spendable_balance(self) -> uint64:
spendable_am = await self.wallet_state_manager.get_confirmed_spendable_balance_for_wallet(
+21
View File
@@ -424,6 +424,27 @@ class WalletStateManager:
result = confirmed - removal_amount
return uint64(result)
async def get_frozen_balance(self, wallet_id: int) -> uint64:
current_index = self.block_records[self.lca].height
coinbase_freeze_period = self.constants["COINBASE_FREEZE_PERIOD"]
valid_index = current_index - coinbase_freeze_period
not_frozen: Set[
WalletCoinRecord
] = await self.wallet_store.get_spendable_for_index(valid_index, wallet_id)
all_records: Set[
WalletCoinRecord
] = await self.wallet_store.get_spendable_for_index(current_index, wallet_id)
sum_not_frozen = sum(
record.coin.amount for record in not_frozen if record.coinbase
)
sum_all_records = sum(
record.coin.amount for record in all_records if record.coinbase
)
return uint64(sum_all_records - sum_not_frozen)
async def unconfirmed_additions_for_wallet(
self, wallet_id: int
) -> Dict[bytes32, Coin]: