async private Task <Stellar.Transaction> GenerateSignedTransaction(Stellar.KeyPair keypair) { long randomSequence = (long)(99999999 - Math.Floor((decimal) new Random().Next() * 65536)); Stellar.Account account = new Stellar.Account(keypair, randomSequence); Stellar.Transaction.Builder txBuilder = new Stellar.Transaction.Builder(account); StellarResponses.AssetResponse asset = await new Library.Client().StellarAsset(); Stellar.Operation op = new Stellar.PaymentOperation.Builder(keypair, asset.Asset, "0.000001").Build(); Stellar.Transaction tx = txBuilder.AddOperation(op).Build(); tx.Sign(keypair); return(Stellar.Transaction.FromEnvelopeXdr(tx.ToEnvelopeXdr())); }
///<summary>Submit transaction</summary> ///<param name="buildFn">Callback to build the transaction</param> ///<returns>Promise that resolves or rejects with response of horizon</returns> async public Task <StellarResponses.SubmitTransactionResponse> SubmitTx(Action <Stellar.Transaction.Builder> buildFn) { var account = new Stellar.Account(UserAccount().KeyPair(), UserAccount().Info().SequenceNumber); var builder = new Stellar.Transaction.Builder(account); buildFn(builder); var tx = builder.Build(); tx.Sign(AppKeypair()); var response = await this.ClientInstance.SubmitTransaction(tx); await this.Reload(); return(response); }
///<summary>Generates challenge transaction signed by developers private key.</summary> ///<param name="developerSecret">Developers secret seed</param> ///<param name="expireIn">Session expiration time in seconds from now. Default is Client.ChallengeExpiresIn.</param> ///<returns>Returns base64-encoded transaction envelope</returns> public string Call(string developerSecret, int expireIn = 0) { if (expireIn == 0) { expireIn = Client.ChallengeExpiresIn; } var keypair = this.Keypair(developerSecret); var account = new Stellar.Account(keypair, this.RandomSequence()); var operation = new Stellar.PaymentOperation.Builder(keypair, new Stellar.AssetTypeNative(), "0.000001") .SetSourceAccount(Stellar.KeyPair.Random()) .Build(); var tx = new Stellar.Transaction.Builder(account) .AddMemo(this.Memo()) .AddTimeBounds(this.BuildTimeBounds(expireIn)) .AddOperation(operation) .Build(); tx.Sign(keypair); return(tx.ToEnvelopeXdrBase64()); }