• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ payment_address类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中payment_address的典型用法代码示例。如果您正苦于以下问题:C++ payment_address类的具体用法?C++ payment_address怎么用?C++ payment_address使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了payment_address类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: do_fetch_outputs

void bdb_blockchain::do_fetch_outputs(const payment_address& address,
    fetch_handler_outputs handle_fetch)
{
    // Associated outputs
    message::output_point_list assoc_outs;
    txn_guard_ptr txn = std::make_shared<txn_guard>(env_);
    Dbc* cursor;
    db_address_->cursor(txn->get(), &cursor, 0);
    BITCOIN_ASSERT(cursor != nullptr);
    readable_data_type key;
    // version byte + hash for key
    serializer serial;
    serial.write_byte(address.version());
    serial.write_short_hash(address.hash());
    key.set(serial.data());
    writable_data_type value;
    int ret = cursor->get(key.get(), value.get(), DB_SET);
    while (ret != DB_NOTFOUND)
    {
        message::output_point outpoint;
        // We need a copy not a temporary
        data_chunk raw_outpoint(value.data());
        // Then read the value off
        deserializer deserial(raw_outpoint);
        outpoint.hash = deserial.read_hash();
        outpoint.index = deserial.read_4_bytes();
        assoc_outs.push_back(outpoint);
        ret = cursor->get(key.get(), value.get(), DB_NEXT_DUP);
    }
    cursor->close();
    txn->commit();
    handle_fetch(std::error_code(), assoc_outs);
}
开发者ID:da2ce7,项目名称:libbitcoin,代码行数:33,代码来源:bdb_blockchain.cpp


示例2: post_updates

void subscribe_manager::post_updates(const payment_address& address,
    size_t height, const bc::hash_digest& block_hash,
    const bc::transaction_type& tx)
{
    auto range = subs_.equal_range(address);
    // Avoid expensive serialization if not needed.
    if (range.first == range.second)
        return;
    // [ addr,version ] (1 byte)
    // [ addr.hash ] (20 bytes)
    // [ height ] (4 bytes)
    // [ block_hash ] (32 bytes)
    // [ tx ]
    constexpr size_t info_size = 1 + short_hash_size + 4 + hash_size;
    data_chunk data(info_size + satoshi_raw_size(tx));
    auto serial = make_serializer(data.begin());
    serial.write_byte(address.version());
    serial.write_short_hash(address.hash());
    serial.write_4_bytes(height);
    serial.write_hash(block_hash);
    BITCOIN_ASSERT(serial.iterator() == data.begin() + info_size);
    // Now write the tx part.
    auto rawtx_end_it = satoshi_save(tx, serial.iterator());
    BITCOIN_ASSERT(rawtx_end_it == data.end());
    // Send the result to everyone interested.
    for (auto it = range.first; it != range.second; ++it)
    {
        const subscription& sub_detail = it->second;
        outgoing_message update(
            sub_detail.client_origin, "address.update", data);
        sub_detail.queue_send(update);
    }
}
开发者ID:BWallet,项目名称:obelisk,代码行数:33,代码来源:subscribe_manager.cpp


示例3: set_raw_address

 void set_raw_address(const payment_address& address)
 {
     BITCOIN_ASSERT(raw_address_.size() == 1 + short_hash_size);
     auto serial = make_serializer(raw_address_.begin());
     serial.write_byte(address.version());
     serial.write_short_hash(address.hash());
     BITCOIN_ASSERT(
         std::distance(raw_address_.begin(), serial.iterator()) ==
         1 + short_hash_size);
 }
开发者ID:favioflamingo,项目名称:libbitcoin,代码行数:10,代码来源:leveldb_blockchain.cpp


示例4: wrap_fetch_history_args

void wrap_fetch_history_args(data_chunk& data,
    const payment_address& address, size_t from_height)
{
    data.resize(1 + short_hash_size + 4);
    auto serial = make_serializer(data.begin());
    serial.write_byte(address.version());
    serial.write_short_hash(address.hash());
    serial.write_4_bytes(from_height);
    BITCOIN_ASSERT(serial.iterator() == data.end());
}
开发者ID:grazcoin,项目名称:obelisk,代码行数:10,代码来源:fetch_x.cpp


示例5: create_address_key

data_chunk create_address_key(
    const payment_address& address, const output_point& outpoint)
{
    data_chunk result(1 + short_hash_size + 8);
    auto serial = make_serializer(result.begin());
    serial.write_byte(address.version());
    serial.write_short_hash(address.hash());
    serial.write_8_bytes(addr_key_checksum(outpoint));
    BITCOIN_ASSERT(serial.iterator() == result.end());
    return result;
}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:11,代码来源:leveldb_common.cpp


示例6: subscribe

void address_subscriber::subscribe(const payment_address& address,
    update_handler handle_update, subscribe_handler handle_subscribe)
{
    data_chunk data(1 + short_hash_size);
    auto serial = make_serializer(data.begin());
    serial.write_byte(address.version());
    serial.write_short_hash(address.hash());
    BITCOIN_ASSERT(serial.iterator() == data.end());
    backend_.request("address.subscribe", data,
        strand_.wrap(&address_subscriber::receive_subscribe_result,
            this, _1, _2, address, handle_update, handle_subscribe));
}
开发者ID:grazcoin,项目名称:obelisk,代码行数:12,代码来源:interface.cpp


示例7: address_fetch_history

BC_API void obelisk_codec::address_fetch_history(error_handler&& on_error,
    fetch_history_handler&& on_reply,
    const payment_address& address, size_t from_height)
{
    auto data = build_data({
        to_byte(address.version()),
        reverse(address.hash()),
        to_little_endian<uint32_t>(from_height)
    });

    send_request("address.fetch_history", data, std::move(on_error),
        std::bind(decode_fetch_history, _1, std::move(on_reply)));
}
开发者ID:BitcoinKinetics,项目名称:airbitz-core,代码行数:13,代码来源:obelisk_codec.cpp


示例8: build_output_script

bool build_output_script(
    script_type& out_script, const payment_address& payaddr)
{
    switch (payaddr.version())
    {
        case payment_address::pubkey_version:
            out_script = build_pubkey_hash_script(payaddr.hash());
            return true;

        case payment_address::script_version:
            out_script = build_script_hash_script(payaddr.hash());
            return true;
    }
    return false;
}
开发者ID:throughnothing,项目名称:sx,代码行数:15,代码来源:mktx.cpp


示例9: display_history

static void display_history(const std::error_code& code,
    const history_list& history, const payment_address& address,
    std::ostream& output)
{
    const auto encoded_address = address.encoded();

    if (code)
    {
        output << format(BN_FETCH_HISTORY_FAIL) % encoded_address %
            code.message();
        return;
    }

    output << format(BN_FETCH_HISTORY_SUCCESS) % encoded_address;

    for (const auto& row: history)
    {
        const auto hash = bc::encode_hash(row.point.hash);
        if (row.id == point_ident::output)
            output << format(BN_FETCH_HISTORY_OUTPUT) % hash %
                row.point.index % row.height % row.value;
        else
            output << format(BN_FETCH_HISTORY_INPUT) % hash %
                row.point.index % row.height % row.value;
    }
}
开发者ID:libmetrocoin,项目名称:libmetrocoin-node,代码行数:26,代码来源:dispatch.cpp


示例10: add_stealth_info

void add_stealth_info(const data_chunk& stealth_data,
    const payment_address& address, const hash_digest& tx_hash,
    stealth_database& db)
{
    const stealth_bitfield bitfield = calculate_bitfield(stealth_data);
    const data_chunk ephemkey = read_ephemkey(stealth_data);
    auto write_func = [&](uint8_t *it)
    {
        auto serial = make_serializer(it);
        serial.write_uint_auto(bitfield);
        serial.write_data(ephemkey);
        serial.write_byte(address.version());
        serial.write_short_hash(address.hash());
        serial.write_hash(tx_hash);
        BITCOIN_ASSERT(serial.iterator() == it + bitfield_size + 33 + 21 + 32);
    };
    db.store(write_func);
}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:18,代码来源:leveldb_common.cpp


示例11: payaddr_from_stdin

bool payaddr_from_stdin(payment_address& payaddr)
{
    if (!payaddr.set_encoded(read_stdin()))
    {
        std::cerr << "balance: Invalid address." << std::endl;
        return false;
    }
    return true;
}
开发者ID:BitcoinKinetics,项目名称:sx,代码行数:9,代码来源:balance.cpp


示例12: fetch_outputs

void bdb_blockchain::fetch_outputs(const payment_address& address,
    fetch_handler_outputs handle_fetch)
{
    if (address.type() != payment_type::pubkey_hash)
        handle_fetch(error::unsupported_payment_type,
            message::output_point_list());
    else
        queue(
            std::bind(&bdb_blockchain::do_fetch_outputs,
                this, address, handle_fetch));
}
开发者ID:da2ce7,项目名称:libbitcoin,代码行数:11,代码来源:bdb_blockchain.cpp


示例13: json_history_fetched

void json_history_fetched(const payment_address& payaddr,
                          const std::error_code& ec, const blockchain::history_list& history)
{
    if (ec)
    {
        std::cerr << "history: Failed to fetch history: "
                  << ec.message() << std::endl;
        return;
    }
    bool is_first = true;
    for (const auto& row: history)
    {
        // Put commas between each array item in json output.
        if (is_first)
            is_first = false;
        else
            std::cout << "," << std::endl;
        // Actual row data.
        std::cout << "{" << std::endl;
        std::cout << "  \"address\": \"" << payaddr.encoded()
                  << "\"," << std::endl;
        std::cout << "  \"output\": \"" << row.output
                  << "\"," << std::endl;
        std::cout << "  \"output_height\": ";
        if (!row.output_height)
            std::cout << "\"Pending\"";
        else
            std::cout << row.output_height;
        std::cout << "," << std::endl;
        std::cout << "  \"value\":  \"" << row.value << "\"," << std::endl;
        if (row.spend.hash == null_hash)
        {
            std::cout << "  \"spend\": \"Unspent\"," << std::endl;
            std::cout << "  \"spend_height\": \"Unspent\"" << std::endl;
        }
        else
        {
            std::cout << "  \"spend\": \"" << row.spend << "\"," << std::endl;
            std::cout << "  \"spend_height\": ";
            if (!row.spend_height)
                std::cout << "\"Pending\"";
            else
                std::cout << "\"" << row.spend_height << "\"";
        }
        std::cout << "}";
    }
    std::lock_guard<std::mutex> lock(mutex);
    BITCOIN_ASSERT(remaining_count != std::numeric_limits<int>::max());
    --remaining_count;
    condition.notify_one();
    if (remaining_count > 0)
        std::cout << ",";
    std::cout << std::endl;
}
开发者ID:veox,项目名称:sx,代码行数:54,代码来源:history.cpp


示例14: fetch_history

void blockchain_impl::fetch_history(const payment_address& address,
    fetch_handler_history handle_fetch, const uint64_t limit, 
    const uint64_t from_height)
{
    const auto do_fetch = [=](size_t slock)
    {
        const auto history = interface_.history.get(
            address.hash(), limit, from_height);
        return finish_fetch(slock, handle_fetch, std::error_code(), history);
    };
    fetch(do_fetch);
}
开发者ID:libmetrocoin,项目名称:libmetrocoin-blockchain,代码行数:12,代码来源:blockchain_impl.cpp


示例15: json_history_fetched

void json_history_fetched(const payment_address& payaddr,
    const std::error_code& ec, const blockchain::history_list& history)
{
    if (ec)
    {
        std::cerr << "balance: Failed to fetch history: "
            << ec.message() << std::endl;
        return;
    }
    bool is_first = true;
    uint64_t total_recv = 0, balance = 0, pending_balance = 0;
    for (const auto& row: history)
    {
        uint64_t value = row.value;
        BITCOIN_ASSERT(value >= 0);
        total_recv += value;
        // Unconfirmed balance.
        if (row.spend.hash == null_hash)
        {
            pending_balance += value;
        }
        // Confirmed balance.
        if (row.output_height &&
            (row.spend.hash == null_hash || !row.spend_height))
        {
            balance += value;
        }
        BITCOIN_ASSERT(total_recv >= balance);
        BITCOIN_ASSERT(total_recv >= pending_balance);
    }

    // Put commas between each array item in json output.
    if (is_first)
        is_first = false;
    else
        std::cout << "," << std::endl;
    // Actual row data.
    std::cout << "{" << std::endl;
    std::cout << "  \"address\": \"" << payaddr.encoded()
        << "\"," << std::endl;
    std::cout << "  \"paid\":  \"" << balance << "\"," << std::endl;
    std::cout << "  \"pending\":  \"" << pending_balance << "\"," << std::endl;
    std::cout << "  \"received\":  \"" << total_recv << "\"" << std::endl;
    std::cout << "}";
    std::lock_guard<std::mutex> lock(mutex);
    BITCOIN_ASSERT(remaining_count != std::numeric_limits<int>::max());
    --remaining_count;
    condition.notify_one();
    if (remaining_count > 0)
        std::cout << ",";
    std::cout << std::endl;
}
开发者ID:BitcoinKinetics,项目名称:sx,代码行数:52,代码来源:balance.cpp


示例16: extract

		bool extract(payment_address& address, const script_type& script)
		{
			// Cast a data_chunk to a short_hash and set the address
			auto set_hash_data =
				[&address](uint8_t version, const data_chunk& raw_hash)
			{
				short_hash hash_data;
				BITCOIN_ASSERT(raw_hash.size() == hash_data.size());
				std::copy(raw_hash.begin(), raw_hash.end(), hash_data.begin());
				address.set(version, hash_data);
			};
			const operation_stack& ops = script.operations();
			payment_type pay_type = script.type();
			switch (pay_type)
			{
			case payment_type::pubkey:
				BITCOIN_ASSERT(ops.size() == 2);
				set_public_key(address, ops[0].data);
				return true;

			case payment_type::pubkey_hash:
				BITCOIN_ASSERT(ops.size() == 5);
				set_hash_data(payment_address::pubkey_version, ops[2].data);
				return true;

			case payment_type::script_hash:
				BITCOIN_ASSERT(ops.size() == 3);
				set_hash_data(payment_address::script_version, ops[1].data);
				return true;

			case payment_type::multisig:
				// Unimplemented...
				return false;

			case payment_type::pubkey_hash_sig:
				BITCOIN_ASSERT(ops.size() == 2);
				set_public_key(address, ops[1].data);
				return true;

			case payment_type::script_code_sig:
				// Should have at least 1 sig and the script code.
				BITCOIN_ASSERT(ops.size() > 1);
				set_script_hash(address,
					bitcoin_short_hash(ops.back().data));
				return true;

			default:
				return false;
			}
			// Should never happen!
			return false;
		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:52,代码来源:address.cpp


示例17: deserialize_address

bool deserialize_address(payment_address& addr, const data_chunk& data)
{
    auto deserial = make_deserializer(data.begin(), data.end());
    try
    {
        uint8_t version_byte = deserial.read_byte();
        short_hash hash = deserial.read_short_hash();
        addr.set(version_byte, hash);
    }
    catch (end_of_stream)
    {
        return false;
    }
    if (deserial.iterator() != data.end())
        return false;
    return true;
}
开发者ID:BWallet,项目名称:obelisk,代码行数:17,代码来源:subscribe_manager.cpp


示例18: unwrap_fetch_history_args

bool unwrap_fetch_history_args(
    payment_address& payaddr, uint32_t& from_height,
    const incoming_message& request)
{
    const data_chunk& data = request.data();
    if (data.size() != 1 + short_hash_size + 4)
    {
        log_error(LOG_WORKER)
            << "Incorrect data size for .fetch_history";
        return false;
    }
    auto deserial = make_deserializer(data.begin(), data.end());
    uint8_t version_byte = deserial.read_byte();
    short_hash hash = deserial.read_short_hash();
    from_height = deserial.read_4_bytes();
    BITCOIN_ASSERT(deserial.iterator() == data.end());
    payaddr.set(version_byte, hash);
    return true;
}
开发者ID:BitcoinKinetics,项目名称:obelisk,代码行数:19,代码来源:fetch_x.cpp


示例19: history_fetched

void history_fetched(const payment_address& payaddr,
                     const std::error_code& ec, const blockchain::history_list& history)
{
    if (ec)
    {
        std::cerr << "history: Failed to fetch history: "
                  << ec.message() << std::endl;
        return;
    }
    for (const auto& row: history)
    {
        std::cout << "Address: " << payaddr.encoded() << std::endl;
        std::cout << "  output: " << row.output << std::endl;
        std::cout << "  output_height: ";
        if (!row.output_height)
            std::cout << "Pending";
        else
            std::cout << row.output_height;
        std::cout << std::endl;
        std::cout << "  value:  " << row.value << std::endl;
        if (row.spend.hash == null_hash)
        {
            std::cout << "  spend: Unspent" << std::endl;
            std::cout << "  spend_height: Unspent" << std::endl;
        }
        else
        {
            std::cout << "  spend: " << row.spend << std::endl;
            std::cout << "  spend_height: ";
            if (!row.spend_height)
                std::cout << "Pending";
            else
                std::cout << row.spend_height;
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    std::lock_guard<std::mutex> lock(mutex);
    BITCOIN_ASSERT(remaining_count != std::numeric_limits<int>::max());
    --remaining_count;
    condition.notify_one();
}
开发者ID:veox,项目名称:sx,代码行数:42,代码来源:history.cpp


示例20: history_fetched

void history_fetched(const payment_address& payaddr,
    const std::error_code& ec, const blockchain::history_list& history)
{
    if (ec)
    {
        std::cerr << "history: Failed to fetch history: "
            << ec.message() << std::endl;
        return;
    }
    for (const auto& row: history)
    {
        std::cout << "Address: " << payaddr.encoded() << std::endl;
        std::cout << "  output: " << row.output << std::endl;
        std::cout << "  output_height: ";
        if (!row.output_height)
            std::cout << "Pending";
        else
            std::cout << row.output_height;
        std::cout << std::endl;
        std::cout << "  value:  " << row.value << std::endl;
        if (row.spend.hash == null_hash)
        {
            std::cout << "  spend: Unspent" << std::endl;
            std::cout << "  spend_height: Unspent" << std::endl;
        }
        else
        {
            std::cout << "  spend: " << row.spend << std::endl;
            std::cout << "  spend_height: ";
            if (!row.spend_height)
                std::cout << "Pending";
            else
                std::cout << row.spend_height;
            std::cout << std::endl;
        }
        std::cout << std::endl;
    }
    --remaining_count;
}
开发者ID:Bobalot,项目名称:sx,代码行数:39,代码来源:history.cpp



注:本文中的payment_address类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pdvector类代码示例发布时间:2022-05-31
下一篇:
C++ path_type类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap