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("密码错误或者其他错误"); } }
public NEP6Account CreateAccount(string password) { byte[] privateKey = new byte[32]; using (RandomNumberGenerator rng = RandomNumberGenerator.Create()) { rng.GetBytes(privateKey); } var pubkey = Helper.GetPublicKeyFromPrivateKey(privateKey); NEP6Contract contract = new NEP6Contract { Script = Helper.GetScriptFromPublicKey(pubkey) }; var scripthash = Helper.GetScriptHashFromPublicKey(pubkey); var nep2key = Helper.GetNep2FromPrivateKey(privateKey, password); NEP6Account account = new NEP6Account(scripthash, nep2key) { Contract = contract }; AddAccount(account); return(account); }
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("密码错误或者其他错误"); } }
public NEP6Wallet(MyJson.JsonNode_Object wallet) { this.accounts = new Dictionary <string, NEP6Account>(); this.scrypt = ScryptParameters.FromJson(wallet["scrypt"].AsDict()); var accounts = wallet["accounts"].AsList(); foreach (MyJson.JsonNode_Object a in accounts) { var ac = NEP6Account.FromJson(a, this); this.accounts[Helper.Bytes2HexString(ac.ScriptHash)] = ac; } }
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); }
public NEP6Account CreateAccount(byte[] privateKey, string password) { var pubkey = Helper.GetPublicKeyFromPrivateKey(privateKey); NEP6Contract contract = new NEP6Contract { Script = Helper.GetScriptFromPublicKey(pubkey) }; var scripthash = Helper.GetScriptHashFromPublicKey(pubkey); var nep2key = Helper.GetNep2FromPrivateKey(privateKey, password); NEP6Account account = new NEP6Account(scripthash, nep2key) { Contract = contract }; AddAccount(account); return(account); }
public NEP6Wallet(string path) { this.accounts = new Dictionary <string, NEP6Account>(); this.path = path; if (File.Exists(path)) { string txt = System.IO.File.ReadAllText(path); MyJson.JsonNode_Object wallet = MyJson.Parse(txt) as MyJson.JsonNode_Object; this.scrypt = ScryptParameters.FromJson(wallet["scrypt"] as MyJson.JsonNode_Object); var accounts = wallet["accounts"].AsList(); foreach (MyJson.JsonNode_Object a in accounts) { var ac = NEP6Account.FromJson(a, this); this.accounts[Helper.Bytes2HexString(ac.ScriptHash)] = ac; } } else { this.scrypt = ScryptParameters.Default; } }
private void AddAccount(NEP6Account account) { accounts[Helper.Bytes2HexString(account.ScriptHash)] = account; }