Changeset View
Changeset View
Standalone View
Standalone View
src/qt/paymentserver.cpp
Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | for (int i = 1; i < argc; i++) { | ||||
// "wrong network" error. | // "wrong network" error. | ||||
if (arg.startsWith(GUIUtil::URI_SCHEME + ":", | if (arg.startsWith(GUIUtil::URI_SCHEME + ":", | ||||
Qt::CaseInsensitive)) // bitcoincash: URI | Qt::CaseInsensitive)) // bitcoincash: URI | ||||
{ | { | ||||
savedPaymentRequests.append(arg); | savedPaymentRequests.append(arg); | ||||
SendCoinsRecipient r; | SendCoinsRecipient r; | ||||
if (GUIUtil::parseBitcoinURI(arg, &r) && !r.address.isEmpty()) { | if (GUIUtil::parseBitcoinURI(arg, &r) && !r.address.isEmpty()) { | ||||
CBitcoinAddress address(r.address.toStdString()); | if (IsValidDestinationString(r.address.toStdString(), | ||||
Params(CBaseChainParams::MAIN))) { | |||||
if (address.IsValid(Params(CBaseChainParams::MAIN))) { | |||||
SelectParams(CBaseChainParams::MAIN); | SelectParams(CBaseChainParams::MAIN); | ||||
} else if (address.IsValid(Params(CBaseChainParams::TESTNET))) { | } else if (IsValidDestinationString( | ||||
r.address.toStdString(), | |||||
Params(CBaseChainParams::TESTNET))) { | |||||
SelectParams(CBaseChainParams::TESTNET); | SelectParams(CBaseChainParams::TESTNET); | ||||
} | } | ||||
} | } | ||||
} else if (QFile::exists(arg)) { | } else if (QFile::exists(arg)) { | ||||
// Filename | // Filename | ||||
savedPaymentRequests.append(arg); | savedPaymentRequests.append(arg); | ||||
PaymentRequestPlus request; | PaymentRequestPlus request; | ||||
▲ Show 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | #endif | ||||
CClientUIInterface::ICON_WARNING); | CClientUIInterface::ICON_WARNING); | ||||
} | } | ||||
return; | return; | ||||
} else { | } else { | ||||
// normal URI | // normal URI | ||||
SendCoinsRecipient recipient; | SendCoinsRecipient recipient; | ||||
if (GUIUtil::parseBitcoinURI(s, &recipient)) { | if (GUIUtil::parseBitcoinURI(s, &recipient)) { | ||||
CBitcoinAddress address(recipient.address.toStdString()); | if (!IsValidDestinationString( | ||||
if (!address.IsValid()) { | recipient.address.toStdString())) { | ||||
Q_EMIT message( | Q_EMIT message( | ||||
tr("URI handling"), | tr("URI handling"), | ||||
tr("Invalid payment address %1").arg(recipient.address), | tr("Invalid payment address %1").arg(recipient.address), | ||||
CClientUIInterface::MSG_ERROR); | CClientUIInterface::MSG_ERROR); | ||||
} else | } else | ||||
Q_EMIT receivedPaymentRequest(recipient); | Q_EMIT receivedPaymentRequest(recipient); | ||||
} else | } else | ||||
Q_EMIT message( | Q_EMIT message( | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | bool PaymentServer::processPaymentRequest(const PaymentRequestPlus &request, | ||||
QList<std::pair<CScript, CAmount>> sendingTos = request.getPayTo(); | QList<std::pair<CScript, CAmount>> sendingTos = request.getPayTo(); | ||||
QStringList addresses; | QStringList addresses; | ||||
for (const std::pair<CScript, CAmount> &sendingTo : sendingTos) { | for (const std::pair<CScript, CAmount> &sendingTo : sendingTos) { | ||||
// Extract and check destination addresses | // Extract and check destination addresses | ||||
CTxDestination dest; | CTxDestination dest; | ||||
if (ExtractDestination(sendingTo.first, dest)) { | if (ExtractDestination(sendingTo.first, dest)) { | ||||
// Append destination address | // Append destination address | ||||
addresses.append( | addresses.append(QString::fromStdString(EncodeDestination(dest))); | ||||
QString::fromStdString(CBitcoinAddress(dest).ToString())); | |||||
} else if (!recipient.authenticatedMerchant.isEmpty()) { | } else if (!recipient.authenticatedMerchant.isEmpty()) { | ||||
// Unauthenticated payment requests to custom bitcoin addresses are | // Unauthenticated payment requests to custom bitcoin addresses are | ||||
// not supported (there is no good way to tell the user where they | // not supported (there is no good way to tell the user where they | ||||
// are paying in a way they'd have a chance of understanding). | // are paying in a way they'd have a chance of understanding). | ||||
Q_EMIT message(tr("Payment request rejected"), | Q_EMIT message(tr("Payment request rejected"), | ||||
tr("Unverified payment requests to custom payment " | tr("Unverified payment requests to custom payment " | ||||
"scripts are unsupported."), | "scripts are unsupported."), | ||||
CClientUIInterface::MSG_ERROR); | CClientUIInterface::MSG_ERROR); | ||||
▲ Show 20 Lines • Show All 259 Lines • Show Last 20 Lines |