Java Code Examples for net.bither.bitherj.crypto.mnemonic.MnemonicException#MnemonicLengthException
The following examples show how to use
net.bither.bitherj.crypto.mnemonic.MnemonicException#MnemonicLengthException .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractHD.java From bitherj with Apache License 2.0 | 5 votes |
protected void decryptHDSeed(CharSequence password) throws MnemonicException .MnemonicLengthException { if (hdSeedId < 0 || password == null) { return; } String encryptedHDSeed = getEncryptedHDSeed(); if (Utils.isEmpty(encryptedHDSeed)) { initHDSeedFromMnemonicSeed(password); } else { hdSeed = new EncryptedData(encryptedHDSeed).decrypt(password); } }
Example 2
Source File: HDAccount.java From bitherj with Apache License 2.0 | 5 votes |
public Tx newTx(String[] toAddresses, Long[] amounts) throws TxBuilderException, MnemonicException.MnemonicLengthException { List<Out> outs = AbstractDb.hdAccountAddressProvider.getUnspendOutByHDAccount(hdSeedId); Tx tx = TxBuilder.getInstance().buildTxFromAllAddress(outs, getNewChangeAddress(), Arrays .asList(amounts), Arrays.asList(toAddresses)); return tx; }
Example 3
Source File: HDAccountCold.java From bitherj with Apache License 2.0 | 5 votes |
public List<byte[]> signHashes(Collection<byte[]> hashes, Collection<PathTypeIndex> paths, CharSequence password) throws MnemonicException .MnemonicLengthException { assert hashes.size() == paths.size(); ArrayList<byte[]> sigs = new ArrayList<byte[]>(); DeterministicKey master = masterKey(password); DeterministicKey account = getAccount(master); DeterministicKey external = getChainRootKey(account, PathType.EXTERNAL_ROOT_PATH); DeterministicKey internal = getChainRootKey(account, PathType.INTERNAL_ROOT_PATH); master.wipe(); account.wipe(); Iterator<byte[]> hashIterator = hashes.iterator(); Iterator<PathTypeIndex> pathIterator = paths.iterator(); while (hashIterator.hasNext() && pathIterator.hasNext()) { byte[] hash = hashIterator.next(); PathTypeIndex path = pathIterator.next(); DeterministicKey key; if (path.pathType == PathType.EXTERNAL_ROOT_PATH) { key = external.deriveSoftened(path.index); } else { key = internal.deriveSoftened(path.index); } TransactionSignature sig = new TransactionSignature(key.sign(hash), TransactionSignature.SigHash.ALL, false); sigs.add(ScriptBuilder.createInputScript(sig, key).getProgram()); key.wipe(); } external.wipe(); internal.wipe(); return sigs; }
Example 4
Source File: DesktopHDMKeychain.java From bitherj with Apache License 2.0 | 5 votes |
public byte[] getExternalChainRootPubExtended(CharSequence password) throws MnemonicException .MnemonicLengthException { DeterministicKey ex = externalChainRoot(password); byte[] pub = ex.getPubKeyExtended(); ex.wipe(); return pub; }
Example 5
Source File: HDAccountCold.java From bitherj with Apache License 2.0 | 5 votes |
public String accountPubExtendedString(CharSequence password) throws MnemonicException .MnemonicLengthException { byte[] extended = accountPubExtended(password); String result = ""; if (isFromXRandom) { result += QRCodeUtil.XRANDOM_FLAG; } result += Utils.bytesToHexString(extended).toUpperCase(); return result; }
Example 6
Source File: HDMKeychain.java From bitherj with Apache License 2.0 | 5 votes |
private DeterministicKey externalChainRoot(CharSequence password) throws MnemonicException.MnemonicLengthException { DeterministicKey master = masterKey(password); DeterministicKey accountKey = getAccount(master); DeterministicKey externalKey = getChainRootKey(accountKey, PathType.EXTERNAL_ROOT_PATH); master.wipe(); accountKey.wipe(); return externalKey; }
Example 7
Source File: AbstractHD.java From bitherj with Apache License 2.0 | 5 votes |
private void initHDSeedFromMnemonicSeed(CharSequence password) throws MnemonicException .MnemonicLengthException { decryptMnemonicSeed(password); hdSeed = seedFromMnemonic(mnemonicSeed); wipeMnemonicSeed(); AbstractDb.addressProvider.updateEncrypttMnmonicSeed(getHdSeedId(), new EncryptedData(hdSeed, password, isFromXRandom).toEncryptedString()); }
Example 8
Source File: HDMKeychain.java From bitherj with Apache License 2.0 | 5 votes |
public byte[] getExternalChainRootPubExtended(CharSequence password) throws MnemonicException .MnemonicLengthException { DeterministicKey ex = externalChainRoot(password); byte[] pub = ex.getPubKeyExtended(); ex.wipe(); return pub; }
Example 9
Source File: HDAccount.java From bitherj with Apache License 2.0 | 5 votes |
protected void decryptHDSeed(CharSequence password) throws MnemonicException .MnemonicLengthException { if (hdSeedId < 0 || password == null) { return; } String encryptedHDSeed = getEncryptedHDSeed(); if (!Utils.isEmpty(encryptedHDSeed)) { hdSeed = new EncryptedData(encryptedHDSeed).decrypt(password); } }
Example 10
Source File: HDAccountSendActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void send() { tx = null; HDAccount account = (HDAccount) address; SecureCharSequence password = new SecureCharSequence(etPassword.getText()); try { tx = account.newTx(toAddress, btcAmount, AppSharedPreference.getInstance().isSegwitAddressType(), password); } catch (Exception e) { e.printStackTrace(); btcAmount = 0; tx = null; String msg = getString(R.string.send_failed); if (e instanceof KeyCrypterException || e instanceof MnemonicException .MnemonicLengthException) { msg = getString(R.string.password_wrong); } else if (e instanceof TxBuilderException) { msg = e.getMessage(); } final String m = msg; runOnUiThread(new Runnable() { @Override public void run() { if (dp.isShowing()) { dp.dismiss(); } DropdownMessage.showDropdownMessage(HDAccountSendActivity.this, m); } }); } finally { password.wipe(); } if (tx != null) { runOnUiThread(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example 11
Source File: HDAccount.java From bitherj with Apache License 2.0 | 5 votes |
protected DeterministicKey masterKey(CharSequence password) throws MnemonicException .MnemonicLengthException { long begin = System.currentTimeMillis(); decryptHDSeed(password); DeterministicKey master = HDKeyDerivation.createMasterPrivateKey(hdSeed); wipeHDSeed(); log.info("hdm keychain decrypt time: {}", System.currentTimeMillis() - begin); return master; }
Example 12
Source File: SplitBCCHDAccountSendActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void send(String...blockhash) { txs = null; HDAccount account = (HDAccount) address; SecureCharSequence password = new SecureCharSequence(etPassword.getText()); try { txs = account.newForkTx(etAddress.getText().toString().trim(), btcAmount, password, splitCoin,blockhash); } catch (Exception e) { e.printStackTrace(); btcAmount = 0; txs = null; String msg = getString(R.string.send_failed); if (e instanceof KeyCrypterException || e instanceof MnemonicException .MnemonicLengthException) { msg = getString(R.string.password_wrong); } else if (e instanceof TxBuilderException) { msg = e.getMessage(); } final String m = msg; runOnUiThread(new Runnable() { @Override public void run() { if (dp.isShowing()) { dp.dismiss(); } DropdownMessage.showDropdownMessage(SplitBCCHDAccountSendActivity.this, m); } }); } finally { password.wipe(); } if (txs != null) { runOnUiThread(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example 13
Source File: HDAccountCold.java From bitherj with Apache License 2.0 | 5 votes |
public String xPubB58(CharSequence password) throws MnemonicException .MnemonicLengthException { DeterministicKey master = masterKey(password); DeterministicKey purpose = master.deriveHardened(44); DeterministicKey coinType = purpose.deriveHardened(0); DeterministicKey account = coinType.deriveHardened(0); String xpub = account.serializePubB58(); master.wipe(); purpose.wipe(); coinType.wipe(); account.wipe(); return xpub; }
Example 14
Source File: HDAccount.java From bitherj with Apache License 2.0 | 4 votes |
public HDAccount(byte[] mnemonicSeed, CharSequence password) throws MnemonicException .MnemonicLengthException { this(mnemonicSeed, password, true); }
Example 15
Source File: EnterpriseHDMSeed.java From bitherj with Apache License 2.0 | 4 votes |
public EnterpriseHDMSeed(byte[] mnemonicSeed, CharSequence password) throws MnemonicException .MnemonicLengthException { this(mnemonicSeed, false, password); }
Example 16
Source File: AbstractHD.java From bitherj with Apache License 2.0 | 4 votes |
public static final byte[] seedFromMnemonic(byte[] mnemonicSeed) throws MnemonicException .MnemonicLengthException { MnemonicCode mnemonic = MnemonicCode.instance(); return mnemonic.toSeed(mnemonic.toMnemonic(mnemonicSeed), ""); }
Example 17
Source File: HDMKeychain.java From bitherj with Apache License 2.0 | 4 votes |
public String getExternalChainRootPubExtendedAsHex(CharSequence password) throws MnemonicException.MnemonicLengthException { return Utils.bytesToHexString(getExternalChainRootPubExtended(password)).toUpperCase(); }
Example 18
Source File: HDAccountCold.java From bitherj with Apache License 2.0 | 4 votes |
public HDAccountCold(SecureRandom random, CharSequence password) throws MnemonicException .MnemonicLengthException { this(randomByteFromSecureRandom(random, 16), password, random.getClass().getCanonicalName ().indexOf("XRandom") >= 0); }
Example 19
Source File: DesktopHDMKeychain.java From bitherj with Apache License 2.0 | 4 votes |
public String getExternalChainRootPubExtendedAsHex(CharSequence password) throws MnemonicException.MnemonicLengthException { return Utils.bytesToHexString(getExternalChainRootPubExtended(password)).toUpperCase(); }
Example 20
Source File: HDAccount.java From bitherj with Apache License 2.0 | 4 votes |
public Tx newTx(String toAddress, Long amount, CharSequence password) throws TxBuilderException, MnemonicException.MnemonicLengthException { return newTx(new String[]{toAddress}, new Long[]{amount}, password); }