long_hash decode_mnemonic(const word_list& mnemonic) { const auto sentence = join(mnemonic); const std::string salt(passphrase_prefix); return pkcs5_pbkdf2_hmac_sha512(to_chunk(sentence), to_chunk(salt), hmac_iterations); }
long_hash decode_mnemonic(const word_list& mnemonic, const std::string& passphrase) { const auto sentence = join(mnemonic); const std::string prefix(passphrase_prefix); const auto salt = to_normal_nfkd_form(prefix + passphrase); return pkcs5_pbkdf2_hmac_sha512(to_chunk(sentence), to_chunk(salt), hmac_iterations); }
bool minikey_to_secret(ec_secret& out_secret, const std::string& key) { if (!check_minikey(key)) return false; out_secret = sha256_hash(to_chunk(key)); return true; }
operation::stack operation::to_pay_script_hash_pattern(const short_hash& hash) { return operation::stack { operation{ opcode::hash160, data_chunk() }, operation{ opcode::special, to_chunk(hash) }, operation{ opcode::equal, data_chunk() } }; }
operation::stack operation::to_pay_key_hash_pattern(const short_hash& hash) { return operation::stack { operation{ opcode::dup, data_chunk() }, operation{ opcode::hash160, data_chunk() }, operation{ opcode::special, to_chunk(hash) }, operation{ opcode::equalverify, data_chunk() }, operation{ opcode::checksig, data_chunk() } }; }
operation::stack operation::to_pay_public_key_pattern(data_slice point) { if (!is_point(point)) return operation::stack(); return operation::stack { operation{ opcode::special, to_chunk(point) }, operation{ opcode::checksig, data_chunk() } }; }
operation::stack operation::to_null_data_pattern(data_slice data) { if (data.size() > max_null_data_size) return operation::stack(); return operation::stack { operation{ opcode::return_, data_chunk() }, operation{ opcode::special, to_chunk(data) } }; }
operation::stack operation::to_pay_multisig_pattern(uint8_t signatures, const std::vector<ec_compressed>& points) { const auto conversion = [](const ec_compressed& point) { return to_chunk(point); }; std::vector<data_chunk> chunks(points.size()); std::transform(points.begin(), points.end(), chunks.begin(), conversion); return to_pay_multisig_pattern(signatures, chunks); }
void outgoing::send(czmqpp::socket& socket) const { czmqpp::message message; // Optional, ROUTER sockets strip this. if (!destination_.empty()) message.append(destination_); message.append({ command_.begin(), command_.end() }); message.append(to_chunk(to_little_endian(id_))); message.append(data_); message.send(socket); }
void outgoing_message::send(czmqpp::socket& socket) const { czmqpp::message message; // [ DESTINATION ] (optional - ROUTER sockets strip this) if (!dest_.empty()) message.append(dest_); // [ COMMAND ] append_str(message, command_); // [ ID ] auto raw_id = to_chunk(to_little_endian(id_)); BITCOIN_ASSERT(raw_id.size() == sizeof(id_)); message.append(raw_id); // [ DATA ] message.append(data_); // Send. message.send(socket); }
static hash_digest address_hash(const payment_address& address) { return bitcoin_hash(to_chunk(address.encoded())); }
// This call requires an ICU build, the other excluded calls are dependencies. static data_chunk normal(const std::string& passphrase) { return to_chunk(to_normal_nfc_form(passphrase)); }
bool check_minikey(const std::string& minikey) { // Legacy minikeys are 22 chars long bool valid = minikey.size() == 22 || minikey.size() == 30; return valid && sha256_hash(to_chunk(minikey + "?"))[0] == 0x00; }