You are viewing a single comment's thread from:

RE: Steem Api Help???

in #steemdev7 years ago

Any help you can give is much appreciated. Here is the code, I haven't changed any of the internals of the library, and I have used Ditch you can find the link here

            userPrivateKeys = new List<byte[]>
            {
                Base58.GetBytes(WIF)
            };

Convert the keys into a byte array

private static byte[] Base58CheckDecode(string data)
        {
            var s = Decode(data);
            var dec = CutLastBytes(s, 4);

            //var checksum = SHA256.Instance.DoubleHash(dec);
            //for (int i = 0; i < 4; i++)
            //    Assert.IsTrue(checksum[i] == s[s.Length - 4 + i]);

            return CutFirstBytes(dec, 1);
        }

        private static byte[] Decode(string base58)
        {
            // Decode Base58 string to BigInteger 
            BigInteger intData = 0;
            for (var i = 0; i < base58.Length; i++)
            {
                var digit = Digits.IndexOf(base58[i]); //Slow
                if (digit < 0)
                    throw new FormatException($"Invalid Base58 character `{base58[i]}` at position {i}");
                intData = intData * 58 + digit;
            }

            // Encode BigInteger to byte[]
            // Leading zero bytes get encoded as leading `1` characters
            var leadingZeroCount = base58.TakeWhile(c => c == '1').Count();
            var leadingZeros = Enumerable.Repeat((byte)0, leadingZeroCount);
            var bytesWithoutLeadingZeros =
                intData.ToByteArray()
                .Reverse()// to big endian
                .SkipWhile(b => b == 0);//strip sign byte
            var result = leadingZeros.Concat(bytesWithoutLeadingZeros).ToArray();
            return result;
        }

        private static byte[] CutFirstBytes(byte[] source, int cutCount)
        {
            var rez = new byte[source.Length - cutCount];
            Array.Copy(source, cutCount, rez, 0, rez.Length);
            return rez;
        }

Using the Cryptography.ECDSA library to sign the payload

var sig = Secp256k1Manager.SignCompressedCompact(data, userPrivateKey);

RPC Call Message

{"method":"call","params":[3,"broadcast_transaction",[{"ref_block_num":34752,"ref_block_prefix":2723778811,"expiration":"2017-08-01T09:50:54","operations":[["vote",{"voter":"nosajj","author":"jerrybanfield","permlink":"90 -paths-to-profit-online","weight":10000}]],"extensions":[],"signatures":["SIGNATURE"]}]],"jsonrpc":"2.0","id":1}

The returned error message

13 N5boost16exception_detail10clone_implINS0_19error_info_injectorISt12out_of_rangeEEEE: unknown key
unknown key
Sort:  

Hi, I have the same error. What key do I use? Private key for posting? If so this doesn't seem to work.

Coin Marketplace

STEEM 0.16
TRX 0.13
JST 0.027
BTC 60314.14
ETH 2890.04
USDT 1.00
SBD 2.35