Exemple #1
0
        /// <summary>
        /// TODO: This should be made in to a unit test but it's annoying to add the UI for a unit test as the Trezor requires human intervention for the pin
        /// </summary>
        /// <returns></returns>
        private static async Task Go()
        {
            try
            {
                using (var trezorHid = await Connect())
                {
                    using (var trezorManager = new TrezorManager(GetPin, trezorHid, new DefaultCoinUtility()))
                    {
                        await trezorManager.InitializeAsync();

                        var tasks = new List <Task>();

                        for (uint i = 0; i < 50; i++)
                        {
                            tasks.Add(DoGetAddress(trezorManager, i));
                        }

                        await Task.WhenAll(tasks);

                        for (uint i = 0; i < 50; i++)
                        {
                            var address = await GetAddress(trezorManager, i);

                            Console.WriteLine($"Index: {i} (No change) - Address: {address}");

                            if (address != _Addresses[i])
                            {
                                throw new Exception("The ordering got messed up");
                            }
                        }

                        var addressPath = new AddressPath(false, 60, 0, false, 0);

                        var ethAddress = await trezorManager.GetAddressAsync(addressPath, false, false);

                        Console.WriteLine($"First ETH address: {ethAddress}");

                        Console.WriteLine("All good");

                        Console.ReadLine();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
        }
Exemple #2
0
        private static Task <string> GetAddressAsync(bool isSegwit, uint coinNumber, bool isChange, uint index, bool display, string coinName = null, bool isPublicKey = false)
        {
            var addressPath = new AddressPath(isSegwit, coinNumber, 0, isChange, index);

            return(TrezorManager.GetAddressAsync(addressPath, isPublicKey, display));
        }