6 releases (3 breaking)

0.7.0 Jul 6, 2022
0.6.0 Dec 20, 2021
0.3.0 Jul 6, 2021
0.2.3 Jun 20, 2021
0.2.2 Apr 4, 2021

#37 in #handshake

25 downloads per month

LGPL-3.0-or-later

125KB
2.5K SLoC

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

Dependencies

~6MB
~110K SLoC