Crate coins_core
source ·Expand description
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 Input
s and Output
s. 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
- Contains simplified access to
bech32
andbase58check
encoder/decoder for Bitcoin addresses. Also defines common encoder errors. - Holds utilites for working with cryptographic digests, and disambiguating digests via marker traits.
- Useful macros for implementing new chains
- Re-exports of common types.
- A simple trait for binary (de)Serialization using std
Read
andWrite
traits.
Macros
- Implement
serde::Serialize
andserde::Deserialize
by passing through to the hex - Implement conversion between script types by passing via
as_ref().into()
- Instantiate a new marked digest. Wraps the output of some type that implemented
digest::Digest
- Wrap a prefixed vector of bytes (
u8
) in a newtype, and implement convenience functions for it.