Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[Qt] Optimize SendToSelf rendering with a single non-change output #11471

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants
Member

jonasschnelli commented Oct 9, 2017

Partially fixes #11464

This is a simple improvement to render singe non-change output self-to-self transactions with the corresponding output-address/label.
Multi non-change output self-to-self transaction do keep the (n.a.) label (we could show all the addresses coma separated).

Screen:
bildschirmfoto 2017-10-09 um 14 18 13

@jonasschnelli jonasschnelli added the GUI label Oct 9, 2017

Concept ACK.

we could show all the addresses coma separated

That sounds sensible.

src/qt/transactionrecord.cpp
@@ -94,10 +94,25 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
if (fAllFromMe && fAllToMe)
{
+ std::string address = "";
+ for (const CTxOut& txout : wtx.tx->vout)
@promag

promag Oct 9, 2017

Contributor

{ in this line.

@jonasschnelli

jonasschnelli Oct 10, 2017

Member

I always try to keep the surrounding code-folding style... and here, we have \n{ everywhere.

src/qt/transactionrecord.cpp
+ std::string address = "";
+ for (const CTxOut& txout : wtx.tx->vout)
+ {
+ if (wallet->IsChange(txout))
@promag

promag Oct 9, 2017

Contributor

One line? if (wallet->IsChange(txout)) continue;

src/qt/transactionrecord.cpp
+ {
+ continue;
+ }
+ if (wtx.tx->vout.size() == 2)
@promag

promag Oct 9, 2017

Contributor

This if can be moved up to guard the for loop (avoid the loop if transaction hasn't 2 outputs).

src/qt/transactionrecord.cpp
+ if (wtx.tx->vout.size() == 2)
+ {
+ CTxDestination destination;
+ if (ExtractDestination(txout.scriptPubKey, destination))
@promag

promag Oct 9, 2017

Contributor

{ in this line.

src/qt/transactiontablemodel.cpp
@@ -423,6 +423,7 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
case TransactionRecord::SendToOther:
return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::SendToSelf:
+ if (wtx->address != "") { return lookupAddress(wtx->address, tooltip) + watchAddress; }
@promag

promag Oct 9, 2017

Contributor
if (!wtx->address.empty()) return lookupAddress(wtx->address, tooltip) + watchAddress;
Owner

laanwj commented Oct 10, 2017

Optimizing rendering sounds good, do you have FPS numbers? :)

Sorry. Concept ACK.

Member

jonasschnelli commented Oct 10, 2017

Fixed @promag points.

Optimizing rendering sounds good, do you have FPS numbers? :)

Heh. Yes. Rending is maybe not the best word for decomposing a transactions.

Contributor

Sjors commented Nov 9, 2017

Concept ACK.

I can't get it to work. Before & After:
schermafbeelding 2017-11-09 om 12 56 28

I made a transaction from one non-segwit wallet address to another non-segwit wallet address, without change.

Maybe I'm doing something wrong?

I think we should remove "Payment to yourself" (and just show a send+receive pair), but this seems like a strict improvement.

@@ -423,6 +423,7 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b
case TransactionRecord::SendToOther:
return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::SendToSelf:
+ if (!wtx->address.empty()) { return lookupAddress(wtx->address, tooltip) + watchAddress; }
@luke-jr

luke-jr Nov 10, 2017

Member

Please document the intended fallthru.

luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Nov 11, 2017

luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Nov 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment