Search in sources :

Example 1 with BaseChain

use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.

the class WKey method getKeyWithPathfromEntropy.

// singer
public static DeterministicKey getKeyWithPathfromEntropy(Account account, String entropy) {
    BaseChain chain = getChain(account.baseChain);
    if (!chain.equals(FETCHAI_MAIN)) {
        DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(getHDSeed(WUtil.HexStringToByteArray(entropy)));
        return new DeterministicHierarchy(masterKey).deriveChild(WKey.getParentPath(chain, account.customPath), true, true, new ChildNumber(Integer.parseInt(account.path)));
    } else {
        DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(getHDSeed(WUtil.HexStringToByteArray(entropy)));
        if (account.customPath != 2) {
            DeterministicKey targetKey = new DeterministicHierarchy(masterKey).deriveChild(WKey.getParentPath(chain, account.customPath), true, true, new ChildNumber(Integer.parseInt(account.path)));
            return targetKey;
        } else {
            DeterministicKey targetKey = new DeterministicHierarchy(masterKey).deriveChild(WKey.getParentPath(chain, account.customPath), true, true, new ChildNumber(Integer.parseInt(account.path), true));
            DeterministicKey targetKey2 = new DeterministicHierarchy(targetKey).deriveChild(WKey.getFetchParentPath2(), true, true, ChildNumber.ZERO);
            return targetKey2;
        }
    }
}
Also used : ChildNumber(org.bitcoinj.crypto.ChildNumber) BaseChain(wannabit.io.cosmostaion.base.BaseChain) DeterministicKey(org.bitcoinj.crypto.DeterministicKey) DeterministicHierarchy(org.bitcoinj.crypto.DeterministicHierarchy)

Example 2 with BaseChain

use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.

the class WalletSwitchActivity method loadChains.

private void loadChains() {
    mAccount = getBaseDao().onSelectAccount(getBaseDao().getLastUser());
    ArrayList<BaseChain> mDisplayChains = getBaseDao().dpSortedChains();
    mExpendedChains = getBaseDao().getExpendedChains();
    mSelectedChain = BaseChain.getChain(mAccount.baseChain);
    getBaseDao().setLastChain(mSelectedChain.getChain());
    for (BaseChain chain : mDisplayChains) {
        if (mExpendedChains.contains(chain) || mSelectedChain.equals(chain)) {
            mChainAccounts.add(new ChainAccounts(true, chain, getBaseDao().onSelectAccountsByChain(chain)));
        } else {
            mChainAccounts.add(new ChainAccounts(false, chain, getBaseDao().onSelectAccountsByChain(chain)));
        }
    }
    mAccountRecyclerView.scrollToPosition(getBaseDao().dpSortedChains().indexOf(mSelectedChain));
    mAccountListAdapter.notifyDataSetChanged();
}
Also used : ChainAccounts(wannabit.io.cosmostaion.dao.ChainAccounts) BaseChain(wannabit.io.cosmostaion.base.BaseChain)

Example 3 with BaseChain

use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.

the class AccountDetailActivity method onClick.

@Override
public void onClick(View v) {
    if (v.equals(mBtnCheck)) {
        if (mAccount.hasPrivateKey) {
            Intent intent = new Intent(AccountDetailActivity.this, PasswordCheckActivity.class);
            intent.putExtra(BaseConstant.CONST_PW_PURPOSE, BaseConstant.CONST_PW_CHECK_MNEMONIC);
            intent.putExtra("checkid", mAccount.id);
            startActivity(intent);
            overridePendingTransition(R.anim.slide_in_bottom, R.anim.fade_out);
        } else {
            Intent restoreIntent = new Intent(AccountDetailActivity.this, RestoreActivity.class);
            restoreIntent.putExtra("chain", mBaseChain.getChain());
            startActivity(restoreIntent);
        }
    } else if (v.equals(mBtnCheckKey)) {
        if (mAccount.hasPrivateKey) {
            Intent intent = new Intent(AccountDetailActivity.this, PasswordCheckActivity.class);
            intent.putExtra(BaseConstant.CONST_PW_PURPOSE, BaseConstant.CONST_PW_CHECK_PRIVATE_KEY);
            intent.putExtra("checkid", mAccount.id);
            startActivity(intent);
            overridePendingTransition(R.anim.slide_in_bottom, R.anim.fade_out);
        } else {
            Intent restoreIntent = new Intent(AccountDetailActivity.this, RestoreKeyActivity.class);
            restoreIntent.putExtra("chain", mBaseChain.getChain());
            startActivity(restoreIntent);
        }
    } else if (v.equals(mBtnDelete)) {
        int accountSum = 0;
        for (BaseChain baseChain : getBaseDao().dpSortedChains()) {
            accountSum = accountSum + getBaseDao().onSelectAccountsByChain(baseChain).size();
        }
        if (accountSum <= 1) {
            Toast.makeText(AccountDetailActivity.this, getString(R.string.error_reserve_1_account), Toast.LENGTH_SHORT).show();
            return;
        }
        AlertDialogUtils.showDoubleButtonDialog(this, getString(R.string.str_delete_title), getString(R.string.str_delete_msg), AlertDialogUtils.highlightingText(getString(R.string.str_delete)), view -> onStartDeleteUser(), getString(R.string.str_close), null);
    } else if (v.equals(mNameEditImg)) {
        Bundle bundle = new Bundle();
        bundle.putLong("id", mAccount.id);
        bundle.putString("name", mAccount.nickName);
        Dialog_ChangeNickName delete = Dialog_ChangeNickName.newInstance(bundle);
        delete.setCancelable(true);
        getSupportFragmentManager().beginTransaction().add(delete, "dialog").commitNowAllowingStateLoss();
    } else if (v.equals(mBtnQr)) {
        Bundle bundle = new Bundle();
        bundle.putString("address", mAccount.address);
        bundle.putString("title", mAccountName.getText().toString());
        Dialog_AccountShow show = Dialog_AccountShow.newInstance(bundle);
        show.setCancelable(true);
        getSupportFragmentManager().beginTransaction().add(show, "dialog").commitNowAllowingStateLoss();
    } else if (v.equals(mBtnRewardAddressChange)) {
        if (!mAccount.hasPrivateKey) {
            AlertDialogUtils.showDoubleButtonDialog(this, getString(R.string.str_only_observe_title), getString(R.string.str_only_observe_msg), Html.fromHtml("<font color=\"#9C6CFF\">" + getString(R.string.str_add_mnemonics) + "</font>"), view -> onAddMnemonicForAccount(), getString(R.string.str_close), null);
            return;
        }
        if (TextUtils.isEmpty(mRewardAddress.getText().toString())) {
            Toast.makeText(getBaseContext(), R.string.error_network_error, Toast.LENGTH_SHORT).show();
            return;
        }
        AlertDialogUtils.showDoubleButtonDialog(this, getString(R.string.str_reward_address_change_title), Html.fromHtml(getString(R.string.str_reward_address_change_msg) + "<br/><br/><font color=\"#ff0000\">" + AlertDialogUtils.highlightingText(getString(R.string.str_reward_address_change_market_no) + "</font>")), AlertDialogUtils.highlightingText(getString(R.string.str_cancel)), null, getString(R.string.str_continue), view -> onStartChangeRewardAddress(), true);
    }
}
Also used : WLog(wannabit.io.cosmostaion.utils.WLog) TASK_FETCH_NODE_INFO(wannabit.io.cosmostaion.base.BaseConstant.TASK_FETCH_NODE_INFO) Bundle(android.os.Bundle) CONST_PW_TX_SIMPLE_CHANGE_REWARD_ADDRESS(wannabit.io.cosmostaion.base.BaseConstant.CONST_PW_TX_SIMPLE_CHANGE_REWARD_ADDRESS) ImageView(android.widget.ImageView) Intent(android.content.Intent) WDp(wannabit.io.cosmostaion.utils.WDp) MenuItem(android.view.MenuItem) PushUpdateTask(wannabit.io.cosmostaion.task.FetchTask.PushUpdateTask) BigDecimal(java.math.BigDecimal) Lists(com.google.common.collect.Lists) WUtil(wannabit.io.cosmostaion.utils.WUtil) NodeInfo(wannabit.io.cosmostaion.model.NodeInfo) Handler(android.os.Handler) Looper(android.os.Looper) Toast(android.widget.Toast) TaskResult(wannabit.io.cosmostaion.task.TaskResult) View(android.view.View) Button(android.widget.Button) Dialog_ChangeNickName(wannabit.io.cosmostaion.dialog.Dialog_ChangeNickName) WithdrawAddressGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.WithdrawAddressGrpcTask) OKEX_MAIN(wannabit.io.cosmostaion.base.BaseChain.OKEX_MAIN) CardView(androidx.cardview.widget.CardView) BaseConstant(wannabit.io.cosmostaion.base.BaseConstant) TaskListener(wannabit.io.cosmostaion.task.TaskListener) SwitchCompat(androidx.appcompat.widget.SwitchCompat) AsyncTask(android.os.AsyncTask) CompoundButton(android.widget.CompoundButton) Dialog_AccountShow(wannabit.io.cosmostaion.dialog.Dialog_AccountShow) TextUtils(android.text.TextUtils) R(wannabit.io.cosmostaion.R) BaseChain(wannabit.io.cosmostaion.base.BaseChain) AlertDialogUtils(wannabit.io.cosmostaion.dialog.AlertDialogUtils) List(java.util.List) TextView(android.widget.TextView) TASK_GRPC_FETCH_WITHDRAW_ADDRESS(wannabit.io.cosmostaion.base.BaseConstant.TASK_GRPC_FETCH_WITHDRAW_ADDRESS) Html(android.text.Html) RelativeLayout(android.widget.RelativeLayout) Toolbar(androidx.appcompat.widget.Toolbar) BaseActivity(wannabit.io.cosmostaion.base.BaseActivity) NodeInfoGrpcTask(wannabit.io.cosmostaion.task.gRpcTask.NodeInfoGrpcTask) BaseChain.isGRPC(wannabit.io.cosmostaion.base.BaseChain.isGRPC) NodeInfoTask(wannabit.io.cosmostaion.task.FetchTask.NodeInfoTask) TASK_GRPC_FETCH_NODE_INFO(wannabit.io.cosmostaion.base.BaseConstant.TASK_GRPC_FETCH_NODE_INFO) Bundle(android.os.Bundle) Dialog_AccountShow(wannabit.io.cosmostaion.dialog.Dialog_AccountShow) Intent(android.content.Intent) BaseChain(wannabit.io.cosmostaion.base.BaseChain) Dialog_ChangeNickName(wannabit.io.cosmostaion.dialog.Dialog_ChangeNickName)

Example 4 with BaseChain

use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.

the class IBCSendStep4Fragment method onRefreshTab.

@Override
public void onRefreshTab() {
    mDpDecimal = WDp.mainDivideDecimal(getSActivity().mBaseChain);
    BigDecimal feeAmount = new BigDecimal(getSActivity().mTxFee.amount.get(0).amount);
    BigDecimal toSendAmount = new BigDecimal(getSActivity().mAmounts.get(0).amount);
    mFeeAmount.setText(WDp.getDpAmount2(getContext(), feeAmount, mDpDecimal, mDpDecimal));
    WDp.setGasDenomTv(getSActivity(), getSActivity().mBaseChain, getSActivity().mTxFee.amount.get(0).denom, mFeeAmountSymbol);
    WDp.showCoinDp(getSActivity(), getBaseDao(), getSActivity().mToIbcDenom, toSendAmount.toPlainString(), mSendAmountSymbol, mSendAmount, getSActivity().mBaseChain);
    BaseChain toChain = WDp.getChainTypeByChainId(getSActivity().mIbcSelectedRelayer.chain_id);
    WDp.getChainTitle(getSActivity(), toChain, mRecipientChain);
    mRecipientChain.setTextColor(WDp.getChainColor(getSActivity(), toChain));
    mRecipientAddress.setText(getSActivity().mToAddress);
}
Also used : BaseChain(wannabit.io.cosmostaion.base.BaseChain) BigDecimal(java.math.BigDecimal)

Example 5 with BaseChain

use of wannabit.io.cosmostaion.base.BaseChain in project cosmostation-android by cosmostation.

the class MainActivity method onChainSelect.

private void onChainSelect(BaseChain baseChain) {
    invalidateOptionsMenu();
    mChainAccounts.clear();
    ArrayList<BaseChain> mDisplayChains = new ArrayList<>();
    mDisplayChains = getBaseDao().dpSortedChains();
    mExpendedChains = getBaseDao().getExpendedChains();
    mSelectedChain = baseChain;
    getBaseDao().setLastChain(mSelectedChain.getChain());
    for (BaseChain chain : mDisplayChains) {
        if (mExpendedChains.contains(chain) || mSelectedChain.equals(chain)) {
            mChainAccounts.add(new ChainAccounts(true, chain, getBaseDao().onSelectAccountsByChain(chain)));
        } else {
            mChainAccounts.add(new ChainAccounts(false, chain, getBaseDao().onSelectAccountsByChain(chain)));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ChainAccounts(wannabit.io.cosmostaion.dao.ChainAccounts) BaseChain(wannabit.io.cosmostaion.base.BaseChain)

Aggregations

BaseChain (wannabit.io.cosmostaion.base.BaseChain)9 BigDecimal (java.math.BigDecimal)2 ChainAccounts (wannabit.io.cosmostaion.dao.ChainAccounts)2 Intent (android.content.Intent)1 AsyncTask (android.os.AsyncTask)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Looper (android.os.Looper)1 Html (android.text.Html)1 Spanned (android.text.Spanned)1 TextUtils (android.text.TextUtils)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 Button (android.widget.Button)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 RelativeLayout (android.widget.RelativeLayout)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1 SwitchCompat (androidx.appcompat.widget.SwitchCompat)1