handshakes

Crates.iohandshakes
lib.rshandshakes
version0.7.0
sourcesrc
created_at2021-04-04 18:26:24.808946
updated_at2022-07-06 19:36:07.921812
descriptionHandshake transaction construction in Rust
homepage
repositoryhttps://github.com/summa-tx/riemann-rs
max_upload_size
id378900
size125,173
James Prestwich (prestwich)

documentation

README

handshakes

This crate provides an interface for interacting with the Handshake network. Build, serialize and deserialize transactions with full covenant support. The coins-bip32 crate can be used with this crate to sign transactions.

This crate is under active development, and the API may change.

Usage

Typically, you'll want to use a network as an entry point. It will ensure that the correct network specific constants are used. The tx_builder is useful for creating and serializing transactions.

use coins_core::{builder::TxBuilder, nets::Network, ByteFormat};
use std::convert::TryFrom;

use handshakes::{
    types::{Covenant, CovenantData, CovenantType, HandshakeTx, Outpoint},
    HandshakeMainnet,
};

// Create a covenant
let covenant = Covenant {
    covenant_type: CovenantType::try_from("NONE").unwrap(),
    covenant_data: CovenantData::null(),
};

// Create an address
let address = HandshakeMainnet::string_to_address("hs1qcu0cff5ma6uxgy0ffkmgsj28ucqwtqt9eqnp06").unwrap();

// Build a transaction
let tx = HandshakeMainnet::tx_builder()
    .spend(Outpoint::default(), 0x00000000)
    .pay_covenant(0x8000_0000, &address, covenant)
    .build()
    .unwrap();

let hex = tx.serialize_hex();
let serialized = HandshakeTx::deserialize_hex(&hex).unwrap();

assert_eq!(tx, serialized);

See the documentation for more details.

Building & Running Tests

  • cargo build
  • cargo test
  • build the docs: $ cargo rustdoc
Commit count: 377

cargo fmt