Exemple #1
0
bool version::from_data(reader& source)
{
    reset();
    value = source.read_4_bytes_little_endian();
    services = source.read_8_bytes_little_endian();
    timestamp = source.read_8_bytes_little_endian();
    auto result = static_cast<bool>(source);
    if (result)
        result = address_me.from_data(source, false);

    if (result && (value >= 106))
    {
        result = address_you.from_data(source, false);
        nonce = source.read_8_bytes_little_endian();
        user_agent = source.read_string();
        if (value >= 209)
            start_height = source.read_4_bytes_little_endian();

        // The satoshi client treats 209 as the "initial protocol version"
        // and disconnects peers below 31800 (for getheaders support).
        if (value >= 70001)
            relay = (source.read_byte() != 0);

        result &= source;
    }

    if (!result)
        reset();

    return result;
}
bool alert_payload::from_data(reader& source)
{
    reset();

    version = source.read_4_bytes_little_endian();
    relay_until = source.read_8_bytes_little_endian();
    expiration = source.read_8_bytes_little_endian();
    id = source.read_4_bytes_little_endian();
    cancel = source.read_4_bytes_little_endian();

    uint64_t set_cancel_size = source.read_variable_uint_little_endian();
    for (uint64_t i = 0; i < set_cancel_size && source; i++)
        set_cancel.push_back(source.read_4_bytes_little_endian());

    min_version = source.read_4_bytes_little_endian();
    max_version = source.read_4_bytes_little_endian();

    uint64_t set_sub_version_size = source.read_variable_uint_little_endian();
    for (uint64_t i = 0; i < set_sub_version_size && source; i++)
        set_sub_version.push_back(source.read_string());

    priority = source.read_4_bytes_little_endian();
    comment = source.read_string();
    status_bar = source.read_string();
    reserved = source.read_string();

    if (!source)
        reset();

    return source;
}
// Avoid point reuse due to affect on store tx serialization.
bool payment_record::from_data(reader& source, bool wire)
{
    valid_ = true;
    output_ = (source.read_byte() == 1);

    if (wire)
    {
        height_ = source.read_4_bytes_little_endian();
        link_ = unlinked;
        hash_ = source.read_hash();
        index_ = source.read_4_bytes_little_endian();
    }
    else
    {
        height_ = 0;
        link_ = source.read_8_bytes_little_endian();
        hash_ = null_hash;
        index_ = source.read_2_bytes_little_endian();

        // Convert 16 bit sentinel to 32 bit sentinel.
        if (index_ == max_uint16)
            index_ = point::null_index;
    }

    data_ = source.read_8_bytes_little_endian();

    if (!source)
        reset();

    return source;
}
Exemple #4
0
bool nonce_::from_data(reader& source)
{
    reset();

    nonce = source.read_8_bytes_little_endian();

    if (!source)
        reset();

    return source;
}
Exemple #5
0
bool output::from_data(reader& source)
{
    reset();
    value = source.read_8_bytes_little_endian();
    auto result = static_cast<bool>(source);

    if (result)
        result = script.from_data(source, true, 
        script::parse_mode::raw_data_fallback);

    if (!result)
        reset();

    return result;
}
Exemple #6
0
bool output::from_data(reader& source)
{
    auto result = true;

    reset();

    value = source.read_8_bytes_little_endian();
    result = source;

    if (result)
        result = script.from_data(source, true, script::parse_mode::strict);

    if (!result)
        reset();

    return result;
}
bool send_compact::from_data(uint32_t version,
    reader& source)
{
    reset();

    const auto mode = source.read_byte();

    if (mode > 1)
        source.invalidate();

    high_bandwidth_mode_ = (mode == 1);
    this->version_ = source.read_8_bytes_little_endian();

    if (version < send_compact::version_minimum)
        source.invalidate();

    if (!source)
        reset();

    return source;
}