コード例 #1
0
        public string Get([FromQuery] string code)
        {
            MixinApi mixinApi = new MixinApi();

            mixinApi.Init(USRCONFIG.ClientId, USRCONFIG.ClientSecret, USRCONFIG.SessionId, USRCONFIG.PinToken, USRCONFIG.PrivateKey);

            string token = mixinApi.GetClientAuthToken(code);

            System.Console.WriteLine(token);

            var a = mixinApi.ReadProfile(token);
            var b = mixinApi.ReadAssets(token);

            return(b.ToString());
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("======== Mixin C# SDK Test ========= \n");
            MixinApi mixinApi = new MixinApi();

            mixinApi.Init(USRCONFIG.ClientId, USRCONFIG.ClientSecret, USRCONFIG.SessionId, USRCONFIG.PinToken, USRCONFIG.PrivateKey);

            Console.WriteLine("======== Initiation Finished ========= \n");

            Console.WriteLine("======== Test Create PIN ===========\n");

            //Console.WriteLine(mixinApi.CreatePIN(USRCONFIG.PinCode, "123456").ToString());

            Console.WriteLine();

            //Console.WriteLine(mixinApi.CreatePIN("123456", USRCONFIG.PinCode).ToString());

            Console.WriteLine("\n\n======== Test Verify PIN ===========\n");

            //Console.WriteLine(mixinApi.VerifyPIN(USRCONFIG.PinCode).ToString());


            Console.WriteLine("\n\n======== Test Deposit ===========\n");
            Console.WriteLine(mixinApi.Deposit("3596ab64-a575-39ad-964e-43b37f44e8cb").ToString());


            Console.WriteLine("\n\n======== Test Read Assets ===========\n");

            var assets = mixinApi.ReadAssets();

            foreach (var asset in assets)
            {
                Console.WriteLine(asset.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Read Asset ===========\n");
            Console.WriteLine(mixinApi.ReadAsset("6cfe566e-4aad-470b-8c9a-2fd35b49c68d"));

            Console.WriteLine("\n\n======== Test Search Assest ===========\n");

            assets = mixinApi.SearchAssets("CNB");
            foreach (var asset in assets)
            {
                Console.WriteLine(asset.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Network Asset ===========\n");
            Console.WriteLine(mixinApi.NetworkAsset("965e5c6e-434c-3fa9-b780-c50f43cd955c"));

            Console.WriteLine("\n\n======== Test Top Assets ===========\n");
            var topasset = mixinApi.TopAssets();

            foreach (var asset in topasset)
            {
                Console.WriteLine(asset.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Network Snapshot don't auth ===========\n");
            Console.WriteLine(mixinApi.NetworkSnapshot("85b8c435-1ef6-4f2a-85f9-8def2a852473", false));


            Console.WriteLine("\n\n======== Test Network Snapshot auth ===========\n");
            Console.WriteLine(mixinApi.NetworkSnapshot("85b8c435-1ef6-4f2a-85f9-8def2a852473", true));

            Console.WriteLine("\n\n======== Test Network Snapshots ===========\n");

            var snaps = mixinApi.NetworkSnapshots(2, "2019-01-02T15:04:05.999999999-07:00", null, null, false);

            foreach (var sn in snaps)
            {
                Console.WriteLine(sn.ToString());
                Console.WriteLine();
            }

            snaps = mixinApi.NetworkSnapshots(2, "2019-01-02T15:04:05.999999999-07:00", null, null, true);
            foreach (var sn in snaps)
            {
                Console.WriteLine(sn.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== External Transactions ===========\n");
            var ts = mixinApi.ExternalTransactions("6cfe566e-4aad-470b-8c9a-2fd35b49c68d", null, null, null, 10, null);

            foreach (var t in ts)
            {
                Console.WriteLine(t.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Create Address ===========\n");
            //var addr = mixinApi.CreateAddress("965e5c6e-434c-3fa9-b780-c50f43cd955c", "0xe6Bf2C2E8f3243dF46308ca472038eA9Fa1bc42C", "CNB withdraw", null, null, USRCONFIG.PinCode);
            //Console.WriteLine(addr);

            Console.WriteLine("\n\n======== Test Create Address ===========\n");
            //addr = mixinApi.CreateAddress("965e5c6e-434c-3fa9-b780-c50f43cd955c", "0x078C5AF6C8Ab533b8ef7FAb822B5B5f70A9d1c35", "CNB withdraw123", null, null, USRCONFIG.PinCode);
            //Console.WriteLine(addr);

            Console.WriteLine("\n\n======== Test Read Address ===========\n");
            //Console.WriteLine(mixinApi.ReadAddress(addr.address_id));

            Console.WriteLine("\n\n======== Test Delete Address ===========\n");
            //Console.WriteLine(mixinApi.DeleteAddress(USRCONFIG.PinCode, addr.address_id));

            Console.WriteLine("\n\n======== Test Withdrawal Addresses ===========\n");
            var addrlist = mixinApi.WithdrawalAddresses("965e5c6e-434c-3fa9-b780-c50f43cd955c");

            foreach (var a in addrlist)
            {
                Console.WriteLine(a.ToString());
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Withdrawal  ===========\n");
            //Console.WriteLine(mixinApi.Withdrawal(addrlist[0].address_id, "100", USRCONFIG.PinCode, System.Guid.NewGuid().ToString(), "Test withdraw"));


            Console.WriteLine("\n\n======== Test Search User  ===========\n");
            var u = mixinApi.SearchUser("31243");

            Console.WriteLine(u);

            Console.WriteLine("\n\n======== Test Read User  ===========\n");
            Console.WriteLine(mixinApi.ReadUser("cf0b9c0e-a80a-4044-a6dc-797400c148d7"));

            Console.WriteLine("\n\n======== Test Transfer  ===========\n");
            //Console.WriteLine(mixinApi.Transfer("965e5c6e-434c-3fa9-b780-c50f43cd955c", "cf0b9c0e-a80a-4044-a6dc-797400c148d7", "100", USRCONFIG.PinCode, System.Guid.NewGuid().ToString(), "Test Transfer"));


            Console.WriteLine("\n\n======== Test Verify Payment ===========\n");
            Console.WriteLine(mixinApi.VerifyPayment("965e5c6e-434c-3fa9-b780-c50f43cd955c", "cf0b9c0e-a80a-4044-a6dc-797400c148d7", "100", "414c95cc-d695-48df-b23b-00815b21ed00"));

            Console.WriteLine("\n\n======== Test Read Transfer ===========\n");
            Console.WriteLine(mixinApi.ReadTransfer("414c95cc-d695-48df-b23b-00815b21ed00"));

            Console.WriteLine("\n\n======== Test APP User ===========\n");

            var kpgen = new RsaKeyPairGenerator();

            kpgen.Init(new KeyGenerationParameters(new SecureRandom(new CryptoApiRandomGenerator()), 1024));

            var keyPair = kpgen.GenerateKeyPair();
            AsymmetricKeyParameter privateKey = keyPair.Private;
            AsymmetricKeyParameter publicKey  = keyPair.Public;

            SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(keyPair.Public);
            string pk = Convert.ToBase64String(info.GetDerEncoded());


            var user = mixinApi.APPUser("Csharp" + (new Random().Next() % 100) + "test", pk);

            Console.WriteLine(user);

            Console.WriteLine("\n\n======== Test Read Profile ===========\n");
            Console.WriteLine(mixinApi.ReadProfile());

            Console.WriteLine("\n\n======== Test Update Profile ===========\n");
            Console.WriteLine(mixinApi.UpdateProfile("mixin_csharp_sdk_demo", "iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAAK/INwWK6QAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4wEJAgwnFleLvwAAEWhJREFUaN61mXmMXVd9xz/nnLu8bfbNY4+dOCZ2bJOoIRskbKLQQJpUgbD8QdWyFpWyCRpQoSrQShVFLFUqBahUGkGRKEVBVgqEUoJLgCQkBBLHOI4dO9jO2GN7tjdvu/csv/5x74xnbIdCoEf6+ln33Tnn+z2/9ZyneJZj3+GnOVlbzwXMcdT3c7IHTSvsHNLRTE/qCjUoUAMiBQ4lbQ0LG+u68/NZ7/pixURFWO/nOK6HGOmd4OLNF/zGPNSzIX/P4SYpjhOhxiO9lJcP2eGWU8/NA1d54TLgQqMYU4qKAiPgRegGOIlwONY8kmge7Itk74OtePGiKGNSt8iJuPaCwf8/Ad974jSTeol9YZzXXPiQuuvo1dss6mYn6qaA2hlrNVCLoBYpYg1GgVIgAl4gD0LXQdcLLjCvFY/GyF2pDrte9YPKwW+9OONVU10ePpVyxWTtdyfggaNNZrqQ6MBB28/GqLMpw7zNinpj7rkoMYqRiqY/KYgvTyrnWUiAPEAzF2azgA9IxXAg0XJHPeKOp9r6+Na+gBXF1qjJBZNjv52Ag0emua89SEUHptI8Ppqlr85Ff7DruSL3wmhVM1nXxPr/3gs5a8HcC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zA4OjAw1FL7XAAAAEN0RVh0c29mdHdhcmUAL3Vzci9sb2NhbC9pbWFnZW1hZ2ljay9zaGFyZS9kb2MvSW1hZ2VNYWdpY2stNy8vaW5kZXguaHRtbL21eQoAAAAYdEVYdFRodW1iOjpEb2N1bWVudDo6UGFnZXMAMaf/uy8AAAAYdEVYdFRodW1iOjpJbWFnZTo6SGVpZ2h0ADEyOEN8QYAAAAAXdEVYdFRodW1iOjpJbWFnZTo6V2lkdGgAMTI40I0R3QAAABl0RVh0VGh1bWI6Ok1pbWV0eXBlAGltYWdlL3BuZz+yVk4AAAAXdEVYdFRodW1iOjpNVGltZQAxNTQ2OTcxMTU59OK0DQAAABJ0RVh0VGh1bWI6OlNpemUAMTYxODVCiLvlAQAAAGJ0RVh0VGh1bWI6OlVSSQBmaWxlOi8vL2hvbWUvd3d3cm9vdC9uZXdzaXRlL3d3dy5lYXN5aWNvbi5uZXQvY2RuLWltZy5lYXN5aWNvbi5jbi9maWxlcy8xMDgvMTA4NjU1NS5wbmcDuUg9AAAAAElFTkSuQmCC"));

            Console.WriteLine("\n\n======== Test Update Perference ===========\n");
            Console.WriteLine(mixinApi.UpdatePerference("CONTACTS", "CONTACTS"));
            Console.WriteLine(mixinApi.UpdatePerference("EVERYBODY", "EVERYBODY"));

            Console.WriteLine("\n\n======== Test Rotate User's QR ===========\n");
            Console.WriteLine(mixinApi.RotateUserQR());

            Console.WriteLine("\n\n======== Test Friends ===========\n");
            var friends = mixinApi.Friends();

            foreach (var f in friends)
            {
                Console.WriteLine(f);
                Console.WriteLine();
            }

            Console.WriteLine("\n\n======== Test Create Attachment ===========\n");
            Console.WriteLine(mixinApi.CreateAttachment());


            Console.WriteLine("\n\n======== Test Create Conversation ===========\n");

            var users = new List <ParticipantAction>();

            users.Add(new ParticipantAction {
                action = "ADD", role = "", user_id = u.user_id
            });
            Console.WriteLine(mixinApi.CreateConversation("GROUP", users));

            Console.WriteLine(mixinApi.CreateConversation("CONTACT", users));

            Console.WriteLine("\n\n======== Test Read Conversation ===========\n");
            Console.WriteLine(mixinApi.ReadConversation("fd72abcd-b080-3e0e-bfea-a0b1282b4bd0"));



            mixinApi.WebSocketConnect(HandleOnRecivedMessage).Wait();

            mixinApi.StartRecive();

            do
            {
                var msg = Console.ReadLine();
                mixinApi.SendTextMessage("fd72abcd-b080-3e0e-bfea-a0b1282b4bd0", msg).Wait();
            } while (true);
        }
コード例 #3
0
// # // Mixin Network support cryptocurrencies (2019-02-19)
// # // |EOS|6cfe566e-4aad-470b-8c9a-2fd35b49c68d
// # // |CNB|965e5c6e-434c-3fa9-b780-c50f43cd955c
// # // |BTC|c6d0c728-2624-429b-8e0d-d9d19b6592fa
// # // |ETC|2204c1ee-0ea2-4add-bb9a-b3719cfff93a
// # // |XRP|23dfb5a5-5d7b-48b6-905f-3970e3176e27
// # // |XEM|27921032-f73e-434e-955f-43d55672ee31
// # // |ETH|43d61dcd-e413-450d-80b8-101d5e903357
// # // |DASH|6472e7e3-75fd-48b6-b1dc-28d294ee1476
// # // |DOGE|6770a1e5-6086-44d5-b60f-545f9d9e8ffd
// # // |LTC|76c802a2-7c88-447f-a93e-c29c9e5dd9c8
// # // |SC|990c4c29-57e9-48f6-9819-7d986ea44985
// # // |ZEN|a2c5d22b-62a2-4c13-b3f0-013290dbac60
// # // |ZEC|c996abc9-d94e-4494-b1cf-2a3fd3ac5714
// # // |BCH|fd11b6e3-0b87-41f1-a41f-f0e9b49e5bf0
        static void Main(string[] args)
        {
            MixinApi mixinApi = new MixinApi();

            mixinApi.Init(ClientId,
                          ClientSecret,
                          SessionId,
                          PinToken,
                          PrivateKey);
            string PromptMsg;

            PromptMsg  = "1: Create user and update PIN\n2: Read Bitcoin balance \n3: Read Bitcoin Address\n4: Read EOS balance\n";
            PromptMsg += "5: Read EOS address\n6: Transfer Bitcoin from bot to new account\n7: Transfer Bitcoin from new account to Master\n";
            PromptMsg += "8: Withdraw bot's Bitcoin\n8: Withdraw bot's EOS\na: Verify Pin\nd: Create Address and Delete it\nr: Create Address and read it\n";
            PromptMsg += "q: Exit \nMake your choose:";
            // Console.WriteLine(mixinApi.VerifyPIN(PinCode).ToString());
            do
            {
                Console.WriteLine(PromptMsg);
                var cmd = Console.ReadLine();
                if (cmd == "1")
                {
                    var kpgen = new RsaKeyPairGenerator();

                    kpgen.Init(new KeyGenerationParameters(new SecureRandom(new CryptoApiRandomGenerator()), 1024));

                    var keyPair = kpgen.GenerateKeyPair();
                    AsymmetricKeyParameter privateKey = keyPair.Private;
                    AsymmetricKeyParameter publicKey  = keyPair.Public;

                    SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(keyPair.Public);
                    string pk = Convert.ToBase64String(info.GetDerEncoded());


                    var user = mixinApi.APPUser("Csharp" + (new Random().Next() % 100) + " Cat", pk);
                    Console.WriteLine(user);

                    using (var writer = new StreamWriter("new_users.csv", append: true))
                        using (var csv = new CsvWriter(writer))
                        {
                            csv.WriteField(user.user_id);

//Write Private key to CSV
                            RsaPrivateCrtKeyParameters rsaParameters = (RsaPrivateCrtKeyParameters)privateKey;
                            RSACryptoServiceProvider   priKey        = new RSACryptoServiceProvider();
                            priKey.ImportParameters(DotNetUtilities.ToRSAParameters(rsaParameters));
                            TextWriter pemText = new StringWriter();
                            ExportPrivateKey(priKey, pemText);
                            csv.WriteField(pemText.ToString());

                            csv.WriteField(user.pin_token);
                            csv.WriteField(user.session_id);
                            csv.NextRecord();
                            csv.Flush();

//Update the pincode of New user
                            MixinApi mixinApiNewUser = new MixinApi();
                            mixinApiNewUser.Init(user.user_id, "", user.session_id, user.pin_token, pemText.ToString());
                            Console.WriteLine(mixinApiNewUser.CreatePIN("", "123456").ToString());
                        }
                }
                if (cmd == "2" || cmd == "3")
                {
                    using (TextReader fileReader = File.OpenText(@"new_users.csv"))
                    {
                        var csv = new CsvReader(fileReader);
                        csv.Configuration.HasHeaderRecord = false;
                        while (csv.Read())
                        {
                            string UserIDNewUser;
                            csv.TryGetField <string>(0, out UserIDNewUser);
                            string PrivateKeyNewUser;
                            csv.TryGetField <string>(1, out PrivateKeyNewUser);
                            string PinTokenNewUser;
                            csv.TryGetField <string>(2, out PinTokenNewUser);
                            string SessionIDNewUser;
                            csv.TryGetField <string>(3, out SessionIDNewUser);

                            MixinApi mixinApiNewUser = new MixinApi();
                            mixinApiNewUser.Init(UserIDNewUser, "", SessionIDNewUser, PinTokenNewUser, PrivateKeyNewUser);
                            Asset AssetBTC = mixinApiNewUser.ReadAsset(ASSET_ID_BTC);
                            Console.WriteLine("New User " + UserIDNewUser + " 's BTC balance is " + AssetBTC.balance);
                            Console.WriteLine("New User " + UserIDNewUser + " 's BTC address is " + AssetBTC.public_key);
                        }
                    }
                }
                if (cmd == "4" || cmd == "5")
                {
                    using (TextReader fileReader = File.OpenText(@"new_users.csv"))
                    {
                        var csv = new CsvReader(fileReader);
                        csv.Configuration.HasHeaderRecord = false;
                        while (csv.Read())
                        {
                            string UserIDNewUser;
                            csv.TryGetField <string>(0, out UserIDNewUser);
                            string PrivateKeyNewUser;
                            csv.TryGetField <string>(1, out PrivateKeyNewUser);
                            string PinTokenNewUser;
                            csv.TryGetField <string>(2, out PinTokenNewUser);
                            string SessionIDNewUser;
                            csv.TryGetField <string>(3, out SessionIDNewUser);

                            MixinApi mixinApiNewUser = new MixinApi();
                            mixinApiNewUser.Init(UserIDNewUser, "", SessionIDNewUser, PinTokenNewUser, PrivateKeyNewUser);
                            Asset AssetEOS = mixinApiNewUser.ReadAsset(ASSET_ID_EOS);
                            Console.WriteLine("New User " + UserIDNewUser + " 's EOS balance is " + AssetEOS.balance);
                            Console.WriteLine("New User " + UserIDNewUser +
                                              " 's EOS address is " + AssetEOS.account_name + " " + AssetEOS.account_tag);
                        }
                    }
                }
                if (cmd == "6")
                {
                    using (TextReader fileReader = File.OpenText(@"new_users.csv"))
                    {
                        var csv = new CsvReader(fileReader);
                        csv.Configuration.HasHeaderRecord = false;
                        while (csv.Read())
                        {
                            string UserIDNewUser;
                            csv.TryGetField <string>(0, out UserIDNewUser);
                            Transfer reqInfo = mixinApi.Transfer(ASSET_ID_BTC,
                                                                 UserIDNewUser,
                                                                 AMOUNT, PinCode,
                                                                 System.Guid.NewGuid().ToString(),
                                                                 "Test");
                            Console.WriteLine(reqInfo);
                        }
                    }
                }
                if (cmd == "7")
                {
                    using (TextReader fileReader = File.OpenText(@"new_users.csv"))
                    {
                        var csv = new CsvReader(fileReader);
                        csv.Configuration.HasHeaderRecord = false;
                        while (csv.Read())
                        {
                            string UserIDNewUser;
                            csv.TryGetField <string>(0, out UserIDNewUser);
                            string PrivateKeyNewUser;
                            csv.TryGetField <string>(1, out PrivateKeyNewUser);
                            string PinTokenNewUser;
                            csv.TryGetField <string>(2, out PinTokenNewUser);
                            string SessionIDNewUser;
                            csv.TryGetField <string>(3, out SessionIDNewUser);

                            MixinApi mixinApiNewUser = new MixinApi();
                            mixinApiNewUser.Init(UserIDNewUser, "", SessionIDNewUser, PinTokenNewUser, PrivateKeyNewUser);
                            // Console.WriteLine(mixinApiNewUser.CreatePIN("", "123456").ToString());
                            Transfer reqInfo = mixinApiNewUser.Transfer(ASSET_ID_BTC,
                                                                        MASTER_UUID,
                                                                        AMOUNT,
                                                                        "123456",
                                                                        System.Guid.NewGuid().ToString(),
                                                                        "Test");
                            Console.WriteLine(reqInfo);
                        }
                    }
                }
                if (cmd == "8")
                {
                    var addr = mixinApi.CreateAddress(ASSET_ID_BTC, BTC_WALLET_ADDR, "BTC withdraw", null, null, PinCode);
                    Console.WriteLine(addr);
                    // Console.WriteLine(mixinApi.Withdrawal(addr.address_id,AMOUNT,PinCode,System.Guid.NewGuid().ToString(), "Test withdraw"));
                }
                if (cmd == "9")
                {
                    var addr = mixinApi.CreateAddress(null, null, "EOS withdraw", "eoswithmixin", "d80363afcc466fbaf2daa7328ae2adfa", PinCode);
                    Console.WriteLine(addr);
                    // Console.WriteLine(mixinApi.Withdrawal(addr.address_id,AMOUNT,PinCode,System.Guid.NewGuid().ToString(), "Test withdraw"));
                }
                if (cmd == "q")
                {
                    break;
                }
                if (cmd == "d")
                {
                    var addr = mixinApi.CreateAddress(ASSET_ID_BTC, BTC_WALLET_ADDR, "BTC withdraw", null, null, PinCode);
                    Console.WriteLine(addr);
                    Console.WriteLine(mixinApi.DeleteAddress(PinCode, addr.address_id));
                }
                if (cmd == "r")
                {
                    var addr = mixinApi.CreateAddress(ASSET_ID_BTC, BTC_WALLET_ADDR, "BTC withdraw", null, null, PinCode);
                    Console.WriteLine(addr);
                    Console.WriteLine(mixinApi.ReadAddress(addr.address_id));
                }
                if (cmd == "qs")
                {
                    var assets = mixinApi.ReadAssets();
                    foreach (var asset in assets)
                    {
                        Console.WriteLine(asset.ToString());
                        Console.WriteLine();
                    }
                }
                if (cmd == "s")
                {
                    var u = mixinApi.SearchUser("37222956");
                    Console.WriteLine(u);
                    Console.WriteLine(u.user_id);
                    Console.WriteLine(u.full_name);

                    using (var writer = new StreamWriter("new_users.csv"))
                        using (var csv = new CsvWriter(writer))
                        {
                            csv.WriteField(u.user_id);
                            csv.WriteField(u.full_name);
                            csv.NextRecord();
                            csv.Flush();
                        }
                }
            } while (true);
        }