Skip to content

Commit

Permalink
remove rewards from the available balance
Browse files Browse the repository at this point in the history
The rationale is to have an easy way to show what's the spendable UTxO amount.
  • Loading branch information
KtorZ committed Jul 6, 2020
1 parent 1736316 commit c59e19c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,7 @@ spec = do
verify r
[ expectField (#balance . #getApiT . #reward) (.> (Quantity 0))
]
let Quantity totalBalance =
getFromResponse (#balance . #getApiT . #total) r
let Quantity rewardBalance =
getFromResponse (#balance . #getApiT . #reward) r
pure $ Quantity (totalBalance - rewardBalance)
pure $ getFromResponse (#balance . #getApiT . #available) r

-- Use rewards
addrs <- listAddresses @n ctx w
Expand Down
2 changes: 1 addition & 1 deletion lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ mkShelleyWallet ctx wid cp meta pending progress = do
pure ApiWallet
{ addressPoolGap = ApiT $ getState cp ^. #externalPool . #gap
, balance = ApiT $ WalletBalance
{ available = Quantity $ reward + availableBalance pending cp
{ available = Quantity $ availableBalance pending cp
, total = Quantity $ reward + totalBalance pending cp
, reward = Quantity reward
}
Expand Down
4 changes: 2 additions & 2 deletions specifications/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,13 @@ x-walletBalance: &walletBalance
properties:
available:
<<: *amount
description: Available balance (funds that can be spent)
description: Available UTxO balance (funds that can be spent without condition).
reward:
<<: *amount
description: The balance of the reward account for this wallet.
total:
<<: *amount
description: Total balance (available balance plus pending change)
description: Total balance (available balance plus pending change and reward balance).

x-byronWalletBalance: &byronWalletBalance
description: Byron wallet's current balance(s)
Expand Down

0 comments on commit c59e19c

Please sign in to comment.