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().
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
$hash
public
string|null
$hash
= null
$type
public
XdrClaimableBalanceIDType
$type
Methods
__construct()
public
__construct(XdrClaimableBalanceIDType $type, string $hash) : mixed
Parameters
- $type : XdrClaimableBalanceIDType
- $hash : string
decode()
public
static decode(XdrBuffer $xdr) : static
Parameters
- $xdr : XdrBuffer
Return values
staticencode()
public
encode() : string
Return values
stringforClaimableBalanceId()
public
static forClaimableBalanceId(string $claimableBalanceId) : XdrClaimableBalanceID
Parameters
- $claimableBalanceId : string
Return values
XdrClaimableBalanceIDfromBase64Xdr()
public
static fromBase64Xdr(string $xdr) : static
Parameters
- $xdr : string
Return values
staticfromJson()
public
static fromJson(string $json) : static
Parameters
- $json : string
Tags
Return values
staticfromJsonValue()
public
static fromJsonValue(mixed $value) : static
Parameters
- $value : mixed
Return values
staticfromTxRep()
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
staticgetCanonicalHashHex()
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
Return values
string —the balance hash as 64 lower case hexadecimal characters
getHash()
public
getHash() : string|null
Return values
string|nullgetPaddedBalanceIdHex()
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
Return values
string —balance id as hex string with leading zeros, so it can be used in horizon requests.
getType()
public
getType() : XdrClaimableBalanceIDType
Return values
XdrClaimableBalanceIDTypepaddedBalanceIdHexFor()
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
Return values
string —the 72-character hexadecimal form
setHash()
public
setHash(string|null $hash) : void
Parameters
- $hash : string|null
setType()
public
setType(XdrClaimableBalanceIDType $type) : void
Parameters
- $type : XdrClaimableBalanceIDType
toBase64Xdr()
public
toBase64Xdr() : string
Return values
stringtoJson()
public
toJson() : string
Tags
Return values
stringtoJsonValue()
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
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>