static void PaymentFromMaster(KeyPair kp, long amount) { // get master var master = KeyPair.Master(); Account masterSource = new Account(master, 1); // load asset Stellar.Generated.Asset asset = Stellar.Asset.Native(); var operation = new PaymentOperation.Builder(kp, asset, amount) .SetSourceAccount(masterSource.KeyPair) .Build(); masterSource.IncrementSequenceNumber(); Stellar.Transaction transaction = new Stellar.Transaction.Builder(masterSource) .AddOperation(operation) .Build(); transaction.Sign(masterSource.KeyPair); string message = transaction.ToEnvelopeXdrBase64(); string response = GetResult(message); Console.WriteLine(response); }
static void Payment(KeyPair from, KeyPair to, long amount) { Account source = new Account(from, GetSequence(from.Address)); // load asset Stellar.Generated.Asset asset = Stellar.Asset.Native(); var operation = new PaymentOperation.Builder(to, asset, amount) .SetSourceAccount(from) .Build(); source.IncrementSequenceNumber(); Stellar.Transaction transaction = new Stellar.Transaction.Builder(source) .AddOperation(operation) .Build(); transaction.Sign(source.KeyPair); var tx = transaction.ToEnvelopeXdrBase64(); var response = PostResult(tx); Console.WriteLine(response.ReasonPhrase); }
public static Asset FromXDR(Generated.Asset asset) { switch (asset.Discriminant.InnerValue) { case Generated.AssetType.AssetTypeEnum.ASSET_TYPE_NATIVE: return(new Asset()); case Generated.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4: return(new Asset(Encoding.ASCII.GetString(asset.AlphaNum4.AssetCode), KeyPair.FromXdrPublicKey(asset.AlphaNum4.Issuer.InnerValue))); case Generated.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM12: return(new Asset(Encoding.ASCII.GetString(asset.AlphaNum12.AssetCode), KeyPair.FromXdrPublicKey(asset.AlphaNum12.Issuer.InnerValue))); default: throw new ArgumentException("Invalid asset."); } }
public Builder(KeyPair destination, Generated.Asset asset, long amount) { this.Destination = CheckNotNull(destination, "destination cannot be null."); this.Asset = CheckNotNull(asset, "asset cannot be null."); this.Amount = amount; }
private PaymentOperation(KeyPair destination, Generated.Asset asset, long amount) { this.Destination = CheckNotNull(destination, "destination cannot be null."); this.Asset = CheckNotNull(asset, "asset cannot be null."); this.Amount = amount; }
public Builder(Generated.Asset asset, long limit) { Asset = CheckNotNull(asset, "asset cannot be null."); Limit = CheckNotNull(limit, "limit cannot be null."); }
private ChangeTrustOperation(Generated.Asset asset, long limit) { Asset = CheckNotNull(asset, "asset cannot be null."); Limit = CheckNotNull(limit, "limit cannot be null."); }