MCPcopy Create free account
hub / github.com/bitcoinxt/bitcoinxt / processPaymentRequest

Method processPaymentRequest

src/qt/paymentserver.cpp:527–617  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527bool PaymentServer::processPaymentRequest(const PaymentRequestPlus& request, SendCoinsRecipient& recipient)
528{
529 if (!optionsModel)
530 return false;
531
532 if (request.IsInitialized()) {
533 // Payment request network matches client network?
534 if (!verifyNetwork(request.getDetails())) {
535 Q_EMIT message(tr("Payment request rejected"), tr("Payment request network doesn't match client network."),
536 CClientUIInterface::MSG_ERROR);
537
538 return false;
539 }
540
541 // Make sure any payment requests involved are still valid.
542 // This is re-checked just before sending coins in WalletModel::sendCoins().
543 if (verifyExpired(request.getDetails())) {
544 Q_EMIT message(tr("Payment request rejected"), tr("Payment request expired."),
545 CClientUIInterface::MSG_ERROR);
546
547 return false;
548 }
549 } else {
550 Q_EMIT message(tr("Payment request error"), tr("Payment request is not initialized."),
551 CClientUIInterface::MSG_ERROR);
552
553 return false;
554 }
555
556 recipient.paymentRequest = request;
557 recipient.message = GUIUtil::HtmlEscape(request.getDetails().memo());
558
559 request.getMerchant(PaymentServer::certStore, recipient.authenticatedMerchant);
560
561 QList<std::pair<CScript, CAmount> > sendingTos = request.getPayTo();
562 QStringList addresses;
563
564 Q_FOREACH(const PAIRTYPE(CScript, CAmount)& sendingTo, sendingTos) {
565 // Extract and check destination addresses
566 CTxDestination dest;
567 if (ExtractDestination(sendingTo.first, dest)) {
568 // Append destination address
569 addresses.append(QString::fromStdString(CBitcoinAddress(dest).ToString()));
570 }
571 else if (!recipient.authenticatedMerchant.isEmpty()) {
572 // Unauthenticated payment requests to custom bitcoin addresses are not supported
573 // (there is no good way to tell the user where they are paying in a way they'd
574 // have a chance of understanding).
575 Q_EMIT message(tr("Payment request rejected"),
576 tr("Unverified payment requests to custom payment scripts are unsupported."),
577 CClientUIInterface::MSG_ERROR);
578 return false;
579 }
580
581 // Bitcoin amounts are stored as (optional) uint64 in the protobuf messages (see paymentrequest.proto),
582 // but CAmount is defined as int64_t. Because of that we need to verify that amounts are in a valid range
583 // and no overflow has happened.
584 if (!verifyAmount(sendingTo.second)) {

Callers

nothing calls this directly

Calls 5

HtmlEscapeFunction · 0.85
IsInitializedMethod · 0.80
getMerchantMethod · 0.80
getPayToMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected