Пример #1
0
        public async Task <UnsignedTransaction> Send(string fromAddress, string toAddress, string fromPrivate, string fromPublic,
                                                     Satoshi amount)
        {
            var unsignedTx = await PostAsync <UnsignedTransaction>("txs/new", new BasicTransaction {
                Inputs = new[] {
                    new TxInput {
                        Addresses = new[] {
                            fromAddress
                        }
                    }
                },
                Outputs = new[] {
                    new TxOutput {
                        Addresses = new[] {
                            toAddress
                        },
                        Value = amount
                    }
                }
            });

            // SIGN

            unsignedTx.Signatures = new List <string>();
            unsignedTx.PubKeys    = new List <string>();

            Sign(unsignedTx, fromPrivate, true, true, true);

            return(await PostAsync <UnsignedTransaction>("txs/send", unsignedTx));
        }
Пример #2
0
        public async Task <UnsignedTransaction> Send(string fromAddress, string toAddress, string fromPrivate,
                                                     Satoshi amount, string preference, Satoshi fee = null)
        {
            try
            {
                var unsignedTx = await PostAsync <UnsignedTransaction>("txs/new", new BasicTransaction
                {
                    Inputs = new[] {
                        new TxInput {
                            Addresses = new[] {
                                fromAddress
                            }
                        }
                    },
                    Outputs = new[] {
                        new TxOutput {
                            Addresses = new[] {
                                toAddress
                            },
                            Value = -1 //Value -1 indicates to spend all the value in address
                        }
                    },
                    Preference = preference
                });

                return(await processSend(unsignedTx, fromPrivate));
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }
Пример #3
0
        public async Task <ActionResult> Faucet()
        {
            Satoshi satoshi = new Satoshi(10000);
            await bc.Faucet("BuCuWnhdpi4CcM2oYFf7Cs1akdANiur7eY", satoshi);


            return(View());
        }
Пример #4
0
        public async Task <ActionResult> Balance(string address)
        {
            var request = await bc.GetBalanceForAddress(address);

            Satoshi satoshi = request.Balance;

            decimal count = satoshi.Btc;

            ViewData["Address"] = count;

            return(View());
        }
Пример #5
0
        public Task <Faucet> Faucet(string address, Satoshi amount)
        {
            if (Endpoint != Endpoint.BcyTest)
            {
                throw new Exception("Invalid endpoint: faucet is only allowed for BcyTest");
            }

            return(PostAsync <Faucet>("faucet", new {
                address,
                amount = (int)amount.Value
            }));
        }
Пример #6
0
        static void Main(string[] args)
        {
            Satoshi s = new Satoshi("a91335f18f9ffbddc5b98834040c715ff35cb83f");
            double lost = 0;
            double won = 0;
            Random r = new Random();
            while(true)
            {
                s.NewGame(5, 0);
                if (s.Data == null || s.Data.status != "success")
                {
                    Console.WriteLine("Failed.");
                    Console.ReadLine();
                    return;
                }
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("Game started. Game type: {0} | Bombs: {1}", s.Data.gametype, s.Data.num_mines);
                Console.ForegroundColor = ConsoleColor.Blue;
                bool cashout = false;
                while (!cashout)
                {
                    int sq = r.Next(1, 24);
                    Console.WriteLine("betting square {0}", sq);

                    BetData b = s.Bet(sq);
                    Console.WriteLine("Outome: {0}", b.outcome);
                    if (b.outcome == "bomb")
                    {
                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.WriteLine("Lost {0}", b.stake);
                        lost ++;
                        break;
                    }
                    else
                    {
                        cashout = r.Next(0, 2) == 1;
                        if (cashout)
                        {
                            won++;
                            CashOutData co = s.CashOut();
                            Console.ForegroundColor = ConsoleColor.Green;
                            Console.WriteLine(co.message);
                        }
                    }
                }
                if(won != 0 || lost != 0)
                    Console.WriteLine("Win percent: {0}% || Wins: {1} | Losses: {2}", (won / (won + lost)) * 100, won, lost);
                Console.WriteLine();
            }
        }
Пример #7
0
        public async Task <UnsignedTransaction> Send(string fromAddress, string toAddress, string fromPrivate,
                                                     string fromPublic, Satoshi amount)
        {
            var unsignedTx = await PostAsync <UnsignedTransaction>("txs/new", new BasicTransaction {
                Inputs = new[] {
                    new TxInput {
                        Addresses = new[] {
                            fromAddress
                        }
                    }
                },
                Outputs = new[] {
                    new TxOutput {
                        Addresses = new[] {
                            toAddress
                        },
                        Value = amount
                    }
                }
            });

            return(await processSend(unsignedTx, fromPrivate));
        }
Пример #8
0
 public Task <UnsignedTransaction> Send(AddressInfo fromAddress, AddressInfo toAddress, Satoshi amount)
 {
     return(Send(fromAddress.Address, toAddress.Address, fromAddress.Private, fromAddress.Public, amount));
 }