Ejemplo n.º 1
0
        public void TestAddCreateTransaction()
        {
            using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
                if (lServerAccess.Logon("*****@*****.**", "davinci", "test"))
                {
                    var lControl  = CurrencyControl.GetCurrencyControl();
                    var lRootSeed = lControl.GenerateRootSeed("*****@*****.**", "davinci", "test");
                    var lAdvocacy = lControl.GetCryptoCurrency(1, "");
                    lAdvocacy.RootSeed = lRootSeed;
                    lServerAccess.AddMonitoredAccount(1, lAdvocacy.GetAddress(10));
                    var lTransaction = new CurrencyTransaction();
                    var s            = lServerAccess.GetTransactionRecords(1, 0);
                    var lTxList      = Newtonsoft.Json.JsonConvert.DeserializeObject <TransactionRecord[]>(s, new Pandora.Client.ClientLib.PandoraJsonConverter());
                    var lTx          = lTxList[0];
                    lTransaction.AddInput(lTx.Outputs[0]);
                    lTransaction.AddOutput(lTx.Outputs[0].Amount - 1000, "mzqD8sEGXfRMvcnNnkoGn6wyMN9AGUxaAB");
                    lTransaction.CurrencyId = 1;
                    lTransaction.TxFee      = 1000;
                    var lTxData = lServerAccess.CreateTransaction(lTransaction);

                    lTxData = lAdvocacy.SignTransaction(lTxData, lTransaction);

                    //lServerAccess.SendTransaction(1, lTxData);
                    lServerAccess.Logoff();
                }
                else
                {
                    throw new Exception("Basic Logon and log off failed.");
                }
        }
        private CurrencyTransaction CreateNewCurrencyTransaction(uint aCurrencyID, ulong aAmountToSend, string aToAddress, ulong aTxFee = 0)
        {
            CurrencyTransaction lCurrecyTransaction = new CurrencyTransaction();

            lock (FUnspent)
                lCurrecyTransaction.AddInput(FUnspent[aCurrencyID]);

            lCurrecyTransaction.AddOutput(aAmountToSend, aToAddress);

            ulong lChangeAmount = FBalance[aCurrencyID].Total - aAmountToSend - aTxFee;

            if (lChangeAmount > 0)
            {
                lCurrecyTransaction.AddOutput(lChangeAmount, FAddresses[aCurrencyID].First());
            }

            lCurrecyTransaction.TxFee = aTxFee;

            lCurrecyTransaction.CurrencyId = aCurrencyID;

            return(lCurrecyTransaction);
        }
Ejemplo n.º 3
0
        public void FetchingDataTests()
        {
            PandorasServer TestServer = new PandorasServer(Path.Combine(Directory.GetCurrentDirectory(), "DBTEST"), "localhost", 20159);

            Assert.IsTrue(TestServer.Logon("*****@*****.**", "Dj", "test"));

            List <CurrencyItem> TestCurrencies = TestServer.FetchCurrencies();

            Assert.IsTrue(TestCurrencies[1].Name == "Litecoin");

            List <CurrencyStatusItem> TestStatus = TestServer.FetchCurrencyStatus(2);

            Assert.IsTrue(TestStatus[0].ExtendedInfo == "The coin is working fine with 3 servers running with consensus.");

            List <CurrencyStatusItem> TestStatus2 = TestServer.FetchCurrencyStatus(2);

            Assert.IsTrue(TestStatus2[0].ExtendedInfo == "The servers are under maintaince and should be back up soon.");

            List <CurrencyStatusItem> TestStatus3 = TestServer.FetchCurrencyStatus(3);

            Assert.IsTrue(TestStatus3[0].ExtendedInfo == "Coin may not come back up.");

            CurrencyTransaction TestCurr = new CurrencyTransaction();

            TestCurr.AddInput(10000000000, "zBvBMSEYstWetqTFn5Au4m4GFgaxJaNVN3");
            TestCurr.AddOutput(10000000000, "zJvBMSEYstWetqTFn5Au4m4GFgaxJaNVN3");
            TestCurr.AddInput(10000000000, "zBvBMSEYstWetqTFn5Au4m4GFgaxJaNVN3");
            TestCurr.AddOutput(10000000000, "zJvBMSEYstWetqTFn5Au4m4GFgaxJaNVN3");

            TestCurr.TxFee = 100;

            string jsonstring = JsonConvert.SerializeObject(TestCurr);
            PandoraJsonConverter lJsonConverter = new PandoraJsonConverter();
            var Response = Newtonsoft.Json.JsonConvert.DeserializeObject <CurrencyTransaction>(jsonstring, lJsonConverter);

            Assert.IsTrue(Response.TxFee == 100 && Response.Outputs[1].Address == "zJvBMSEYstWetqTFn5Au4m4GFgaxJaNVN3");
            TestServer.Logoff();
        }
        public void SignTxTest()
        {
            var lTx       = new CurrencyTransaction();
            var lAdvocacy = new EthereumCurrencyAdvocacy(1000, FEthChainParams, () => "6A41F49D98D83DF2EEB89F8E895D22697A41F49D98D83DF2EEB89F8E895D2269");
            var lString   = lAdvocacy.GetAddress(0);

            Assert.AreEqual("0xFF3225E2c09280797F5848Ad204e9c0C331Af2c0", lString);
            // 1 eth is 1 Quintillion 1, or 1000 Quadrillion
            // 1,000,000,000,000,000,000 Wei (1018)
            lTx.AddInput(13689000000000000, lString);                                      // how much I have
            lTx.TxFee = 420000000000000;                                                   // fee to pay
            lTx.AddOutput(1100000000000000, "0x596a2232d098965bc56b762549E045829CF43c8D"); // amount to move
            var ldata = lAdvocacy.SignTransaction("30", lTx);

            Assert.AreEqual("f8728087019945ca2620008704cbd15e72600094596a2232d098965bc56b762549e045829cf43c8d8703e871b540c000801ca0fb1f1e416a5b9d22b2b34242807e0c41994e1be4909cc16370b5187011a109fea03165afb74b0d47138e86e2faec57bce8079bdd7024937d64c8fdc454d2dfc512", ldata);
        }
Ejemplo n.º 5
0
        public void TestSendTransaction()
        {
            using (var lServerAccess = new ServerAccess.PandoraWalletServiceAccess("localhost", 20159, false))
                if (lServerAccess.Logon("*****@*****.**", "davinci", "test"))
                {
                    var lTransaction = new CurrencyTransaction();
                    lTransaction.CurrencyId = 3;
                    var lControl  = CurrencyControl.GetCurrencyControl();
                    var lRootSeed = lControl.GenerateRootSeed("*****@*****.**", "davinci", "test");
                    var lAdvocacy = lControl.GetCryptoCurrency(lTransaction.CurrencyId, "");
                    lAdvocacy.RootSeed = lRootSeed;
                    var lAddress = lAdvocacy.GetAddress(10);
                    lServerAccess.AddMonitoredAccount(lTransaction.CurrencyId, lAddress);

                    var s       = lServerAccess.GetTransactionRecords(lTransaction.CurrencyId, 0);
                    var lTxList = Newtonsoft.Json.JsonConvert.DeserializeObject <TransactionRecord[]>(s, new Pandora.Client.ClientLib.PandoraJsonConverter());
                    var lTx     = lTxList[0];
                    lTransaction.AddInput(lTx.Outputs[0]);
                    lTransaction.AddOutput(lTx.Outputs[0].Amount - 1000, "yPueC9mAxBj7yrPxj4M2vNY3rn4Yz3thrY");
                    lTransaction.TxFee = 1000;
                    var lTxData = lServerAccess.CreateTransaction(lTransaction);

                    lTxData = lAdvocacy.SignTransaction(lTxData, lTransaction);

                    var lHandle = lServerAccess.SendTransaction(lTransaction.CurrencyId, lTxData);
                    System.Threading.Thread.Sleep(5000);
                    if (lServerAccess.IsTransactionSent(lHandle))
                    {
                        var lTxId = lServerAccess.GetTransactionId(lHandle);
                    }
                    lServerAccess.Logoff();
                }
                else
                {
                    throw new Exception("Basic Logon and log off failed.");
                }
        }
Ejemplo n.º 6
0
        public void PandoraServerTest()
        {
            TestServer = new PandorasServer(Path.Combine(Directory.GetCurrentDirectory(), "DBTEST"), "localhost", 20159);

            Assert.IsTrue(TestServer.Logon("*****@*****.**", "quality", "quality"));

            TestServer.OnTransactions += NewTransactionTestHandler;

            var TestUserStatus = (TestServer.GetUserStatus());

            Assert.IsTrue(TestUserStatus.Active && TestUserStatus.ExtendedInfo == "Quality Testing User");

            CurrencyItem[] Currencies = TestServer.GetCurrencyList();

            Assert.IsTrue(Currencies.Count() > 0 && Currencies[0].Name == "Bitcoin");

            CurrencyStatusItem Result2 = TestServer.GetCurrencyStatus(1);

            Assert.IsTrue(Result2.Status == CurrencyStatus.Active && Result2.ExtendedInfo == "The coin is working fine with 3 servers running with consensus.");

            CurrencyAccount[] Accounts = TestServer.MonitoredAccounts.GetById(1);

            Assert.AreEqual(Accounts[0].Address, "mk4DoTmTB8PnNgPyvzozTeNGxC1fduJqb5");

            TestServer.StartTxUpdatingTask();

            while (!Records.Any())
            {
                Records = TestServer.GetTransactions(1);
                System.Threading.Thread.Sleep(1000);
            }

            TransactionRecord Record = Records.FirstOrDefault();

            Assert.IsTrue(Record.TxId == "30c8e2f7f5cf8b00f8b8bff127a8ceb726e30ab354dda361199fc435c22275b9");

            Assert.IsTrue(Record.Block == 1355565);

            Assert.IsTrue(Record.Outputs.Count() == 2);

            var Outputs = Record.Outputs.ToList();

            Assert.IsTrue(Outputs.Exists(x => x.Address == "mk4DoTmTB8PnNgPyvzozTeNGxC1fduJqb5" && x.Amount == 150000000));
            Assert.IsTrue(Outputs.Exists(x => x.Address == "2MwqZdwPUrmBACjacg8uwEZ8rVoCUX7GD2h" && x.Amount == 111418554));

            var Transaction = new CurrencyTransaction();

            Transaction.AddInput(150000000, "mk4DoTmTB8PnNgPyvzozTeNGxC1fduJqb5", 10151);
            Transaction.AddOutput(100000000, "mtCFoNLWbgHnB1SG7R7VqiDizGUP8K2uae");
            Transaction.AddOutput(50000000, "mk4DoTmTB8PnNgPyvzozTeNGxC1fduJqb5");

            Transaction.TxFee = 250000;

            Transaction.CurrencyId = 1;

            //var Response = TestServer.CreateTransaction(1, Transaction);

            //Assert.IsTrue(Response == "0100000001b97522c235c49f1961a3dd54b30ae326b7cea827f1bfb8f8008bcff5f7e2c830010000001976a91431ca57b301db0088e2d5912cff743210364b126c88acffffffff0200e1f505000000001976a9148b10583ecc2a455ab21342b3b34943ec711e694888ac80f0fa02000000001976a91431ca57b301db0088e2d5912cff743210364b126c88ac00000000");

            TestServer.Logoff();
        }