StrKey

object StrKey

StrKey is a helper class for encoding and decoding Stellar keys to/from strings. Stellar uses a base32 encoding with checksums called "strkey" for human-readable keys.

The decode contract

Every decodeX runs the same checks in the same order and reports the first one the string fails as an IllegalArgumentException:

  1. the character count is one the requested type has;

  2. every character is inside the ASCII range;

  3. the character count leaves no partially filled trailing character;

  4. every character is one of the 32 in BASE32_ALPHABET;

  5. the unused trailing bits of the last character are zero;

  6. the version byte names a strkey type;

  7. the decoded payload has a size that type admits;

  8. the framing that type defines inside its payload holds;

  9. the version byte names the type the caller asked for;

  10. the checksum matches the payload it covers.

Checks 2 and 4 answer one question - whether the string is written in the characters a strkey is written in - and report it in the same words. Check 5 has nothing to read for a type whose character count fills its last character, and check 8 nothing to read for a type whose payload is an opaque key of a fixed size.

Each decodeX documents only what its own type fixes: the character count it has, the version byte it is written under and the framing it defines. Each isValidX reports whether the matching decodeX accepts the string, so it is false wherever that decode throws.

Functions

Link copied to clipboard

Decodes strkey claimable balance ID (B...) to raw bytes

Link copied to clipboard

Decodes strkey contract address (C...) to raw bytes

Link copied to clipboard

Decodes strkey ed25519 public key (G...) to raw bytes

Link copied to clipboard

Decodes strkey ed25519 secret seed (S...) to raw bytes

Link copied to clipboard

Decodes strkey liquidity pool ID (L...) to raw bytes

Link copied to clipboard

Decodes strkey muxed ed25519 public key (M...) to raw bytes

Link copied to clipboard

Decodes strkey pre-authorized transaction hash (T...) to raw bytes

Link copied to clipboard

Decodes strkey SHA-256 hash (X...) to raw bytes

Link copied to clipboard

Decodes strkey signed payload (P...) to raw bytes

Link copied to clipboard

Encodes raw bytes to strkey claimable balance ID (B...)

Link copied to clipboard

Encodes raw bytes to strkey contract address (C...)

Link copied to clipboard

Encodes raw bytes to strkey ed25519 public key (G...)

Link copied to clipboard

Encodes raw bytes to strkey ed25519 secret seed (S...)

Link copied to clipboard

Encodes raw bytes to strkey liquidity pool ID (L...)

Link copied to clipboard

Encodes raw bytes to strkey muxed ed25519 public key (M...)

Link copied to clipboard

Encodes raw bytes to strkey pre-authorized transaction hash (T...)

Link copied to clipboard

Encodes raw bytes to strkey SHA-256 hash (X...)

Link copied to clipboard

Encodes raw bytes to strkey signed payload (P...)

Link copied to clipboard
fun isValidClaimableBalance(claimableBalanceId: String): Boolean

Checks validity of claimable balance ID (B...)

Link copied to clipboard

Checks validity of contract address (C...)

Link copied to clipboard

Checks validity of Stellar account ID (G...)

Link copied to clipboard

Checks validity of seed (S...)

Link copied to clipboard
fun isValidLiquidityPool(liquidityPoolId: String): Boolean

Checks validity of liquidity pool ID (L...)

Link copied to clipboard
fun isValidMed25519PublicKey(med25519PublicKey: String): Boolean

Checks validity of muxed ed25519 public key (M...)

Link copied to clipboard

Checks validity of pre-authorized transaction hash (T...)

Link copied to clipboard
fun isValidSha256Hash(sha256Hash: String): Boolean

Checks validity of SHA-256 hash (X...)

Link copied to clipboard
fun isValidSignedPayload(signedPayload: String): Boolean

Checks validity of signed payload (P...)