Changeset View
Changeset View
Standalone View
Standalone View
src/qt/guiutil.cpp
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static bool IsCashAddrEncoded(const QUrl &uri) { | static bool IsCashAddrEncoded(const QUrl &uri) { | ||||
const std::string addr = (uri.scheme() + ":" + uri.path()).toStdString(); | const std::string addr = (uri.scheme() + ":" + uri.path()).toStdString(); | ||||
auto decoded = cashaddr::Decode(addr); | auto decoded = cashaddr::Decode(addr); | ||||
return !decoded.first.empty(); | return !decoded.first.empty(); | ||||
} | } | ||||
bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) { | bool parseBitcoinURI(const QString &scheme, const QUrl &uri, | ||||
// return if URI is not valid or is no bitcoincash: URI | SendCoinsRecipient *out) { | ||||
if (!uri.isValid() || uri.scheme() != URI_SCHEME) return false; | // return if URI has wrong scheme. | ||||
if (!uri.isValid() || uri.scheme() != scheme) { | |||||
return false; | |||||
} | |||||
SendCoinsRecipient rv; | SendCoinsRecipient rv; | ||||
if (IsCashAddrEncoded(uri)) { | if (IsCashAddrEncoded(uri)) { | ||||
rv.address = uri.scheme() + ":" + uri.path(); | rv.address = uri.scheme() + ":" + uri.path(); | ||||
} else { | } else { | ||||
// strip out uri scheme for base58 encoded addresses | // strip out uri scheme for base58 encoded addresses | ||||
rv.address = uri.path(); | rv.address = uri.path(); | ||||
} | } | ||||
Show All 40 Lines | for (QList<QPair<QString, QString>>::iterator i = items.begin(); | ||||
} | } | ||||
} | } | ||||
if (out) { | if (out) { | ||||
*out = rv; | *out = rv; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool parseBitcoinURI(QString uri, SendCoinsRecipient *out) { | bool parseBitcoinURI(const QString &scheme, QString uri, | ||||
// Convert bitcoincash:// to bitcoincash: | SendCoinsRecipient *out) { | ||||
// | // | ||||
// Cannot handle this later, because bitcoincash:// | // Cannot handle this later, because bitcoincash:// | ||||
// will cause Qt to see the part after // as host, | // will cause Qt to see the part after // as host, | ||||
// which will lower-case it (and thus invalidate the address). | // which will lower-case it (and thus invalidate the address). | ||||
if (uri.startsWith(URI_SCHEME + "://", Qt::CaseInsensitive)) { | if (uri.startsWith(scheme + "://", Qt::CaseInsensitive)) { | ||||
uri.replace(0, URI_SCHEME.length() + 3, URI_SCHEME + ":"); | uri.replace(0, scheme.length() + 3, scheme + ":"); | ||||
} | } | ||||
QUrl uriInstance(uri); | QUrl uriInstance(uri); | ||||
return parseBitcoinURI(uriInstance, out); | return parseBitcoinURI(scheme, uriInstance, out); | ||||
} | } | ||||
QString formatBitcoinURI(const Config &cfg, const SendCoinsRecipient &info) { | QString formatBitcoinURI(const Config &cfg, const SendCoinsRecipient &info) { | ||||
QString ret = info.address; | QString ret = info.address; | ||||
if (!cfg.UseCashAddrEncoding()) { | if (!cfg.UseCashAddrEncoding()) { | ||||
// prefix address with uri scheme for base58 encoded addresses. | // prefix address with uri scheme for base58 encoded addresses. | ||||
ret = (URI_SCHEME + ":%1").arg(ret); | ret = (URI_SCHEME + ":%1").arg(ret); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 763 Lines • Show Last 20 Lines |