Crate coins_core[][src]

coins-core is an abstract description of UTXO transactions. It provides a collection of traits that provide consistent interfaces to UTXO transaction construction. Coins’s traits ensure that types are consistent across all steps in the tx construction process, and allow for code reuse when building transactions on multiple chains (e.g. Bitcoin Mainnet and Bitcoin Testnet).

Many concepts familiar to UTXO chain developers have been genericized. Transactions are modeled as a collection of Inputs and Outputs. Rather than addresses or scripts, the Output trait has an associated RecipientIdentifier. Similarly, rather than an outpoint, the Input trait has an associated TXOIdentfier.

Support for other chains may be added by implementing these traits. We have provided an implementation suitable for Bitcoin chains (mainnet, testnet, and signet) in the bitcoins crate.

Re-exports

pub use prelude::*;

Modules

builder

The builder module defines an abstract TxBuilder trait. A concrete implementation for Bitcoin can be found in the bitcoin crate

enc

Holds generalized encoding tools. This includes an AddressEncoder and bech32 encoding and decoding functionality.

hashes

Holds utilites for working with cryptographic digests, and disambiguating digests via marker traits.

macros

Useful macros for implementing new chains

nets

The nets module defines an abstract Network. The Network trait is a highly-abstracted representation of the relationships between types in a UTXO network. Concrete implementations for various Bitcoin networks are found in the bitcoin crate.

prelude

Re-exports of common types.

ser

A simple trait for binary (de)Serialization using std Read and Write traits.

types

Holds generic types useful describing transactions. The Transaction trait conceptualizes UTXO transactions as a list of inputs and outputs, and allows implementations to define what those are precisely.

Macros

impl_hex_serde

Implement serde::Serialize and serde::Deserialize by passing through to the hex

impl_script_conversion

Implement conversion between script types by passing via as_ref().into()

marked_digest

Instantiate a new marked digest. Wraps the output of some type that implemented digest::Digest

wrap_prefixed_byte_vector

Wrap a prefixed vector of bytes (u8) in a newtype, and implement convenience functions for it.