#bitcoin #cash #address #key

app rscash

Rust比特币现金库

1个不稳定版本

0.0.1 2019年10月25日

#24#cash

MIT 许可证

5KB

rscash

Rust比特币现金库

入门

安装

首先将 rscash 添加到您的 Cargo.toml 文件的 dependencies 块中。

[dependencies]
rscash = "0.0.1"

用法

extern crate bitcoin;
extern crate secp256k1;

use bitcoin::{
    network::constants::Network,
    util::{address::Address, key, key::PublicKey},
};
use secp256k1::{rand::thread_rng, Secp256k1};

fn main() {
    let s: Secp256k1<_> = Secp256k1::new();
    let public_key: PublicKey = key::PublicKey {
        compressed: true,
        key: s.generate_keypair(&mut thread_rng()).1,
    };
    // Generate pay-to-pubkey-hash address
    let address: Address = Address::p2pkh(&public_key, Network::Bitcoin);
    println!("Hello, {}!", address);
}

然后运行它时

cargo run
   Compiling rscash v0.0.1 (/Users/username/rscash)
    Finished dev [unoptimized + debuginfo] target(s) in 0.48s
     Running `target/debug/rscash`
Hello, 1HZ3X63fM5mWJbMpwhEXVFysXoQgxCjCXn!

依赖关系

~2.2–4.5MB
~74K SLoC