Crate spark_address

Source
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 the secp256k1 crate.

§MSRV

Minimum supported Rust version: 1.70.

Structs§

SparkAddressData
Result of a successful decode, or input to encode.

Enums§

Network
Networks supported by Spark.
SparkAddressError

Functions§

decode_spark_address
Decode a Spark address, returning (pubkey, network).
encode_spark_address
Encode a (pubkey, network) into a Spark Bech32m address.