Changeset View
Changeset View
Standalone View
Standalone View
src/qt/guiutil.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | |||||
// Just some dummy data to generate an convincing random-looking (but | // Just some dummy data to generate an convincing random-looking (but | ||||
// consistent) address | // consistent) address | ||||
static const uint8_t dummydata[] = { | static const uint8_t dummydata[] = { | ||||
0xeb, 0x15, 0x23, 0x1d, 0xfc, 0xeb, 0x60, 0x92, 0x58, 0x86, 0xb6, 0x7d, | 0xeb, 0x15, 0x23, 0x1d, 0xfc, 0xeb, 0x60, 0x92, 0x58, 0x86, 0xb6, 0x7d, | ||||
0x06, 0x52, 0x99, 0x92, 0x59, 0x15, 0xae, 0xb1, 0x72, 0xc0, 0x66, 0x47}; | 0x06, 0x52, 0x99, 0x92, 0x59, 0x15, 0xae, 0xb1, 0x72, 0xc0, 0x66, 0x47}; | ||||
// Generate a dummy address with invalid CRC, starting with the network prefix. | // Generate a dummy address with invalid CRC, starting with the network prefix. | ||||
static std::string DummyAddress(const CChainParams ¶ms) { | static std::string DummyAddress(const CChainParams ¶ms) { | ||||
std::vector<uint8_t> sourcedata = | std::vector<unsigned char> sourcedata = | ||||
params.Base58Prefix(CChainParams::PUBKEY_ADDRESS); | params.Base58Prefix(CChainParams::PUBKEY_ADDRESS); | ||||
sourcedata.insert(sourcedata.end(), dummydata, | sourcedata.insert(sourcedata.end(), dummydata, | ||||
dummydata + sizeof(dummydata)); | dummydata + sizeof(dummydata)); | ||||
for (int i = 0; i < 256; ++i) { // Try every trailing byte | for (int i = 0; i < 256; ++i) { // Try every trailing byte | ||||
std::string s = EncodeBase58(sourcedata.data(), | std::string s = EncodeBase58(sourcedata.data(), | ||||
sourcedata.data() + sourcedata.size()); | sourcedata.data() + sourcedata.size()); | ||||
if (!CBitcoinAddress(s).IsValid()) return s; | if (!IsValidDestinationString(s)) { | ||||
return s; | |||||
} | |||||
sourcedata[sourcedata.size() - 1] += 1; | sourcedata[sourcedata.size() - 1] += 1; | ||||
} | } | ||||
return ""; | return ""; | ||||
} | } | ||||
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent) { | void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent) { | ||||
parent->setFocusProxy(widget); | parent->setFocusProxy(widget); | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | if (!info.message.isEmpty()) { | ||||
QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg); | QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg); | ||||
paramCount++; | paramCount++; | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
bool isDust(const QString &address, const CAmount &amount) { | bool isDust(const QString &address, const CAmount &amount) { | ||||
CTxDestination dest = CBitcoinAddress(address.toStdString()).Get(); | CTxDestination dest = DecodeDestination(address.toStdString()); | ||||
CScript script = GetScriptForDestination(dest); | CScript script = GetScriptForDestination(dest); | ||||
CTxOut txOut(amount, script); | CTxOut txOut(amount, script); | ||||
return txOut.IsDust(dustRelayFee); | return txOut.IsDust(dustRelayFee); | ||||
} | } | ||||
QString HtmlEscape(const QString &str, bool fMultiLine) { | QString HtmlEscape(const QString &str, bool fMultiLine) { | ||||
#if QT_VERSION < 0x050000 | #if QT_VERSION < 0x050000 | ||||
QString escaped = Qt::escape(str); | QString escaped = Qt::escape(str); | ||||
▲ Show 20 Lines • Show All 730 Lines • Show Last 20 Lines |