Skip to content

Commit

Permalink
Merge bitcoin#2003: [GUI] Tx detail, don't show inputs if there is no…
Browse files Browse the repository at this point in the history
… information for them.

ba51720 GUI: do not try to show the inputs if all of them are shielded and not from this wallet. (furszy)

Pull request description:

  The transaction detail dialog was trying to show the shielded inputs of a transaction when the tx was not from the wallet. Which is impossible as it has no information about them. This fixes it.

ACKs for top commit:
  random-zebra:
    utACK ba51720
  Fuzzbawls:
    ACK ba51720

Tree-SHA512: 139be4d563383ebddf3468a33860acd109ecc990cb0a8d1c1ba71a2286e4f4a0b310092c9b947ba51e1e7e3ab2356de75ecbcf48a02354e4e0831b4baae56855
  • Loading branch information
random-zebra committed Dec 2, 2020
2 parents 0756462 + ba51720 commit 8a07799
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 31 deletions.
72 changes: 41 additions & 31 deletions src/qt/pivx/sendconfirmdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,18 @@ void TxDetailDialog::setData(WalletModel *_model, const QModelIndex &index)
(_tx->sapData ? _tx->sapData->vShieldedOutput.size() : 0)) + " recipients");
}
ui->textSend->setVisible(false);
isShieldedToShieldedRecv = rec->type == TransactionRecord::Type::RecvWithShieldedAddress;

// Do not show inputs button if there is no data to show
QString shieldedInputsExtraMsg = "";
if (isShieldedToShieldedRecv) {
ui->pushInputs->setVisible(false);
shieldedInputsExtraMsg = " shielded";
}

setInputsType(_tx);
int inputsSize = (_tx->sapData && !_tx->sapData->vShieldedSpend.empty()) ? _tx->sapData->vShieldedSpend.size() : _tx->vin.size();
ui->textInputs->setText(QString::number(inputsSize));
ui->textInputs->setText(QString::number(inputsSize) + shieldedInputsExtraMsg);
ui->textConfirmations->setText(QString::number(rec->status.depth));
ui->textDate->setText(GUIUtil::dateTimeStrWithSeconds(date));
ui->textStatus->setText(QString::fromStdString(rec->statusToString()));
Expand Down Expand Up @@ -209,41 +217,43 @@ void TxDetailDialog::onInputsClicked()
if (ui->gridInputs->isVisible()) {
ui->gridInputs->setVisible(false);
} else {
bool showGrid = true;
bool showGrid = !isShieldedToShieldedRecv;
if (!inputsLoaded) {
inputsLoaded = true;
const CWalletTx* walletTx = (this->tx) ? this->tx->getTransaction() : model->getTx(this->txHash);
if (walletTx) {
if (walletTx->sapData && walletTx->sapData->vShieldedSpend.empty()) {
// transparent inputs
ui->gridInputs->setMinimumHeight(50 + (50 * walletTx->vin.size()));
int i = 1;
for (const CTxIn& in : walletTx->vin) {
QString hash = QString::fromStdString(in.prevout.hash.GetHex());
loadInputs(hash.left(18) + "..." + hash.right(18),
QString::number(in.prevout.n),
ui->gridLayoutInput, i);
i++;
}
} else {
ui->gridInputs->setMinimumHeight(50 + (50 * walletTx->sapData->vShieldedSpend.size()));
bool fInfoAvailable = false;
for (int i = 0; i < (int) walletTx->sapData->vShieldedSpend.size(); ++i) {
Optional<QString> opAddr = model->getShieldedAddressFromSpendDesc(walletTx, i);
if (opAddr) {
QString addr = *opAddr;
loadInputs(addr.left(18) + "..." + addr.right(18),
QString::number(i),
ui->gridLayoutInput, i + 1);
fInfoAvailable = true;
if (showGrid) {
const CWalletTx* walletTx = (this->tx) ? this->tx->getTransaction() : model->getTx(this->txHash);
if (walletTx) {
if (walletTx->sapData && walletTx->sapData->vShieldedSpend.empty()) {
// transparent inputs
ui->gridInputs->setMinimumHeight(50 + (50 * walletTx->vin.size()));
int i = 1;
for (const CTxIn& in : walletTx->vin) {
QString hash = QString::fromStdString(in.prevout.hash.GetHex());
loadInputs(hash.left(18) + "..." + hash.right(18),
QString::number(in.prevout.n),
ui->gridLayoutInput, i);
i++;
}
} else {
ui->gridInputs->setMinimumHeight(50 + (50 * walletTx->sapData->vShieldedSpend.size()));
bool fInfoAvailable = false;
for (int i = 0; i < (int) walletTx->sapData->vShieldedSpend.size(); ++i) {
Optional<QString> opAddr = model->getShieldedAddressFromSpendDesc(walletTx, i);
if (opAddr) {
QString addr = *opAddr;
loadInputs(addr.left(18) + "..." + addr.right(18),
QString::number(i),
ui->gridLayoutInput, i + 1);
fInfoAvailable = true;
}
}
}

if (!fInfoAvailable) {
// note: the spends are not from the wallet, let's not show anything here
showGrid = false;
}
if (!fInfoAvailable) {
// note: the spends are not from the wallet, let's not show anything here
showGrid = false;
}

}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/qt/pivx/sendconfirmdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public Q_SLOTS:
WalletModel::SendCoinsReturn sendStatus;
WalletModelTransaction* tx{nullptr};
uint256 txHash;
// Shielded tx with not inputs data
bool isShieldedToShieldedRecv{false};

bool inputsLoaded = false;
bool outputsLoaded = false;
Expand Down

0 comments on commit 8a07799

Please sign in to comment.