コード例 #1
0
        public void CreateTransactionPassPhraseVerifyTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from SMARTHOLDEM-NET",
                                                      _passPhrase);


            Assert.IsTrue(Crypto.Verify(tx));
        }
コード例 #2
0
        public void CreateTransactionPassPhraseVerifyTest()
        {
            var tx = TransactionApi.CreateTransaction("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25",
                                                      133380000000,
                                                      "This is first transaction from ARK-NET",
                                                      "this is a top secret passphrase");


            Assert.IsTrue(Crypto.Verify(tx));
        }
コード例 #3
0
        public (bool status, string data, string error) SendArk(long satosshiAmount, string recepientAddres,
                                                                string vendorFiend, string passPhrase, string secondPassPhrase = null)
        {
            var tx = TransactionApi.CreateTransaction(recepientAddres,
                                                      satosshiAmount,
                                                      vendorFiend,
                                                      passPhrase,
                                                      secondPassPhrase);

            return(TransactionService.PostTransaction(tx));
        }
コード例 #4
0
        //public bool AskRemoteSignature()
        //{
        //    throw new NotImplementedException();
        //}

        //public void SendMultisignSmartHoldem()
        //{
        //    throw new NotImplementedException();
        //}

        public SmartHoldemTransactionPostResponse SendSmartHoldem(long satoshiAmount, string recipientAddress,
                                                                  string vendorField)
        {
            var tx = TransactionApi.CreateTransaction(recipientAddress,
                                                      satoshiAmount,
                                                      vendorField,
                                                      _passPhrase,
                                                      _secondPassPhrase);

            return(TransactionService.PostTransaction(tx));
        }
コード例 #5
0
        public void MultiplePostTransactionSuccessTest()
        {
            var tx = TransactionApi.CreateTransaction("ASJBHz4JfWVUGDyN61hMMnW1Y4ZCTBHL1K",
                                                      1000,
                                                      "This is first Multi transaction from ARK-NET",
                                                      "ski rose knock live elder parade dose device fetch betray loan holiday");

            var res = TransactionService.MultipleBroadCast(tx);

            Assert.IsTrue(res > 0);
        }
コード例 #6
0
        public async Task <List <SmartHoldemTransactionPostResponse> > SendSmartHoldemUsingMultiBroadCastAsync(long satoshiAmount, string recipientAddress,
                                                                                                               string vendorField)
        {
            var tx = TransactionApi.CreateTransaction(recipientAddress,
                                                      satoshiAmount,
                                                      vendorField,
                                                      _passPhrase,
                                                      _secondPassPhrase);

            return(await TransactionService.MultipleBroadCastAsync(tx));
        }
コード例 #7
0
        public void MultiplePostTransactionSuccessTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first Multi transaction from SmartHoldem-NET",
                                                      _passPhrase);

            var res = TransactionService.MultipleBroadCast(tx);

            Assert.IsTrue(res.Where(x => x.Success).Count() > 0);
        }
コード例 #8
0
        public void PostTransactionTransferTest()
        {
            var tx = TransactionApi.CreateTransaction("ASJBHz4JfWVUGDyN61hMMnW1Y4ZCTBHL1K",
                                                      1000,
                                                      "This is first transaction from ARK-NET 22",
                                                      "ski rose knock live elder parade dose device fetch betray loan holiday");

            var result = TransactionService.PostTransaction(tx);

            Assert.IsTrue(result.status);
        }
コード例 #9
0
ファイル: NetworkTests.cs プロジェクト: waffle-iron/ark-net
        public void PostTransactionNoBalanceTest()
        {
            var tx = TransactionApi.CreateTransaction(_noBalanceAddress,
                                                      133380000000,
                                                      "This is first transaction from ARK-NET",
                                                      _noBalanceAddressPassPhrase);

            var result = TransactionService.PostTransaction(tx);

            Assert.AreEqual(result.Error, string.Format("Account does not have enough ARK: {0} balance: 0", _noBalanceAddress));
        }
コード例 #10
0
        public void MultiplePostTransactionSuccessTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first Multi transaction from ARK-NET",
                                                      _passPhrase);

            var res = TransactionService.MultipleBroadCast(tx);

            Assert.IsTrue(res > 0);
        }
コード例 #11
0
ファイル: NetworkTests.cs プロジェクト: waffle-iron/ark-net
        public async Task MultiplePostTransactionAsyncSuccessTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first Multi transaction from ARK-NET",
                                                      _passPhrase);

            var res = await TransactionService.MultipleBroadCastAsync(tx);

            Assert.IsTrue(res.Where(x => x.Success).Count() > 0);
        }
コード例 #12
0
ファイル: AccountController.cs プロジェクト: dnovacik/ark-net
        public async Task <ArkTransactionPostResponse> SendArkAsync(long satoshiAmount, string recipientAddress,
                                                                    string vendorField)
        {
            var tx = TransactionApi.CreateTransaction(recipientAddress,
                                                      satoshiAmount,
                                                      vendorField,
                                                      _passPhrase,
                                                      _secondPassPhrase);

            return(await TransactionService.PostTransactionAsync(tx));
        }
コード例 #13
0
ファイル: AccountController.cs プロジェクト: dnovacik/ark-net
        public int SendArkUsingMultiBroadCast(long satoshiAmount, string recipientAddress,
                                              string vendorField)
        {
            var tx = TransactionApi.CreateTransaction(recipientAddress,
                                                      satoshiAmount,
                                                      vendorField,
                                                      _passPhrase,
                                                      _secondPassPhrase);

            return(TransactionService.MultipleBroadCast(tx));
        }
コード例 #14
0
        public void CreateTransactionFeeChangeTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from SMARTHOLDEM-NET",
                                                      _passPhrase);
            var json = tx.ToJson();

            tx.Fee = 11;

            Assert.IsFalse(Crypto.Verify(tx));
            Assert.AreNotEqual(json, tx.ToJson());
        }
コード例 #15
0
        public void CreateTransactionRecepientChangeTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from ARK-NET",
                                                      _passPhrase);
            var json = tx.ToJson();

            tx.RecipientId = "AavdJLxqBnWqaFXWm2xNirNArJNUmyUpup";

            Assert.IsFalse(Crypto.Verify(tx));
            Assert.AreNotEqual(json, tx.ToJson());
        }
コード例 #16
0
        public void CreateTransactionFeeChangeTest()
        {
            var tx = TransactionApi.CreateTransaction("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25",
                                                      133380000000,
                                                      "This is first transaction from ARK-NET",
                                                      "this is a top secret passphrase");
            var json = tx.ToJson();

            tx.Fee = 11;

            Assert.IsFalse(Crypto.Verify(tx));
            Assert.AreNotEqual(json, tx.ToJson());
        }
コード例 #17
0
        public void CreateTransactionRecepientChangeTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from SMARTHOLDEM-NET",
                                                      _passPhrase);
            var json = tx.ToJson();

            tx.RecipientId = "SbNu1nZevSh1Qx9zL4VjqatcE7DQSnLn37";

            Assert.IsFalse(Crypto.Verify(tx));
            Assert.AreNotEqual(json, tx.ToJson());
        }
コード例 #18
0
        public void CreateTransactionRecepientChangeTest()
        {
            var tx = TransactionApi.CreateTransaction("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25",
                                                      133380000000,
                                                      "This is first transaction from ARK-NET",
                                                      "this is a top secret passphrase");
            var json = tx.ToJson();

            tx.RecipientId = "AavdJLxqBnWqaFXWm2xNirNArJNUmyUpup";

            Assert.IsFalse(Crypto.Verify(tx));
            Assert.AreNotEqual(json, tx.ToJson());
        }
コード例 #19
0
        public void CreateTransactionAmountChangeTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from ARK-NET",
                                                      _passPhrase);
            var json = tx.ToJson();

            tx.Amount = 10100000000000000;

            Assert.IsFalse(Crypto.Verify(tx));
            Assert.AreNotEqual(json, tx.ToJson());
        }
コード例 #20
0
ファイル: NetworkTests.cs プロジェクト: waffle-iron/ark-net
        public void PostTransactionTransferTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from ARK-NET 22",
                                                      _passPhrase);

            var result = TransactionService.PostTransaction(tx);

            Assert.IsTrue(result.Success);
            Assert.IsNotNull(result.TransactionIds);
            Assert.IsTrue(result.TransactionIds.Count > 0);
        }
コード例 #21
0
ファイル: NetworkTests.cs プロジェクト: waffle-iron/ark-net
        public void TransactionSerializeTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from ARK-NET 22",
                                                      _passPhrase);

            tx.Timestamp = 100;
            File.WriteAllText(@"C:\temp\txNew.json", tx.SerializeObject2JSon());
            File.WriteAllText(@"C:\temp\txNew.xml", tx.SerializeObject2Xml());

            Assert.IsTrue(1 == 1);
        }
コード例 #22
0
        public void PostTransactionNoBalanceTest()
        {
            var tx = TransactionApi.CreateTransaction("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25",
                                                      133380000000,
                                                      "This is first transaction from ARK-NET",
                                                      "this is a top secret passphrase");

            //var peer = NetworkApi.Instance.GetRandomPeer();


            var result = TransactionService.PostTransaction(tx);

            Assert.AreEqual(result.error, "Account does not have enough ARK: AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC balance: 0");
        }
コード例 #23
0
        public void JSONSerDeSerTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from SMARTHOLDEM-NET",
                                                      _passPhrase);
            var json = tx.ToJson();

            Console.WriteLine(json);

            var tx2 = TransactionApi.FromJson(json);

            Assert.AreEqual(json, tx2.ToJson());
        }
コード例 #24
0
        public void TransactionSerializeTest()
        {
            var tx = TransactionApi.CreateTransaction("ASJBHz4JfWVUGDyN61hMMnW1Y4ZCTBHL1K",
                                                      1000,
                                                      "This is first transaction from ARK-NET 22",
                                                      "ski rose knock live elder parade dose device fetch betray loan holiday");

            tx.Timestamp = 100;
            File.WriteAllText(@"C:\temp\txNew.json", tx.SerializeObject2JSon());
            File.WriteAllText(@"C:\temp\txNew.xml", tx.SerializeObject2Xml());


            Assert.IsTrue(1 == 1);
        }
コード例 #25
0
        public void JSONSerDeSerTest()
        {
            var tx = TransactionApi.CreateTransaction("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25",
                                                      133380000000,
                                                      "This is first transaction from ARK-NET",
                                                      "this is a top secret passphrase",
                                                      "this is a top secret second passphrase");
            var json = tx.ToJson();

            Console.WriteLine(json);

            var tx2 = TransactionApi.FromJson(json);

            Assert.AreEqual(json, tx2.ToJson());
        }
コード例 #26
0
        public void CreateTransaction2ndPassPhraseandVerifyTest()
        {
            var tx = TransactionApi.CreateTransaction("AXoXnFi4z1Z6aFvjEYkDVCtBGW2PaRiM25",
                                                      133380000000,
                                                      "This is first transaction from ARK-NET",
                                                      "this is a top secret passphrase",
                                                      "this is a top secret second passphrase");

            var secondPublicKeyHex = Crypto.GetKeys("this is a top secret second passphrase").PubKey.ToBytes();

            var secondPublicKeyHexStr = Encoders.Hex.EncodeData(secondPublicKeyHex);

            Assert.IsTrue(Crypto.Verify(tx));
            Assert.IsTrue(Crypto.SecondVerify(tx, secondPublicKeyHexStr));
        }
コード例 #27
0
        public void CreateTransaction2ndPassPhraseandVerifyTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from SMARTHOLDEM-NET",
                                                      _passPhrase,
                                                      "this is a top secret second passphrase");

            var secondPublicKeyHex = Crypto.GetKeys("this is a top secret second passphrase").PubKey.ToBytes();

            var secondPublicKeyHexStr = Encoders.Hex.EncodeData(secondPublicKeyHex);

            Assert.IsTrue(Crypto.Verify(tx));
            Assert.IsTrue(Crypto.SecondVerify(tx, secondPublicKeyHexStr));
        }
コード例 #28
0
        public void JSONSerDeSerNegTest()
        {
            var tx = TransactionApi.CreateTransaction(_address,
                                                      1,
                                                      "This is first transaction from ARK-NET",
                                                      _passPhrase);
            var json = tx.ToJson();

            Console.WriteLine(json);

            var tx2 = TransactionApi.FromJson(json);

            tx2.SignSignature = "Change";

            Assert.AreNotEqual(json, tx2.ToJson());
        }
コード例 #29
0
        public async Task <IHttpActionResult> CreateTransaction(TransactionCreateViewModel model)
        {
            try
            {
                var transactionApi = new TransactionApi();
                var UserManager    = Request.GetOwinContext().GetUserManager <ApplicationUserManager>();
                var user           = await UserManager.FindByNameAsync(model.Username);

                var userId = user.Id;
                model.TransactionDate = DateTime.Now;
                model.AspNetUserId    = userId;
                model.EndTime         = model.TransactionDate.AddHours(model.Duration);
                var transaction = transactionApi.CreateTransaction(model);
                var parkingLot  = (new ParkingLotApi()).Get(model.ParkingLotId);
                transaction.TransactionCode = parkingLot.Address + transaction.Id + "";
                transactionApi.Edit(transaction.Id, transaction);
                TransactionCreateReturnViewModel result = new TransactionCreateReturnViewModel()
                {
                    Id              = transaction.Id,
                    Amount          = transaction.Amount,
                    AspNetUserId    = transaction.AspNetUserId,
                    CarParkId       = transaction.CarParkId,
                    EndTime         = transaction.EndTime,
                    LongEndTime     = transaction.EndTime.Value.Ticks,
                    ParkingLotId    = transaction.ParkingLotId,
                    Status          = transaction.Status,
                    TransactionCode = transaction.TransactionCode,
                    TransactionDate = transaction.TransactionDate,
                };
                return(Json(new ResultModel
                {
                    obj = result,
                    success = true,
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ResultModel
                {
                    success = false,
                }));
            }
        }