private void on_pay_sgas(bool timeout, WWW www) { if (!check_www_result(www)) { return; } NeoGameSDK_pay_data one = new NeoGameSDK_pay_data(); one.uid = roleInfo.getInstance().uid; one.token = roleInfo.getInstance().token; one.txid = m_cur_txid; one.cnts = m_num.ToString(); //api的登入成功后回调函数 NeoGameSDK_CS.api_cb_pay(one); }
IEnumerator HTTP_nel_post_tan_sgas(decimal num) { WWWForm www_getuxo_form = Helper.GetWWWFormPost("getutxo", new MyJson.JsonNode_ValueString(roleInfo.getInstance().address)); WWW www = new WWW(global.api, www_getuxo_form); yield return(www); Dictionary <string, List <Utxo> > _dir = get_utxo(www.text); if (_dir.ContainsKey(global.id_GAS) == false) { Debug.Log("no gas"); } string paparms; ThinNeo.Transaction tran = null; { byte[] script = null; using (var sb = new ThinNeo.ScriptBuilder()) { var array = new MyJson.JsonNode_Array(); array.AddArrayValue("(addr)" + roleInfo.getInstance().address); //from array.AddArrayValue("(addr)" + global.cp_adress); //to array.AddArrayValue("(int)" + Decimal.ToInt32(num * 100000000)); //value sb.EmitParamJson(array); //参数倒序入 sb.EmitParamJson(new MyJson.JsonNode_ValueString("(str)transfer")); //参数倒序入 ThinNeo.Hash160 shash = new ThinNeo.Hash160(global.id_sgas); sb.EmitAppCall(shash); //nep5脚本 //拼接发给后台做验证的json字符串 MyJson.JsonNode_Object account = new MyJson.JsonNode_Object(); account["sbParamJson"] = array; account["sbPushString"] = new MyJson.JsonNode_ValueString("transfer"); account["nnc"] = new MyJson.JsonNode_ValueString(global.id_sgas); account["cnts"] = new MyJson.JsonNode_ValueString(num.ToString()); paparms = account.ToString(); script = sb.ToArray(); } tran = Helper.makeTran(_dir[global.id_GAS], roleInfo.getInstance().address, new ThinNeo.Hash256(global.id_GAS), 0); tran.type = ThinNeo.TransactionType.InvocationTransaction; var idata = new ThinNeo.InvokeTransData(); tran.extdata = idata; idata.script = script; } //sign and broadcast var signdata = ThinNeo.Helper.Sign(tran.GetMessage(), roleInfo.getInstance().prikey); tran.AddWitness(signdata, roleInfo.getInstance().pubkey, roleInfo.getInstance().address); var trandata = tran.GetRawData(); var strtrandata = ThinNeo.Helper.Bytes2HexString(trandata); WWWForm www_form_sendraw = Helper.GetWWWFormPost("sendrawtransaction", new MyJson.JsonNode_ValueString(strtrandata)); WWW sendraw = new WWW(global.api, www_form_sendraw); yield return(sendraw); var json = MyJson.Parse(sendraw.text).AsDict(); if (json.ContainsKey("result")) { var resultv = json["result"].AsList()[0].AsDict(); var txid = resultv["txid"].AsString(); if (txid.Length > 0) { Debug.Log("txid=" + txid); api_tool._instance.addUserWalletLogs(roleInfo.getInstance().uid, roleInfo.getInstance().token, txid, global.game_id.ToString(), num.ToString(), "3", paparms, global.netType, "0", (bool timeout1, WWW www1) => { testtool.panel_main.on_refresh_WalletListss(); }); NeoGameSDK_pay_data data = new NeoGameSDK_pay_data(); data.uid = roleInfo.getInstance().uid; data.token = roleInfo.getInstance().token; data.cnts = num.ToString(); data.txid = txid; NeoGameSDK_CS.api_cb_pay(data); } else { Debug.Log("交易失败"); } } else { Debug.Log("交易失败"); } }