void onCLick_wallet_open3() { if (roleInfo.getInstance().wallet_json == "") { showNotice("未导入钱包"); return; } //默认第一个 ThinNeo.NEP6.NEP6Wallet one = new ThinNeo.NEP6.NEP6Wallet(roleInfo.getInstance().wallet_json, ""); ThinNeo.NEP6.NEP6Account acc = one.accounts.Values.FirstOrDefault(); if (acc == null || acc.nep2key == null) { showNotice("密码错误或者其他错误"); return; } try { var prikey = acc.GetPrivate(one.scrypt, input_wallet_password.text); var wif = ThinNeo.Helper.GetWifFromPrivateKey(prikey); sdk_http._instance.wallet_bind(wif, roleInfo.getInstance().wallet_json, on_get_wallet_file); } catch { showNotice("密码错误或者其他错误"); } }
void onClick_wallet_password() { string password = input_wallet_password2.text; ThinNeo.NEP6.NEP6Wallet one = new ThinNeo.NEP6.NEP6Wallet(roleInfo.getInstance().wallet_json, ""); ThinNeo.NEP6.NEP6Account acc = one.accounts.Values.FirstOrDefault(); if (acc == null || acc.nep2key == null) { showNotice("密码错误或者其他错误"); return; } try { var prikey = acc.GetPrivate(one.scrypt, password); var wif = ThinNeo.Helper.GetWifFromPrivateKey(prikey); panel_password.gameObject.SetActive(false); roleInfo.getInstance().set_storage(wif); sdk_http._instance.get_main_info(); on_get_wallet_file(false); } catch { showNotice("密码错误或者其他错误"); } }
void onClick_wallet_password() { string password = input_wallet_password.text; ThinNeo.NEP6.NEP6Wallet one = new ThinNeo.NEP6.NEP6Wallet(roleInfo.getInstance().wallet_json, ""); ThinNeo.NEP6.NEP6Account acc = one.accounts.Values.FirstOrDefault(); if (acc == null || acc.nep2key == null) { testtool.showNotice("密码错误或者其他错误"); return; } try { var prikey = acc.GetPrivate(one.scrypt, password); var wif = ThinNeo.Helper.GetWifFromPrivateKey(prikey); roleInfo.getInstance().set_storage(wif); testtool.panel_login.hide(); hide(); testtool.panel_main.show(); testtool.panel_main.on_refresh_WalletListss(); testtool.panel_main.on_refresh_plat_NotifyList(); roleInfo.getInstance().logined_cb(); sdk_http._instance.get_main_info(); } catch { testtool.showNotice("密码错误或者其他错误"); } }
void onCLick_wallet_open3() { if (roleInfo.getInstance().wallet_json == "") { testtool.showNotice("未导入钱包"); return; } //默认第一个 ThinNeo.NEP6.NEP6Wallet one = new ThinNeo.NEP6.NEP6Wallet(roleInfo.getInstance().wallet_json, ""); ThinNeo.NEP6.NEP6Account acc = one.accounts.Values.FirstOrDefault(); if (acc == null || acc.nep2key == null) { testtool.showNotice("密码错误或者其他错误"); return; } try { var prikey = acc.GetPrivate(one.scrypt, input_wallet_password.text); var wif = ThinNeo.Helper.GetWifFromPrivateKey(prikey); roleInfo.getInstance().set_storage(wif); m_panel.FindChild("wallet_open").gameObject.SetActive(false); api_tool._instance.bindWallet(roleInfo.getInstance().uid, roleInfo.getInstance().token, roleInfo.getInstance().wallet_json, on_wallet_bind); } catch { testtool.showNotice("密码错误或者其他错误"); } }
void onCLick_wallet_creat2() { string passward1 = m_panel.FindChild("wallet_create/wallet_password1").GetComponent <InputField>().text; string passward2 = m_panel.FindChild("wallet_create/wallet_password2").GetComponent <InputField>().text; if (passward1 == "") { testtool.showNotice("请输入密码"); return; } if (passward2 == "") { testtool.showNotice("请确认密码"); return; } if (passward1 != passward2) { testtool.showNotice("密码不一致"); return; } try { //创建一个钱包 ThinNeo.NEP6.NEP6Wallet wallet = new ThinNeo.NEP6.NEP6Wallet(""); byte[] privateKey = new byte[32]; RandomNumberGenerator rng = RandomNumberGenerator.Create(); rng.GetBytes(privateKey); wallet.CreateAccount(privateKey, passward1); MyJson.JsonNode_Object wallet_json = new MyJson.JsonNode_Object(); var n = new MyJson.JsonNode_ValueNumber(); n.SetNull(); wallet_json["name"] = n; wallet_json["version"] = new MyJson.JsonNode_ValueString("1.0"); wallet_json["scrypt"] = wallet.scrypt.ToJson(); wallet_json["accounts"] = new MyJson.JsonNode_Array(); foreach (var ac in wallet.accounts.Values) { var jnot = ac.ToJson(); wallet_json["accounts"].AsList().Add(jnot); } wallet_json["extra"] = n; var wif = ThinNeo.Helper.GetWifFromPrivateKey(privateKey); roleInfo.getInstance().set_storage(wif); m_panel.FindChild("wallet_create").gameObject.SetActive(false); api_tool._instance.bindWallet(roleInfo.getInstance().uid, roleInfo.getInstance().token, wallet_json.ToString(), on_wallet_bind); } catch { testtool.showNotice("创建钱包错误"); } }
public static NEP6Account FromJson(MyJson.JsonNode_Object json, NEP6Wallet wallet) { var strAdd = json["address"].AsString(); var pubkeyhash = Helper.GetPublicKeyHashFromAddress(strAdd); var key = json["key"]?.AsString(); return(new NEP6Account(pubkeyhash, key) { //Label = json["label"]?.AsString(), //IsDefault = json["isDefault"].AsBoolean(), //Lock = json["lock"].AsBoolean(), Contract = NEP6Contract.FromJson(json["contract"].AsDict()), //Extra = json["extra"] }); }
public static NEP6Account FromJson(MyJson.JsonNode_Object json, NEP6Wallet wallet) { var strAdd = json["address"].AsString(); var pubkeyhash = Helper.GetPublicKeyHashFromAddress(strAdd); string key = null; if (json.ContainsKey("key") && json["key"].IsNull() == false) { key = json["key"].AsString(); } var acc = new NEP6Account(pubkeyhash, key); if (json.ContainsKey("contract") && json["contract"].IsNull() == false) { acc.Contract = NEP6Contract.FromJson(json["contract"].AsDict()); } return(acc); }
public static NEP6Account FromJson(Newtonsoft.Json.Linq.JObject json, NEP6Wallet wallet) { var strAdd = (json["address"] as Newtonsoft.Json.Linq.JValue).Value as string; var pubkeyhash = Helper_NEO.GetScriptHash_FromAddress(strAdd); string key = null; if (json.ContainsKey("key") && json["key"] != null) { key = json["key"].Value <string>(); } var acc = new NEP6Account(pubkeyhash, key); if (json.ContainsKey("contract") && json["contract"] != null) { acc.Contract = NEP6Contract.FromJson(json["contract"] as JObject); } return(acc); }