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

Fix incorrect beacon length warning in GUI transaction list #1585

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/qt/bitcoinstrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Compute Neural Network Hashes..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Connect only to the specified node(s)"),
QT_TRANSLATE_NOOP("bitcoin-core", "Connect through socks proxy"),
QT_TRANSLATE_NOOP("bitcoin-core", "Connect to a node to retrieve peer addresses, and disconnect"),
QT_TRANSLATE_NOOP("bitcoin-core", "Contract length for beacon is less then 256 in length. Size: "),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid beacon contract. Size: "),
QT_TRANSLATE_NOOP("bitcoin-core", "Current Neural Hash"),
QT_TRANSLATE_NOOP("bitcoin-core", "Data"),
QT_TRANSLATE_NOOP("bitcoin-core", "Delete Beacon Contract"),
Expand Down
14 changes: 8 additions & 6 deletions src/rpcrawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,23 @@ std::vector<std::pair<std::string, std::string>> GetTxNormalBoincHashInfo(const
{
res.push_back(std::make_pair(_("Message Type"), _("Add Beacon Contract")));

std::string sBeaconEncodedContract = ExtractXML(msg, "<MV>", "</MV>");
bool invalid = false;
const std::string sBeaconEncodedContract = ExtractXML(msg, "<MV>", "</MV>");
const std::string sBeaconDecodedContract = DecodeBase64(sBeaconEncodedContract, &invalid);

if (sBeaconEncodedContract.length() < 256)
if (invalid)
{
// If for whatever reason the contract is not a proper one and the average length does exceed this size; Without this a seg fault will occur on the DecodeBase64
// Another example is if an admin accidently uses add instead of delete in addkey to remove a beacon the 1 in <MV>1</MV> would cause a seg fault as well
res.push_back(std::make_pair(_("ERROR"), _("Contract length for beacon is less then 256 in length. Size: ") + ToString(sBeaconEncodedContract.length())));
// If for whatever reason the contract is not a proper one.
// Another example is if an admin accidently uses add instead
// of delete in addkey to remove a beacon the 1 in <MV>1</MV>
res.push_back(std::make_pair(_("ERROR"), _("Invalid beacon contract. Size: ") + ToString(sBeaconEncodedContract.length())));

if (fDebug)
res.push_back(std::make_pair(_("Message Data"), sBeaconEncodedContract));

return res;
}

std::string sBeaconDecodedContract = DecodeBase64(sBeaconEncodedContract);
std::vector<std::string> vBeaconContract = split(sBeaconDecodedContract.c_str(), ";");
std::string sBeaconAddress = vBeaconContract[2];
std::string sBeaconPublicKey = vBeaconContract[3];
Expand Down