Ejemplo n.º 1
0
        public Client()
        {
            if (Stellar.Network.Current == null)
            {
                SetNetwork("TESTNET");
            }

            InnerNetwork = Stellar.Network.Current;
        }
Ejemplo n.º 2
0
        ///<summary>Set Stellar network to use</summary>
        ///<param name="value">string: network to use</param>
        public void SetNetwork(string value = "TESTNET")
        {
            if (value == "TESTNET")
            {
                Stellar.Network.UseTestNetwork();
            }
            else if (value == "PUBLIC")
            {
                Stellar.Network.UsePublicNetwork();
            }
            else
            {
                throw new Exception("Must provide value network. TESTNET or PUBLIC");
            }

            InnerNetwork = Stellar.Network.Current;
        }
Ejemplo n.º 3
0
        public async Task <bool> SubmitAsync(Server server, stellar_dotnet_sdk.Network network, string logDescription)
        {
            try
            {
                var transaction = Builder.Build();

                SourceAccounts.Add(KeyPair.FromSecretSeed(_sourceAccountSeed));

                foreach (var sourceAccountSeed in SourceAccounts.Select(account => account.SecretSeed).Distinct())
                {
                    transaction.Sign(KeyPair.FromSecretSeed(sourceAccountSeed), network);
                }

                var response = await server.SubmitTransaction(transaction);

                Console.WriteLine($"{logDescription} - Success: {response.IsSuccess()}");

                if (!response.IsSuccess())
                {
                    Console.WriteLine($"{logDescription} - Failure Message: {response.ResultXdr}");
                }

                return(response.IsSuccess());
            }
            catch (Exception exception)
            {
                Console.WriteLine($"{logDescription} Exception: {exception.Message + Environment.NewLine + exception.StackTrace}");
            }
            finally
            {
                SourceAccounts.Clear();
                SourceAccounts.Add(KeyPair.FromSecretSeed(_sourceAccountSeed));

                this.Builder = new TransactionBuilder(_account);
            }

            return(false);
        }