本文整理汇总了C++中payment_address::set方法的典型用法代码示例。如果您正苦于以下问题:C++ payment_address::set方法的具体用法?C++ payment_address::set怎么用?C++ payment_address::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类payment_address
的用法示例。
在下文中一共展示了payment_address::set方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: set_script
void set_script(payment_address& address, const script_type& eval_script)
{
address.set(payment_address::script_version,
bitcoin_short_hash(save_script(eval_script)));
}
示例5: set_public_key
void set_public_key(payment_address& address, const data_chunk& public_key)
{
address.set(payment_address::pubkey_version,
bitcoin_short_hash(public_key));
}
示例6: set_script_hash
void set_script_hash(payment_address& address,
const short_hash& script_hash)
{
address.set(payment_address::script_version, script_hash);
}
示例7: set_public_key_hash
void set_public_key_hash(payment_address& address,
const short_hash& pubkey_hash)
{
address.set(payment_address::pubkey_version, pubkey_hash);
}
示例8: set_script
bool set_script(payment_address& address, const script& eval_script)
{
return address.set(payment_type::script_hash,
generate_ripemd_hash(save_script(eval_script)));
}
示例9: set_public_key
bool set_public_key(payment_address& address, const data_chunk& public_key)
{
return address.set(payment_type::pubkey_hash,
generate_ripemd_hash(public_key));
}
示例10: set_script_hash
bool set_script_hash(payment_address& address,
const short_hash& script_hash)
{
return address.set(payment_type::script_hash, script_hash);
}
示例11: set_public_key_hash
bool set_public_key_hash(payment_address& address,
const short_hash& pubkey_hash)
{
return address.set(payment_type::pubkey_hash, pubkey_hash);
}