Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions StellarDotnetSdk/Accounts/IAccountId.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
namespace StellarDotnetSdk.Accounts;

/// <summary>
/// Represents a Stellar account identifier, providing access to the account's public key,
/// address, and signing key. Implemented by both standard <see cref="KeyPair" /> and
/// <see cref="MuxedAccountMed25519" /> accounts.
/// </summary>
public interface IAccountId
{
Xdr.MuxedAccount MuxedAccount { get; }
Expand Down
5 changes: 5 additions & 0 deletions StellarDotnetSdk/Accounts/ITransactionBuilderAccount.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
namespace StellarDotnetSdk.Accounts;

/// <summary>
/// Represents a Stellar account used for building transactions. Provides access to the account's
/// key pair, sequence number management, and muxed account information needed by
/// <see cref="StellarDotnetSdk.Transactions.TransactionBuilder" />.
/// </summary>
public interface ITransactionBuilderAccount
{
string AccountId { get; }
Expand Down
26 changes: 22 additions & 4 deletions StellarDotnetSdk/Accounts/KeyPair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
namespace StellarDotnetSdk.Accounts;

/// <summary>
/// <see cref="KeyPair" /> represents public (and secret) keys of the account.
/// Currently <see cref="KeyPair" /> only supports ed25519 but in a future this class can be abstraction layer for
/// other public-key signature systems.
/// Represents the public (and optionally secret) keys of a Stellar account, providing methods
/// for signing data, verifying signatures, and encoding/decoding account identifiers.
/// </summary>
/// <remarks>
/// Currently only supports Ed25519 keys, but is designed to serve as an abstraction layer for
/// other public-key signature systems in the future. Use factory methods such as
/// <see cref="FromSecretSeed(string)" />, <see cref="FromAccountId" />, or <see cref="Random" />
/// to create instances.
/// </remarks>
[JsonConverter(typeof(KeyPairJsonConverter))]
public class KeyPair : IAccountId, IEquatable<KeyPair>
{
Expand Down Expand Up @@ -154,7 +159,8 @@ public SignerKey XdrSignerKey
public string Address => StrKey.EncodeCheck(StrKey.VersionByte.ACCOUNT_ID, PublicKey);

/// <summary>
/// The signing key.
/// Gets the <see cref="KeyPair" /> used for signing transactions. For a standard (non-muxed) account,
/// this returns the current instance itself, since the key pair is its own signing key.
/// </summary>
[JsonIgnore]
public KeyPair SigningKey => this;
Expand All @@ -176,8 +182,20 @@ public Xdr.MuxedAccount MuxedAccount
}
}

/// <summary>
/// Gets a value indicating whether this account is a muxed (multiplexed) account.
/// Always returns <c>false</c> for <see cref="KeyPair" />; muxed accounts are represented
/// by <see cref="MuxedAccountMed25519" />.
/// </summary>
public bool IsMuxedAccount => false;

/// <summary>
/// Determines whether the specified <see cref="KeyPair" /> is equal to this instance.
/// Two key pairs are considered equal if they share the same public key and both either
/// contain or lack a secret seed.
/// </summary>
/// <param name="other">The <see cref="KeyPair" /> to compare with this instance.</param>
/// <returns><c>true</c> if the key pairs are equal; otherwise, <c>false</c>.</returns>
public bool Equals(KeyPair? other)
{
if (other == null)
Expand Down
10 changes: 10 additions & 0 deletions StellarDotnetSdk/Accounts/MuxedAccountMed25519.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

namespace StellarDotnetSdk.Accounts;

/// <summary>
/// Represents a multiplexed (muxed) Stellar account that combines an Ed25519 public key with
/// a 64-bit numeric identifier. Muxed accounts allow a single Stellar account to distinguish
/// between multiple virtual accounts (e.g., for custodial services) without requiring separate
/// on-ledger accounts. Addresses for muxed accounts start with "M".
/// </summary>
public class MuxedAccountMed25519 : IAccountId
{
/// <summary>
Expand Down Expand Up @@ -57,6 +63,10 @@ public Xdr.MuxedAccount MuxedAccount
/// </summary>
public KeyPair SigningKey => Key;

/// <summary>
/// Gets a value indicating whether this account is a muxed (multiplexed) account.
/// Always returns <c>true</c> for <see cref="MuxedAccountMed25519" />.
/// </summary>
public bool IsMuxedAccount => true;

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions StellarDotnetSdk/Assets/AssetTypeCreditAlphaNum12.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

namespace StellarDotnetSdk.Assets;

/// <summary>
/// Represents a Stellar credit asset with an alphanumeric code between 5 and 12 characters long.
/// </summary>
public class AssetTypeCreditAlphaNum12 : AssetTypeCreditAlphaNum
{
public const string RestApiType = "credit_alphanum12";
Expand Down
3 changes: 3 additions & 0 deletions StellarDotnetSdk/Assets/AssetTypeCreditAlphaNum4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace StellarDotnetSdk.Assets;

/// <summary>
/// Represents a Stellar credit asset with an alphanumeric code between 1 and 4 characters long.
/// </summary>
public class AssetTypeCreditAlphaNum4 : AssetTypeCreditAlphaNum
{
public const string RestApiType = "credit_alphanum4";
Expand Down
3 changes: 3 additions & 0 deletions StellarDotnetSdk/Assets/AssetTypeNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace StellarDotnetSdk.Assets;

/// <summary>
/// Represents the native Stellar asset (XLM/Lumens). This is the built-in currency of the Stellar network.
/// </summary>
public class AssetTypeNative : Asset
{
public const string RestApiType = "native";
Expand Down
4 changes: 4 additions & 0 deletions StellarDotnetSdk/Assets/ChangeTrustAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public static ChangeTrustAsset FromXdr(Xdr.ChangeTrustAsset changeTrustXdr)

public abstract Xdr.ChangeTrustAsset ToXdr();

/// <summary>
/// Wraps a standard <see cref="Asset" /> instance as a <see cref="ChangeTrustAsset" />,
/// enabling non-pool-share assets to be used in change trust operations.
/// </summary>
public class Wrapper : ChangeTrustAsset
{
public Wrapper(Asset asset)
Expand Down
8 changes: 8 additions & 0 deletions StellarDotnetSdk/Assets/LiquidityPoolShareChangeTrustAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

namespace StellarDotnetSdk.Assets;

/// <summary>
/// Represents a liquidity pool share asset used in change trust operations.
/// This asset type allows accounts to establish trustlines to liquidity pools on the Stellar network.
/// </summary>
public class LiquidityPoolShareChangeTrustAsset : ChangeTrustAsset
{
public const string RestApiType = "pool_share";
Expand All @@ -30,6 +34,10 @@ public LiquidityPoolShareChangeTrustAsset(Asset assetA, Asset assetB, int feeBp)

public override string Type => RestApiType;

/// <summary>
/// Gets the unique identifier of the liquidity pool associated with this asset.
/// </summary>
/// <returns>The <see cref="LiquidityPoolId" /> derived from the pool parameters.</returns>
public LiquidityPoolId GetLiquidityPoolId()
{
return Parameters.GetId();
Expand Down
8 changes: 8 additions & 0 deletions StellarDotnetSdk/Assets/LiquidityPoolShareTrustlineAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

namespace StellarDotnetSdk.Assets;

/// <summary>
/// Represents a liquidity pool share as a trustline asset.
/// This is used to reference an existing liquidity pool trustline by its pool ID.
/// </summary>
public class LiquidityPoolShareTrustlineAsset : TrustlineAsset
{
public const string RestApiType = "pool_share";
Expand Down Expand Up @@ -51,6 +55,10 @@ public override int CompareTo(TrustlineAsset asset)
StringComparison.Ordinal);
}

/// <summary>
/// Converts this liquidity pool share trustline asset to its XDR <see cref="TrustLineAsset" /> representation.
/// </summary>
/// <returns>A <see cref="TrustLineAsset" /> XDR object with the pool share discriminant and pool ID.</returns>
public TrustLineAsset ToXdrTrustLineAsset()
{
var xdr = new TrustLineAsset
Expand Down
13 changes: 13 additions & 0 deletions StellarDotnetSdk/Assets/TrustlineAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public static TrustlineAsset FromXdr(TrustLineAsset trustLineAssetXdr)

public abstract int CompareTo(TrustlineAsset asset);

/// <summary>
/// Converts this trustline asset to its XDR <see cref="TrustLineAsset" /> representation.
/// </summary>
/// <returns>A <see cref="TrustLineAsset" /> XDR object corresponding to the concrete asset type.</returns>
/// <exception cref="InvalidOperationException">Thrown when the trustline asset type is not recognized.</exception>
public TrustLineAsset ToXdr()
{
return this switch
Expand All @@ -83,6 +88,10 @@ public TrustLineAsset ToXdr()
};
}

/// <summary>
/// Wraps a standard <see cref="Asset" /> instance as a <see cref="TrustlineAsset" />,
/// enabling non-pool-share assets to be used where a trustline asset is required.
/// </summary>
public class Wrapper : TrustlineAsset
{
public Wrapper(Asset asset)
Expand Down Expand Up @@ -112,6 +121,10 @@ public override int CompareTo(TrustlineAsset asset)
return Asset.CompareTo(((Wrapper)asset).Asset);
}

/// <summary>
/// Converts the wrapped asset to its XDR <see cref="TrustLineAsset" /> representation.
/// </summary>
/// <returns>A <see cref="TrustLineAsset" /> XDR object with the discriminant and asset data from the wrapped asset.</returns>
public TrustLineAsset ToXdrTrustLineAsset()
{
var trustlineAssetXdr = new TrustLineAsset();
Expand Down
7 changes: 7 additions & 0 deletions StellarDotnetSdk/Base32Encoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,15 @@ private static char ValueToChar(byte b)
throw new ArgumentException("Byte is not a value Base32 value.", "b");
}

/// <summary>
/// Options for controlling Base32 encoding behavior.
/// </summary>
public class Base32EncodingOptions
{
/// <summary>
/// Gets or sets a value indicating whether to omit trailing '=' padding characters
/// from the Base32-encoded output.
/// </summary>
public bool OmitPadding { get; set; }
}
}
13 changes: 13 additions & 0 deletions StellarDotnetSdk/ClaimAtom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public static ClaimAtom FromXdr(Xdr.ClaimAtom xdrClaimAtom)
}
}

/// <summary>
/// Represents a claim atom from an order book trade on the Stellar decentralized exchange.
/// Contains the seller, offer ID, and the assets and amounts exchanged.
/// </summary>
public class ClaimAtomOrderBook : ClaimAtom
{
private ClaimAtomOrderBook(
Expand Down Expand Up @@ -82,6 +86,11 @@ public static ClaimAtomOrderBook FromXdr(Xdr.ClaimAtom xdrClaimAtom)
}
}

/// <summary>
/// Represents a V0 claim atom from a trade on the Stellar network.
/// This is the original format that identifies the seller by their Ed25519 public key
/// rather than a full account ID.
/// </summary>
public class ClaimAtomV0 : ClaimAtom
{
private ClaimAtomV0(
Expand Down Expand Up @@ -112,6 +121,10 @@ public static ClaimAtomV0 FromXdr(Xdr.ClaimAtom xdrClaimAtom)
}
}

/// <summary>
/// Represents a claim atom from a liquidity pool trade on the Stellar network.
/// Contains the liquidity pool ID and the assets and amounts exchanged.
/// </summary>
public class ClaimAtomLiquidityPool : ClaimAtom
{
private ClaimAtomLiquidityPool(
Expand Down
10 changes: 10 additions & 0 deletions StellarDotnetSdk/Claimants/ClaimPredicateAnd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

namespace StellarDotnetSdk.Claimants;

/// <summary>
/// Represents a logical AND combination of two claim predicates.
/// A claimable balance can be claimed only when both the left and right predicates are satisfied.
/// </summary>
public class ClaimPredicateAnd : ClaimPredicate
{
/// <summary>
/// Initializes a new instance of the <see cref="ClaimPredicateAnd" /> class with two predicates
/// that must both be satisfied for the claim to succeed.
/// </summary>
/// <param name="leftPredicate">The first predicate that must be satisfied.</param>
/// <param name="rightPredicate">The second predicate that must be satisfied.</param>
public ClaimPredicateAnd(ClaimPredicate leftPredicate, ClaimPredicate rightPredicate)
{
LeftPredicate = leftPredicate;
Expand Down
23 changes: 23 additions & 0 deletions StellarDotnetSdk/Claimants/ClaimPredicateBeforeAbsoluteTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,47 @@

namespace StellarDotnetSdk.Claimants;

/// <summary>
/// Represents a claim predicate that is valid only before a specified absolute point in time.
/// The claimable balance can be claimed only before the given Unix timestamp.
/// </summary>
public class ClaimPredicateBeforeAbsoluteTime : ClaimPredicate
{
/// <summary>
/// Initializes a new instance of the <see cref="ClaimPredicateBeforeAbsoluteTime" /> class
/// with a <see cref="DateTimeOffset" /> representing the deadline.
/// </summary>
/// <param name="dateTime">The absolute point in time before which the balance can be claimed.</param>
public ClaimPredicateBeforeAbsoluteTime(DateTimeOffset dateTime)
{
TimePoint.InnerValue = new Uint64((ulong)dateTime.ToUnixTimeSeconds());
}

/// <summary>
/// Initializes a new instance of the <see cref="ClaimPredicateBeforeAbsoluteTime" /> class
/// with an XDR <see cref="Xdr.TimePoint" /> value.
/// </summary>
/// <param name="timePoint">The XDR time point representing the deadline as a Unix timestamp.</param>
public ClaimPredicateBeforeAbsoluteTime(TimePoint timePoint)
{
TimePoint = timePoint;
}

/// <summary>
/// Initializes a new instance of the <see cref="ClaimPredicateBeforeAbsoluteTime" /> class
/// with a Unix timestamp in seconds.
/// </summary>
/// <param name="timePoint">The Unix timestamp (in seconds) before which the balance can be claimed.</param>
public ClaimPredicateBeforeAbsoluteTime(ulong timePoint)
{
TimePoint = new TimePoint(new Uint64(timePoint));
}

/// <summary>
/// Gets the absolute deadline as a <see cref="DateTimeOffset" />, converted from the underlying Unix timestamp.
/// </summary>
public DateTimeOffset DateTime => DateTimeOffset.FromUnixTimeSeconds((long)TimePoint.InnerValue.InnerValue);

public TimePoint TimePoint { get; } = new();

public override Xdr.ClaimPredicate ToXdr()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

namespace StellarDotnetSdk.Claimants;

/// <summary>
/// Represents a claim predicate that is valid only before a specified duration has elapsed
/// since the claimable balance was created. The duration is measured in seconds.
/// </summary>
public class ClaimPredicateBeforeRelativeTime : ClaimPredicate
{
[Obsolete("Use the ClaimPredicateBeforeRelativeTime(long duration) constructor instead.")]
Expand Down
8 changes: 8 additions & 0 deletions StellarDotnetSdk/Claimants/ClaimPredicateNot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

namespace StellarDotnetSdk.Claimants;

/// <summary>
/// Represents a logical NOT (negation) of a claim predicate.
/// A claimable balance can be claimed only when the inner predicate is <em>not</em> satisfied.
/// </summary>
public class ClaimPredicateNot : ClaimPredicate
{
/// <summary>
/// Initializes a new instance of the <see cref="ClaimPredicateNot" /> class that negates the given predicate.
/// </summary>
/// <param name="predicate">The predicate to negate.</param>
public ClaimPredicateNot(ClaimPredicate predicate)
{
Predicate = predicate;
Expand Down
10 changes: 10 additions & 0 deletions StellarDotnetSdk/Claimants/ClaimPredicateOr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,18 @@

namespace StellarDotnetSdk.Claimants;

/// <summary>
/// Represents a logical OR combination of two claim predicates.
/// A claimable balance can be claimed when either the left or right predicate (or both) is satisfied.
/// </summary>
public class ClaimPredicateOr : ClaimPredicate
{
/// <summary>
/// Initializes a new instance of the <see cref="ClaimPredicateOr" /> class with two predicates
/// where at least one must be satisfied for the claim to succeed.
/// </summary>
/// <param name="leftPredicate">The first predicate.</param>
/// <param name="rightPredicate">The second predicate.</param>
public ClaimPredicateOr(ClaimPredicate leftPredicate, ClaimPredicate rightPredicate)
{
LeftPredicate = leftPredicate;
Expand Down
4 changes: 4 additions & 0 deletions StellarDotnetSdk/Claimants/ClaimPredicateUnconditional.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace StellarDotnetSdk.Claimants;

/// <summary>
/// Represents an unconditional claim predicate that is always satisfied.
/// A claimable balance with this predicate can be claimed at any time without restrictions.
/// </summary>
public class ClaimPredicateUnconditional : ClaimPredicate
{
public override Xdr.ClaimPredicate ToXdr()
Expand Down
Loading
Loading