Package org.stellar.sdk
Class StrKey
java.lang.Object
org.stellar.sdk.StrKey
StrKey is a helper class that allows encoding and decoding Stellar keys to/from strings, i.e.
between their binary and string (i.e. "GABCD...", etc.) representations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
decodeClaimableBalance
(String data) Decodes strkey claimable balance ID (B...) to raw bytes.static byte[]
decodeContract
(String data) Decodes strkey contract ID (C...) to raw bytes.static byte[]
decodeEd25519PublicKey
(String data) Decodes strkey ed25519 public key (G...) to raw datastatic byte[]
decodeEd25519SecretSeed
(char[] data) Decodes strkey ed25519 seed char array (S...) to raw bytesstatic byte[]
decodeLiquidityPool
(String data) Decodes strkey liquidity pool ID (L...) to raw bytes.static byte[]
Decodes strkey Stellar med25519 public key (M...) to raw bytesstatic MuxedAccount
decodeMuxedAccount
(String address) Deprecated.static byte[]
decodePreAuthTx
(String data) Decodes strkey PreAuthTx (T...) to raw bytesstatic byte[]
decodeSha256Hash
(String data) Decodes strkey SHA256 hash (X...) to raw bytesstatic SignedPayloadSigner
decodeSignedPayload
(String data) Decodes strkey signed payload (P...) toSignedPayloadSigner
static String
encodeClaimableBalance
(byte[] data) Encodes raw data to strkey claimable balance ID (B...)static String
encodeContract
(byte[] data) Encodes raw data to strkey contract ID (C...)static String
encodeEd25519PublicKey
(byte[] data) Encodes raw data to strkey ed25519 public key (G...)static String
encodeEd25519PublicKey
(AccountID accountID) Deprecated.static char[]
encodeEd25519SecretSeed
(byte[] data) Encodes raw data to strkey ed25519 seed in char array (S...)static String
encodeLiquidityPool
(byte[] data) Encodes raw data to strkey liquidity pool ID (L...)static String
encodeMed25519PublicKey
(byte[] data) Encodes raw data to strkey Stellar med25519 public key (M...)static String
encodeMuxedAccount
(MuxedAccount muxedAccount) Deprecated.static String
encodePreAuthTx
(byte[] data) Encodes raw data to strkey PreAuthTx (T...)static String
encodeSha256Hash
(byte[] data) Encodes raw data to strkey SHA256 hash (X...)static String
encodeSignedPayload
(SignedPayloadSigner signedPayloadSigner) EncodesSignedPayloadSigner
to strkey signed payload (P...)static AccountID
encodeToXDRAccountId
(String data) Deprecated.static MuxedAccount
Deprecated.static boolean
isValidClaimableBalance
(String claimableBalanceId) Checks validity of claimable balance (B...) address.static boolean
isValidContract
(String contractId) Checks validity of contract (C...) address.static boolean
isValidEd25519PublicKey
(String accountID) Checks validity of Stellar account ID (G...).static boolean
isValidEd25519SecretSeed
(char[] seed) Checks validity of seed (S...).static boolean
isValidLiquidityPool
(String liquidityPoolId) Checks validity of liquidity pool (L...) address.static boolean
isValidMed25519PublicKey
(String med25519PublicKey) Checks validity of med25519 public key (M...).static boolean
isValidPreAuthTx
(String preAuthTx) Checks validity of PreAuthTx (T...).static boolean
isValidSha256Hash
(String sha256Hash) Checks validity of SHA256 hash (X...).
-
Constructor Details
-
StrKey
public StrKey()
-
-
Method Details
-
encodeEd25519PublicKey
Encodes raw data to strkey ed25519 public key (G...)- Parameters:
data
- data to encode- Returns:
- "G..." representation of the key
-
decodeEd25519PublicKey
Decodes strkey ed25519 public key (G...) to raw data- Parameters:
data
- data to decode- Returns:
- raw bytes
-
isValidEd25519PublicKey
Checks validity of Stellar account ID (G...).- Parameters:
accountID
- the account ID to check- Returns:
- true if the given Stellar account ID is a valid Stellar account ID, false otherwise
-
encodeEd25519SecretSeed
public static char[] encodeEd25519SecretSeed(byte[] data) Encodes raw data to strkey ed25519 seed in char array (S...)- Parameters:
data
- data to encode- Returns:
- "S..." representation of the key in char array
-
decodeEd25519SecretSeed
public static byte[] decodeEd25519SecretSeed(char[] data) Decodes strkey ed25519 seed char array (S...) to raw bytes- Parameters:
data
- data to decode- Returns:
- raw bytes
-
isValidEd25519SecretSeed
public static boolean isValidEd25519SecretSeed(char[] seed) Checks validity of seed (S...).- Parameters:
seed
- the seed to check- Returns:
- true if the given seed is a valid seed, false otherwise
-
encodePreAuthTx
Encodes raw data to strkey PreAuthTx (T...)- Parameters:
data
- data to encode- Returns:
- "T..." representation of the key
-
decodePreAuthTx
Decodes strkey PreAuthTx (T...) to raw bytes- Parameters:
data
- data to decode- Returns:
- raw bytes
-
isValidPreAuthTx
Checks validity of PreAuthTx (T...).- Parameters:
preAuthTx
- the PreAuthTx to check- Returns:
- true if the given PreAuthTx is a valid PreAuthTx, false otherwise
-
encodeSha256Hash
Encodes raw data to strkey SHA256 hash (X...)- Parameters:
data
- data to encode- Returns:
- "X..." representation of the key
-
decodeSha256Hash
Decodes strkey SHA256 hash (X...) to raw bytes- Parameters:
data
- data to decode- Returns:
- raw bytes
-
isValidSha256Hash
Checks validity of SHA256 hash (X...).- Parameters:
sha256Hash
- the SHA256 hash to check- Returns:
- true if the given SHA256 hash is a valid SHA256 hash, false otherwise
-
encodeSignedPayload
EncodesSignedPayloadSigner
to strkey signed payload (P...)- Parameters:
signedPayloadSigner
- the signed payload signer- Returns:
- "P..." representation of the key
-
decodeSignedPayload
Decodes strkey signed payload (P...) toSignedPayloadSigner
- Parameters:
data
- data to decode- Returns:
- raw bytes
-
encodeContract
Encodes raw data to strkey contract ID (C...)- Parameters:
data
- data to encode- Returns:
- "C..." representation of the key
-
decodeContract
Decodes strkey contract ID (C...) to raw bytes.- Parameters:
data
- data to decode- Returns:
- raw bytes
-
isValidContract
Checks validity of contract (C...) address.- Parameters:
contractId
- the contract ID to check- Returns:
- true if the given contract ID is a valid contract ID, false otherwise
-
encodeLiquidityPool
Encodes raw data to strkey liquidity pool ID (L...)- Parameters:
data
- data to encode- Returns:
- "L..." representation of the key
-
decodeLiquidityPool
Decodes strkey liquidity pool ID (L...) to raw bytes.- Parameters:
data
- data to decode- Returns:
- raw bytes
-
isValidLiquidityPool
Checks validity of liquidity pool (L...) address.- Parameters:
liquidityPoolId
- the liquidity pool ID to check- Returns:
- true if the given liquidity pool ID is a valid liquidity pool ID, false otherwise
-
encodeClaimableBalance
Encodes raw data to strkey claimable balance ID (B...)- Parameters:
data
- data to encode- Returns:
- "B..." representation of the key
-
decodeClaimableBalance
Decodes strkey claimable balance ID (B...) to raw bytes.- Parameters:
data
- data to decode- Returns:
- raw bytes
-
isValidClaimableBalance
Checks validity of claimable balance (B...) address.- Parameters:
claimableBalanceId
- the claimable balance ID to check- Returns:
- true if the given claimable balance ID is a valid claimable balance ID, false otherwise
-
encodeMed25519PublicKey
Encodes raw data to strkey Stellar med25519 public key (M...)- Parameters:
data
- data to encode- Returns:
- "M..." representation of the key
-
decodeMed25519PublicKey
Decodes strkey Stellar med25519 public key (M...) to raw bytes- Parameters:
data
- data to decode- Returns:
- raw bytes
-
isValidMed25519PublicKey
Checks validity of med25519 public key (M...).- Parameters:
med25519PublicKey
- the med25519 public key to check- Returns:
- true if the given med25519 public key is a valid med25519 public key, false otherwise
-
encodeEd25519PublicKey
Deprecated.Encodes raw data to strkey Stellar account ID (G...)This method is deprecated and will be removed in future versions, use
encodeEd25519PublicKey(byte[])
instead.- Parameters:
accountID
- data to encode- Returns:
- "G..." representation of the key
-
encodeMuxedAccount
Deprecated.Encodes raw data to strkey Stellar muxed account ID (M... or G...)This method is deprecated and will be removed in future versions, use
MuxedAccount
instead.- Parameters:
muxedAccount
- the muxed account to encode- Returns:
- "M..." or "G..." representation of the key
-
decodeMuxedAccount
Deprecated.Decodes strkey Stellar account ID (G...) or muxed account ID (M...) toMuxedAccount
.This method is deprecated and will be removed in future versions, use
MuxedAccount
instead.- Parameters:
address
- the address to decode- Returns:
MuxedAccount
representation of the key
-
encodeToXDRAccountId
Deprecated.Encodes strkey Stellar account ID (G...) toAccountID
.This method is deprecated and will be removed in future versions, use
KeyPair.getXdrAccountId()
instead.- Parameters:
data
- the data to encode- Returns:
AccountID
representation of the key
-
encodeToXDRMuxedAccount
Deprecated.Encodes strkey Stellar account ID (G...) or muxed account ID (M...) toMuxedAccount
.This method is deprecated and will be removed in future versions, use
MuxedAccount
instead.- Parameters:
data
- the data to encode- Returns:
MuxedAccount
representation of the key
-