internal RipTaskTransferResponse Rip_Sign(int[] SecretSalt, int[] SecretPW, BitfiWallet.NOXWS.NoxTxnProcess tproc)
        {
            RipTaskTransferResponse taskTransferResponse = new RipTaskTransferResponse();

            byte[] keybytes = HDDerriveKey(SecretSalt, SecretPW, 0, "xrp");

            byte[] bts   = Convert.FromBase64String(tproc.MXTxn);
            string MXTxn = System.Text.Encoding.UTF8.GetString(bts);

            RipGen ripGen = new RipGen();

            string fromadr = ripGen.GetAddress(keybytes);

            if (fromadr != tproc.NoxAddress.BTCAddress)
            {
                Sclear.EraseBytes(keybytes);
                taskTransferResponse.Error = "Invalid information.";
                return(taskTransferResponse);
            }

            JsonSerializerSettings ser = new JsonSerializerSettings();

            ser.MissingMemberHandling  = MissingMemberHandling.Ignore;
            ser.NullValueHandling      = NullValueHandling.Ignore;
            ser.ObjectCreationHandling = ObjectCreationHandling.Auto;
            ser.TypeNameHandling       = TypeNameHandling.All;
            var data = JsonConvert.DeserializeObject <RipTxnModel>(MXTxn, ser);


            var chamount = Convert.ToDecimal(data.Amount) * 0.000001M;

            if (chamount > Convert.ToDecimal(tproc.Amount))
            {
                Sclear.EraseBytes(keybytes);
                taskTransferResponse.Error = "Error parsing amount.";
                return(taskTransferResponse);
            }
            if (data.Destination.ToUpper() != tproc.ToAddress.ToUpper())
            {
                Sclear.EraseBytes(keybytes);
                taskTransferResponse.Error = "Error parsing destination.";
                return(taskTransferResponse);
            }

            try
            {
                string txn = ripGen.CreateTxn(keybytes, MXTxn);

                Sclear.EraseBytes(keybytes);
                taskTransferResponse.TxnHex = txn;
                return(taskTransferResponse);
            }
            catch (Exception ex)
            {
                Sclear.EraseBytes(keybytes);
                taskTransferResponse.Error = ex.Message;
                return(taskTransferResponse);
            }
        }
        internal string GetNewAddress(int[] SecretSalt, int[] SecretPW, int hdIndex, string currencySymbol, string firstaddress, bool DoSegwit)
        {
            try
            {
                ExtKey masterKey  = GetExtKey(SecretSalt, SecretPW);
                ExtKey masterKeyD = masterKey.Derive(GetCurrencyIndex("btc"), hardened: true);
                ExtKey key        = masterKeyD.Derive((uint)0);
                byte[] keybytes   = key.PrivateKey.ToBytes();
                Key    pkey       = new Key(keybytes, -1, false);
                var    address    = pkey.PubKey.GetAddress(GetBLKNetworkAlt("btc")).ToString();
                if (address != firstaddress)
                {
                    Sclear.EraseBytes(keybytes);
                    masterKey  = null;
                    masterKeyD = null;
                    key        = null;
                    pkey       = null;
                    return(null);
                }
                ExtKey masterKeyA = masterKey.Derive(GetCurrencyIndex(currencySymbol), hardened: true);
                key      = masterKeyA.Derive((uint)hdIndex);
                keybytes = key.PrivateKey.ToBytes();

                if (GetBLKNetworkAlt(currencySymbol) != null)
                {
                    BitfiWallet.AltCoinGen altCoinGen = new BitfiWallet.AltCoinGen(GetBLKNetworkAlt(currencySymbol));
                    address = altCoinGen.GetNewAddress(keybytes, DoSegwit);
                }
                else
                {
                    if (currencySymbol == "apl")
                    {
                        APLGen aPL = new APLGen();
                        address = aPL.GetPublicKey(keybytes);
                    }



                    if (currencySymbol == "xrp" && hdIndex == 0)
                    {
                        RipGen ripGen = new RipGen();
                        address = ripGen.GetAddress(keybytes);
                    }
                }

                Sclear.EraseBytes(keybytes);
                masterKey  = null;
                masterKeyD = null;
                masterKeyA = null;
                key        = null;
                pkey       = null;

                return(address);
            }
            catch
            {
                return(null);
            }
        }
예제 #3
0
        internal List\\ GetReviewIndexes(BitfiWallet.SGADWS.NoxAddressReviewV3 noxAddressReviews, ExtKey masterKey)
        {
            List\\ noxAddresses = new List\\();

            foreach (var adrReview in noxAddressReviews.AdrReview)
            {
                string currencySymbol = adrReview.Blk;
                ExtKey ASmasterKey = masterKey.Derive(GetCurrencyIndex(currencySymbol), hardened: true);


                for (int i = 0; i \                {

                    string address = "";
                    ExtKey key = ASmasterKey.Derive((uint)i);
                    byte[] keybytes = key.PrivateKey.ToBytes();

                    if (GetBLKNetworkAlt(adrReview.Blk) != null)
                    {

                        foreach(var nadr in noxAddressReviews.Addresses)
                        {
                            if (nadr.BlkNet == adrReview.Blk && nadr.HDIndex == i)
                            {
                                BitfiWallet.AltCoinGen altCoinGen = new BitfiWallet.AltCoinGen(GetBLKNetworkAlt(adrReview.Blk));
                                address = altCoinGen.GetNewAddress(keybytes, nadr.DoSegwit);
                                break;
                            }
                        }


                    }
                    if (adrReview.Blk == "apl")
                    {
                        APLGen aPL = new APLGen();
                        address =  aPL.GetAccountID(keybytes);
                    }
                    if (adrReview.Blk == "neo")
                    {
                         var NEOkeypair = new KeyPair(keybytes);
                        address = NEOkeypair.address;
                        NEOkeypair.Dispose();
                    }
                    if (adrReview.Blk == "xmr")
                    {
                        MoneroWallet.Wallet wallet = MoneroWallet.Wallet.OpenWallet(keybytes);
                        address = wallet.Address;
                        wallet.Dispose();

                    }
                    if (adrReview.Blk == "eth")
                    {
                        EthECKey ETHkey = new EthECKey(keybytes, true);
                        address = ETHkey.GetPublicAddress();
                    }
                    if (adrReview.Blk == "xrp")
                    {
                        RipGen ripGen = new RipGen();
                        address = ripGen.GetAddress(keybytes);
                    }
                    Sclear.EraseBytes(keybytes);
                    key = null;

                    noxAddresses.Add(new BitfiWallet.NOXWS.NoxAddresses { BlkNet = currencySymbol, BTCAddress = address}

                    );

                }

            }
            masterKey = null;

            return noxAddresses;
        }