public OperationManagerTest() { _login = new Dictionary <string, string>() { { "Steem", "Test Login" }, { "Golos", Constants.GolosUser } }; _userPrivateKeys = new Dictionary <string, List <byte[]> >() { { "Steem", new List <byte[]> { Base58.GetBytes(Constants.SteemPostingKey) } }, { "Golos", new List <byte[]> { Base58.GetBytes(Constants.GolosPostingKey) } } }; _chain = new Dictionary <string, ChainInfo>(); var steemChainInfo = ChainManager.GetChainInfo(KnownChains.Steem); _chain.Add("Steem", steemChainInfo); _steem = new OperationManager(steemChainInfo.Url, steemChainInfo.ChainId); var golosChainInfo = ChainManager.GetChainInfo(KnownChains.Golos); _chain.Add("Golos", golosChainInfo); _golos = new OperationManager(golosChainInfo.Url, golosChainInfo.ChainId); }
public void Base58HexTest(string key, string value) { var hex = Base58.GetBytes(key); var sHex = string.Join(string.Empty, hex.Select(i => i.ToString("x2"))); Assert.IsTrue(sHex.Equals(value)); }
public void FollowOperation() { Login = new Dictionary <string, string>() { { "Steem", txtUsername.Text } }; UserPrivateKeys = new Dictionary <string, List <byte[]> >() { { "Steem", new List <byte[]> { Base58.GetBytes(txtPassword.Text) } } }; Chain = new Dictionary <string, ChainInfo>(); var steemChainInfo = ChainManager.GetChainInfo(KnownChains.Steem); Chain.Add("Steem", steemChainInfo); Steem = new OperationManager(steemChainInfo.Url, steemChainInfo.ChainId); var op = new UnFollowOperation(txtUsername.Text, txtFollower.Text, FollowType.blog, txtUsername.Text); var prop = Manager("Steem").VerifyAuthority(UserPrivateKeys["Steem"], op); var propa = Manager("Steem").BroadcastOperations(UserPrivateKeys["Steem"], op); if (propa.Error == null) { lblStatus.Text = "Follow user '" + txtFollower.Text + "' transaction successfully completed!"; } else { lblStatus.Text = "Error follow user: " + propa.Error.Message.ToString(); } }
public void SigningKeyTest(string text, string sig) { var msg = System.Text.Encoding.UTF8.GetBytes(text); var hex = Base58.GetBytes(TestWif); var sha256 = Proxy.GetMessageHash(msg); var signature = Proxy.SignCompressedCompact(sha256, hex); Assert.IsTrue(signature.Length == 65); var sRez = Hex.ToString(signature); Assert.IsTrue(sig.Equals(sRez), $"Expected:{sig} but was {sRez}"); }
public void SignCompressedCompactTest() { var sw1 = new Stopwatch(); var sw2 = new Stopwatch(); var rand = new Random(); byte[] msg; for (int i = 1; i < 1000; i++) { msg = new byte[i]; rand.NextBytes(msg); var hex = Base58.GetBytes(TestWif); var hash = Secp256k1Manager.GetMessageHash(msg); sw1.Start(); var signature1 = Proxy.SignCompressedCompact(hash, hex); sw1.Stop(); sw2.Start(); var signature2 = Secp256k1Manager.SignCompressedCompact(hash, hex); sw2.Stop(); Assert.IsTrue(signature1.Length == 65); Assert.IsTrue(signature2.Length == 65); Assert.IsTrue(Secp256k1Manager.IsCanonical(signature2, 1)); if (Secp256k1Manager.IsCanonical(signature1, 1)) { for (int j = 0; j < signature1.Length; j++) { Assert.IsTrue(signature1[j] == signature2[j]); } } else { Console.WriteLine($"signature1 not canonical - skip [{i}]"); } } Console.WriteLine($"Proxy time {sw1.ElapsedTicks} / Secp256k1Manager time {sw2.ElapsedTicks}"); }
public void PostDataToSteemWithUpvote() { Login = new Dictionary <string, string>() { { "Steem", txtUsername.Text } }; UserPrivateKeys = new Dictionary <string, List <byte[]> >() { { "Steem", new List <byte[]> { Base58.GetBytes(txtPassword.Text) } } }; Chain = new Dictionary <string, ChainInfo>(); var steemChainInfo = ChainManager.GetChainInfo(KnownChains.Steem); Chain.Add("Steem", steemChainInfo); Steem = new OperationManager(steemChainInfo.Url, steemChainInfo.ChainId); var op = new PostOperation(txtTag1.Text, txtUsername.Text, txtTitle.Text, txtResponse.Text, "{\"app\": \"steemit/0.1\", \"tags\": [\"" + txtTag2.Text + "\",\"" + txtTag3.Text + "\",\"" + txtTag4.Text + "\",\"" + txtTag5.Text + "\"]}"); var prop = Manager("Steem").VerifyAuthority(UserPrivateKeys["Steem"], op); var propa = Manager("Steem").BroadcastOperations(UserPrivateKeys["Steem"], op); if (propa.Error == null) { lblStatus.Text = "'Post to STEEM' transaction successfully completed!"; var up = new UpVoteOperation(txtUsername.Text, txtUsername.Text, op.Permlink); var uprop = Manager("Steem").VerifyAuthority(UserPrivateKeys["Steem"], up); var upropa = Manager("Steem").BroadcastOperations(UserPrivateKeys["Steem"], up); } else { lblStatus.Text = "Error posting on STEEM: " + propa.Error.Message.ToString(); } }
public void PostDataToSteem() { Login = new Dictionary <string, string>() { { "Steem", txtUsername.Text } }; UserPrivateKeys = new Dictionary <string, List <byte[]> >() { { "Steem", new List <byte[]> { Base58.GetBytes(txtPassword.Text) } } }; Chain = new Dictionary <string, ChainInfo>(); var steemChainInfo = ChainManager.GetChainInfo(KnownChains.Steem); Chain.Add("Steem", steemChainInfo); Steem = new OperationManager(steemChainInfo.Url, steemChainInfo.ChainId); var op = new PostOperation(txtTag1.Text, txtUsername.Text, txtTitle.Text, txtResponse.Text, "{\"app\": \"steemit/0.1\", \"tags\": [\"" + txtTag2.Text + "\",\"" + txtTag3.Text + "\",\"" + txtTag4.Text + "\",\"" + txtTag5.Text + "\"]}"); var prop = Manager("Steem").VerifyAuthority(UserPrivateKeys["Steem"], op); var resp = Manager("Steem").GetAccountBandwidth(txtUsername.Text, BandwidthType.Post); var Text = JsonConvert.SerializeObject(resp.Result); var propa = Manager("Steem").BroadcastOperations(UserPrivateKeys["Steem"], op); if (propa.Error == null) { lblStatus.Text = "Posted to STEEM blockchain, finished"; } else { lblStatus.Text = propa.Error.Message.ToString(); } }