net.bither.bitherj.exception.TxBuilderException Java Examples
The following examples show how to use
net.bither.bitherj.exception.TxBuilderException.
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: WalletUtils.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public static void initTxBuilderException() { for (TxBuilderException.TxBuilderErrorType type : TxBuilderException.TxBuilderErrorType .values()) { String format = LocaliserUtils.getString("send_failed"); switch (type) { case TxNotEnoughMoney: format = LocaliserUtils.getString("send_failed_missing_btc"); break; case TxDustOut: format = LocaliserUtils.getString("send_failed_dust_out_put"); break; case TxWaitConfirm: format = LocaliserUtils.getString("send_failed_pendding"); break; } type.registerFormatString(format); } }
Example #2
Source File: WalletUtils.java From bither-desktop-java with Apache License 2.0 | 6 votes |
public static void initTxBuilderException() { for (TxBuilderException.TxBuilderErrorType type : TxBuilderException.TxBuilderErrorType .values()) { String format = LocaliserUtils.getString("send_failed"); switch (type) { case TxNotEnoughMoney: format = LocaliserUtils.getString("send_failed_missing_btc"); break; case TxDustOut: format = LocaliserUtils.getString("send_failed_dust_out_put"); break; case TxWaitConfirm: format = LocaliserUtils.getString("send_failed_pendding"); break; } type.registerFormatString(format); } }
Example #3
Source File: CompleteTransactionRunnable.java From bither-android with Apache License 2.0 | 6 votes |
public static void registerTxBuilderExceptionMessages() { for (TxBuilderException.TxBuilderErrorType type : TxBuilderException.TxBuilderErrorType .values()) { int format = R.string.send_failed; switch (type) { case TxNotEnoughMoney: format = R.string.send_failed_missing_btc; break; case TxDustOut: format = R.string.send_failed_dust_out_put; break; case TxWaitConfirm: format = R.string.send_failed_pendding; break; case TxMaxSize: format = R.string.send_failed_max_tx_size; break; } type.registerFormatString(BitherApplication.mContext.getString(format)); } }
Example #4
Source File: HDAccountSendPanel.java From bither-desktop-java with Apache License 2.0 | 5 votes |
private void send() { tx = null; HDAccount account = (HDAccount) Bither.getActionAddress(); SecureCharSequence password = new SecureCharSequence(currentPassword.getPassword()); try { tx = account.newTx(toAddress, btcAmount, password); } catch (Exception e) { e.printStackTrace(); btcAmount = 0; tx = null; String msg = LocaliserUtils.getString("send_failed"); if (e instanceof KeyCrypterException || e instanceof MnemonicException .MnemonicLengthException) { msg = LocaliserUtils.getString("password_wrong"); } else if (e instanceof TxBuilderException) { msg = e.getMessage(); } final String m = msg; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dp.dispose(); new MessageDialog(m).showMsg(); } }); } finally { password.wipe(); } if (tx != null) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example #5
Source File: CompleteTransactionRunnable.java From bither-desktop-java with Apache License 2.0 | 5 votes |
public String getMessageFromException(Exception e) { if (e != null && e instanceof TxBuilderException) { return e.getMessage(); } else if (e != null && e instanceof PasswordException) { return LocaliserUtils.getString("password_wrong"); } else { return LocaliserUtils.getString("send_failed"); } }
Example #6
Source File: CompleteTransactionRunnable.java From bither-desktop-java with Apache License 2.0 | 5 votes |
public String getMessageFromException(Exception e) { if (e != null && e instanceof TxBuilderException) { return e.getMessage(); } else if (e != null && e instanceof PasswordException) { return LocaliserUtils.getString("password_wrong"); } else { return LocaliserUtils.getString("send_failed"); } }
Example #7
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 #8
Source File: Address.java From bitherj with Apache License 2.0 | 5 votes |
public Tx buildTx(long amount, String address, String changeAddress) throws TxBuilderException { List<Long> amounts = new ArrayList<Long>(); amounts.add(amount); List<String> addresses = new ArrayList<String>(); addresses.add(address); return buildTx(changeAddress, amounts, addresses); }
Example #9
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 #10
Source File: EnterpriseHDMSendActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void send() { tx = null; String changeTo = getChangeAddress(); try { tx = address.buildTx(btcAmount, toAddress, changeTo == null ? address.getAddress() : changeTo); } 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(EnterpriseHDMSendActivity.this, m); } }); } if (tx != null) { runOnUiThread(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example #11
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 #12
Source File: SplitBCCHDAccountMonitoredSendActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void send() { this.txs = null; HDAccount account = (HDAccount) address; try { txs = account.newForkTx(toAddress, btcAmount, splitCoin); } 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(SplitBCCHDAccountMonitoredSendActivity.this, m); } }); } if (this.txs != null) { runOnUiThread(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example #13
Source File: BCCAssetsDetectHDActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void send() { txs = null; HDAccount account = (HDAccount) address; SecureCharSequence password = new SecureCharSequence(etPassword.getText()); try { txs = account.extractBcc(etAddress.getText().toString().trim(), getAmount(outs), outs, path, index, password); } 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(BCCAssetsDetectHDActivity.this, m); } }); } finally { password.wipe(); } if (txs != null) { runOnUiThread(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example #14
Source File: CompleteTransactionRunnable.java From bither-android with Apache License 2.0 | 5 votes |
public String getMessageFromException(Exception e) { if (e != null && e instanceof TxBuilderException) { return e.getMessage(); } else if (e != null && e instanceof PasswordException) { return BitherApplication.mContext.getString(R.string.password_wrong); } else if (e != null && e instanceof HDMServerSignException) { return e.getMessage(); } else { return BitherApplication.mContext.getString(R.string.send_failed); } }
Example #15
Source File: BCCAssetsHDAccountMonitoredActivity.java From bither-android with Apache License 2.0 | 5 votes |
private void send() { this.txs = null; HDAccount account = (HDAccount) address; try { txs = account.newForkTx(toAddress, btcAmount,outs, SplitCoin.BCC); } 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(BCCAssetsHDAccountMonitoredActivity.this, m); } }); } if (this.txs != null) { runOnUiThread(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example #16
Source File: HDAccountSendPanel.java From bither-desktop-java with Apache License 2.0 | 5 votes |
private void send() { tx = null; HDAccount account = (HDAccount) Bither.getActionAddress(); SecureCharSequence password = new SecureCharSequence(currentPassword.getPassword()); try { tx = account.newTx(toAddress, btcAmount, password); } catch (Exception e) { e.printStackTrace(); btcAmount = 0; tx = null; String msg = LocaliserUtils.getString("send_failed"); if (e instanceof KeyCrypterException || e instanceof MnemonicException .MnemonicLengthException) { msg = LocaliserUtils.getString("password_wrong"); } else if (e instanceof TxBuilderException) { msg = e.getMessage(); } final String m = msg; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dp.dispose(); new MessageDialog(m).showMsg(); } }); } finally { password.wipe(); } if (tx != null) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example #17
Source File: HDAccountMonitoredSendActivity.java From bither-android with Apache License 2.0 | 4 votes |
private void send() { tx = null; HDAccount account = (HDAccount) address; try { boolean isSegwitChangeAddress = AppSharedPreference.getInstance().isSegwitAddressType(); if (isSegwitChangeAddress) { if (address instanceof HDAccount && ((HDAccount) address).getExternalPub(AbstractHD.PathType.EXTERNAL_BIP49_PATH) == null) { isSegwitChangeAddress = false; } } tx = account.newTx(toAddress, btcAmount, isSegwitChangeAddress); } 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(HDAccountMonitoredSendActivity.this, m); } }); } if (tx != null) { runOnUiThread(new Runnable() { @Override public void run() { showConfirm(); } }); } }
Example #18
Source File: DesktopHDMKeychain.java From bitherj with Apache License 2.0 | 4 votes |
public Tx newTx(String toAddress, Long amount) throws TxBuilderException, MnemonicException.MnemonicLengthException { return newTx(new String[]{toAddress}, new Long[]{amount}); }
Example #19
Source File: DesktopHDMKeychain.java From bitherj with Apache License 2.0 | 4 votes |
public Tx newTx(String[] toAddresses, Long[] amounts) throws TxBuilderException, MnemonicException.MnemonicLengthException { List<Out> outs = AbstractDb.desktopTxProvider.getUnspendOutByHDAccount(hdSeedId); Tx tx = TxBuilder.getInstance().buildTxFromAllAddress(outs, getNewChangeAddress(), Arrays .asList(amounts), Arrays.asList(toAddresses)); List<DesktopHDMAddress> signingAddresses = getSigningAddressesForInputs(tx.getIns()); assert signingAddresses.size() == tx.getIns().size(); List<byte[]> unsignedHashes = tx.getUnsignedInHashes(); assert unsignedHashes.size() == signingAddresses.size(); // DeterministicKey master = masterKey(password); // if (master == null) { // return null; // } // DeterministicKey accountKey = getAccount(master); // DeterministicKey external = getChainRootKey(accountKey, AbstractHD.PathType.EXTERNAL_ROOT_PATH); // DeterministicKey internal = getChainRootKey(accountKey, AbstractHD.PathType.INTERNAL_ROOT_PATH); // accountKey.wipe(); // master.wipe(); // ArrayList<byte[]> signatures = new ArrayList<byte[]>(); // HashMap<String, DeterministicKey> addressToKeyMap = new HashMap<String, DeterministicKey> // (signingAddresses.size()); // // for (int i = 0; // i < signingAddresses.size(); // i++) { // DesktopHDMAddress a = signingAddresses.get(i); // byte[] unsigned = unsignedHashes.get(i); // // if (!addressToKeyMap.containsKey(a.getAddress())) { // if (a.getPathType() == AbstractHD.PathType.EXTERNAL_ROOT_PATH) { // addressToKeyMap.put(a.getAddress(), external.deriveSoftened(a.getIndex())); // } else { // addressToKeyMap.put(a.getAddress(), internal.deriveSoftened(a.getIndex())); // } // } // // DeterministicKey key = addressToKeyMap.get(a.getAddress()); // assert key != null; // // TransactionSignature signature = new TransactionSignature(key.sign(unsigned, null), // TransactionSignature.SigHash.ALL, false); // signatures.add(ScriptBuilder.createInputScript(signature, key).getProgram()); // } // // tx.signWithSignatures(signatures); assert tx.verifySignatures(); // external.wipe(); // internal.wipe(); // for (DeterministicKey key : addressToKeyMap.values()) { // key.wipe(); // } return tx; }
Example #20
Source File: Address.java From bitherj with Apache License 2.0 | 4 votes |
public Tx buildTx(List<Long> amounts, List<String> addresses) throws TxBuilderException { return buildTx(getAddress(), amounts, addresses); }
Example #21
Source File: Address.java From bitherj with Apache License 2.0 | 4 votes |
public Tx buildTx(String changeAddress, List<Long> amounts, List<String> addresses) throws TxBuilderException { return TxBuilder.getInstance().buildTx(this, changeAddress, amounts, addresses); }
Example #22
Source File: Address.java From bitherj with Apache License 2.0 | 4 votes |
public Tx buildTx(long amount, String address) throws TxBuilderException { return buildTx(amount, address, getAddress()); }
Example #23
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); }
Example #24
Source File: HDAccount.java From bitherj with Apache License 2.0 | 4 votes |
public Tx newTx(String[] toAddresses, Long[] amounts, CharSequence password) throws TxBuilderException, MnemonicException.MnemonicLengthException { if (password != null && !hasPrivKey()) { throw new RuntimeException("Can not sign without private key"); } Tx tx = newTx(toAddresses, amounts); List<HDAccountAddress> signingAddresses = getSigningAddressesForInputs(tx.getIns()); assert signingAddresses.size() == tx.getIns().size(); DeterministicKey master = masterKey(password); if (master == null) { return null; } DeterministicKey accountKey = getAccount(master); DeterministicKey external = getChainRootKey(accountKey, AbstractHD.PathType .EXTERNAL_ROOT_PATH); DeterministicKey internal = getChainRootKey(accountKey, AbstractHD.PathType .INTERNAL_ROOT_PATH); accountKey.wipe(); master.wipe(); List<byte[]> unsignedHashes = tx.getUnsignedInHashes(); assert unsignedHashes.size() == signingAddresses.size(); ArrayList<byte[]> signatures = new ArrayList<byte[]>(); HashMap<String, DeterministicKey> addressToKeyMap = new HashMap<String, DeterministicKey> (signingAddresses.size()); for (int i = 0; i < signingAddresses.size(); i++) { HDAccountAddress a = signingAddresses.get(i); byte[] unsigned = unsignedHashes.get(i); if (!addressToKeyMap.containsKey(a.getAddress())) { if (a.getPathType() == AbstractHD.PathType.EXTERNAL_ROOT_PATH) { addressToKeyMap.put(a.getAddress(), external.deriveSoftened(a.index)); } else { addressToKeyMap.put(a.getAddress(), internal.deriveSoftened(a.index)); } } DeterministicKey key = addressToKeyMap.get(a.getAddress()); assert key != null; TransactionSignature signature = new TransactionSignature(key.sign(unsigned, null), TransactionSignature.SigHash.ALL, false); signatures.add(ScriptBuilder.createInputScript(signature, key).getProgram()); } tx.signWithSignatures(signatures); assert tx.verifySignatures(); external.wipe(); internal.wipe(); for (DeterministicKey key : addressToKeyMap.values()) { key.wipe(); } return tx; }
Example #25
Source File: HDAccount.java From bitherj with Apache License 2.0 | 4 votes |
public Tx newTx(String toAddress, Long amount) throws TxBuilderException, MnemonicException .MnemonicLengthException { return newTx(new String[]{toAddress}, new Long[]{amount}); }