Expand description
Minimal Spark address codec.
Avoids unsafe code and works in no_std
+ alloc
environments.
§Crate Overview
The spark-address crate encodes & decodes Spark Bech32m addresses. A Spark
address couples a compressed secp256k1 public key with a network identifier
(see Network
) and represents them as human-friendly Bech32m strings like
sp1…
or sprt1…
.
use spark_address::{encode_spark_address, decode_spark_address, SparkAddressData, Network};
let pubkey = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798";
let data = SparkAddressData { identity_public_key: pubkey.into(), network: Network::Mainnet };
let addr = encode_spark_address(&data)?;
let decoded = decode_spark_address(&addr)?;
assert_eq!(decoded, data);
§Feature Flags
std
(default) — Use the Rust standard library. Disable to build for#![no_std]
+alloc
targets.validate-secp256k1
— Validate the public key using thesecp256k1
crate.
§MSRV
Minimum supported Rust version: 1.70.
Structs§
- Spark
Address Data - Result of a successful decode, or input to
encode
.
Enums§
- Network
- Networks supported by Spark.
- Spark
Address Error
Functions§
- decode_
spark_ address - Decode a Spark address, returning
(pubkey, network)
. - encode_
spark_ address - Encode a
(pubkey, network)
into a Spark Bech32m address.