internal NEOTaskTransferResponse NEO_ClaimGas(int[] SecretSalt, int[] SecretPW, BitfiWallet.NOXWS.NoxGasRequests req) { NEOTaskTransferResponse taskTransferResponse = new NEOTaskTransferResponse(); byte[] bts = Convert.FromBase64String(req.NXTxn); string jData = System.Text.Encoding.UTF8.GetString(bts); NEONeoscanUnclaimed unclaimed = JsonConvert.DeserializeObject <NEONeoscanUnclaimed>(jData); if (unclaimed == null) { taskTransferResponse.Error = "Error, no claimable values."; return(taskTransferResponse); } if (unclaimed.claimable == null) { taskTransferResponse.Error = "Error, no claimable values."; return(taskTransferResponse); } List <NeoGasLibrary.NeoAPI.ClaimEntry> claims = new List <NeoGasLibrary.NeoAPI.ClaimEntry>(); foreach (var un in unclaimed.claimable) { NeoGasLibrary.NeoAPI.ClaimEntry entry = new NeoGasLibrary.NeoAPI.ClaimEntry(); entry.index = UInt16.Parse(un.n.ToString()); entry.txid = un.txid; entry.value = un.unclaimed; claims.Add(entry); } if (claims.Count < 1) { taskTransferResponse.Error = "Error, no claimable values."; return(taskTransferResponse); } byte[] keybytes = HDDerriveKey(SecretSalt, SecretPW, 0, "neo"); var keypair = new NeoGasLibrary.KeyPair(keybytes); Sclear.EraseBytes(keybytes); string neoaddress = keypair.address; if (neoaddress.ToUpper() != req.NeoAddress.ToUpper()) { keypair.Dispose(); taskTransferResponse.Error = "Invalid information."; return(taskTransferResponse); } var tx = NeoGasLibrary.NeoAPI.BuildClamTx(claims, NeoGasLibrary.NeoAPI.Net.Main, keypair.address); var txHex = NeoGasLibrary.NeoAPI.SignAndSerialize(tx, keypair); keypair.Dispose(); taskTransferResponse.TxnHex = txHex; return(taskTransferResponse); }
//TRANSACTIONS internal NEOTaskTransferResponse NEO_Sign(int[] SecretSalt, int[] SecretPW, string MXTxn, string BlkNet, string ToAddress, string Amount, string FromAddress) { NEOTaskTransferResponse taskTransferResponse = new NEOTaskTransferResponse(); try { byte[] bts = Convert.FromBase64String(MXTxn); string jData = System.Text.Encoding.UTF8.GetString(bts); NEONeoscanUnspent[] unspent = JsonConvert.DeserializeObject <NEONeoscanUnspent[]>(jData); if (unspent == null || unspent.Length < 1) { taskTransferResponse.Error = "No unspent."; return(taskTransferResponse); } List <NeoGasLibrary.NeoAPI.UnspentEntry> entries = new List <NeoGasLibrary.NeoAPI.UnspentEntry>(); foreach (var un in unspent) { NeoGasLibrary.NeoAPI.UnspentEntry entry = new NeoGasLibrary.NeoAPI.UnspentEntry(); entry.index = UInt16.Parse(un.n.ToString()); entry.txid = un.txid; entry.value = un.value; entries.Add(entry); } if (entries == null || entries.Count < 1) { taskTransferResponse.Error = "No Entries."; return(taskTransferResponse); } byte[] keybytes = HDDerriveKey(SecretSalt, SecretPW, 0, "neo"); var assetId = BlkNet.ToLower() == "gas" ? NeoGasLibrary.NeoAPI.gasId : NeoGasLibrary.NeoAPI.neoId; NeoGasLibrary.NeoAPI.Transaction tx = NeoGasLibrary.NeoAPI.BuildContractTx(entries, 0, FromAddress, ToAddress, Amount, assetId); NeoGasLibrary.KeyPair keypair = new NeoGasLibrary.KeyPair(keybytes); Sclear.EraseBytes(keybytes); string neoaddress = keypair.address; if (neoaddress != FromAddress) { keypair.Dispose(); taskTransferResponse.Error = "Invalid information."; return(taskTransferResponse); } string txHex = NeoGasLibrary.NeoAPI.SignAndSerialize(tx, keypair); taskTransferResponse.TxnHex = txHex; taskTransferResponse.Error = ""; keypair.Dispose(); return(taskTransferResponse); } catch (Exception ex) { taskTransferResponse.Error = "Error: " + ex.Message; return(taskTransferResponse); } }