MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetPaymentRequestMerchant

Function GetPaymentRequestMerchant

src/qt/transactiondesc.cpp:54–78  ·  view source on GitHub ↗

Takes an encoded PaymentRequest as a string and tries to find the Common Name of the X.509 certificate used to sign the PaymentRequest.

Source from the content-addressed store, hash-verified

52// Takes an encoded PaymentRequest as a string and tries to find the Common Name of the X.509 certificate
53// used to sign the PaymentRequest.
54bool GetPaymentRequestMerchant(const std::string& pr, QString& merchant)
55{
56 // Search for the supported pki type strings
57 if (pr.find(std::string({0x12, 0x0b}) + "x509+sha256") != std::string::npos || pr.find(std::string({0x12, 0x09}) + "x509+sha1") != std::string::npos) {
58 // We want the common name of the Subject of the cert. This should be the second occurrence
59 // of the bytes 0x0603550403. The first occurrence of those is the common name of the issuer.
60 // After those bytes will be either 0x13 or 0x0C, then length, then either the ascii or utf8
61 // string with the common name which is the merchant name
62 size_t cn_pos = pr.find({0x06, 0x03, 0x55, 0x04, 0x03});
63 if (cn_pos != std::string::npos) {
64 cn_pos = pr.find({0x06, 0x03, 0x55, 0x04, 0x03}, cn_pos + 5);
65 if (cn_pos != std::string::npos) {
66 cn_pos += 5;
67 if (pr[cn_pos] == 0x13 || pr[cn_pos] == 0x0c) {
68 cn_pos++; // Consume the type
69 int str_len = pr[cn_pos];
70 cn_pos++; // Consume the string length
71 merchant = QString::fromUtf8(pr.data() + cn_pos, str_len);
72 return true;
73 }
74 }
75 }
76 }
77 return false;
78}
79
80QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wallet, TransactionRecord *rec, int unit)
81{

Callers 1

toHTMLMethod · 0.85

Calls 2

findMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected