Skip to content

Commit 9f113f1

Browse files
authored
Merge pull request #1585 from cyrossignol/fix-beacon-length-warning
Fix incorrect beacon length warning in GUI transaction list
2 parents ccd9f0d + f35ea99 commit 9f113f1

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/qt/bitcoinstrings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Compute Neural Network Hashes..."),
140140
QT_TRANSLATE_NOOP("bitcoin-core", "Connect only to the specified node(s)"),
141141
QT_TRANSLATE_NOOP("bitcoin-core", "Connect through socks proxy"),
142142
QT_TRANSLATE_NOOP("bitcoin-core", "Connect to a node to retrieve peer addresses, and disconnect"),
143-
QT_TRANSLATE_NOOP("bitcoin-core", "Contract length for beacon is less then 256 in length. Size: "),
143+
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid beacon contract. Size: "),
144144
QT_TRANSLATE_NOOP("bitcoin-core", "Current Neural Hash"),
145145
QT_TRANSLATE_NOOP("bitcoin-core", "Data"),
146146
QT_TRANSLATE_NOOP("bitcoin-core", "Delete Beacon Contract"),

src/rpcrawtransaction.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,23 @@ std::vector<std::pair<std::string, std::string>> GetTxNormalBoincHashInfo(const
114114
{
115115
res.push_back(std::make_pair(_("Message Type"), _("Add Beacon Contract")));
116116

117-
std::string sBeaconEncodedContract = ExtractXML(msg, "<MV>", "</MV>");
117+
bool invalid = false;
118+
const std::string sBeaconEncodedContract = ExtractXML(msg, "<MV>", "</MV>");
119+
const std::string sBeaconDecodedContract = DecodeBase64(sBeaconEncodedContract, &invalid);
118120

119-
if (sBeaconEncodedContract.length() < 256)
121+
if (invalid)
120122
{
121-
// 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
122-
// 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
123-
res.push_back(std::make_pair(_("ERROR"), _("Contract length for beacon is less then 256 in length. Size: ") + ToString(sBeaconEncodedContract.length())));
123+
// If for whatever reason the contract is not a proper one.
124+
// Another example is if an admin accidently uses add instead
125+
// of delete in addkey to remove a beacon the 1 in <MV>1</MV>
126+
res.push_back(std::make_pair(_("ERROR"), _("Invalid beacon contract. Size: ") + ToString(sBeaconEncodedContract.length())));
124127

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

128131
return res;
129132
}
130133

131-
std::string sBeaconDecodedContract = DecodeBase64(sBeaconEncodedContract);
132134
std::vector<std::string> vBeaconContract = split(sBeaconDecodedContract.c_str(), ";");
133135
std::string sBeaconAddress = vBeaconContract[2];
134136
std::string sBeaconPublicKey = vBeaconContract[3];

0 commit comments

Comments
 (0)