Search in sources :

Example 1 with GetNewAddressResponse

use of run.wallet.iota.api.responses.GetNewAddressResponse in project run-wallet-android by runplay.

the class AddressSecurityChangeRequestHandler method handle.

@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;
    AddressSecurityChangeRequest gnr = ((AddressSecurityChangeRequest) request);
    try {
        jota.dto.response.GetNewAddressResponse resp = apiProxy.getNewAddress(gnr.getAddress().getAddress(), gnr.getSecurity(), gnr.getAddress().getIndex(), false, 1, true);
        // Log.e("ADDRES-SECURITY","has response: "+resp.getAddresses().get(0));
        response = new GetNewAddressResponse(gnr.getSeed(), resp);
        Store.updateAddressFromSecurity(context, gnr, (GetNewAddressResponse) response);
        return new AddressSecurityChangeResponse();
    } catch (ArgumentException e) {
        response = new NetworkError();
    }
    return response;
}
Also used : GetNewAddressResponse(run.wallet.iota.api.responses.GetNewAddressResponse) AddressSecurityChangeRequest(run.wallet.iota.api.requests.AddressSecurityChangeRequest) AddressSecurityChangeResponse(run.wallet.iota.api.responses.AddressSecurityChangeResponse) NetworkError(run.wallet.iota.api.responses.error.NetworkError) ArgumentException(jota.error.ArgumentException) ApiResponse(run.wallet.iota.api.responses.ApiResponse)

Example 2 with GetNewAddressResponse

use of run.wallet.iota.api.responses.GetNewAddressResponse in project run-wallet-android by runplay.

the class GetNewAddressRequestHandler method handle.

@Override
public ApiResponse handle(ApiRequest request) {
    ApiResponse response;
    GetNewAddressRequest gnr = ((GetNewAddressRequest) request);
    List<Address> alreadyAddress = Store.getAddresses(context, gnr.getSeed());
    gnr.setIndex(alreadyAddress.size());
    try {
        jota.dto.response.GetNewAddressResponse resp = apiProxy.getNewAddress(String.valueOf(Store.getSeedRaw(context, gnr.getSeed())), gnr.getSecurity(), alreadyAddress.size(), gnr.isChecksum(), 1, gnr.isReturnAll());
        /*
            jota.dto.response.GetNewAddressResponse resp=apiProxy.getNewAddress(((GetNewAddressRequest) request).getSeedValue(),
                    ((GetNewAddressRequest) request).getSecurity(),
                    ((GetNewAddressRequest) request).getIndex(),
                    ((GetNewAddressRequest) request).isChecksum(),
                    ((GetNewAddressRequest) request).getTotal(),
                    ((GetNewAddressRequest) request).isReturnAll());
            */
        response = new GetNewAddressResponse(gnr.getSeed(), resp);
        Store.addAddress(context, gnr, (GetNewAddressResponse) response);
        AppService.auditAddresses(context, gnr.getSeed());
    // SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
    // if (prefs.getBoolean(Constants.PREFERENCES_LOCAL_POW, true)
    // && !((GetNewAddressResponse) response).getAddresses().isEmpty()) {
    // AppService.attachNewAddress(context,((GetNewAddressRequest) request).getSeed(),((GetNewAddressResponse) response).getAddresses().get(0));
    // }
    } catch (ArgumentException e) {
        response = new NetworkError();
    }
    return response;
}
Also used : GetNewAddressResponse(run.wallet.iota.api.responses.GetNewAddressResponse) Address(run.wallet.iota.model.Address) GetNewAddressRequest(run.wallet.iota.api.requests.GetNewAddressRequest) NetworkError(run.wallet.iota.api.responses.error.NetworkError) ArgumentException(jota.error.ArgumentException) ApiResponse(run.wallet.iota.api.responses.ApiResponse)

Aggregations

ArgumentException (jota.error.ArgumentException)2 ApiResponse (run.wallet.iota.api.responses.ApiResponse)2 GetNewAddressResponse (run.wallet.iota.api.responses.GetNewAddressResponse)2 NetworkError (run.wallet.iota.api.responses.error.NetworkError)2 AddressSecurityChangeRequest (run.wallet.iota.api.requests.AddressSecurityChangeRequest)1 GetNewAddressRequest (run.wallet.iota.api.requests.GetNewAddressRequest)1 AddressSecurityChangeResponse (run.wallet.iota.api.responses.AddressSecurityChangeResponse)1 Address (run.wallet.iota.model.Address)1