Stellar PHP SDK API Documentation

XdrClaimableBalanceID extends XdrClaimableBalanceIDBase
in package

ClaimableBalanceID union override that stores $hash as hexadecimal rather than as the raw bytes the generated base expects, and accepts more than one hexadecimal spelling of it; see getCanonicalHashHex().

Tags
phpstan-consistent-constructor

Table of Contents

Properties

$hash  : string|null
$type  : XdrClaimableBalanceIDType

Methods

__construct()  : mixed
decode()  : static
encode()  : string
forClaimableBalanceId()  : XdrClaimableBalanceID
fromBase64Xdr()  : static
fromJson()  : static
fromJsonValue()  : static
fromTxRep()  : static
Override fromTxRep to store the hash as a hex string (as the constructor and encode() expect) rather than converting to/from binary bytes.
getCanonicalHashHex()  : string
Returns the 32-byte balance hash as 64 lower case hexadecimal characters, whichever of the accepted spellings the hash field holds.
getHash()  : string|null
getPaddedBalanceIdHex()  : string
Returns the balance id as hex string with leading zeros, so it can be used in horizon requests.
getType()  : XdrClaimableBalanceIDType
paddedBalanceIdHexFor()  : string
The id in the spelling Horizon takes in request URLs: the 4-byte XDR union discriminant ahead of the hash, as 72 hexadecimal characters.
setHash()  : void
setType()  : void
toBase64Xdr()  : string
toJson()  : string
toJsonValue()  : string
Returns the balance id as the "B..." strkey that SEP-51 uses for ClaimableBalanceID, resolving whichever spelling the hash field holds.
toTxRep()  : void
Emits the hash as the bare 32-byte balance hash in hexadecimal, resolving whichever spelling the hash field holds.

Properties

Methods

fromBase64Xdr()

public static fromBase64Xdr(string $xdr) : static
Parameters
$xdr : string
Return values
static

fromJson()

public static fromJson(string $json) : static
Parameters
$json : string
Tags
throws
JsonException

If $json is not syntactically valid JSON.

InvalidArgumentException

If an object in $json repeats a key, or if the JSON shape does not match this type.

Return values
static

fromJsonValue()

public static fromJsonValue(mixed $value) : static
Parameters
$value : mixed
Return values
static

fromTxRep()

Override fromTxRep to store the hash as a hex string (as the constructor and encode() expect) rather than converting to/from binary bytes.

public static fromTxRep(array<string, string> $map, string $prefix) : static
Parameters
$map : array<string, string>
$prefix : string
Return values
static

getCanonicalHashHex()

Returns the 32-byte balance hash as 64 lower case hexadecimal characters, whichever of the accepted spellings the hash field holds.

public getCanonicalHashHex() : string

A balance id reaches this class in four shapes, all denoting the same hash: the strkey form "B..."; the bare hash as 64 hexadecimal characters; the hash behind the 1-byte strkey discriminant, as 66 hexadecimal characters, which is what StrKey::decodeClaimableBalanceIdHex() hands back; and the hash behind the 4-byte XDR union discriminant, as 72 hexadecimal characters, which is what Horizon reports and what getPaddedBalanceIdHex() produces. A discriminant carried in the hexadecimal must name CLAIMABLE_BALANCE_ID_TYPE_V0, the case this id holds; anything else means the prefix and the type field describe different balance ids.

Tags
throws
InvalidArgumentException

when the hash field is unset, holds a string that is neither a "B..." strkey nor hexadecimal, has a length matching none of the accepted shapes, or carries a discriminant other than CLAIMABLE_BALANCE_ID_TYPE_V0

Return values
string —

the balance hash as 64 lower case hexadecimal characters

getPaddedBalanceIdHex()

Returns the balance id as hex string with leading zeros, so it can be used in horizon requests.

public getPaddedBalanceIdHex() : string

e.g. '000000003be9c4382b2e4acc74600f6eb1b68e51de5e5cc22ee2adcf68bd7fdfa1f40cf9' instead of '3be9c4382b2e4acc74600f6eb1b68e51de5e5cc22ee2adcf68bd7fdfa1f40cf9'

The zeros stand for the 4-byte XDR union discriminant, so they may only ever pad a full 32-byte hash.

Tags
throws
InvalidArgumentException

when the hash field holds none of the spellings getCanonicalHashHex() accepts

Return values
string —

balance id as hex string with leading zeros, so it can be used in horizon requests.

paddedBalanceIdHexFor()

The id in the spelling Horizon takes in request URLs: the 4-byte XDR union discriminant ahead of the hash, as 72 hexadecimal characters.

public static paddedBalanceIdHexFor(string $claimableBalanceId) : string
Parameters
$claimableBalanceId : string

the balance id in any spelling forClaimableBalanceId() accepts

Tags
throws
InvalidArgumentException

when $claimableBalanceId holds none of the accepted spellings

Return values
string —

the 72-character hexadecimal form

toJson()

public toJson() : string
Tags
throws
JsonException

If the value contains structures that cannot be encoded as JSON.

Return values
string

toJsonValue()

Returns the balance id as the "B..." strkey that SEP-51 uses for ClaimableBalanceID, resolving whichever spelling the hash field holds.

public toJsonValue() : string
Tags
throws
InvalidArgumentException

when the hash field holds none of the spellings getCanonicalHashHex() accepts, or when the discriminant is not CLAIMABLE_BALANCE_ID_TYPE_V0

Return values
string —

the balance id as a "B..." strkey

toTxRep()

Emits the hash as the bare 32-byte balance hash in hexadecimal, resolving whichever spelling the hash field holds.

public toTxRep(string $prefix, array<string, string> &$lines) : void
Parameters
$prefix : string
$lines : array<string, string>
Tags
throws
InvalidArgumentException

when the hash field holds none of the spellings getCanonicalHashHex() accepts

On this page

Search results