如何为 Windows 安装“libbitcoin”库?

问题描述 投票:0回答:0

我正在读《精通比特币》这本书,里面有这样的代码:

#include <bitcoin/bitcoin.hpp>

int main()
{
// Private secret key string as base16
bc::ec_secret decoded;
bc::decode_base16(decoded,
"038109007313a5807b2eccc082c8c3fbb988a973cacf1a7df9ce725c31b14776");
bc::wallet::ec_private secret(
decoded, bc::wallet::ec_private::mainnet_p2kh);
// Get public key.
bc::wallet::ec_public public_key(secret);
std::cout << "Public key: " << public_key.encoded() << std::endl;
// Create Bitcoin address.
// Normally you can use:
// bc::wallet::payment_address payaddr =
// public_key.to_payment_address(
// bc::wallet::ec_public::mainnet_p2kh);
// const std::string address = payaddr.encoded();
// Compute hash of public key for P2PKH address.
bc::data_chunk public_key_data;
public_key.to_data(public_key_data);
const auto hash = bc::bitcoin_short_hash(public_key_data);
bc::data_chunk unencoded_address;
// Reserve 25 bytes
// [ version:1 ]
// [ hash:20 ]
// [ checksum:4 ]
unencoded_address.reserve(25);
// Version byte, 0 is normal BTC address (P2PKH).
unencoded_address.push_back(0);
// Hash data
bc::extend_data(unencoded_address, hash);
// Checksum is computed by hashing data, and adding 4 bytes from hash.
bc::append_checksum(unencoded_address);
// Finally we must encode the result in Bitcoin's base58 encoding.
assert(unencoded_address.size() == 25);
const std::string address = bc::encode_base58(unencoded_address);
std::cout << "Address: " << address << std::endl;
return 0;
}

我知道“#include ”必须替换为#include 。但是,在他们的 gitHub 存储库中,他们说 libbitcoin 在 Nuget 上可用,但我找不到它(对于 C++)。他们还说 Nuget 中的所有包都是分开的 - “boost,boost_atomic ...”。那么现在,我如何下载这个库并将其设置在我的 Visual Studio (2022) 中并包含“system.hpp”。

我试过:

  1. 逐步下载,但文件configure.ac只是作为VS代码文件打开。
  2. 安装boost,但没有任何“system.hpp”。
c++ bitcoin bitcoinlib
© www.soinside.com 2019 - 2024. All rights reserved.