Changeset View
Changeset View
Standalone View
Standalone View
src/qt/guiutil.cpp
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | std::string DummyAddress(const CChainParams ¶ms) { | ||||
const CTxDestination dstKey = CKeyID(uint160(dummydata)); | const CTxDestination dstKey = CKeyID(uint160(dummydata)); | ||||
return MakeAddrInvalid(EncodeCashAddr(dstKey, params), params); | return MakeAddrInvalid(EncodeCashAddr(dstKey, params), params); | ||||
} | } | ||||
// Addresses are stored in the database with the encoding that the client was | // Addresses are stored in the database with the encoding that the client was | ||||
// configured with at the time of creation. | // configured with at the time of creation. | ||||
// | // | ||||
// This converts to clients current configuration. | // This converts to cashaddr. | ||||
QString convertToConfiguredAddressFormat(const Config &config, | QString convertToCashAddr(const CChainParams ¶ms, const QString &addr) { | ||||
const QString &addr) { | if (!IsValidDestinationString(addr.toStdString(), params)) { | ||||
if (!IsValidDestinationString(addr.toStdString(), | |||||
config.GetChainParams())) { | |||||
// We have something sketchy as input. Do not try to convert. | // We have something sketchy as input. Do not try to convert. | ||||
return addr; | return addr; | ||||
} | } | ||||
CTxDestination dst = | CTxDestination dst = DecodeDestination(addr.toStdString(), params); | ||||
DecodeDestination(addr.toStdString(), config.GetChainParams()); | return QString::fromStdString(EncodeCashAddr(dst, params)); | ||||
return QString::fromStdString(EncodeDestination(dst, config)); | |||||
} | } | ||||
void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent) { | void setupAddressWidget(QValidatedLineEdit *widget, QWidget *parent) { | ||||
parent->setFocusProxy(widget); | parent->setFocusProxy(widget); | ||||
widget->setFont(fixedPitchFont()); | widget->setFont(fixedPitchFont()); | ||||
// We don't want translators to use own addresses in translations | // We don't want translators to use own addresses in translations | ||||
// and this is the only place, where this address is supplied. | // and this is the only place, where this address is supplied. | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | bool parseBitcoinURI(const QString &scheme, QString uri, | ||||
// which will lower-case it (and thus invalidate the address). | // which will lower-case it (and thus invalidate the address). | ||||
if (uri.startsWith(scheme + "://", Qt::CaseInsensitive)) { | if (uri.startsWith(scheme + "://", Qt::CaseInsensitive)) { | ||||
uri.replace(0, scheme.length() + 3, scheme + ":"); | uri.replace(0, scheme.length() + 3, scheme + ":"); | ||||
} | } | ||||
QUrl uriInstance(uri); | QUrl uriInstance(uri); | ||||
return parseBitcoinURI(scheme, uriInstance, out); | return parseBitcoinURI(scheme, uriInstance, out); | ||||
} | } | ||||
QString formatBitcoinURI(const Config &config, const SendCoinsRecipient &info) { | QString formatBitcoinURI(const SendCoinsRecipient &info) { | ||||
QString ret = info.address; | QString ret = convertToCashAddr(Params(), info.address); | ||||
if (!config.UseCashAddrEncoding()) { | |||||
// prefix address with uri scheme for base58 encoded addresses. | |||||
ret = (bitcoinURIScheme(config) + ":%1").arg(ret); | |||||
} | |||||
int paramCount = 0; | int paramCount = 0; | ||||
if (info.amount != Amount::zero()) { | if (info.amount != Amount::zero()) { | ||||
ret += | ret += | ||||
QString("?amount=%1") | QString("?amount=%1") | ||||
.arg(BitcoinUnits::format(BitcoinUnits::BCH, info.amount, false, | .arg(BitcoinUnits::format(BitcoinUnits::BCH, info.amount, false, | ||||
BitcoinUnits::separatorNever)); | BitcoinUnits::separatorNever)); | ||||
paramCount++; | paramCount++; | ||||
▲ Show 20 Lines • Show All 773 Lines • Show Last 20 Lines |