Пример #1
0
 uchar_vector fromBase58ExtKey(const std::string& extKey) {
     static unsigned int dummy = 0;
     uchar_vector fillKey;
     fromBase58Check(extKey, fillKey, dummy);
     static const std::string VERSION_BYTE("04");
     return uchar_vector(VERSION_BYTE+fillKey.getHex()); //append VERSION_BYTE to begining
 }
Пример #2
0
PaymentRequest::PaymentRequest(const QUrl& url)
{
    if (url.scheme().compare(VALID_URL_SCHEME, Qt::CaseInsensitive) != 0) {
        throw std::runtime_error(QObject::tr("Invalid payment request URL scheme").toStdString());
    }

    QString path = url.path();
    address_ = path.section(';', 0, 0);
    hasAddress_ = !address_.isEmpty();
    if (!hasAddress_) {
        throw std::runtime_error(QObject::tr("Payment address is missing").toStdString());
    }

    QStringList versionParts = path.section(';', 1).split('=');
    hasVersion_ = versionParts.count() != 1;
    if (hasVersion_) {
        if (versionParts.count() != 2 || versionParts[0] != "version") {
            throw std::runtime_error(QObject::tr("Payment version is invalid").toStdString());
        }
        version_ = versionParts[1];
    }

    bytes_t payload;
    unsigned int addressVersion;
    if (!fromBase58Check(address_.toStdString(), payload, addressVersion, BASE58_CHARS) || payload.size() != ADDRESS_DATA_SIZE ||
        [&]() { for (int i = 0; i < VALID_VERSION_COUNT; i++) { if (addressVersion == VALID_ADDRESS_VERSIONS[i]) return false; } return true; }()) {

        throw std::runtime_error(QObject::tr("Invalid payment address").toStdString());
    }

    QUrlQuery query(url);

    hasValue_ = query.hasQueryItem("amount");
    if (hasValue_) value_ = parseAmount(query.queryItemValue("amount"));

    hasLabel_ = query.hasQueryItem("label");
    if (hasLabel_) label_ = query.queryItemValue("label");

    hasMessage_ = query.hasQueryItem("message");
    if (hasMessage_) message_ = query.queryItemValue("message");

    hasSend_ = query.hasQueryItem("send");
    if (hasSend_) send_ = query.queryItemValue("send");
}
Пример #3
0
secure_bytes_t ImportBIP32Dialog::getExtendedKey() const
{
    secure_bytes_t extkey;
    if (!fromBase58Check(m_base58Edit->text().toStdString(), extkey)) throw std::runtime_error("Invalid BIP32.");
    return extkey;
}