mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #17587: gui: show watch-only balance in send screen
4a96e459d733f1b6427221aaa1874ea00f79988a [gui] send: show watch-only balance in send screen (Sjors Provoost)
2689c8fd7159f47248c5fc365463be8b0e8b039c [test] qt: add send screen balance test (Sjors Provoost)
Pull request description:
Now that we can create a PSBT from a watch-only wallet (#16944), we should also display the watch-only balance on the send screen.
Before:
<img width="1008" alt="before" src="https://user-images.githubusercontent.com/10217/69533384-030e9180-0f78-11ea-9748-c32c957e822e.png">
After:
<img width="1009" alt="Schermafbeelding 2019-11-26 om 11 44 17" src="https://user-images.githubusercontent.com/10217/69622879-19811f80-1042-11ea-8279-091012f39b38.png">
I added a test to check the balance on the send screen, but it only covers regular wallets. A better would add a watch-only only wallet.
ACKs for top commit:
meshcollider:
utACK 4a96e459d733f1b6427221aaa1874ea00f79988a
jb55:
utACK 4a96e459d733f1b6427221aaa1874ea00f79988a
promag:
reACK 4a96e45, rebased and label change since last review.
instagibbs:
code review and light test ACK 4a96e459d7
Tree-SHA512: 4213549888bd309f72bdbba1453218f4a2b07e809100d786a3791897c75468f9092b06fe4b971942b1c228aa75ee7c04971f262ca9a478b42756e056eb534620
This commit is contained in:
parent
6146d2991d
commit
d48a10f435
@ -1116,7 +1116,7 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelBalanceText">
|
||||
<widget class="QLabel" name="labelBalanceName">
|
||||
<property name="text">
|
||||
<string>Balance:</string>
|
||||
</property>
|
||||
|
@ -1694,7 +1694,7 @@ QDialog#SendCoinsDialog .QScrollArea#scrollArea .QWidget#scrollAreaWidgetContent
|
||||
background-color: #00000000;
|
||||
}
|
||||
|
||||
QDialog#SendCoinsDialog QLabel#labelBalanceText,
|
||||
QDialog#SendCoinsDialog QLabel#labelBalanceName,
|
||||
QDialog#SendCoinsDialog QLabel#labelBalance {
|
||||
qproperty-alignment: 'AlignLeading | AlignLeft';
|
||||
min-height: 20px;
|
||||
|
@ -79,7 +79,7 @@ SendCoinsDialog::SendCoinsDialog(bool _fCoinJoin, QWidget* parent) :
|
||||
}, GUIUtil::FontWeight::Bold);
|
||||
|
||||
GUIUtil::setFont({ui->labelBalance,
|
||||
ui->labelBalanceText
|
||||
ui->labelBalanceName,
|
||||
}, GUIUtil::FontWeight::Bold, 14);
|
||||
|
||||
GUIUtil::setFont({ui->labelCoinControlFeatures
|
||||
@ -641,14 +641,17 @@ void SendCoinsDialog::setBalance(const interfaces::WalletBalances& balances)
|
||||
{
|
||||
if(model && model->getOptionsModel())
|
||||
{
|
||||
CAmount bal = 0;
|
||||
if (m_coin_control->IsUsingCoinJoin()) {
|
||||
bal = balances.anonymized_balance;
|
||||
CAmount balance = 0;
|
||||
if (model->privateKeysDisabled()) {
|
||||
balance = balances.watch_only_balance;
|
||||
ui->labelBalanceName->setText(tr("Watch-only balance:"));
|
||||
} else if (m_coin_control->IsUsingCoinJoin()) {
|
||||
balance = balances.anonymized_balance;
|
||||
} else {
|
||||
bal = balances.balance;
|
||||
balance = balances.balance;
|
||||
}
|
||||
|
||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), bal));
|
||||
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), balance));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,16 @@ void TestGUI(interfaces::Node& node)
|
||||
sendCoinsDialog.setModel(&walletModel);
|
||||
transactionView.setModel(&walletModel);
|
||||
|
||||
{
|
||||
// Check balance in send dialog
|
||||
QLabel* balanceLabel = sendCoinsDialog.findChild<QLabel*>("labelBalance");
|
||||
QString balanceText = balanceLabel->text();
|
||||
int unit = walletModel.getOptionsModel()->getDisplayUnit();
|
||||
CAmount balance = walletModel.wallet().getBalance();
|
||||
QString balanceComparison = BitcoinUnits::formatWithUnit(unit, balance, false /*, BitcoinUnits::separatorAlways*/);
|
||||
QCOMPARE(balanceText, balanceComparison);
|
||||
}
|
||||
|
||||
// Send two transactions, and verify they are added to transaction list.
|
||||
TransactionTableModel* transactionTableModel = walletModel.getTransactionTableModel();
|
||||
QCOMPARE(transactionTableModel->rowCount({}), 105);
|
||||
|
Loading…
Reference in New Issue
Block a user