internal ApolloTaskTransferResponse APL_Sign(int[] SecretSalt, int[] SecretPW, BitfiWallet.NOXWS.NoxTxnProcess tproc) { ApolloTaskTransferResponse taskTransferResponse = new ApolloTaskTransferResponse(); byte[] keybytes = HDDerriveKey(SecretSalt, SecretPW, tproc.NoxAddress.HDIndex, "apl"); APLGen aPL = new APLGen(); string fromadr = aPL.GetPublicKey(keybytes); if (fromadr != tproc.NoxAddress.BTCAddress) { Sclear.EraseBytes(keybytes); taskTransferResponse.Error = "Invalid information."; return taskTransferResponse; } try { string check = aPL.CheckTransactionError(tproc.MXTxn, tproc.ToAddress, tproc.Amount, tproc.FeeValue); if (!string.IsNullOrEmpty(check)) { Sclear.EraseBytes(keybytes); taskTransferResponse.Error = check; return taskTransferResponse; } var signedtxn = aPL.SignTransaction(keybytes, tproc.MXTxn); Sclear.EraseBytes(keybytes); taskTransferResponse.TxnHex = signedtxn; 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); } }
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; }