public void OnClickNewCLAddress() { string strPath; string strCLAddress; strPath = m_ifKeyPath.text; if (string.IsNullOrEmpty(strPath)) { strCLAddress = m_kCLB.GenerateNewMCLAddress(m_strMasterKeyName); } else { string strCelAddress = m_kCLB.GetCelAddressByPath(m_strMasterKeyName, strPath); if (string.IsNullOrEmpty(strCelAddress)) { TextOut("GetCelAddressByPath error, path: " + strPath, "red"); return; } strCLAddress = m_kCLB.EncodeMCLAddress(m_strMasterKeyName, strPath, strCelAddress); } if (string.IsNullOrEmpty(strCLAddress)) { TextOut("Generate new MCL address error!", "red"); return; } m_ifCLAddr.text = strCLAddress; string strName; string strBTAddress; if (m_kCLB.DecodeMCLAddress(strCLAddress, out strName, out strPath, out strBTAddress)) { m_ifBTAddr.text = strBTAddress; m_ifMasterKeyName.text = strName; ExtKey kEKey = m_kCLB.GetExtKeyByPath(m_strMasterKeyName, strPath); string strPriKey = kEKey.PrivateKey.GetWif(m_kCLB.network).ToWif(); m_ifPriKey.text = strPriKey; TextOut("Generate new MCL address succeed."); } }
public void Initialize(IxMagnaChainBridge kCLB, string strMasterKey, string strAddress, string strDestAddress, Role kOther, int iID) { m_kCLB = kCLB; m_kOtherRole = kOther; m_iID = iID; m_strMasterKey = strMasterKey; m_strAddress = strAddress; if (m_strDestAddress == null) { m_strDestAddress = strDestAddress; } string strSaveName = SAVE_ADDRESS_NAME_PREFIX + m_iID; if (PlayerPrefs.HasKey(strSaveName)) { m_strAddress = PlayerPrefs.GetString(strSaveName); m_kOtherRole.SetDestCLAddress(m_strAddress); } //string strName; string strPath; m_kCLB.DecodeMCLAddress(m_strAddress, out m_strMasterKeyName, out strPath, out m_strBTAddress); List <string> listAddress = new List <string>(); listAddress.Add(strAddress); m_kCLB.ImportMasterExtKey(strMasterKey, listAddress); if (m_txtAddress != null) { m_txtAddress.text = strAddress; } if (m_txtBTAddress != null) { m_txtBTAddress.text = m_strBTAddress; } if (m_ifDestAddress != null) { m_ifDestAddress.text = m_strDestAddress; } m_fUpdateTick = m_fUpdateTime; UpdateBalance(); }
public void OnClickTransfer() { string strMoney = m_ifMoney.text; string strDestAddress = m_ifDestAddress.text; string strChangeCLAddress = null; if (m_iID > 1000) { strChangeCLAddress = m_kCLB.GenerateNewMCLAddress(m_strMasterKeyName); } if (string.IsNullOrEmpty(strMoney) || string.IsNullOrEmpty(strDestAddress)) { MessageBox.ms_kSig.Show("Prompt", "Money or DestAddress is null"); return; } float fMoney = Convert.ToSingle(strMoney); if (fMoney <= 0.0f) { MessageBox.ms_kSig.Show("Prompt", "Money must > 0"); return; } if (fMoney > m_fBalance) { MessageBox.ms_kSig.Show("Prompt", "Not enough money"); return; } IxMagnaChainBridge.ON_TRANSFER_DONE fnTransferDone = delegate(RPCError kError, string strTxid) { if (kError != null) { Debug.LogError(kError.Message); return; } Debug.Log("Transfer done."); if (m_iID > 1000) { m_strAddress = strChangeCLAddress; m_txtAddress.text = strChangeCLAddress; string strName; string strPath; string strBTAddress; m_kCLB.DecodeMCLAddress(strChangeCLAddress, out strName, out strPath, out strBTAddress); m_txtBTAddress.text = strBTAddress; m_kOtherRole.SetDestCLAddress(strChangeCLAddress); string strSaveName = SAVE_ADDRESS_NAME_PREFIX + m_iID; PlayerPrefs.SetString(strSaveName, strChangeCLAddress); } m_fUpdateTick = m_fUpdateTime; UpdateBalance(); }; m_kCLB.TransferMCLToMCLAddressAsync(m_strAddress, strDestAddress, fMoney, fnTransferDone, -1.0f, strChangeCLAddress); }