Пример #1
0
        /// <summary>
        /// Creates the buy in tx
        /// </summary>
        /// <param name="address"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public static async Task <String> CreateBuyInTx(String tableAddress, UInt64 amount)
        {
            BlockrTransactionRepository repo  = new BlockrTransactionRepository(NBitcoin.Network.TestNet);
            IEnumerable <Coin>          utxos = await repo.GetUnspentAsync(carol.ToString());

            TransactionBuilder builder = new TransactionBuilder();

            builder.AddCoins(utxos)
            .AddKeys(carol_secret)
            .BuildTransaction(true);

            //return builder.trans

            return("");
        }
Пример #2
0
        private static async Task <Transaction> CreateTransaction(BitcoinSecret secret, IDestination address, Int64 amount)
        {
            //Alice tx
            //d74b4bfc99dd46adb7c30877cc3ce7ea13feb51a6fab3b9b15f75f4e213ac0da
            BlockrTransactionRepository repo  = new BlockrTransactionRepository(Network.TestNet);
            IEnumerable <Coin>          utxos = await repo.GetUnspentAsync(secret.GetAddress().ToString());

            //Coin[] coins = utxos.OrderByDescending(u => u.Amount).Select(u => new Coin(u.Outpoint, u.TxOut)).ToArray();

            TransactionBuilder txBuilder = new TransactionBuilder();
            Transaction        tx        = txBuilder
                                           .AddCoins(utxos)
                                           .AddKeys(secret)
                                           .Send(address, new Money(amount))
                                           .SendFees(new Money(10000))
                                           .SetChange(address)
                                           .BuildTransaction(true);

            return(tx);
        }
Пример #3
0
        //[Trait("UnitTest", "UnitTest")]
        public static void CanRequestBlockr()
        {
            var repo   = new BlockrTransactionRepository(Network.Main);
            var result = repo.Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de");

            Assert.NotNull(result);
            Assert.Equal("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de", result.GetHash().ToString());

            result = repo.Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927df");
            Assert.Null(result);

            var unspent = repo.GetUnspentAsync("1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa").Result;

            Assert.True(unspent.Count != 0);

            repo   = new BlockrTransactionRepository(Network.TestNet);
            result = repo.Get("7d4c5d69a85c70ff70daff789114b9b76fb6d2613ac18764bd96f0a2b9358782");
            Assert.NotNull(result);

            unspent = repo.GetUnspentAsync("2N66DDrmjDCMM3yMSYtAQyAqRtasSkFhbmX").Result;
            Assert.True(unspent.Count != 0);
        }
Пример #4
0
		public static void CanRequestBlockr()
		{
			var repo = new BlockrTransactionRepository(Network.Main);
			var result = repo.Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de");
			Assert.NotNull(result);
			Assert.Equal("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927de", result.GetHash().ToString());

			result = repo.Get("c3462373f1a722c66cbb1b93712df94aa7b3731f4142cd8413f10c9e872927df");
			Assert.Null(result);

			var unspent = repo.GetUnspentAsync("15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe").Result;
			Assert.True(unspent.Count != 0);

			repo = new BlockrTransactionRepository(Network.TestNet);
			result = repo.Get("7d4c5d69a85c70ff70daff789114b9b76fb6d2613ac18764bd96f0a2b9358782");
			Assert.NotNull(result);

			unspent = repo.GetUnspentAsync("2N66DDrmjDCMM3yMSYtAQyAqRtasSkFhbmX").Result;
			Assert.True(unspent.Count != 0);
		}