jota.error.ArgumentException Java Examples

The following examples show how to use jota.error.ArgumentException. 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: TangleEntity.java    From qupla with Apache License 2.0 6 votes vote down vote up
private void process(final String zmqMessage)
{
  Qupla.log(zmqMessage);

  try
  {
    final String[] messageFragments = zmqMessage.split(" ");
    String addressTrytes = messageFragments[1];
    String txHashTrytes = messageFragments[2];
    final List<Transaction> transactions = iotaAPI.findTransactionsObjectsByHashes(new String[] { txHashTrytes });
    if (transactions.size() < 2)
    {
      return;
    }

    processTransaction(addressTrytes, transactions);
  }
  catch (final ArgumentException e)
  {
    Qupla.log(zmqMessage);
    e.printStackTrace();
  }
}
 
Example #2
Source File: TangleEntity.java    From qupla with Apache License 2.0 6 votes vote down vote up
public String publish(final String address, final String tag, final String content)
{
  try
  {
    final ArrayList<Transfer> transfers = new ArrayList<>();
    transfers.add(new Transfer(address, 0, content.substring(0, SIGNATURE_FRAGMENTS_LENGTH), tag));
    transfers.add(new Transfer(address, 0, content.substring(SIGNATURE_FRAGMENTS_LENGTH, SIGNATURE_FRAGMENTS_LENGTH + 81), tag));
    final SendTransferResponse response = iotaAPI.sendTransfer("", 1, depth, minWeightMagnitude, transfers, new LinkedList<>(), "", false, false, null);
    return response.getTransactions().get(0).getBundle();
  }
  catch (final ArgumentException e)
  {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}
 
Example #3
Source File: TangleEntity.java    From qupla with Apache License 2.0 6 votes vote down vote up
private void onSubscribe(final TritVector address, final TritVector id)
{
  idMap.put(address, id);

  try
  {
    // we just got informed that this address is interesting to us
    final List<Transaction> transactions = iotaAPI.findTransactionObjectsByAddresses(new String[] { address.toTrytes() });
    if (transactions.size() != 0)
    {
      int breakPoint = 0;
    }
  }
  catch (ArgumentException e)
  {
    e.printStackTrace();
  }
}
 
Example #4
Source File: TangleInterface.java    From qupla with Apache License 2.0 6 votes vote down vote up
private List<Transaction> fetchOrderedBundleTransactions(String bundleHash)
{
  List<Transaction> orderedBundleTxs;
  try
  {
    String[] txHashes = iotaAPI.findTransactionsByBundles(bundleHash).getHashes();
    List<Transaction> unorderedBundleTxs = iotaAPI.findTransactionsObjectsByHashes(txHashes);
    orderedBundleTxs = orderTransactionsByIndex(unorderedBundleTxs);
  }
  catch (ArgumentException e)
  {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
  return orderedBundleTxs;
}
 
Example #5
Source File: TangleInterface.java    From qupla with Apache License 2.0 6 votes vote down vote up
/**
 * Publishes a transaction bundle to the Tangle.
 *
 * @param address Address to which the transactions are sent.
 * @param tag     Tag used for the transactions.
 * @param content Tryte message to publish.
 * @return Hahs of the published bundle.
 * @throws RuntimeException if any argument is invalid.
 */
public String publish(String address, String tag, String content)
{

  String header = createMessagePacketHeader(content.length());
  String packet = header + content;
  try
  {
    List<Transfer> transfers = partitionMessagePacket(address, tag, packet);
    SendTransferResponse response = iotaAPI.sendTransfer("", 1, depth, minWeightMagnitude, transfers, new LinkedList<>(), "", false, false, null);
    return response.getTransactions().get(0).getBundle();
  }
  catch (ArgumentException e)
  {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}
 
Example #6
Source File: ReplayBundleRequestHandler.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
@Override
    public ApiResponse handle(ApiRequest request) {
        ApiResponse response;
        int notificationId = Utils.createNewID();

//        NotificationHelper.requestNotification(context,
//                R.drawable.ic_replay, context.getString(R.string.notification_replay_bundle_request_title), notificationId);

        try {
            response = new ReplayBundleResponse(apiProxy.replayBundle(((ReplayBundleRequest) request).getHash(),
                    ((ReplayBundleRequest) request).getDepth(),
                    ((ReplayBundleRequest) request).getMinWeightMagnitude()));
        } catch (ArgumentException e) {
            NetworkError error = new NetworkError();
            error.setErrorType(NetworkErrorType.INVALID_HASH_ERROR);
            response = error;
        }

//        if (response instanceof ReplayBundleResponse && Arrays.asList(((ReplayBundleResponse) response).getSuccessfully()).contains(true))
//            NotificationHelper.responseNotification(context, R.drawable.ic_replay, context.getString(R.string.notification_replay_bundle_response_succeeded_title), notificationId);
//        else if (response instanceof NetworkError)
//            NotificationHelper.responseNotification(context, R.drawable.ic_replay, context.getString(R.string.notification_replay_bundle_response_failed_title), notificationId);
        return response;
    }
 
Example #7
Source File: GetAccountDataRequestHandler.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;

    try {
        response = new GetAccountDataResponse(apiProxy.getAccountData(((GetAccountDataRequest) request).getSeed(),
                ((GetAccountDataRequest) request).getSecurity(),
                ((GetAccountDataRequest) request).getIndex(),
                ((GetAccountDataRequest) request).isChecksum(),
                ((GetAccountDataRequest) request).getTotal(),
                ((GetAccountDataRequest) request).isReturnAll(),
                ((GetAccountDataRequest) request).getStart(),
                ((GetAccountDataRequest) request).getEnd(),
                ((GetAccountDataRequest) request).isInclusionState(),
                ((GetAccountDataRequest) request).getThreshold()));
    } catch (ArgumentException e) {
        response = new NetworkError();
    }
    return response;
}
 
Example #8
Source File: GetNewAddressRequestHandler.java    From guarda-android-wallets with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;

    try {
        response = new GetNewAddressResponse(apiProxy.getNewAddress(((GetNewAddressRequest) request).getSeed(),
                ((GetNewAddressRequest) request).getSecurity(),
                ((GetNewAddressRequest) request).getIndex(),
                ((GetNewAddressRequest) request).isChecksum(),
                ((GetNewAddressRequest) request).getTotal(),
                ((GetNewAddressRequest) request).isReturnAll()));
    } catch (ArgumentException e) {
        response = new NetworkError();
    }
    return response;
}
 
Example #9
Source File: ReplayBundleRequestHandler.java    From android-wallet-app with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;
    int notificationId = Utils.createNewID();

    NotificationHelper.requestNotification(context,
            R.drawable.ic_replay, context.getString(R.string.notification_replay_bundle_request_title), notificationId);

    try {
        response = new ReplayBundleResponse(apiProxy.replayBundle(((ReplayBundleRequest) request).getHash(),
                ((ReplayBundleRequest) request).getDepth(),
                ((ReplayBundleRequest) request).getMinWeightMagnitude()));
    } catch (ArgumentException e) {
        NetworkError error = new NetworkError();
        error.setErrorType(NetworkErrorType.INVALID_HASH_ERROR);
        response = error;
    }

    if (response instanceof ReplayBundleResponse && Arrays.asList(((ReplayBundleResponse) response).getSuccessfully()).contains(true))
        NotificationHelper.responseNotification(context, R.drawable.ic_replay, context.getString(R.string.notification_replay_bundle_response_succeeded_title), notificationId);
    else if (response instanceof NetworkError)
        NotificationHelper.responseNotification(context, R.drawable.ic_replay, context.getString(R.string.notification_replay_bundle_response_failed_title), notificationId);
    return response;
}
 
Example #10
Source File: GetAccountDataRequestHandler.java    From android-wallet-app with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;

    try {
        response = new GetAccountDataResponse(apiProxy.getAccountData(((GetAccountDataRequest) request).getSeed(),
                ((GetAccountDataRequest) request).getSecurity(),
                ((GetAccountDataRequest) request).getIndex(),
                ((GetAccountDataRequest) request).isChecksum(),
                ((GetAccountDataRequest) request).getTotal(),
                ((GetAccountDataRequest) request).isReturnAll(),
                ((GetAccountDataRequest) request).getStart(),
                ((GetAccountDataRequest) request).getEnd(),
                ((GetAccountDataRequest) request).isInclusionState(),
                ((GetAccountDataRequest) request).getThreshold()));
    } catch (ArgumentException e) {
        response = new NetworkError();
    }
    return response;
}
 
Example #11
Source File: GetNewAddressRequestHandler.java    From android-wallet-app with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;

    try {
        response = new GetNewAddressResponse(apiProxy.getNewAddress(((GetNewAddressRequest) request).getSeed(),
                ((GetNewAddressRequest) request).getSecurity(),
                ((GetNewAddressRequest) request).getIndex(),
                ((GetNewAddressRequest) request).isChecksum(),
                ((GetNewAddressRequest) request).getTotal(),
                ((GetNewAddressRequest) request).isReturnAll()));
    } catch (ArgumentException e) {
        response = new NetworkError();
    }
    return response;
}
 
Example #12
Source File: GenerateQRCodeFragment.java    From android-wallet-app with GNU General Public License v3.0 5 votes vote down vote up
private String getAddress() {
    try {
        return Checksum.removeChecksum(addressEditText.getText().toString());
    } catch (ArgumentException e) {
        e.printStackTrace();
    }
    return "";
}
 
Example #13
Source File: GenerateQRCodeFragment.java    From android-wallet-app with GNU General Public License v3.0 5 votes vote down vote up
private boolean isValidAddress() {
    String address = addressEditText.getText().toString();
    try {
        //noinspection StatementWithEmptyBody
        if (Checksum.isAddressWithoutChecksum(address)) {
        }
    } catch (ArgumentException e) {
        addressEditTextInputLayout.setError(getString(R.string.messages_enter_txaddress_with_checksum));
        return false;
    }
    return true;
}
 
Example #14
Source File: NewTransferFragment.java    From android-wallet-app with GNU General Public License v3.0 5 votes vote down vote up
private String getAddress() {
    try {
        return Checksum.removeChecksum(addressEditText.getText().toString());
    } catch (ArgumentException e) {
        e.printStackTrace();
    }
    return "";
}
 
Example #15
Source File: NewTransferFragment.java    From android-wallet-app with GNU General Public License v3.0 5 votes vote down vote up
private boolean isValidAddress() {
    String address = addressEditText.getText().toString();
    try {
        //noinspection StatementWithEmptyBody
        if (Checksum.isAddressWithoutChecksum(address)) {
        }
    } catch (ArgumentException e) {
        addressEditTextInputLayout.setError(getString(R.string.messages_enter_txaddress_with_checksum));
        return false;
    }
    return true;
}
 
Example #16
Source File: GetBundleRequestHandler.java    From android-wallet-app with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;
    try {
        response =  new GetBundleResponse(apiProxy.getBundle(((GetBundleRequest) request).getTransaction()));
    } catch (ArgumentException e) {
        NetworkError error = new NetworkError();
        error.setErrorType(NetworkErrorType.INVALID_HASH_ERROR);
        response = error;
    }
    return response;
}
 
Example #17
Source File: GetBundleRequestHandler.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;
    try {
        response =  new GetBundleResponse(apiProxy.getBundle(((GetBundleRequest) request).getTransaction()));
    } catch (ArgumentException e) {
        NetworkError error = new NetworkError();
        error.setErrorType(NetworkErrorType.INVALID_HASH_ERROR);
        response = error;
    }
    return response;
}
 
Example #18
Source File: TangleInterface.java    From qupla with Apache License 2.0 5 votes vote down vote up
/**
 * @param hash Hash of transaction to fetch.
 * @return Message of fetched transaction interpreted as ASCII.
 * @throws RuntimeException if argument is invalid.
 **/
public String fetchByHash(String hash)
{
  Transaction transaction;
  try
  {
    transaction = iotaAPI.findTransactionsObjectsByHashes(new String[] { hash }).get(0);
  }
  catch (ArgumentException e)
  {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
  return readAsciiTxMsg(transaction);
}
 
Example #19
Source File: TangleInterface.java    From qupla with Apache License 2.0 5 votes vote down vote up
/**
 * @param address Address from which transactions shall be fetched.
 * @return Message of fetched transactions interpreted as ASCII.
 * @throws RuntimeException if argument is invalid.
 **/
public String[] fetchByAddress(String address)
{
  List<Transaction> transactions;
  try
  {
    transactions = iotaAPI.findTransactionObjectsByAddresses(new String[] { address });
  }
  catch (ArgumentException e)
  {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
  return readAsciiTxMsg(transactions);
}
 
Example #20
Source File: SendTransferRequestHandler.java    From android-wallet-app with GNU General Public License v3.0 4 votes vote down vote up
@Override
public ApiResponse handle(ApiRequest request) {
    int notificationId = Utils.createNewID();
    ApiResponse response;
    // if we generate a new address the tag == address
    if (((SendTransferRequest) request).getValue().equals("0")
            && ((SendTransferRequest) request).getTag().equals(Constants.NEW_ADDRESS_TAG)) {
        NotificationHelper.requestNotification(context,
                R.drawable.ic_add, context.getString(R.string.notification_attaching_new_address_request_title), notificationId);
    } else {
        NotificationHelper.requestNotification(context,
                R.drawable.ic_fab_send, context.getString(R.string.notification_send_transfer_request_title), notificationId);
    }

    try {
        response = new SendTransferResponse(apiProxy.sendTransfer(((SendTransferRequest) request).getSeed(),
                ((SendTransferRequest) request).getSecurity(),
                ((SendTransferRequest) request).getDepth(),
                ((SendTransferRequest) request).getMinWeightMagnitude(),
                ((SendTransferRequest) request).prepareTransfer(),
                //inputs
                null,
                //remainder address
                null,
                false,
                true));
    } catch (ArgumentException | IllegalAccessError e) {
        NetworkError error = new NetworkError();

        NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        if (mNotificationManager != null) {
            mNotificationManager.cancel(notificationId);
        }

        if (e instanceof ArgumentException) {
            if (e.getMessage().contains("Sending to a used address.") || e.getMessage().contains("Private key reuse detect!") || e.getMessage().contains("Send to inputs!")) {
                final Activity activity = (Activity) context;
                Bundle bundle = new Bundle();
                bundle.putString("error", e.getMessage());
                KeyReuseDetectedDialog dialog = new KeyReuseDetectedDialog();
                dialog.setArguments(bundle);
                dialog.show(activity.getFragmentManager(), null);
                error.setErrorType(NetworkErrorType.KEY_REUSE_ERROR);
            }
        }

        if (e instanceof IllegalAccessError) {
            error.setErrorType(NetworkErrorType.ACCESS_ERROR);
            if (((SendTransferRequest) request).getTag().equals(Constants.NEW_ADDRESS_TAG))
                NotificationHelper.responseNotification(context, R.drawable.ic_error, context.getString(R.string.notification_address_attach_to_tangle_blocked_title), notificationId);
            else
                NotificationHelper.responseNotification(context, R.drawable.ic_error, context.getString(R.string.notification_transfer_attach_to_tangle_blocked_title), notificationId);
        } else {
            if (error.getErrorType() != NetworkErrorType.KEY_REUSE_ERROR) {
                error.setErrorType(NetworkErrorType.NETWORK_ERROR);
            }
            if (((SendTransferRequest) request).getValue().equals("0") && ((SendTransferRequest) request).getTag().equals(Constants.NEW_ADDRESS_TAG)) {
                NotificationHelper.responseNotification(context, R.drawable.ic_address, context.getString(R.string.notification_attaching_new_address_response_failed_title), notificationId);

            } else {
                NotificationHelper.responseNotification(context, R.drawable.ic_fab_send, context.getString(R.string.notification_send_transfer_response_failed_title), notificationId);
            }
        }

        response = error;
    }

    if (response instanceof SendTransferResponse && ((SendTransferRequest) request).getValue().equals("0")
            && ((SendTransferRequest) request).getTag().equals(Constants.NEW_ADDRESS_TAG)) {
        if (Arrays.asList(((SendTransferResponse) response).getSuccessfully()).contains(true))
            NotificationHelper.responseNotification(context, R.drawable.ic_address, context.getString(R.string.notification_attaching_new_address_response_succeeded_title), notificationId);
        else
            NotificationHelper.responseNotification(context, R.drawable.ic_address, context.getString(R.string.notification_attaching_new_address_response_failed_title), notificationId);

    } else if (response instanceof SendTransferResponse) {
        if (Arrays.asList(((SendTransferResponse) response).getSuccessfully()).contains(true))
            NotificationHelper.responseNotification(context, R.drawable.ic_fab_send, context.getString(R.string.notification_send_transfer_response_succeeded_title), notificationId);
        else
            NotificationHelper.responseNotification(context, R.drawable.ic_fab_send, context.getString(R.string.notification_send_transfer_response_failed_title), notificationId);
    }

    return response;
}
 
Example #21
Source File: GetAccountDataResponse.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public GetAccountDataResponse(jota.dto.response.GetAccountDataResponse apiResponse) throws ArgumentException {

        attachedAddresses = apiResponse.getAddresses();
        Collections.reverse(attachedAddresses);

        Bundle[] transferBundle = apiResponse.getTransfers();

        if (transferBundle != null) {
            for (Bundle aTransferBundle : transferBundle) {

                totalValue = 0;

                for (Transaction trx : aTransferBundle.getTransactions()) {

                    address = trx.getAddress();
                    persistence = trx.getPersistence();
                    value = trx.getValue();

                    if (value != 0 && attachedAddresses.contains(Checksum.addChecksum(address)))
                        totalValue += value;

                    if (trx.getCurrentIndex() == 0) {
                        timestamp = trx.getAttachmentTimestamp() / 1000;
                        tag = trx.getTag();
                        destinationAddress = address;
                        hash = trx.getHash();
                    }

                    // check if sent transaction
                    if (attachedAddresses.contains(Checksum.addChecksum(address))) {
                        boolean isRemainder = (trx.getCurrentIndex() == trx.getLastIndex()) && trx.getLastIndex() != 0;
                        if (value < 0 && !isRemainder) {

                            if (addresses.contains(new Address(Checksum.addChecksum(address), false)))
                                addresses.remove(new Address(Checksum.addChecksum(address), false));

                            if (!addresses.contains(new Address(Checksum.addChecksum(address), true)))
                                addresses.add(new Address(Checksum.addChecksum(address), true));
                        } else {
                            if (!addresses.contains(new Address(Checksum.addChecksum(address), true)) &&
                                    !addresses.contains(new Address(Checksum.addChecksum(address), false)))
                                addresses.add(new Address(Checksum.addChecksum(address), false));
                        }
                    }
                }

                transfers.add(new Transfer(timestamp, destinationAddress, hash, persistence, totalValue, message, tag));

            }

            // sort the addresses
            final Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < attachedAddresses.toArray().length; ++i)
                map.put(attachedAddresses.get(i), i);
            Collections.sort(addresses, new Comparator<Address>() {
                @Override
                public int compare(Address add1, Address add2) {
                    return map.get(add1.getAddress()) - map.get(add2.getAddress());
                }
            });

            Collections.sort(transfers);

            //Don't know why, but in ver. 1.5.5 correct balance = value, before it was apiResponse.getBalance()
            setBalance(value);
            setDuration(apiResponse.getDuration());
        }
    }
 
Example #22
Source File: GetAccountDataResponse.java    From android-wallet-app with GNU General Public License v3.0 4 votes vote down vote up
public GetAccountDataResponse(jota.dto.response.GetAccountDataResponse apiResponse) throws ArgumentException {

        attachedAddresses = apiResponse.getAddresses();
        Collections.reverse(attachedAddresses);

        Bundle[] transferBundle = apiResponse.getTransfers();

        if (transferBundle != null) {
            for (Bundle aTransferBundle : transferBundle) {

                totalValue = 0;

                for (Transaction trx : aTransferBundle.getTransactions()) {

                    address = trx.getAddress();
                    persistence = trx.getPersistence();
                    value = trx.getValue();

                    if (value != 0 && attachedAddresses.contains(Checksum.addChecksum(address)))
                        totalValue += value;

                    if (trx.getCurrentIndex() == 0) {
                        timestamp = trx.getAttachmentTimestamp() / 1000;
                        tag = trx.getTag();
                        destinationAddress = address;
                        hash = trx.getHash();
                    }

                    // check if sent transaction
                    if (attachedAddresses.contains(Checksum.addChecksum(address))) {
                        boolean isRemainder = (trx.getCurrentIndex() == trx.getLastIndex()) && trx.getLastIndex() != 0;
                        if (value < 0 && !isRemainder) {

                            if (addresses.contains(new Address(Checksum.addChecksum(address), false)))
                                addresses.remove(new Address(Checksum.addChecksum(address), false));

                            if (!addresses.contains(new Address(Checksum.addChecksum(address), true)))
                                addresses.add(new Address(Checksum.addChecksum(address), true));
                        } else {
                            if (!addresses.contains(new Address(Checksum.addChecksum(address), true)) &&
                                    !addresses.contains(new Address(Checksum.addChecksum(address), false)))
                                addresses.add(new Address(Checksum.addChecksum(address), false));
                        }
                    }
                }

                transfers.add(new Transfer(timestamp, destinationAddress, hash, persistence, totalValue, message, tag));

            }

            // sort the addresses
            final Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i < attachedAddresses.toArray().length; ++i)
                map.put(attachedAddresses.get(i), i);
            Collections.sort(addresses, new Comparator<Address>() {
                @Override
                public int compare(Address add1, Address add2) {
                    return map.get(add1.getAddress()) - map.get(add2.getAddress());
                }
            });

            Collections.sort(transfers);

            setBalance(apiResponse.getBalance());
            setDuration(apiResponse.getDuration());
        }
    }
 
Example #23
Source File: SendTransferRequestHandler.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public ApiResponse handle(ApiRequest request) {
        int notificationId = Utils.createNewID();
        ApiResponse response;
        // if we generate a new address the tag == address
//        if (((SendTransferRequest) request).getValue().equals("0")
//                && ((SendTransferRequest) request).getTag().equals(Constants.NEW_ADDRESS_TAG)) {
//            NotificationHelper.requestNotification(context,
//                    R.drawable.ic_add, context.getString(R.string.notification_attaching_new_address_request_title), notificationId);
//        } else {
//            NotificationHelper.requestNotification(context,
//                    R.drawable.ic_fab_send, context.getString(R.string.notification_send_transfer_request_title), notificationId);
//        }

        try {
            response = new SendTransferResponse(apiProxy.sendTransfer(((SendTransferRequest) request).getSeed(),
                    ((SendTransferRequest) request).getSecurity(),
                    ((SendTransferRequest) request).getDepth(),
                    ((SendTransferRequest) request).getMinWeightMagnitude(),
                    ((SendTransferRequest) request).prepareTransfer(),
                    //inputs
                    null,
                    //remainder address
                    null,
                    false));
        } catch (ArgumentException | IllegalAccessError e) {
            NetworkError error = new NetworkError();

            NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
            if (mNotificationManager != null) {
                mNotificationManager.cancel(notificationId);
            }

            if (e instanceof ArgumentException) {
                if (e.getMessage().contains("Sending to a used address.") || e.getMessage().contains("Private key reuse detect!") || e.getMessage().contains("Send to inputs!")) {
                    final Activity activity = (Activity) context;
                    Bundle bundle = new Bundle();
                    bundle.putString("error", e.getMessage());
//                    KeyReuseDetectedDialog dialog = new KeyReuseDetectedDialog();
//                    dialog.setArguments(bundle);
//                    dialog.show(activity.getFragmentManager(), null);
                    error.setErrorType(NetworkErrorType.KEY_REUSE_ERROR);
                }
            }

            if (e instanceof IllegalAccessError) {
                error.setErrorType(NetworkErrorType.ACCESS_ERROR);
//                if (((SendTransferRequest) request).getTag().equals(Constants.NEW_ADDRESS_TAG))
//                    NotificationHelper.responseNotification(context, R.drawable.ic_error, context.getString(R.string.notification_address_attach_to_tangle_blocked_title), notificationId);
//                else
//                    NotificationHelper.responseNotification(context, R.drawable.ic_error, context.getString(R.string.notification_transfer_attach_to_tangle_blocked_title), notificationId);
            } else {
                if (error.getErrorType() != NetworkErrorType.KEY_REUSE_ERROR) {
                    error.setErrorType(NetworkErrorType.NETWORK_ERROR);
                }
//                if (((SendTransferRequest) request).getValue().equals("0") && ((SendTransferRequest) request).getTag().equals(Constants.NEW_ADDRESS_TAG)) {
//                    NotificationHelper.responseNotification(context, R.drawable.ic_address, context.getString(R.string.notification_attaching_new_address_response_failed_title), notificationId);
//                } else {
//                    NotificationHelper.responseNotification(context, R.drawable.ic_fab_send, context.getString(R.string.notification_send_transfer_response_failed_title), notificationId);
//                }
            }

            response = error;
        }

        if (response instanceof SendTransferResponse && ((SendTransferRequest) request).getValue().equals("0")
                && ((SendTransferRequest) request).getTag().equals(Constants.NEW_ADDRESS_TAG)) {
//            if (Arrays.asList(((SendTransferResponse) response).getSuccessfully()).contains(true))
//                NotificationHelper.responseNotification(context, R.drawable.ic_address, context.getString(R.string.notification_attaching_new_address_response_succeeded_title), notificationId);
//            else
//                NotificationHelper.responseNotification(context, R.drawable.ic_address, context.getString(R.string.notification_attaching_new_address_response_failed_title), notificationId);

        } else if (response instanceof SendTransferResponse) {
//            if (Arrays.asList(((SendTransferResponse) response).getSuccessfully()).contains(true))
//                NotificationHelper.responseNotification(context, R.drawable.ic_fab_send, context.getString(R.string.notification_send_transfer_response_succeeded_title), notificationId);
//            else
//                NotificationHelper.responseNotification(context, R.drawable.ic_fab_send, context.getString(R.string.notification_send_transfer_response_failed_title), notificationId);
        }

        return response;
    }