public address_response GetWallet(string seed)
 {
     compute_address adr = new compute_address();
     adr.seed_string = seed;
     adr.nettype_string = "MAINNET";
     string genKeysData = JsonConvert.SerializeObject(adr, ser);
     byte[] genKeysDataArr = Encoding.UTF8.GetBytes(genKeysData);
     var genKeysDataLen = XMRNative.GetKeysAndAddress(genKeysDataArr, genKeysDataArr.Length);
     byte[] genKeysDataRes = new byte[genKeysDataLen];
     XMRNative.GetKeysAndAddressGetData(genKeysDataRes, genKeysDataLen);
     var genKeysDataString = Encoding.UTF8.GetString(genKeysDataRes);
     return JsonConvert.DeserializeObject\\(genKeysDataString, ser);
 }
Exemple #2
0
        public XMRTaskImageResponse XMR_GetImages(BitfiWallet.NOXWS.ImageRequestTable[] requestTable)
        {
            XMRTaskImageResponse taskTransferResponse = new XMRTaskImageResponse();

            try
            {
                List <string> imgList = new List <string>();
                foreach (var tx in requestTable)
                {
                    compute_key_images img = new compute_key_images();
                    img.pub_spendKey_string = MoneroWallet.Converters.ByteArrayToHex(wallet.Keys.SpendPublic);
                    img.sec_spendKey_string = MoneroWallet.Converters.ByteArrayToHex(wallet.Keys.SpendSecret);
                    img.sec_viewKey_string  = MoneroWallet.Converters.ByteArrayToHex(wallet.Keys.ViewSecret);
                    img.tx_pub_key          = tx.TxPubKey;
                    img.out_index           = tx.OutIndex;

                    byte[] abcArr = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(img, ser));
                    var    rrr    = XMRNative.GenerateKeyImage(abcArr, abcArr.Length);
                    byte[] res123 = new byte[rrr];
                    XMRNative.GenerateKeyImageGetData(res123, rrr);
                    var result123 = Encoding.UTF8.GetString(res123);

                    var resp = JsonConvert.DeserializeObject <key_images_response>(result123, ser);
                    if (resp != null && !string.IsNullOrEmpty(resp.retVal))
                    {
                        if (string.IsNullOrEmpty(resp.err_msg))
                        {
                            imgList.Add(resp.retVal);
                        }
                    }
                }


                taskTransferResponse.SpendKeyImages = imgList.ToArray();
                taskTransferResponse.WalletAddress  = wallet.Address;
                taskTransferResponse.Error          = null;

                if (imgList.Count() < 1)
                {
                    taskTransferResponse.Error = "Invalid info or request for key images.";
                }

                return(taskTransferResponse);
            }
            catch (Exception ex)
            {
                taskTransferResponse.Error = ex.Message;
                return(taskTransferResponse);
            }
        }
 public key_images_response GetKeyImage(string ViewKey, string PubKey, string Secret, string Txn)
 {
     compute_key_images img = new compute_key_images();
     img.pub_spendKey_string = PubKey;
     img.sec_spendKey_string = Secret;
     img.sec_viewKey_string = ViewKey;
     img.tx_pub_key = Txn;
     byte[] abcArr = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(img, ser));
     var rrr = XMRNative.GenerateKeyImage(abcArr, abcArr.Length);
     byte[] res123 = new byte[rrr];
     XMRNative.GenerateKeyImageGetData(res123, rrr);
     var result123 = Encoding.UTF8.GetString(res123);
     return JsonConvert.DeserializeObject\\(result123, ser);
 }
        private Step2Response TryReconstructTransaction(string ToAddress, string Amount, string BaseData, string FromAddress, string feeNeeded = null)
        {
            string s1jData = "";
            string s2jData = "";
            var res = Double.Parse(Amount) * 1e12;
            Amount = res.ToString();
            XMRTaskTransferResponse taskTransferResponse = new XMRTaskTransferResponse();
            MoneroWalletInput data = ConvertFromString(BaseData);
            data.PassedInAttemptAtFee = null;
            if (feeNeeded != null) data.PassedInAttemptAtFee = feeNeeded;
            Step1Prepare step1Prepare = ConvertFromWSObject(data, Amount);
            byte[] s1compdata = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(step1Prepare, ser));
            int s1len = XMRNative.s1compute(s1compdata, s1compdata.Length); s1compdata = new byte[s1len]; XMRNative.s1getdata(s1compdata, s1len);
            s1jData = System.Text.Encoding.UTF8.GetString(s1compdata);
            Step1Response step1Response = JsonConvert.DeserializeObject\\(s1jData, ser);
            if (!string.IsNullOrEmpty(step1Response.err_msg)) throw new Exception(step1Response.err_msg);
            if (!string.IsNullOrEmpty(step1Response.using_fee) && !string.IsNullOrEmpty(data.MaxAllowedFee))
            {
                BigInteger UsingFee = BigInteger.Parse(step1Response.using_fee);
                BigInteger MaxFee = BigInteger.Parse(data.MaxAllowedFee);
                if (UsingFee \>\ MaxFee) throw new Exception("Max fee exceeded by " + NDReverse((UsingFee - MaxFee).ToString(), 12));
            }
            string[] amounts = new string[step1Response.using_outs.Length];
            for (int i = 0; i \            string mix = WS.XMRGetRandom(step1Response.mixin, amounts);
            MixOutput[] mixOuts = JsonConvert.DeserializeObject\\(mix);
            Step2Prepare step2Prepare = ConcertFromWSObjectAndMergeStep1(step1Response, data, Amount, MoneroWallet.Converters.ByteArrayToHex(wallet.Keys.SpendSecret), MoneroWallet.Converters.ByteArrayToHex(wallet.Keys.ViewSecret), FromAddress, ToAddress, mixOuts);

            var s2 = JsonConvert.SerializeObject(step2Prepare, ser);
            byte[] s2compdata = System.Text.Encoding.UTF8.GetBytes(s2);
            int s2len = XMRNative.s2compute(s2compdata, s2compdata.Length);
            s2compdata = new byte[s2len];
            XMRNative.s2getdata(s2compdata, s2len);
            s2jData = System.Text.Encoding.UTF8.GetString(s2compdata);
            Step2Response step2Response = JsonConvert.DeserializeObject\\(s2jData, ser);
            return step2Response;
        }