diff --git a/ChangeLog.md b/ChangeLog.md index 0478d2b9..2e0dcded 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ ## Unreleased +- Display the correct "at disposal" balance when used with node versions prior to 7. - Fix a bug in correctly accounting for parsed events. - Change `--out` flag for `./client validator add` to `--validator-credentials-out`, fixing an issue where this command had two diff --git a/src/Concordium/Client/GRPC2.hs b/src/Concordium/Client/GRPC2.hs index b84c019f..4e95bc7d 100644 --- a/src/Concordium/Client/GRPC2.hs +++ b/src/Concordium/Client/GRPC2.hs @@ -729,7 +729,17 @@ instance FromProto Proto.AccountInfo where Just asi -> fromProto asi aiAccountAddress <- fromProto $ ai ^. ProtoFields.address aiAccountCooldowns <- mapM fromProto $ ai ^. ProtoFields.cooldowns - aiAccountAvailableAmount <- fromProto $ ai ^. ProtoFields.availableBalance + -- The available balance is only provided by node version 7 onwards, so we compute it + -- if it is not present. + mAvailableBalance <- mapM fromProto $ ai ^. ProtoFields.maybe'availableBalance + let stakedTotal = + sum (cooldownAmount <$> aiAccountCooldowns) + case aiStakingInfo of + AccountStakingDelegated{..} -> asiStakedAmount + AccountStakingBaker{..} -> asiStakedAmount + AccountStakingNone -> 0 + let computedAvailable = + aiAccountAmount - max stakedTotal (releaseTotal aiAccountReleaseSchedule) + let aiAccountAvailableAmount = fromMaybe computedAvailable mAvailableBalance return AccountInfo{..} where versionTag = 0