当前位置: 首页>>代码示例>>Java>>正文


Java MnemonicException.MnemonicLengthException方法代码示例

本文整理汇总了Java中org.bitcoinj.crypto.MnemonicException.MnemonicLengthException方法的典型用法代码示例。如果您正苦于以下问题:Java MnemonicException.MnemonicLengthException方法的具体用法?Java MnemonicException.MnemonicLengthException怎么用?Java MnemonicException.MnemonicLengthException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bitcoinj.crypto.MnemonicException的用法示例。


在下文中一共展示了MnemonicException.MnemonicLengthException方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRandomSeedWords

import org.bitcoinj.crypto.MnemonicException; //导入方法依赖的package包/类
private List<String> getRandomSeedWords() {
    List<String> seedWords;
    try {
        final MnemonicCode mnemonicCode = new MnemonicCode();
        seedWords = mnemonicCode.toMnemonic(getRandomSeed());
    } catch (IOException | MnemonicException.MnemonicLengthException e) {
        throw new RuntimeException(e);
    }
    return seedWords;
}
 
开发者ID:MineboxOS,项目名称:minebox,代码行数:11,代码来源:KeyResource.java

示例2: newWallet

import org.bitcoinj.crypto.MnemonicException; //导入方法依赖的package包/类
/**
 * Create new wallet.
 *
 * @param  int nbWords number of words in menmonic
 * @param  String passphrase optional BIP39 passphrase
 * @param  int nbAccounts create this number of accounts
 *
 * @return Wallet
 *
 */
public Wallet newWallet(int nbWords, String passphrase, int nbAccounts) throws IOException, MnemonicException.MnemonicLengthException   {

	Wallet hdw = null;

	if((nbWords % 3 != 0) || (nbWords < 12 || nbWords > 24)) {
		nbWords = 12;
	}

	// len == 16 (12 words), len == 24 (18 words), len == 32 (24 words)
	int len = (nbWords / 3) * 4;

	if(passphrase == null) {
		passphrase = "";
	}

	NetworkParameters params = MainNetParams.get();

	SecureRandom random = new SecureRandom();
	byte seed[] = new byte[len];
	random.nextBytes(seed);

	MnemonicCode mc = new MnemonicCode();
	hdw = new Wallet(mc, params, seed, passphrase);

	wallets.clear();
	wallets.add(hdw);

	return hdw;
}
 
开发者ID:matthiaszimmermann,项目名称:bitcoin-paper-wallet,代码行数:40,代码来源:WalletFactory.java

示例3: get

import org.bitcoinj.crypto.MnemonicException; //导入方法依赖的package包/类
/**
 * Get wallet for this instance.
 *
 * @return Wallet
 *
 */
public Wallet get() throws IOException, MnemonicException.MnemonicLengthException {

	if(wallets.size() < 1) {
		wallets.clear();
		wallets.add(newWallet(12, "", 1));
	}

	return wallets.get(0);
}
 
开发者ID:matthiaszimmermann,项目名称:bitcoin-paper-wallet,代码行数:16,代码来源:WalletFactory.java

示例4: bytesToMnemonic

import org.bitcoinj.crypto.MnemonicException; //导入方法依赖的package包/类
public static List<String> bytesToMnemonic(byte[] bytes) {
    List<String> mnemonic;
    try {
        mnemonic = MnemonicCode.INSTANCE.toMnemonic(bytes);
    } catch (MnemonicException.MnemonicLengthException e) {
        throw new RuntimeException(e); // should not happen, we have 16bytes of entropy
    }
    return mnemonic;
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:10,代码来源:CoreUtils.java

示例5: onStart

import org.bitcoinj.crypto.MnemonicException; //导入方法依赖的package包/类
@Override
public void onStart()
{
    super.onStart();

    WalletState.getState().triggerUpdate();

    if (WalletState.getState().getFirstLaunch())
    {
        // At first launch, calculate the mnemonic and display it to the user
        final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);

        try
        {
            final List<String> mnemonic = MnemonicCode.INSTANCE.toMnemonic(
                WalletState.getState().getConfiguration().getSeed());
            final String fullMnemonic = Joiner.on(" ").join(mnemonic);

            alertDialog.setTitle(getString(R.string.general_first_launch_title));
            alertDialog.setMessage(getString(R.string.general_first_launch_message, fullMnemonic));

            alertDialog.setPositiveButton(
                getString(R.string.general_first_launch_close),
                new DialogInterface.OnClickListener()
                {
                    public void onClick(DialogInterface dialog, int which)
                    {
                        dialog.dismiss();
                        WalletState.getState().unsetFirstLaunch();
                    }
                });

            alertDialog.show();
        }
        catch (MnemonicException.MnemonicLengthException exception)
        { }
    }
}
 
开发者ID:Coinprism,项目名称:android-wallet,代码行数:39,代码来源:WalletOverview.java

示例6: Wallet

import org.bitcoinj.crypto.MnemonicException; //导入方法依赖的package包/类
/**
 * Constructor for wallet.
 *
 * @param MnemonicCode mc mnemonic code object
 * @param NetworkParameters params
 * @param byte[] seed seed for this wallet
 * @param String passphrase optional BIP39 passphrase
 * @param int nbAccounts number of accounts to create
 *
 */
public Wallet(MnemonicCode mc, NetworkParameters params, byte[] seed, String passphrase) throws MnemonicException.MnemonicLengthException {
	wordList = mc.toMnemonic(seed);
	init(params, seed, passphrase);
}
 
开发者ID:matthiaszimmermann,项目名称:bitcoin-paper-wallet,代码行数:15,代码来源:Wallet.java


注:本文中的org.bitcoinj.crypto.MnemonicException.MnemonicLengthException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。