本文整理汇总了C++中payment_address::encoded方法的典型用法代码示例。如果您正苦于以下问题:C++ payment_address::encoded方法的具体用法?C++ payment_address::encoded怎么用?C++ payment_address::encoded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类payment_address
的用法示例。
在下文中一共展示了payment_address::encoded方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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();
}
示例5: history_fetched
void 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;
}
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);
}
std::cout << "Address: " << payaddr.encoded() << std::endl;
std::cout << " Paid balance: " << balance << std::endl;
std::cout << " Pending balance: " << pending_balance << std::endl;
std::cout << " Total received: " << total_recv << 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();
}
示例6: 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;
}
示例7: address_hash
static hash_digest address_hash(const payment_address& address)
{
return bitcoin_hash(to_chunk(address.encoded()));
}