Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added transaction categories for beacon and voting #973

Closed
wants to merge 8 commits into from
Closed

Added transaction categories for beacon and voting #973

wants to merge 8 commits into from

Conversation

Pythonix
Copy link
Contributor

I have added two new transaction categories. One for voting and one for sending the beacon.
The category for sending the Beacon does not yet have its own icon.
image

This would close #389

@iFoggz
Copy link
Member

iFoggz commented Feb 27, 2018

We use 4 spaces not tabs
no spaces after a {
ex:

if (currentcondition == statecondition)
{
1234command structure here
}

if (a == b)
{
1234command structure here
}

void dummyfunction()
{
1234command structure here.
}

Like the idea so please clean it up cheers

1234 is the spacing since i havent had my coffee yet and forgot the code block

@@ -163,8 +164,31 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
if (ExtractDestination(txout.scriptPubKey, address))
{
// Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress;
sub.address = CBitcoinAddress(address).ToString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                // Sent to testnet or mainnet vote / beacon address
                if (sub.address == GetBurnAddress())
                {
                    std::vector<std::pair<std::string, std::string>> vTxNormalInfoIn = GetTxNormalBoincHashInfo(wtx);
                    for (const auto& vTxNormalInfo : vTxNormalInfoIn)
                    {
                        if (vTxNormalInfo.first == "Message Type")
                        {
                            if (vTxNormalInfo.second == "Vote" || vTxNormalInfo.second == "Add Poll")
                            {
                                if (fDebug)
                                    OutputDebugStringF("Vote/Add Poll\n");

                                sub.type = TransactionRecord::Vote;

                                break;
                            }

                            else if (vTxNormalInfo.second == "Add Beacon Contract")
                            {
                                sub.type = TransactionRecord::Beacon;

                                break;
                            }
                            /* Message icon example as well
                            else if (vTxNormalInfo.second == "Text Message")
                            {
                                sub.type TransactionRecord::Message;

                                break;
                            }
                            */
                            // Message type is not one we are checking for. end the for auto loop
                            else
                                break;
                        }
                    }
                }
            }

that is likely better @denravonska may chime in that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Message icon part is if u add a message icon change as i asked

@@ -2,13 +2,14 @@
#include "wallet.h"
#include "base58.h"

std::vector<std::pair<std::string, std::string>> GetTxNormalBoincHashInfo(const CMerkleTx& mtx);
std::string GetTxProject(uint256 hash, int& out_blocknumber, int& out_blocktype, double& out_rac);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if u use the suggested code block below add here
std::string GetBurnAddress();

@tomasbrod
Copy link
Member

tomasbrod commented Feb 27, 2018

I do not remember you @Pythonix. Please do not take the white-space criticism personally. It is a minor thing. Either fix it or say you won't.
I am saying that, because I was new too and got pissed of by white-space complaints.

@Pythonix
Copy link
Contributor Author

I don't take it personally. I'm glade for the help @Foggyx420 offered me and I'm happy to change my code.

@iFoggz
Copy link
Member

iFoggz commented Feb 28, 2018

I wasn't criticizing at all. N I did help him get it going.

@denravonska
Copy link
Member

denravonska commented Feb 28, 2018

@Pythonix @tomasbrod Don't just say you won't do it unless you can argue why, other than lazyness. I have a 3-year old who does that and it's super annoying.

added categories for send/receive message and send/receive rain
@iFoggz
Copy link
Member

iFoggz commented Feb 28, 2018

@denravonska travis fails to find the icon file idk if it has not pulled it from the pr or its just a travis issue. I successfully compiled his branch for that icon locally linux 64

@TheCharlatan
Copy link
Contributor

The .svg file needs to be added to the RES_ICONS file list in Makefile.qt.include. This should fix the travis issue.

@TheCharlatan
Copy link
Contributor

There is still one error: The SendMessage enum seems to conflict with a macro when compiling with mingw32. Either add

#undef SENDMESSAGE
#undef SendMessage

To transactionrecord.h and .cpp and transactiontablemodel.cpp , or rename the SendMessage enum to something that does not conflict.

Copy link
Member

@tomasbrod tomasbrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have a look how this could be improved.

typeWidget->addItem(tr("Vote"), TransactionFilterProxy::TYPE(TransactionRecord::Vote));
typeWidget->addItem(tr("Beacon"), TransactionFilterProxy::TYPE(TransactionRecord::Beacon));
typeWidget->addItem(tr("Sent message"), TransactionFilterProxy::TYPE(TransactionRecord::SendMessage));
typeWidget->addItem(tr("Received message"), TransactionFilterProxy::TYPE(TransactionRecord::RecvMessage));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the transaction is "To yourself" "Sent message" and "Received message" at the same time?

std::vector<std::pair<std::string, std::string>> vTxNormalInfoIn = GetTxNormalBoincHashInfo(wtx);
for (const auto& vTxNormalInfo : vTxNormalInfoIn)
{
if (vTxNormalInfo.first == "Message Type")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably fail when localized.

SendToSelf,
Vote,
Beacon,
SendMessage,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Macros are evil in c++. I suggest the #undef option.

@jamescowens jamescowens modified the milestones: Camilla, Denise Mar 7, 2019
@jamescowens jamescowens modified the milestones: Denise, Elizabeth Mar 30, 2019
@jamescowens jamescowens modified the milestones: Elizabeth, Fern Aug 8, 2019
@iFoggz
Copy link
Member

iFoggz commented Aug 21, 2019

Anything left to be done with this?

Copy link
Member

@jamescowens jamescowens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Tomas is right. The vTxNormalInfo stuff... "Message Type" is not safe under localization. We need to rethink this...

@jamescowens
Copy link
Member

@iFoggz There are a lot of changes that were made to transactionrecord.cpp for sidestaking that are going to make the merge resolution very tricky.

@iFoggz
Copy link
Member

iFoggz commented Aug 24, 2019

Localization as in language of the client user?

The data stored in the blocks for messages, etc is unaffected by the translations as those are done at compile for what we have slated to have available translations.

Example the boincHash stuff always in english.
If a chinese user sends a chinese message to a user they receive the message in chinese however the boincHash is still the way it is coded.
vTxNormalInfo is always in same format regardless of localization. if it wasn't we would have to compensate for every localization

I cannot tie anything here that suggests translation macros would affect our core code or block boincHash format.

If anyone has any ideas of this please let me know.

as for merge conflicts since other areas have been done it will be better to redo this ontop of current code base to make this more clean and more fitting into existing changes.

@jamescowens
Copy link
Member

jamescowens commented Aug 24, 2019 via email

@jamescowens
Copy link
Member

So we have confirmed that localization is not an issue here. We have a lot of conflicts in transactionrecord.cpp because this was extensively modified for sidestaking. Given that, ifoggz is going to redo this on top of the head of development and put up another PR to control the regression risk. I concur with that strategy. We will leave this open until the new PR is up.

@cyrossignol
Copy link
Member

This implementation uses GetTxNormalBoincHashInfo() which applies localization to the identifiers that these changes rely on for categorizing the transactions:

res.push_back(std::make_pair(_("Message Type"), _("Add Beacon Contract")));

As it is written here, we'll get the desired behavior de facto because none of the translation units contain a valid substitution for those identifiers yet. If someone adds localization for those in a language besides English, the categorization will break when the wallet is configured to use that language:

if (vTxNormalInfo.first == "Message Type")

To avoid the localization issue, we need to remove the localization from GetTxNormalBoincHashInfo() or write a new routine that tags the transactions with real constants.

@jamescowens
Copy link
Member

The issue with doing your second option is that it is not backwards facing, whereas playing games with the messages is a UI model only thing that is entirely local on the node. Bad set of choices IMHO.

@cyrossignol
Copy link
Member

@jamescowens Sorry for being unclear--I'm not suggesting any changes to the protocol. The second solution that I proposed should just do what the wallet already does here but in a way that doesn't rely on localized strings. The GetTxNormalBoincHashInfo() function just parses a transaction into a presentation structure for output. The changes in this PR just need a similar structure that's not dependent on localization (so we're still only playing games in the UI code 🙂 ).

@jamescowens
Copy link
Member

@iFoggz ^ See @cyrossignol's comments.

@iFoggz
Copy link
Member

iFoggz commented Sep 17, 2019

this should be redone on latest commits.and GetTxNormalBoincHashInfo just reads whats in the transaction if does not have anything to do with language localization but i will look to redo most this and from there. i have not reviewed most of this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Highlight beacon transactions in wallet
7 participants