Class TrustLineAsset

java.lang.Object
org.stellar.sdk.TrustLineAsset

public class TrustLineAsset extends Object
Represents a trustline asset in the Stellar network. A trustline is a declaration that an account trusts an issuer of an asset up to a certain limit. This class can represent both regular assets and liquidity pool shares.
  • Constructor Details

    • TrustLineAsset

      public TrustLineAsset(@NonNull @NonNull Asset asset)
      Creates a TrustLineAsset for a regular asset.
      Parameters:
      asset - The asset for which the trustline is created.
    • TrustLineAsset

      public TrustLineAsset(@NonNull @NonNull String liquidityPoolId)
      Creates a TrustLineAsset for a liquidity pool share.
      Parameters:
      liquidityPoolId - The ID of the liquidity pool.
  • Method Details

    • toXdr

      public TrustLineAsset toXdr()
      Converts this TrustLineAsset to its XDR representation.
      Returns:
      The XDR representation of this TrustLineAsset.
    • fromXdr

      public static TrustLineAsset fromXdr(TrustLineAsset trustLineAsset)
      Creates a TrustLineAsset from its XDR representation.
      Parameters:
      trustLineAsset - The XDR representation of the TrustLineAsset.
      Returns:
      A new TrustLineAsset instance.
      Throws:
      IllegalArgumentException - if the asset type is unknown.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getAssetType

      @NonNull public @NonNull AssetType getAssetType()
      The type of the asset.
    • getAsset

      @Nullable public Asset getAsset()
      The asset for which the trustline is established. This is null if the trustline is for a liquidity pool share.

      If assetType is one of AssetType.ASSET_TYPE_NATIVE, AssetType.ASSET_TYPE_CREDIT_ALPHANUM4 or AssetType.ASSET_TYPE_CREDIT_ALPHANUM12 then this field will be set.

    • getLiquidityPoolId

      @Nullable public String getLiquidityPoolId()
      The ID of the liquidity pool for which the trustline is established. This is null if the trustline is for a regular asset.

      If assetType is AssetType.ASSET_TYPE_POOL_SHARE then this field will be set.